Paul Menzel (paulepanter@users.sourceforge.net) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/5388
-gerrit
commit c9c8be3c6a56e5d6bdfe46483a131298b15dad32 Author: Paul Menzel paulepanter@users.sourceforge.net Date: Sun Mar 16 00:15:57 2014 +0100
util/cbfstool: Use `%zu` instead of `%ld` for size_t arguments
Since commit aa2f739a (cbfs: fix issues with word size and endianness.) [1] cbfstool fails to built under 32-bit platforms.
error: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘size_t’
Some of these errors were fixed indirectly by subsequent patches, but not all of them.
Also no error is seen when building a coreboot image which indirectly builds cbfstool at `build/cbfstool` too.
For arguments of size_t the length modifier `z` and, as sizes are non-negative, the conversion specifier `u` should be used, so use `%zu` instead of `%ld` as the format string.
Also cast one argument, a sum of summands with types Elf64_Off and Elf64_Xaddr, to size_t, so it builds on 32-bit and 64-bit platforms.
[1] http://review.coreboot.org/4817
Change-Id: Id84a20fbf237376a31f7e4816bd139463800c977 Signed-off-by: Paul Menzel paulepanter@users.sourceforge.net --- util/cbfstool/cbfs-mkstage.c | 4 ++-- util/cbfstool/elfheaders.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/util/cbfstool/cbfs-mkstage.c b/util/cbfstool/cbfs-mkstage.c index 6aa3746..2a92c9f 100644 --- a/util/cbfstool/cbfs-mkstage.c +++ b/util/cbfstool/cbfs-mkstage.c @@ -132,8 +132,8 @@ int parse_elf_to_stage(const struct buffer *input, struct buffer *output, continue; if (input->size < (phdr[i].p_offset + phdr[i].p_filesz)){ ERROR("Underflow copying out the segment." - "File has %ld bytes left, segment end is %ld\n", - input->size, phdr[i].p_offset + phdr[i].p_filesz); + "File has %zu bytes left, segment end is %zu\n", + input->size, (size_t)(phdr[i].p_offset + phdr[i].p_filesz)); return -1; } memcpy(buffer + (l_start - data_start), diff --git a/util/cbfstool/elfheaders.c b/util/cbfstool/elfheaders.c index f3ed05c..816278f 100644 --- a/util/cbfstool/elfheaders.c +++ b/util/cbfstool/elfheaders.c @@ -147,7 +147,7 @@ check_size(const struct buffer *b, size_t offset, size_t size, const char *desc)
if (offset >= buffer_size(b) || (offset + size) > buffer_size(b)) { ERROR("The file is not large enough for the '%s'. " - "%ld bytes @ offset %zu, input %zu bytes.\n", + "%zu bytes @ offset %zu, input %zu bytes.\n", desc, size, offset, buffer_size(b)); return -1; }