Zepp-Hanzj opened a new pull request, #19594: URL: https://github.com/apache/nuttx/pull/19594
## Summary The integer conversion interfaces document explicit bases from 2 through 36. The shared `lib_checkbase()` helper currently rejects bases above 26 even though `lib_isbasedigit()` already supports digits `0-9` and letters `a-z`/`A-Z`. Raise the explicit-base limit from 26 to 36 so `strtol()`, `strtoul()`, `strtoll()`, `strtoull()`, `strtoimax()`, and `strtoumax()` accept the full documented range. Bases below 2 and above 36 remain invalid. ## Impact Explicit bases 27 through 36 no longer fail with `EINVAL`. Existing base-0 detection, bases 2 through 26, and invalid-base handling are unchanged. ## Testing ### NuttX sim Built the current upstream `sim:nsh` configuration and ran a dedicated 117-assertion test program covering: - every explicit base from 2 through 36 - lowercase and uppercase alphabetic digits - all six integer conversion interfaces - whitespace, signs, and end pointers - base-36 64-bit limits and overflow saturation - invalid bases 1, 37, and -2 - base-0 decimal, octal, and hexadecimal detection - out-of-base digits, no-conversion input, and unsigned negation ```text BASE36-TEST BEGIN BASE36-TEST SUMMARY total=117 passed=117 failed=0 BASE36-TEST PASS ``` ### STM32F407ZG hardware A/B Built and flashed the same 110-assertion test program before and after this one-line change. J-Link verified both images after programming. The serial results below are from the physical STM32F407ZG target at 115200 baud. <details> <summary>Before fix: 69 passed, 41 failed</summary> ```text BASE36-TEST BEGIN FAIL api=strtoul case=max-lower input='q#' base=27 value=0 expected=26 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='Q#' base=27 value=0 expected=26 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=27 value=0 expected=27 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='r#' base=28 value=0 expected=27 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='R#' base=28 value=0 expected=27 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=28 value=0 expected=28 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='s#' base=29 value=0 expected=28 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='S#' base=29 value=0 expected=28 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=29 value=0 expected=29 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='t#' base=30 value=0 expected=29 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='T#' base=30 value=0 expected=29 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=30 value=0 expected=30 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='u#' base=31 value=0 expected=30 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='U#' base=31 value=0 expected=30 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=31 value=0 expected=31 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='v#' base=32 value=0 expected=31 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='V#' base=32 value=0 expected=31 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=32 value=0 expected=32 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='w#' base=33 value=0 expected=32 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='W#' base=33 value=0 expected=32 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=33 value=0 expected=33 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='x#' base=34 value=0 expected=33 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='X#' base=34 value=0 expected=33 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=34 value=0 expected=34 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='y#' base=35 value=0 expected=34 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='Y#' base=35 value=0 expected=34 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=35 value=0 expected=35 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=max-lower input='z#' base=36 value=0 expected=35 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=max-upper input='Z#' base=36 value=0 expected=35 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoul case=positional-10 input='10!' base=36 value=0 expected=36 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoul case=whitespace-plus input=' +z!' base=36 value=0 expected=35 end=0 expected_end=4 errno=22 expected_errno=0 FAIL api=strtoll case=negative input='-z!' base=36 value=0 expected=18446744073709551581 end=0 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoull case=ull-simple input='Z!' base=36 value=0 expected=35 end=0 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoimax case=imax-simple input='-z!' base=36 value=0 expected=18446744073709551581 end=1 expected_end=2 errno=22 expected_errno=0 FAIL api=strtoumax case=umax-simple input='z!' base=36 value=0 expected=35 end=-134373988 expected_end=1 errno=22 expected_errno=0 FAIL api=strtoull case=ull-max input='3w5e11264sgsf!' base=36 value=0 expected=18446744073709551615 end=0 expected_end=13 errno=22 expected_errno=0 FAIL api=strtoull case=ull-overflow input='3w5e11264sgsg!' base=36 value=0 expected=18446744073709551615 end=0 expected_end=13 errno=22 expected_errno=34 FAIL api=strtoll case=ll-max input='1y2p0ij32e8e7!' base=36 value=0 expected=9223372036854775807 end=0 expected_end=13 errno=22 expected_errno=0 FAIL api=strtoll case=ll-positive-overflow input='1y2p0ij32e8e8!' base=36 value=0 expected=9223372036854775807 end=0 expected_end=13 errno=22 expected_errno=34 FAIL api=strtoll case=ll-min input='-1y2p0ij32e8e8!' base=36 value=0 expected=9223372036854775808 end=0 expected_end=14 errno=22 expected_errno=0 FAIL api=strtoll case=ll-negative-overflow input='-1y2p0ij32e8e9!' base=36 value=0 expected=9223372036854775808 end=0 expected_end=14 errno=22 expected_errno=34 BASE36-TEST SUMMARY total=110 passed=69 failed=41 BASE36-TEST FAIL ``` </details> <details> <summary>After fix: 110 passed, 0 failed</summary> ```text BASE36-TEST BEGIN BASE36-TEST SUMMARY total=110 passed=110 failed=0 BASE36-TEST PASS ``` </details> ### Style ```text $ tools/checkpatch.sh -f libs/libc/stdlib/lib_checkbase.c ✔️ All checks pass. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
