diff options
author | Leah Rowe <leah@libreboot.org> | 2025-01-26 08:52:26 +0000 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-01-26 08:52:26 +0000 |
commit | 49506a883283ebb3716de812fd809fba67da602c (patch) | |
tree | f83af82b6ece0fc1241ba28383e2e0e91d01415b | |
parent | 948377b0e7ef939ff24dc7a0a8dc84440c848ec4 (diff) |
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 <leah@libreboot.org>
-rw-r--r-- | util/nvmutil/nvmutil.c | 9 |
1 files changed, 6 insertions, 3 deletions
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; |