safe_macros: add SAFE_STRTOUL
commit 586992b33b tried to set ULONG_MAX as SAFE_STRTOL upper bound,
but this would cause the new issue:
[root@localhost hugeshmat]# ./hugeshmat01
hugeshmat01 0 TINFO : set nr_hugepages to 128
hugeshmat01 1 TBROK : converted value out of range (0 - -1) at mem.c:840
hugeshmat01 2 TBROK : Remaining cases broken
hugeshmat01 0 TINFO : set nr_hugepages to 0
the failure is because SAFE_STRTOL converts ULONG_MAX as long type, which
will change 'ULONG_MAX' as -1.
the patch add a new macro SAFE_STRTOUL, which is a safe mode of strtoul()
Signed-off-by: Zhouping Liu <zliu@redhat.com>
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
3 files changed