diff options
author | Evan Benn <evanbenn@chromium.org> | 2022-12-07 10:29:42 +1100 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-12-11 12:00:46 +0000 |
commit | 65a1a07908c28abe07237a4bd57bfc5af6f64942 (patch) | |
tree | d24566d8d79759e1431247daf30dc8ddb4c3aea7 | |
parent | 601a164a534d80952cf81d68597a1a1fac0da65a (diff) | |
download | vboot-65a1a07908c28abe07237a4bd57bfc5af6f64942.tar.gz |
futility: gbb: Move errorcnt from function to main
Move the error recording from a global to checking the function return
code. The function can then be moved to another translation unit.
BUG=b:260531154
BRANCH=None
TEST=FEATURES=test emerge-grunt vboot_reference
TEST=futility gbb -s --flags 0x0 /tmp/bios /tmp/bios2
Change-Id: I7a2d35471f55d557e707568d0981b1d8cbbc6a19
Signed-off-by: Evan Benn <evanbenn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/4082790
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Tested-by: Edward O'Callaghan <quasisec@chromium.org>
Commit-Queue: Edward O'Callaghan <quasisec@chromium.org>
-rw-r--r-- | futility/cmd_gbb_utility.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/futility/cmd_gbb_utility.c b/futility/cmd_gbb_utility.c index 41610633..7e35cd31 100644 --- a/futility/cmd_gbb_utility.c +++ b/futility/cmd_gbb_utility.c @@ -264,7 +264,6 @@ static int write_to_file(const char *msg, const char *filename, r = errno; fprintf(stderr, "ERROR: Unable to open %s for writing: %s\n", filename, strerror(r)); - errorcnt++; return r; } @@ -273,7 +272,6 @@ static int write_to_file(const char *msg, const char *filename, r = errno; fprintf(stderr, "ERROR: Unable to write to %s: %s\n", filename, strerror(r)); - errorcnt++; } if (0 != fclose(fp)) { @@ -282,7 +280,6 @@ static int write_to_file(const char *msg, const char *filename, strerror(e)); if (!r) r = e; - errorcnt++; } if (!r && msg) @@ -498,19 +495,23 @@ static int do_gbb(int argc, char *argv[]) if (sel_flags) printf("flags: 0x%08x\n", gbb->flags); if (opt_rootkey) - write_to_file(" - exported root_key to file:", - opt_rootkey, - gbb_base + gbb->rootkey_offset, - gbb->rootkey_size); + if (write_to_file(" - exported root_key to file:", + opt_rootkey, + gbb_base + gbb->rootkey_offset, + gbb->rootkey_size)) + errorcnt++; if (opt_bmpfv) - write_to_file(" - exported bmp_fv to file:", opt_bmpfv, - gbb_base + gbb->bmpfv_offset, - gbb->bmpfv_size); + if (write_to_file( + " - exported bmp_fv to file:", opt_bmpfv, + gbb_base + gbb->bmpfv_offset, + gbb->bmpfv_size)) + errorcnt++; if (opt_recoverykey) - write_to_file(" - exported recovery_key to file:", - opt_recoverykey, - gbb_base + gbb->recovery_key_offset, - gbb->recovery_key_size); + if (write_to_file(" - exported recovery_key to file:", + opt_recoverykey, + gbb_base + gbb->recovery_key_offset, + gbb->recovery_key_size)) + errorcnt++; break; case DO_SET: @@ -612,8 +613,9 @@ static int do_gbb(int argc, char *argv[]) /* Write it out if there are no problems. */ if (!errorcnt) - write_to_file("successfully saved new image to:", - outfile, outbuf, filesize); + if (write_to_file("successfully saved new image to:", + outfile, outbuf, filesize)) + errorcnt++; break; @@ -637,8 +639,9 @@ static int do_gbb(int argc, char *argv[]) return 1; } if (!errorcnt) - write_to_file("successfully created new GBB to:", - outfile, outbuf, filesize); + if (write_to_file("successfully created new GBB to:", + outfile, outbuf, filesize)) + errorcnt++; break; } |