mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-28 23:19:03 +02:00
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>
This commit is contained in:
@@ -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);
|
||||
@@ -145,6 +138,19 @@ main(int argc, char *argv[])
|
||||
return errno ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
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[])
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user