From 3e15a29568e40ceb6393d092c6488ef25eb96256 Mon Sep 17 00:00:00 2001 From: Jacob Garber Date: Mon, 5 Aug 2019 11:49:35 -0600 Subject: cgpt: Fix format specifiers for uint64_t These variables are all uint64_t, and so we need to use PRIu64 to ensure they are printed with the correct format specifier. BUG=none TEST=make clean && make runtests BRANCH=none Change-Id: Idb8fee0ef525d224670a9d2b3a7915be1b19fd21 Signed-off-by: Jacob Garber Found-by: Coverity CID 199873, 199878, 199889 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1737200 Reviewed-by: Julius Werner --- cgpt/cgpt_common.c | 4 ++-- cgpt/cgpt_create.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c index 90fe45a2..db180bef 100644 --- a/cgpt/cgpt_common.c +++ b/cgpt/cgpt_common.c @@ -85,13 +85,13 @@ int Load(struct drive *drive, uint8_t **buf, require(buf); if (!sector_count || !sector_bytes) { - Error("%s() failed at line %d: sector_count=%d, sector_bytes=%d\n", + Error("%s() failed at line %d: sector_count=%" PRIu64 ", sector_bytes=%" PRIu64 "\n", __FUNCTION__, __LINE__, sector_count, sector_bytes); return CGPT_FAILED; } /* Make sure that sector_bytes * sector_count doesn't roll over. */ if (sector_bytes > (UINT64_MAX / sector_count)) { - Error("%s() failed at line %d: sector_count=%d, sector_bytes=%d\n", + Error("%s() failed at line %d: sector_count=%" PRIu64 ", sector_bytes=%" PRIu64 "\n", __FUNCTION__, __LINE__, sector_count, sector_bytes); return CGPT_FAILED; } diff --git a/cgpt/cgpt_create.c b/cgpt/cgpt_create.c index e2b4b80b..77980bfc 100644 --- a/cgpt/cgpt_create.c +++ b/cgpt/cgpt_create.c @@ -15,7 +15,7 @@ static void AllocAndClear(uint8_t **buf, uint64_t size) { } else { *buf = calloc(1, size); if (!*buf) { - Error("Cannot allocate %u bytes.\n", size); + Error("Cannot allocate %" PRIu64 " bytes.\n", size); abort(); } } -- cgit v1.2.1