aboutsummaryrefslogtreecommitdiff
path: root/include/vsprintf.h
diff options
context:
space:
mode:
authorSimon Glass2021-07-24 09:03:30 -0600
committerTom Rini2021-08-02 13:32:14 -0400
commit0b1284eb52578e15ec611adc5fee1a9ae68dadea (patch)
tree2d83815e93fc16decbaa5671fd660ade0ec74532 /include/vsprintf.h
parent7e5f460ec457fe310156e399198a41eb0ce1e98c (diff)
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 <sjg@chromium.org>
Diffstat (limited to 'include/vsprintf.h')
-rw-r--r--include/vsprintf.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/vsprintf.h b/include/vsprintf.h
index 5a268ab5cb3..c30e91fd6f7 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