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 <jbeulich@suse.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
#include <string.h>
#include <stddef.h>
#include <inttypes.h>
+#include <limits.h>
#ifdef __sun__
#include <sys/byteorder.h>
#define bswap_16(x) BSWAP_16(x)
{
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;