mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 08:40:14 +02:00
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>
This commit is contained in:
@@ -147,10 +147,10 @@ main(int argc, char *argv[])
|
|||||||
err_if((errno = (cmd == NULL) ? EINVAL : errno)); /* bad user arg */
|
err_if((errno = (cmd == NULL) ? EINVAL : errno)); /* bad user arg */
|
||||||
|
|
||||||
readGbe(); /* read gbe file into memory */
|
readGbe(); /* read gbe file into memory */
|
||||||
(*cmd)(); /* operate on gbe file in memory, as per user command */
|
|
||||||
|
|
||||||
if ((gbeFileChanged) && (flags != O_RDONLY))
|
(*cmd)(); /* operate on gbe file in memory */
|
||||||
writeGbe();
|
|
||||||
|
writeGbe(); /* write changes back to file */
|
||||||
|
|
||||||
err_if((errno != 0) && (cmd != cmd_dump)); /* don't err on dump */
|
err_if((errno != 0) && (cmd != cmd_dump)); /* don't err on dump */
|
||||||
return errno; /* errno can be set by the dump command */
|
return errno; /* errno can be set by the dump command */
|
||||||
@@ -413,6 +413,9 @@ goodChecksum(int partnum)
|
|||||||
void
|
void
|
||||||
writeGbe(void)
|
writeGbe(void)
|
||||||
{
|
{
|
||||||
|
if ((!gbeFileChanged) || (flags == O_RDONLY))
|
||||||
|
return;
|
||||||
|
|
||||||
for (int p = 0; p < 2; p++) {
|
for (int p = 0; p < 2; p++) {
|
||||||
if ((!nvmPartChanged[p]))
|
if ((!nvmPartChanged[p]))
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user