Julius Werner has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32086 )
Change subject: libpayload: Deduplicate strtol and strtoull ......................................................................
Patch Set 1:
Ran a couple of tests to make sure it still spits out the right values. For this I hacked the strto(u)l() bounds to use INT_MAX/MIN instead of LONG_MAX/MIN, so the difference is visible on arm64 (because normally the l and ll functions always show the same):
TEST: strtoll(0) == 0 TEST: strtol(0) == 0 TEST: strtoull(0) == 0 TEST: strtoul(0) == 0 TEST: strtoll(0x7fffffff) == 2147483647 TEST: strtol(0x7fffffff) == 2147483647 TEST: strtoull(0x7fffffff) == 2147483647 TEST: strtoul(0x7fffffff) == 2147483647 TEST: strtoll(0x80000000) == 2147483648 TEST: strtol(0x80000000) == 2147483647 TEST: strtoull(0x80000000) == 2147483648 TEST: strtoul(0x80000000) == 2147483648 TEST: strtoll(0xffffffff) == 4294967295 TEST: strtol(0xffffffff) == 2147483647 TEST: strtoull(0xffffffff) == 4294967295 TEST: strtoul(0xffffffff) == 4294967295 TEST: strtoll(0x100000000LL) == 4294967296 TEST: strtol(0x100000000LL) == 2147483647 TEST: strtoull(0x100000000LL) == 4294967296 TEST: strtoul(0x100000000LL) == 4294967295 TEST: strtoll(0x7fffffffffffffffLL) == 9223372036854775807 TEST: strtol(0x7fffffffffffffffLL) == 2147483647 TEST: strtoull(0x7fffffffffffffffLL) == 9223372036854775807 TEST: strtoul(0x7fffffffffffffffLL) == 4294967295 TEST: strtoll(0x8000000000000000ULL) == 9223372036854775807 TEST: strtol(0x8000000000000000ULL) == 2147483647 TEST: strtoull(0x8000000000000000ULL) == 9223372036854775808 TEST: strtoul(0x8000000000000000ULL) == 4294967295 TEST: strtoll(0xffffffffffffffffULL) == 9223372036854775807 TEST: strtol(0xffffffffffffffffULL) == 2147483647 TEST: strtoull(0xffffffffffffffffULL) == 18446744073709551615 TEST: strtoul(0xffffffffffffffffULL) == 4294967295 TEST: strtoll(-0x7fffffff) == -2147483647 TEST: strtol(-0x7fffffff) == -2147483647 TEST: strtoll(-0x80000000) == -2147483648 TEST: strtol(-0x80000000) == -2147483648 TEST: strtoll(-0x80000001) == -2147483649 TEST: strtol(-0x80000001) == -2147483648 TEST: strtoll(-0xffffffff) == -4294967295 TEST: strtol(-0xffffffff) == -2147483648 TEST: strtoll(-0x100000000LL) == -4294967296 TEST: strtol(-0x100000000LL) == -2147483648 TEST: strtoll(-0x7fffffffffffffffLL) == -9223372036854775807 TEST: strtol(-0x7fffffffffffffffLL) == -2147483648 TEST: strtoll(-0x8000000000000000) == -9223372036854775808 TEST: strtol(-0x8000000000000000) == -2147483648 TEST: strtoll(-0x8000000000000001) == -9223372036854775808 TEST: strtol(-0x8000000000000001) == -2147483648