From e29aef80350b5ee4bf989443acf553f5f295df4c Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 10 Dec 2019 20:42:15 -0800 Subject: Fix format compiler warnings This also allows the compiler to check these at compile time. --- src/common.c | 5 +++-- src/common.h | 3 +++ src/idevicerestore.c | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/common.c b/src/common.c index cc275f0..325ea2d 100644 --- a/src/common.c +++ b/src/common.c @@ -25,6 +25,7 @@ #include #endif +#include #include #include #include @@ -589,7 +590,7 @@ uint64_t _plist_dict_get_uint(plist_t dict, const char *key) } else if (strsz == 1) { uintval = strval[0]; } else { - error("%s: ERROR: invalid size %d for data to integer conversion\n", __func__, strsz); + error("%s: ERROR: invalid size %" PRIu64 " for data to integer conversion\n", __func__, strsz); } free(strval); } @@ -635,7 +636,7 @@ uint8_t _plist_dict_get_bool(plist_t dict, const char *key) if (strsz == 1) { bval = strval[0]; } else { - error("%s: ERROR: invalid size %d for data to boolean conversion\n", __func__, strsz); + error("%s: ERROR: invalid size %" PRIu64 " for data to boolean conversion\n", __func__, strsz); } free(strval); } diff --git a/src/common.h b/src/common.h index d943568..af46737 100644 --- a/src/common.h +++ b/src/common.h @@ -118,8 +118,11 @@ extern struct idevicerestore_mode_t idevicerestore_modes[]; extern int idevicerestore_debug; +__attribute__((format(printf, 1, 2))) void info(const char* format, ...); +__attribute__((format(printf, 1, 2))) void error(const char* format, ...); +__attribute__((format(printf, 1, 2))) void debug(const char* format, ...); void debug_plist(plist_t plist); diff --git a/src/idevicerestore.c b/src/idevicerestore.c index 03e4811..1ce642b 100644 --- a/src/idevicerestore.c +++ b/src/idevicerestore.c @@ -496,7 +496,7 @@ int idevicerestore_start(struct idevicerestore_client_t* client) } unsigned long selected = strtoul(input, NULL, 10); if (selected == 0 || selected > count) { - printf("Invalid input value. Must be in range: 1..%d\n", count); + printf("Invalid input value. Must be in range: 1..%u\n", count); continue; } selected_fw = plist_array_get_item(signed_fws, (uint32_t)selected-1); -- cgit v1.1-32-gdbae