From 90c41c6de562441aa05a2b554eddc2e590066503 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 17 Sep 2026 00:23:18 +0200 Subject: [PATCH] use arraylen --- client/src/cmdhffmcos.c | 4 ++-- client/src/cmdlfcotag.c | 8 ++++---- client/src/frame_data2.c | 6 +++--- doc/commands.json | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/src/cmdhffmcos.c b/client/src/cmdhffmcos.c index 02972c914..91b815ac4 100644 --- a/client/src/cmdhffmcos.c +++ b/client/src/cmdhffmcos.c @@ -32,6 +32,7 @@ #include "protocols.h" #include "mbedtls/des.h" #include +#include "commonutil.h" // ARRAYLEN static int CmdHelp(const char *Cmd); @@ -3873,7 +3874,6 @@ static int CmdHFFmcosHistory(const char *Cmd) { {0x07, "OD limit upd"}, {0x09, "Compound pur"}, }; - const size_t ntypes = sizeof(tx_types) / sizeof(tx_types[0]); PrintAndLogEx(INFO, " # | Date | Time | Type | Amount | OD Limit | Serial | Terminal"); PrintAndLogEx(INFO, "---+------------+----------+--------------+------------+----------+--------+-------------------"); @@ -3924,7 +3924,7 @@ static int CmdHFFmcosHistory(const char *Cmd) { char type_hex_buf[13]; snprintf(type_hex_buf, sizeof(type_hex_buf), "0x%02X ", tx_type); const char *type_name = type_hex_buf; - for (size_t i = 0; i < ntypes; i++) { + for (size_t i = 0; i < ARRAYLEN(tx_types); i++) { if (tx_types[i].code == tx_type) { type_name = tx_types[i].name; break; diff --git a/client/src/cmdlfcotag.c b/client/src/cmdlfcotag.c index e6d81fa8d..4b1b25822 100644 --- a/client/src/cmdlfcotag.c +++ b/client/src/cmdlfcotag.c @@ -31,7 +31,7 @@ #include "ui.h" // PrintAndLog #include "ctype.h" // tolower #include "cliparser.h" -#include "commonutil.h" // reflect32 +#include "commonutil.h" // reflect32, ARRAYLEN #include "cmdlf.h" // lf_getconfig, lf_setconfig, lf_read_cotag #include "graph.h" // g_GraphTraceLen @@ -273,9 +273,9 @@ static int demod_cotag(int32_t *samples, int num_samples, int clock, int clock_s int len; const char *name; } preamble_patterns[] = { - { preamble_a, (int)(sizeof(preamble_a) / sizeof(preamble_a[0])), "A" }, - { preamble_p, (int)(sizeof(preamble_p) / sizeof(preamble_p[0])), "P" }, - { preamble_p0, (int)(sizeof(preamble_p0) / sizeof(preamble_p0[0])), "P-0" }, + { preamble_a, ARRAYLEN(preamble_a), "A" }, + { preamble_p, ARRAYLEN(preamble_p), "P" }, + { preamble_p0, ARRAYLEN(preamble_p0), "P-0" }, { NULL, 0, "" }, }; diff --git a/client/src/frame_data2.c b/client/src/frame_data2.c index 2fe46b932..592ec1f99 100644 --- a/client/src/frame_data2.c +++ b/client/src/frame_data2.c @@ -30,6 +30,7 @@ #else #include #endif +#include "commonutil.h" // ARRAYLEN // ---- ANSI ---------------------------------------------------------------- #define CSI "\x1b[" @@ -52,7 +53,6 @@ static const char *GLYPHS[] = { "\xef\xbe\x96", "\xef\xbe\x97", "\xef\xbe\x98", "\xef\xbe\x99", "\xef\xbe\x9a", "\xef\xbe\x9b", "\xef\xbe\x9c", "\xef\xbe\x9d", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", }; -static const int NGLYPH = (int)(sizeof(GLYPHS) / sizeof(GLYPHS[0])); #define LOGO_BOLD 1 @@ -279,7 +279,7 @@ static void render_frame_locked(void) { } if (frand() < (is_field ? 0.01 : 0.04)) - g_cell[y][x] = (int)(frand() * NGLYPH); + g_cell[y][x] = (int)(frand() * ARRAYLEN(GLYPHS)); const char *g = GLYPHS[g_cell[y][x]]; @@ -360,7 +360,7 @@ static int fx_state_init(int rows) { } for (int y = 0; y < g_rows; y++) for (int x = 0; x < g_cols; x++) - g_cell[y][x] = (int)(frand() * NGLYPH); + g_cell[y][x] = (int)(frand() * ARRAYLEN(GLYPHS)); build_mask(g_rows, g_cols); diff --git a/doc/commands.json b/doc/commands.json index d3d433ced..7e9fdb119 100644 --- a/doc/commands.json +++ b/doc/commands.json @@ -16615,8 +16615,8 @@ } }, "metadata": { - "commands_extracted": 923, + "commands_extracted": 924, "extracted_by": "PM3Help2JSON v1.00", - "extracted_on": "2026-09-16T16:59:05+00:00" + "extracted_on": "2026-09-16T22:14:12+00:00" } }