summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--futility/cmd_gbb_utility.c39
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;
}