diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-03 14:31:17 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-03 14:33:46 +0000 |
| commit | 91879b7606ed3af26dabe60c043acbc7e4dbcde5 (patch) | |
| tree | c0854edaf8266bf8339c4b33858ea0823e2981ba | |
| parent | d37726c35316079a1b3b894db6616104c83ba52f (diff) | |
util/nvmutil: count the number of items in op
don't hardcode it
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 5 |
1 files changed, 4 insertions, 1 deletions
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) { |
