summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-03 15:50:20 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-03 15:50:20 +0000
commit6d8cf8909fbaf091bc2b214139a41c9f3ddbb978 (patch)
tree4c9e7ce5f4c618d6c0c5e73f0a23bd2c94c271c4 /util
parent9f12aa3b91a58a6bc45944d50c473d351730caac (diff)
util/nvmutil: split up set_cmd
the second half of the function is mostly checking arguments, and has the hack to set cmd to cmd_setmac if cmd is unset (no command specified) but argc is above two. stylistically, this is more consistent. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index f2f3fdbc..662204fe 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -15,6 +15,7 @@
#include <unistd.h>
static void set_cmd(int, char **);
+static void check_cmd_args(int, char **);
static void set_io_flags(int, char **);
static void open_files(void);
static void checkdir(const char *);
@@ -102,6 +103,7 @@ main(int argc, char *argv[])
err_if(unveil("/dev/urandom", "r") == -1);
#endif
set_cmd(argc, argv);
+ check_cmd_args(argc, argv);
set_io_flags(argc, argv);
#ifdef __OpenBSD__
if (flags == O_RDONLY) {
@@ -147,7 +149,11 @@ set_cmd(int argc, char *argv[])
} else { /* argc == 2 */
cmd = cmd_setmac;
}
+}
+static void
+check_cmd_args(int argc, char *argv[])
+{
if ((cmd == NULL) && (argc > 2)) { /* nvm gbe [MAC] */
mac = COMMAND;
cmd = cmd_setmac;