From ec3148dc3b5d4fd392ef9cbfe31051e54503768e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 24 Jan 2025 18:14:25 +0000 Subject: [PATCH] util/nvmutil: Show specific error for bad cmd argc For example, if the brick command is used without specifying a part number. Instead of saying "Invalid argument", show a much more useful error message to help the user adapt. 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 c3d242d8..c2839c45 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -130,8 +130,11 @@ main(int argc, char *argv[]) for (int i = 0; (i < 6) && (cmd == NULL); i++) { if (strcmp(COMMAND, op[i].str) != 0) continue; - if (argc >= op[i].args) + if (argc >= op[i].args) { cmd = op[i].cmd; + break; + } + err(errno = EINVAL, "Too few args on command '%s'", op[i].str); } if (cmd == cmd_setmac) {