summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChen Pei <[email protected]>2026-03-06 17:44:25 +0800
committerAnup Patel <[email protected]>2026-04-06 17:53:33 +0530
commit2bf0de88c8897ff4be5b89c04115c17421ad5687 (patch)
tree8d503dc1c9ff16fc83aa0dbc056bcb2489d1df93 /include
parentfdb78b0ec585a318ae6199c7129be389bf78091c (diff)
lib: Fix sbi_strchr to correctly handle null terminator search
The original sbi_strchr implementation did not conform to the C standard behavior. According to the C standard and POSIX specification, strchr(s, 0) should return a pointer to the null terminator at the end of string s. The previous implementation used a while loop that would terminate when either reaching the end of string or finding the character, but it would return NULL when searching for the null terminator instead of returning a pointer to the null terminator itself. The fixed implementation uses a do-while loop that ensures even when searching for the null terminator, the function correctly returns a pointer to the null terminator position rather than NULL. This fix ensures sbi_strchr behavior aligns with standard library function semantics, making it more predictable and safe for users expecting standard C library behavior. Signed-off-by: Chen Pei <[email protected]> Reviewed-by: Anup Patel <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anup Patel <[email protected]>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions