mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-11-29 14:41:26 +01:00
lib: Drop unnecessary check for hex digit
If we see 0x then we can assume this is the start of a hex value. It does not seem necessary to check for a hex digit after that since it will happen when parsing the value anyway. Drop this check to simplify the code and reduce size. Add a few more test cases for when a 0x prefix is used. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
18546f2982
commit
96b23440c1
@ -18,7 +18,7 @@ static const char *_parse_integer_fixup_radix(const char *s, unsigned int *base)
|
|||||||
{
|
{
|
||||||
if (*base == 0) {
|
if (*base == 0) {
|
||||||
if (s[0] == '0') {
|
if (s[0] == '0') {
|
||||||
if (tolower(s[1]) == 'x' && isxdigit(s[2]))
|
if (tolower(s[1]) == 'x')
|
||||||
*base = 16;
|
*base = 16;
|
||||||
else
|
else
|
||||||
*base = 8;
|
*base = 8;
|
||||||
|
|||||||
@ -84,6 +84,8 @@ static int str_simple_strtoul(struct unit_test_state *uts)
|
|||||||
/* Base 10 and base 16 */
|
/* Base 10 and base 16 */
|
||||||
ut_assertok(run_strtoul(uts, str2, 10, 1099, 4, upper));
|
ut_assertok(run_strtoul(uts, str2, 10, 1099, 4, upper));
|
||||||
ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6, upper));
|
ut_assertok(run_strtoul(uts, str2, 16, 0x1099ab, 6, upper));
|
||||||
|
ut_assertok(run_strtoul(uts, str3, 16, 0xb, 3, upper));
|
||||||
|
ut_assertok(run_strtoul(uts, str3, 10, 0, 1, upper));
|
||||||
|
|
||||||
/* Invalid string */
|
/* Invalid string */
|
||||||
ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper));
|
ut_assertok(run_strtoul(uts, str1, 10, 0, 0, upper));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user