From 2ca2bdce02407c572fb0792dcebb9e876a3d553a Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 2 Apr 2015 11:29:48 +0300 Subject: [PATCH] tools: Fix build-error on 32-bit systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The %zX format specifier for st_size causes the following warning: tools/create-image.c:120:5: error: format ‘%zX’ expects argument of type ‘size_t’, but argument 10 has type ‘__off_t’ [-Werror=format=] st.st_size, 0, 0, 0, 0, namelen + 1, 0, name); ^ The best way to solve this (as off_t doesn't have a standard format specifier) is to use 'j' and do a typecast to uintmax_t. --- tools/create-image.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/create-image.c b/tools/create-image.c index c2342790a..d94f99d92 100644 --- a/tools/create-image.c +++ b/tools/create-image.c @@ -34,6 +34,7 @@ #include #include #include +#include /* * The "new" ASCII format uses 8-byte hexadecimal fields for all numbers and @@ -58,7 +59,7 @@ * */ -#define HDR_FMT "%s%08X%08X%08X%08X%08X%08X%08zX%08X%08X%08X%08X%08X%08X%s" +#define HDR_FMT "%s%08X%08X%08X%08X%08X%08X%08jX%08X%08X%08X%08X%08X%08X%s" #define HDR_MAGIC "070701" @@ -117,7 +118,7 @@ static void write_block(FILE *fp, const char *pathname, unsigned int ino, done: fprintf(fp, HDR_FMT, HDR_MAGIC, ino, mode, 0, 0, 1, 0, - st.st_size, 0, 0, 0, 0, namelen + 1, 0, name); + (uintmax_t) st.st_size, 0, 0, 0, 0, namelen + 1, 0, name); pad = 4 - ((110 + namelen) % 4); for (i = 0; i < pad; i++) -- 2.47.3