summaryrefslogtreecommitdiff
path: root/cgpt/cgpt_nor.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2016-09-09 10:17:32 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-15 16:16:12 -0700
commitb56b5f8e06b4cc4d4105a8141b3d2b8647eedff6 (patch)
treeb0e92569a8c46cdc2a7f97fba03192c970368916 /cgpt/cgpt_nor.c
parent8f400498c68098d024170ccbcb4b3018b3417799 (diff)
downloadvboot-b56b5f8e06b4cc4d4105a8141b3d2b8647eedff6.tar.gz
Fix more coverity warnings in utilities
Assorted minor code issues, which we should fix so any new errors stand out more. BUG=chromium:643769 BRANCH=none TEST=make runtests Change-Id: I8fcf0c51e33d5dc49f650f4069f1579091cf188d Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/383713 Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'cgpt/cgpt_nor.c')
-rw-r--r--cgpt/cgpt_nor.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/cgpt/cgpt_nor.c b/cgpt/cgpt_nor.c
index d2e7eafa..f8b361f8 100644
--- a/cgpt/cgpt_nor.c
+++ b/cgpt/cgpt_nor.c
@@ -212,7 +212,8 @@ int ReadNorFlash(char *temp_dir_template) {
ret++;
int fd_flags = fcntl(1, F_GETFD);
// Close stdout on exec so that flashrom does not muck up cgpt's output.
- fcntl(1, F_SETFD, FD_CLOEXEC);
+ if (0 != fcntl(1, F_SETFD, FD_CLOEXEC))
+ Warning("Can't stop flashrom from mucking up our output\n");
if (ForkExecL(temp_dir_template, FLASHROM_PATH, "-i", "RW_GPT:rw_gpt", "-r",
NULL) != 0) {
Error("Cannot exec flashrom to read from RW_GPT section.\n");
@@ -221,7 +222,9 @@ int ReadNorFlash(char *temp_dir_template) {
ret = 0;
}
- fcntl(1, F_SETFD, fd_flags);
+ // Restore stdout flags
+ if (0 != fcntl(1, F_SETFD, fd_flags))
+ Warning("Can't restore stdout flags\n");
return ret;
}
@@ -237,7 +240,8 @@ int WriteNorFlash(const char *dir) {
int nr_fails = 0;
int fd_flags = fcntl(1, F_GETFD);
// Close stdout on exec so that flashrom does not muck up cgpt's output.
- fcntl(1, F_SETFD, FD_CLOEXEC);
+ if (0 != fcntl(1, F_SETFD, FD_CLOEXEC))
+ Warning("Can't stop flashrom from mucking up our output\n");
if (ForkExecL(dir, FLASHROM_PATH, "-i", "RW_GPT_PRIMARY:rw_gpt_1",
"-w", "--fast-verify", NULL) != 0) {
Warning("Cannot write the 1st half of rw_gpt back with flashrom.\n");
@@ -248,7 +252,8 @@ int WriteNorFlash(const char *dir) {
Warning("Cannot write the 2nd half of rw_gpt back with flashrom.\n");
nr_fails++;
}
- fcntl(1, F_SETFD, fd_flags);
+ if (0 != fcntl(1, F_SETFD, fd_flags))
+ Warning("Can't restore stdout flags\n");
switch (nr_fails) {
case 0: ret = 0; break;
case 1: Warning("It might still be okay.\n"); break;