lib: Fix a few bugs in trailing_strtoln()
At present this has a minor bug in that it reads the byte before the start of the string, if it is empty. Also it doesn't handle a non-numeric prefix which is only one character long. Fix these bugs with a reworked implementation. Add a test for the second case. The first one is hard to test. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -257,6 +257,8 @@ static int str_trailing(struct unit_test_state *uts)
|
||||
ut_asserteq(123, trailing_strtoln(str1, str1 + 6));
|
||||
ut_asserteq(-1, trailing_strtoln(str1, str1 + 9));
|
||||
|
||||
ut_asserteq(3, trailing_strtol("a3"));
|
||||
|
||||
return 0;
|
||||
}
|
||||
STR_TEST(str_trailing, 0);
|
||||
|
||||
Reference in New Issue
Block a user