summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorEvan Green <evgreen@chromium.org>2019-07-11 10:40:19 -0700
committerCommit Bot <commit-bot@chromium.org>2019-07-16 00:15:42 +0000
commit92094927ded5bb9729636377642204b16b9bb961 (patch)
tree2ae3fad338185ab1f1f8e09623e502f551bbd9fa /util
parentc9db0502fa3b0de422e46798d489d803f79b9118 (diff)
downloadchrome-ec-92094927ded5bb9729636377642204b16b9bb961.tar.gz
util: ecst: Fix Coverity print format warnings
I noticed Coverity is complaining about a handful of printf format warnings. These were all valid. It looks like a robot, or perhaps a very hasty human went through and split printf strings that extended over 80 columns into multiple calls. But they didn't make sure that the arguments went into the correct corresponding printf call. Recombine a few of those printfs back into a single call, and fix a few other printf-related odds and ends. Also, add the format specifier to my_printf so that these errors are detected at compile time in the future. BUG=chromium:984041 TEST=make -j buildall BRANCH=None Change-Id: I27b352b97d50fbbaee2fb801b817ef82ad90ca98 Signed-off-by: Evan Green <evgreen@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1698488
Diffstat (limited to 'util')
-rw-r--r--util/ecst.c20
-rw-r--r--util/ecst.h1
2 files changed, 8 insertions, 13 deletions
diff --git a/util/ecst.c b/util/ecst.c
index 0680f8b1e8..f7409941c0 100644
--- a/util/ecst.c
+++ b/util/ecst.c
@@ -71,7 +71,7 @@ static int splice_into_path(char *result, const char *path, int resultsz,
"\n\nfilename '%s' with prefix '%s' too long\n\n",
path, prefix);
my_printf(TINF,
- "\n\n%d + %d + 1 needs to fit in %d bytes\n\n",
+ "\n\n%zu + %zu + 1 needs to fit in %d bytes\n\n",
strlen(path), strlen(prefix), resultsz);
return FALSE;
}
@@ -717,8 +717,7 @@ int main(int argc, char *argv[])
if ((main_temp & ADDR_16_BYTES_ALIGNED_MASK)
!= 0) {
my_printf(TERR,
- "\nFW Image address (0x%08X)");
- my_printf(TERR,
+ "\nFW Image address (0x%08X)"
" isn't 16-bytes aligned !\n",
main_temp);
main_status = FALSE;
@@ -1364,11 +1363,10 @@ int main_bin(struct tbinparams binary_params)
if (((int)binary_params.fw_hdr_offset < 0) ||
(binary_params.fw_hdr_offset > bin_file_size_bytes)) {
my_printf(TERR,
- "\nFW header offset 0x%08x (%d) should be in the",
- binary_params.fw_hdr_offset);
- my_printf(TERR,
+ "\nFW header offset 0x%08x (%d) should be in the"
" range of 0 and file size (%d).\n",
binary_params.fw_hdr_offset,
+ binary_params.fw_hdr_offset,
bin_file_size_bytes);
return FALSE;
}
@@ -1889,9 +1887,7 @@ int calc_header_crc_bin(unsigned int *p_cksum)
*/
if (g_verbose == SUPER_VERBOSE) {
if (i%line_print_size == 0)
- my_printf(TDBG,
- "\n[%.4x]: ",
- g_header_array + i);
+ my_printf(TDBG, "\n[%.4x]: ", i);
my_printf(TDBG, "%.2x ", g_header_array[i]);
}
@@ -2101,11 +2097,9 @@ int main_hdr(void)
ptr_fw_addr);
} else {
my_printf(TERR,
- "\n\nCouldn't write signature (%x) and ",
- tmp_long_val);
- my_printf(TERR,
+ "\n\nCouldn't write signature (%x) and "
"pointer to BootLoader header file (%s)\n\n",
- ptr_fw_addr, tmp_file_name);
+ tmp_long_val, tmp_file_name);
return FALSE;
}
diff --git a/util/ecst.h b/util/ecst.h
index 7470b3ab6c..423f65a102 100644
--- a/util/ecst.h
+++ b/util/ecst.h
@@ -269,6 +269,7 @@ int read_from_file(unsigned int offset,
char *print_string);
/* Nice Particular Printf - General */
+__attribute__((__format__(__printf__, 2, 3)))
void my_printf(int error_level, char *fmt, ...);
int str_cmp_no_case(const char *s1, const char *s2);