From 91879b7606ed3af26dabe60c043acbc7e4dbcde5 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 3 Mar 2026 14:31:17 +0000 Subject: util/nvmutil: count the number of items in op don't hardcode it Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 227a2674..08370e5b 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -38,6 +38,8 @@ uint16_t word(int, int); #define SIZE_16KB 0x4000 #define SIZE_128KB 0x20000 +#define items(x) (sizeof((x)) / sizeof((x)[0])) + uint8_t buf[SIZE_8KB]; uint16_t macbuf[3] = {0, 0, 0}; size_t partsize; @@ -101,7 +103,8 @@ set_cmd(int argc, char *argv[]) if (argc < 2) { usage(argv[0]); } else if (argc > 2) { - for (int i = 0; (i < 6) && (cmd == NULL); i++) { + for (long unsigned int i = 0; + (i < items(op)) && (cmd == NULL); i++) { if (strcmp(COMMAND, op[i].str) != 0) continue; if (argc >= op[i].args) { -- cgit v1.2.1