summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-01-24 18:10:17 +0000
committerLeah Rowe <leah@libreboot.org>2025-01-24 18:10:17 +0000
commit073420d30563407f336e28e3df4eacd020e838b5 (patch)
treef9b1e47fc48eb357366419143bd7c6164dbd7fda /util
parenta6c18734e70757973f4f9d816bdb4fa205ef173d (diff)
util/nvmutil: cleaner argument handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 7fbf1664..c3d242d8 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -127,10 +127,12 @@ main(int argc, char *argv[])
err_if(pledge("stdio", NULL) == -1);
#endif
- for (int i = 0; i < 6; i++) /* detect user-supplied command */
- if (strcmp(COMMAND, op[i].str) == 0)
- if ((cmd = argc >= op[i].args ? op[i].cmd : NULL))
- break;
+ for (int i = 0; (i < 6) && (cmd == NULL); i++) {
+ if (strcmp(COMMAND, op[i].str) != 0)
+ continue;
+ if (argc >= op[i].args)
+ cmd = op[i].cmd;
+ }
if (cmd == cmd_setmac) {
strMac = strRMac; /* random MAC */