diff options
author | Simon Glass <sjg@chromium.org> | 2021-07-24 18:03:38 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-08-02 20:32:14 +0300 |
commit | e6951139c0544116330b12e287fe45e30bbab11c (patch) | |
tree | 15216d11d6890cd497b6a97176c7aad4c4d63ecf /include/vsprintf.h | |
parent | 5f4b356121fdb520e4c9bb4fe3483c1a5f93439c (diff) | |
download | u-boot-e6951139c0544116330b12e287fe45e30bbab11c.tar.xz |
lib: Allow using 0x when a decimal value is requested
U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.
But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.
Add this functionality, for increased flexibility.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/vsprintf.h')
-rw-r--r-- | include/vsprintf.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/include/vsprintf.h b/include/vsprintf.h index debf977401..83d187e53d 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -22,8 +22,12 @@ * the end these are ignored. In the worst case, if all characters are invalid, * 0 is returned * - * If @base is 0, octal or hex prefixes are supported (e.g. 0777, 0x123) to - * select a particular base. By default decimal is used. + * A hex prefix is supported (e.g. 0x123) regardless of the value of @base. + * If found, the base is set to hex (16). + * + * If @base is 0: + * - an octal '0' prefix (e.g. 0777) sets the base to octal (8). + * - otherwise the base defaults to decimal (10). */ ulong simple_strtoul(const char *cp, char **endp, unsigned int base); @@ -71,8 +75,12 @@ unsigned long dectoul(const char *cp, char **endp); * * echo will append a newline to the tail. * - * If @base is 0, octal or hex prefixes are supported (e.g. 0777, 0x123) to - * select a particular base. By default decimal is used. + * A hex prefix is supported (e.g. 0x123) regardless of the value of @base. + * If found, the base is set to hex (16). + * + * If @base is 0: + * - an octal '0' prefix (e.g. 0777) sets the base to octal (8). + * - otherwise the base defaults to decimal (10). * * Copied this function from Linux 2.6.38 commit ID: * 521cb40b0c44418a4fd36dc633f575813d59a43d |