From 3401fdcd4125beea1a8cb1cc59ee27df89d4d88a Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 15 Aug 2013 21:32:08 -0600 Subject: [PATCH] Correct some minor compiler warnings A few places in the code through up warnings when building with strict compiler flags. Correct these. BUG=chrome-os-partner:21115 BRANCH=pit TEST=manual Build with: FEATURES=test emerge-peach_pit vboot_reference and see that iot now succeeds. Warnings include: host/arch/arm/lib/crossystem_arch.c: In function 'ReadFdtValue': host/arch/arm/lib/crossystem_arch.c:93:8: error: ignoring return value of 'fread', declared with attribute warn_unused_result [-Werror=unused-result] Change-Id: I765723636e5f8979b794925c7b610081b2849026 Signed-off-by: Simon Glass Reviewed-on: https://gerrit.chromium.org/gerrit/66174 --- futility/futility.c | 3 ++- host/arch/arm/lib/crossystem_arch.c | 5 ++++- host/lib/host_keyblock.c | 2 +- tests/vboot_api_kernel_tests.c | 5 +++-- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/futility/futility.c b/futility/futility.c index 54921d1afb..356208654f 100644 --- a/futility/futility.c +++ b/futility/futility.c @@ -108,7 +108,8 @@ static void log_str(char *str) return; } - write(log_fd, "\n", 1); + if (write(log_fd, "\n", 1) < 0) + return; } static void log_close(void) diff --git a/host/arch/arm/lib/crossystem_arch.c b/host/arch/arm/lib/crossystem_arch.c index 033632e402..99b868978b 100644 --- a/host/arch/arm/lib/crossystem_arch.c +++ b/host/arch/arm/lib/crossystem_arch.c @@ -90,7 +90,10 @@ static int ReadFdtValue(const char *property, int *value) { return E_FILEOP; } - fread(&data, 1, sizeof(data), file); + if (fread(&data, 1, sizeof(data), file) != sizeof(data)) { + fprintf(stderr, "Unable to read FDT property %s\n", property); + return E_FILEOP; + } fclose(file); if (value) diff --git a/host/lib/host_keyblock.c b/host/lib/host_keyblock.c index b12f024fdd..e1dd95bec0 100644 --- a/host/lib/host_keyblock.c +++ b/host/lib/host_keyblock.c @@ -147,7 +147,7 @@ VbKeyBlockHeader* KeyBlockRead(const char* filename) { /* Verify the hash of the key block, since we can do that without * the public signing key. */ if (0 != KeyBlockVerify(block, file_size, NULL, 1)) { - VBDEBUG(("Invalid key block file: filename\n", filename)); + VBDEBUG(("Invalid key block file: %s\n", filename)); free(block); return NULL; } diff --git a/tests/vboot_api_kernel_tests.c b/tests/vboot_api_kernel_tests.c index 56cb21040d..87dc6cfa6f 100644 --- a/tests/vboot_api_kernel_tests.c +++ b/tests/vboot_api_kernel_tests.c @@ -234,7 +234,8 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count, t->disks_to_provide[i].flags; mock_disks[num_disks].handle = (VbExDiskHandle_t) t->disks_to_provide[i].diskname; - VBDEBUG((" mock_disk[%d] %lld %lld 0x%x %s\n", i, + VBDEBUG((" mock_disk[%d] %" PRIu64 " %" PRIu64 + " 0x%x %s\n", i, mock_disks[num_disks].bytes_per_lba, mock_disks[num_disks].lba_count, mock_disks[num_disks].flags, @@ -253,7 +254,7 @@ VbError_t VbExDiskGetInfo(VbDiskInfo **infos_ptr, uint32_t *count, else *count = num_disks; - VBDEBUG((" *count=%lld\n", *count)); + VBDEBUG((" *count=%" PRIu32 "\n", *count)); VBDEBUG((" return 0x%x\n", t->diskgetinfo_return_val)); return t->diskgetinfo_return_val;