global: Convert simple_strtoul() with hex to hextoul()
It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.
Add a proper comment to simple_strtoul() while we are here.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/cmd/md5sum.c b/cmd/md5sum.c
index 5ae3ddf..0f0e1d3 100644
--- a/cmd/md5sum.c
+++ b/cmd/md5sum.c
@@ -25,7 +25,7 @@
if (*dest == '*') {
u8 *ptr;
- ptr = (u8 *)simple_strtoul(dest + 1, NULL, 16);
+ ptr = (u8 *)hextoul(dest + 1, NULL);
for (i = 0; i < 16; i++)
*ptr++ = sum[i];
} else {
@@ -46,7 +46,7 @@
if (*verify_str == '*') {
u8 *ptr;
- ptr = (u8 *)simple_strtoul(verify_str + 1, NULL, 16);
+ ptr = (u8 *)hextoul(verify_str + 1, NULL);
memcpy(vsum, ptr, 16);
} else {
unsigned int i;
@@ -66,7 +66,7 @@
*nullp = '\0';
*(u8 *)(vsum + i) =
- simple_strtoul(vsum_str + (i * 2), NULL, 16);
+ hextoul(vsum_str + (i * 2), NULL);
*nullp = end;
}
}
@@ -97,8 +97,8 @@
return CMD_RET_USAGE;
}
- addr = simple_strtoul(*av++, NULL, 16);
- len = simple_strtoul(*av++, NULL, 16);
+ addr = hextoul(*av++, NULL);
+ len = hextoul(*av++, NULL);
buf = map_sysmem(addr, len);
md5_wd(buf, len, output, CHUNKSZ_MD5);
@@ -147,8 +147,8 @@
if (argc < 3)
return CMD_RET_USAGE;
- addr = simple_strtoul(argv[1], NULL, 16);
- len = simple_strtoul(argv[2], NULL, 16);
+ addr = hextoul(argv[1], NULL);
+ len = hextoul(argv[2], NULL);
buf = map_sysmem(addr, len);
md5_wd(buf, len, output, CHUNKSZ_MD5);