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/efidebug.c b/cmd/efidebug.c
index 8211a58..67ab06a 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -61,7 +61,7 @@
argv++;
}
- capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16);
+ capsule = (typeof(capsule))hextoul(argv[1], &endp);
if (endp == argv[1]) {
printf("Invalid address: %s", argv[1]);
return CMD_RET_FAILURE;
@@ -117,7 +117,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- capsule = (typeof(capsule))simple_strtoul(argv[1], &endp, 16);
+ capsule = (typeof(capsule))hextoul(argv[1], &endp);
if (endp == argv[1]) {
printf("Invalid address: %s", argv[1]);
return CMD_RET_FAILURE;
@@ -256,7 +256,7 @@
argc--;
argv++;
- capsule_id = simple_strtoul(argv[0], &endp, 16);
+ capsule_id = hextoul(argv[0], &endp);
if (capsule_id < 0 || capsule_id > 0xffff)
return CMD_RET_USAGE;
@@ -983,7 +983,7 @@
r = CMD_RET_USAGE;
goto out;
}
- id = (int)simple_strtoul(argv[1], &endp, 16);
+ id = (int)hextoul(argv[1], &endp);
if (*endp != '\0' || id > 0xffff)
return CMD_RET_USAGE;
@@ -1113,7 +1113,7 @@
guid = efi_global_variable_guid;
for (i = 1; i < argc; i++, argv++) {
- id = (int)simple_strtoul(argv[1], &endp, 16);
+ id = (int)hextoul(argv[1], &endp);
if (*endp != '\0' || id > 0xffff)
return CMD_RET_FAILURE;
@@ -1410,7 +1410,7 @@
if (argc != 2)
return CMD_RET_USAGE;
- bootnext = (u16)simple_strtoul(argv[1], &endp, 16);
+ bootnext = (u16)hextoul(argv[1], &endp);
if (*endp) {
printf("invalid value: %s\n", argv[1]);
r = CMD_RET_FAILURE;
@@ -1469,7 +1469,7 @@
return CMD_RET_FAILURE;
for (i = 0; i < argc; i++) {
- id = (int)simple_strtoul(argv[i], &endp, 16);
+ id = (int)hextoul(argv[i], &endp);
if (*endp != '\0' || id > 0xffff) {
printf("invalid value: %s\n", argv[i]);
r = CMD_RET_FAILURE;