提交 b91c6a12 编写于 作者: S Simon Glass 提交者: Bin Meng

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: NSimon Glass <sjg@chromium.org>
Reviewed-by: NBin Meng <bmeng.cn@gmail.com>
上级 a5b87225
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册