From: Jan Beulich Date: Wed, 7 Dec 2016 12:52:59 +0000 (+0100) Subject: libelf: use UINT_MAX X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~3257 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d4c856a57a55f888369c8933d93c6da04cd8036c;p=xen.git libelf: use UINT_MAX While Xen indeed doesn't have limits.h, it still does have UINT_MAX, so we should avoid open coding it (and perhaps - even if unlikely - getting it wrong). Signed-off-by: Jan Beulich Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Roger Pau Monné --- diff --git a/xen/common/libelf/libelf-private.h b/xen/common/libelf/libelf-private.h index d5f9d89f27..388c3da34d 100644 --- a/xen/common/libelf/libelf-private.h +++ b/xen/common/libelf/libelf-private.h @@ -43,6 +43,7 @@ #include #include #include +#include #ifdef __sun__ #include #define bswap_16(x) BSWAP_16(x) diff --git a/xen/common/libelf/libelf-tools.c b/xen/common/libelf/libelf-tools.c index 0197b85819..a5703b307e 100644 --- a/xen/common/libelf/libelf-tools.c +++ b/xen/common/libelf/libelf-tools.c @@ -131,9 +131,10 @@ unsigned elf_shdr_count(struct elf_binary *elf) { unsigned count = elf_uval(elf, elf->ehdr, e_shnum); uint64_t max = elf->size / sizeof(Elf32_Shdr); - if (max > ~(unsigned)0) - max = ~(unsigned)0; /* Xen doesn't have limits.h :-/ */ - if (count > max) + + if ( max > UINT_MAX ) + max = UINT_MAX; + if ( count > max ) { elf_mark_broken(elf, "far too many section headers"); count = max;