From d667a0d8f413d7278f912aa4e671bc56d28b25f2 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 24 Apr 2022 23:30:57 -0600 Subject: 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 --- include/vsprintf.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/vsprintf.h') diff --git a/include/vsprintf.h b/include/vsprintf.h index d4bf3211da4..5172ceedec1 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -98,6 +98,9 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base); * Given a string this finds a trailing number on the string and returns it. * For example, "abc123" would return 123. * + * Note that this does not handle a string without a prefix. See dectoul() for + * that case. + * * @str: String to examine * Return: trailing number if found, else -1 */ -- cgit v1.2.3