mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-16 12:11:32 +00:00
Fix return value in trailing_strtoln()
This function should return -1 if there is no trailing integer in the string. Instead it returns 0. Fix it by checking for this condition at the start. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
a5b8722532
commit
b91c6a1209
1 changed files with 5 additions and 3 deletions
|
@ -160,9 +160,11 @@ long trailing_strtoln(const char *str, const char *end)
|
|||
|
||||
if (!end)
|
||||
end = str + strlen(str);
|
||||
for (p = end - 1; p > str; p--) {
|
||||
if (!isdigit(*p))
|
||||
return simple_strtoul(p + 1, NULL, 10);
|
||||
if (isdigit(end[-1])) {
|
||||
for (p = end - 1; p > str; p--) {
|
||||
if (!isdigit(*p))
|
||||
return simple_strtoul(p + 1, NULL, 10);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
Loading…
Add table
Reference in a new issue