From a70ab825b920ef4def910a022dcea3d865d9d455 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 29 Jan 2025 04:07:54 +0000 Subject: [PATCH] util/nvmutil: allow ./nvm gbe MAC previously, if the user ran: ./nvm GBE [MAC address] it would error, treating the MAC as a command now if only 3 arguments are provided, and the 3rd argument ins't a valid command, it's treated as a MAC address and validated accordingly. this should make nvmutil easier to use, because I imagine a lot of users forget to use setmac there's no reason we should be so pedantic. we should allow it to be used flexibly like this Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 0576167..b8319a0 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -149,7 +149,10 @@ main(int argc, char *argv[]) cmd = cmd_setmac; } - if (cmd == cmd_setmac) { + if ((cmd == NULL) && (argc > 2)) { /* nvm gbe [MAC] */ + strMac = COMMAND; + cmd = cmd_setmac; + } else if (cmd == cmd_setmac) { /* nvm gbe setmac [MAC] */ strMac = strRMac; /* random MAC */ if (argc > 3) /* user-supplied MAC (can be random) */ strMac = MAC_ADDRESS;