summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-03 23:27:59 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-03 23:29:45 +0000
commit8c5c4e1b930d07e87e23894e9d50f3d1c00a70b7 (patch)
tree159f7ea5d2db557eb5c3b4902eedfe503241f096 /util/nvmutil
parent213626d8985a1c79fe53f9008117c408c38c6066 (diff)
util/nvmutil: reset global state in one function
split it out of main. this is good hygiene and it's preparation for a planned expansion in the future, that allows operation on multiple files. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index c1882af2..62821278 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -13,6 +13,7 @@
#include <string.h>
#include <unistd.h>
+static void reset_global_state(int, char **);
static void set_cmd(int, char **);
static void check_cmd_args(int, char **);
static void set_io_flags(int, char **);
@@ -99,17 +100,9 @@ int
main(int argc, char *argv[])
{
argv0 = argv[0];
-
- mac = NULL;
- invert = 0;
- part_modified[0] = 0;
- part_modified[1] = 0;
- fname = "";
- cmd = NULL;
-
if (argc < 2)
usage();
- fname = argv[1];
+ reset_global_state(argc, argv);
#ifdef __OpenBSD__
err_if(pledge("stdio rpath wpath unveil", NULL) == -1);
err_if(unveil("/dev/urandom", "r") == -1);
@@ -146,6 +139,19 @@ main(int argc, char *argv[])
}
static void
+reset_global_state(int argc, char *argv[])
+{
+ mac = NULL;
+ invert = 0;
+ part_modified[0] = 0;
+ part_modified[1] = 0;
+ fname = "";
+ cmd = NULL;
+
+ fname = argv[1];
+}
+
+static void
set_cmd(int argc, char *argv[])
{
size_t i;