Skip to content
Snippets Groups Projects
Commit b91c6a12 authored by Simon Glass's avatar Simon Glass Committed by Bin Meng
Browse files

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: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
parent a5b87225
No related branches found
No related tags found
No related merge requests found
...@@ -160,9 +160,11 @@ long trailing_strtoln(const char *str, const char *end) ...@@ -160,9 +160,11 @@ long trailing_strtoln(const char *str, const char *end)
if (!end) if (!end)
end = str + strlen(str); end = str + strlen(str);
for (p = end - 1; p > str; p--) { if (isdigit(end[-1])) {
if (!isdigit(*p)) for (p = end - 1; p > str; p--) {
return simple_strtoul(p + 1, NULL, 10); if (!isdigit(*p))
return simple_strtoul(p + 1, NULL, 10);
}
} }
return -1; return -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment