From 0b1284eb52578e15ec611adc5fee1a9ae68dadea Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 Jul 2021 09:03:30 -0600 Subject: global: Convert simple_strtoul() with decimal to dectoul() It is a pain to have to specify the value 10 in each call. Add a new dectoul() function and update the code to use it. Signed-off-by: Simon Glass --- include/vsprintf.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/vsprintf.h') diff --git a/include/vsprintf.h b/include/vsprintf.h index 5a268ab..c30e91f 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -38,6 +38,19 @@ ulong simple_strtoul(const char *cp, char **endp, unsigned int base); unsigned long hextoul(const char *cp, char **endp); /** + * dec_strtoul - convert a string in decimal to an unsigned long + * + * @param cp The string to be converted + * @param endp Updated to point to the first character not converted + * @return value decoded from string (0 if invalid) + * + * Converts a decimal string to an unsigned long. If there are invalid + * characters at the end these are ignored. In the worst case, if all characters + * are invalid, 0 is returned + */ +unsigned long dectoul(const char *cp, char **endp); + +/** * strict_strtoul - convert a string to an unsigned long strictly * @param cp The string to be converted * @param base The number base to use -- cgit v1.1