From a5549b43f8acaa5b69cacb6c46c40da1cf44a4c0 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 27 Jan 2025 05:50:34 +0000 Subject: [PATCH] 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 --- util/nvmutil/nvmutil.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 70571be..88ac24d 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); }