summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2025-01-27 05:50:34 +0000
committerLeah Rowe <leah@libreboot.org>2025-01-27 05:50:34 +0000
commit6841a351ebc5ffe32182c3f7079ec41f8dfbdcd0 (patch)
treec95c7888e01ddde72935b715805fdc0c60dd4236
parentda0a6c216cf7de6442fdba8ce1b4801e0c19d9bb (diff)
util/nvmutil: print dump *after* modification
this way, we still get an error exit for example when trying to invalidate an already invalid checksum; this error exit was disabled by the last revisions. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--util/nvmutil/nvmutil.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 70571bee..88ac24dc 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -449,13 +449,6 @@ writeGbe(void)
{
ssize_t tnw = 0; /* total bytes written */
- if ((flags != O_RDONLY) && (cmd != cmd_dump)) {
- if (nvmPartChanged[0] || nvmPartChanged[1])
- printf("The following nvm words will be written:\n");
- cmd_dump();
- errno = 0; /* reset for cmd_brick */
- }
-
for (int p = 0; p < 2; p++) {
if ((!nvmPartChanged[p]) || (flags == O_RDONLY))
continue;
@@ -471,12 +464,20 @@ writeGbe(void)
tnw += nf;
}
+ if ((flags != O_RDONLY) && (cmd != cmd_dump)) {
+ if (nvmPartChanged[0] || nvmPartChanged[1])
+ printf("The following nvm words were written:\n");
+ cmd_dump();
+ }
+
if ((!tnw) && (flags != O_RDONLY))
fprintf(stderr, "No changes needed on file '%s'\n", filename);
else if (tnw)
printf("%ld bytes written to file '%s'\n", tnw, filename);
- errno = 0;
+ if (tnw)
+ errno = 0;
+
err_if(close(fd) == -1);
}