aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-24 09:03:30 -0600
committerTom Rini <trini@konsulko.com>2021-08-02 13:32:14 -0400
commit0b1284eb52578e15ec611adc5fee1a9ae68dadea (patch)
tree2d83815e93fc16decbaa5671fd660ade0ec74532 /lib
parent7e5f460ec457fe310156e399198a41eb0ce1e98c (diff)
downloadu-boot-0b1284eb52578e15ec611adc5fee1a9ae68dadea.zip
u-boot-0b1284eb52578e15ec611adc5fee1a9ae68dadea.tar.gz
u-boot-0b1284eb52578e15ec611adc5fee1a9ae68dadea.tar.bz2
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 'lib')
-rw-r--r--lib/dhry/cmd_dhry.c2
-rw-r--r--lib/fdtdec.c2
-rw-r--r--lib/net_utils.c2
-rw-r--r--lib/strto.c7
4 files changed, 9 insertions, 4 deletions
diff --git a/lib/dhry/cmd_dhry.c b/lib/dhry/cmd_dhry.c
index d55ab54..77b52a2 100644
--- a/lib/dhry/cmd_dhry.c
+++ b/lib/dhry/cmd_dhry.c
@@ -16,7 +16,7 @@ static int do_dhry(struct cmd_tbl *cmdtp, int flag, int argc,
int iterations = 1000000;
if (argc > 1)
- iterations = simple_strtoul(argv[1], NULL, 10);
+ iterations = dectoul(argv[1], NULL);
start = get_timer(0);
dhry(iterations);
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 4b097fb..07c7ebe 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -405,7 +405,7 @@ int fdtdec_add_aliases_for_id(const void *blob, const char *name,
continue;
/* Get the alias number */
- number = simple_strtoul(path + name_len, NULL, 10);
+ number = dectoul(path + name_len, NULL);
if (number < 0 || number >= maxcount) {
debug("%s: warning: alias '%s' is out of range\n",
__func__, path);
diff --git a/lib/net_utils.c b/lib/net_utils.c
index f596c8f..72a3b09 100644
--- a/lib/net_utils.c
+++ b/lib/net_utils.c
@@ -23,7 +23,7 @@ struct in_addr string_to_ip(const char *s)
return addr;
for (addr.s_addr = 0, i = 0; i < 4; ++i) {
- ulong val = s ? simple_strtoul(s, &e, 10) : 0;
+ ulong val = s ? dectoul(s, &e) : 0;
if (val > 255) {
addr.s_addr = 0;
return addr;
diff --git a/lib/strto.c b/lib/strto.c
index 57d6216..72903a5 100644
--- a/lib/strto.c
+++ b/lib/strto.c
@@ -54,6 +54,11 @@ ulong hextoul(const char *cp, char **endp)
return simple_strtoul(cp, endp, 16);
}
+ulong dectoul(const char *cp, char **endp)
+{
+ return simple_strtoul(cp, endp, 10);
+}
+
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
{
char *tail;
@@ -164,7 +169,7 @@ long trailing_strtoln(const char *str, const char *end)
if (isdigit(end[-1])) {
for (p = end - 1; p > str; p--) {
if (!isdigit(*p))
- return simple_strtoul(p + 1, NULL, 10);
+ return dectoul(p + 1, NULL);
}
}