From 49506a883283ebb3716de812fd809fba67da602c Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 26 Jan 2025 08:52:26 +0000 Subject: util/nvmutil: move write checks to writeGbe doing it in main() is messy. better do it from the actual function. now the logic in main is clearer. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'util/nvmutil') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index be02961c..8e1fef4f 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -147,10 +147,10 @@ main(int argc, char *argv[]) err_if((errno = (cmd == NULL) ? EINVAL : errno)); /* bad user arg */ readGbe(); /* read gbe file into memory */ - (*cmd)(); /* operate on gbe file in memory, as per user command */ - if ((gbeFileChanged) && (flags != O_RDONLY)) - writeGbe(); + (*cmd)(); /* operate on gbe file in memory */ + + writeGbe(); /* write changes back to file */ err_if((errno != 0) && (cmd != cmd_dump)); /* don't err on dump */ return errno; /* errno can be set by the dump command */ @@ -413,6 +413,9 @@ goodChecksum(int partnum) void writeGbe(void) { + if ((!gbeFileChanged) || (flags == O_RDONLY)) + return; + for (int p = 0; p < 2; p++) { if ((!nvmPartChanged[p])) continue; -- cgit v1.2.1