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>
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 @@
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 @@
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 @@
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 @@
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 @@
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);
}
}