summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2022-11-27 00:48:37 +0000
committerLeah Rowe <leah@libreboot.org>2022-11-27 00:48:37 +0000
commitff88cb1ac37eed20e7c9bcf9c36fc17947274abb (patch)
tree379850fc876325beaa8896a704b8e6c78a93ff1b
parentb81b51f98bdbed6a3ce33a67c8eefcfc7adce6d1 (diff)
util/nvmutil: further improved errno handling
-rw-r--r--util/nvmutil/nvmutil.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 5ec28949..5081a3e2 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -109,20 +109,19 @@ main(int argc, char *argv[])
cmd = &cmd_copy;
}
- if (errno != 0)
- goto nvmutil_exit;
-
- if (readFromFile(&fd, gbe, FILENAME, flags, SIZE_8KB) != SIZE_8KB)
+ if ((strMac == NULL) && (cmd == NULL))
+ errno = EINVAL;
+ else if (readFromFile(&fd, gbe, FILENAME, flags, SIZE_8KB) != SIZE_8KB)
goto nvmutil_exit;
else if (errno == ENOTDIR)
errno = 0;
- if (strMac != NULL)
+ if (errno != 0)
+ goto nvmutil_exit;
+ else if (strMac != NULL)
setmac(strMac);
else if (cmd != NULL)
(*cmd)();
- else
- errno = EINVAL;
if (gbeFileModified)
writeGbeFile(&fd, FILENAME);