use arraylen

This commit is contained in:
Philippe Teuwen committed 2026-09-17 00:23:18 +02:00
1 parent 8ed285af90
commit 90c41c6de5
4 files changed
+11 -11

No files matched your search

+2 -2
View File
@@ -32,6 +32,7 @@
#include "protocols.h"
#include "mbedtls/des.h"
#include <time.h>
#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;
+4 -4
View File
@@ -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, "" },
};
+3 -3
View File
@@ -30,6 +30,7 @@
#else
#include <sys/ioctl.h>
#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);