mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 18:34:57 +02:00
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>
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
static void set_cmd(int, char **);
|
static void set_cmd(int, char **);
|
||||||
|
static void check_cmd_args(int, char **);
|
||||||
static void set_io_flags(int, char **);
|
static void set_io_flags(int, char **);
|
||||||
static void open_files(void);
|
static void open_files(void);
|
||||||
static void checkdir(const char *);
|
static void checkdir(const char *);
|
||||||
@@ -102,6 +103,7 @@ main(int argc, char *argv[])
|
|||||||
err_if(unveil("/dev/urandom", "r") == -1);
|
err_if(unveil("/dev/urandom", "r") == -1);
|
||||||
#endif
|
#endif
|
||||||
set_cmd(argc, argv);
|
set_cmd(argc, argv);
|
||||||
|
check_cmd_args(argc, argv);
|
||||||
set_io_flags(argc, argv);
|
set_io_flags(argc, argv);
|
||||||
#ifdef __OpenBSD__
|
#ifdef __OpenBSD__
|
||||||
if (flags == O_RDONLY) {
|
if (flags == O_RDONLY) {
|
||||||
@@ -147,7 +149,11 @@ set_cmd(int argc, char *argv[])
|
|||||||
} else { /* argc == 2 */
|
} else { /* argc == 2 */
|
||||||
cmd = cmd_setmac;
|
cmd = cmd_setmac;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
check_cmd_args(int argc, char *argv[])
|
||||||
|
{
|
||||||
if ((cmd == NULL) && (argc > 2)) { /* nvm gbe [MAC] */
|
if ((cmd == NULL) && (argc > 2)) { /* nvm gbe [MAC] */
|
||||||
mac = COMMAND;
|
mac = COMMAND;
|
||||||
cmd = cmd_setmac;
|
cmd = cmd_setmac;
|
||||||
|
|||||||
Reference in New Issue
Block a user