From 7e5f460ec457fe310156e399198a41eb0ce1e98c Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 Jul 2021 09:03:29 -0600 Subject: 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 --- cmd/avb.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'cmd/avb.c') diff --git a/cmd/avb.c b/cmd/avb.c index 88172a9ee67..02b4b1f022c 100644 --- a/cmd/avb.c +++ b/cmd/avb.c @@ -22,7 +22,7 @@ int do_avb_init(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) if (argc != 2) return CMD_RET_USAGE; - mmc_dev = simple_strtoul(argv[1], NULL, 16); + mmc_dev = hextoul(argv[1], NULL); if (avb_ops) avb_ops_free(avb_ops); @@ -53,9 +53,9 @@ int do_avb_read_part(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; part = argv[1]; - offset = simple_strtoul(argv[2], NULL, 16); - bytes = simple_strtoul(argv[3], NULL, 16); - buffer = (void *)simple_strtoul(argv[4], NULL, 16); + offset = hextoul(argv[2], NULL); + bytes = hextoul(argv[3], NULL); + buffer = (void *)hextoul(argv[4], NULL); if (avb_ops->read_from_partition(avb_ops, part, offset, bytes, buffer, &bytes_read) == @@ -86,8 +86,8 @@ int do_avb_read_part_hex(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; part = argv[1]; - offset = simple_strtoul(argv[2], NULL, 16); - bytes = simple_strtoul(argv[3], NULL, 16); + offset = hextoul(argv[2], NULL); + bytes = hextoul(argv[3], NULL); buffer = malloc(bytes); if (!buffer) { @@ -132,9 +132,9 @@ int do_avb_write_part(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; part = argv[1]; - offset = simple_strtoul(argv[2], NULL, 16); - bytes = simple_strtoul(argv[3], NULL, 16); - buffer = (void *)simple_strtoul(argv[4], NULL, 16); + offset = hextoul(argv[2], NULL); + bytes = hextoul(argv[3], NULL); + buffer = (void *)hextoul(argv[4], NULL); if (avb_ops->write_to_partition(avb_ops, part, offset, bytes, buffer) == AVB_IO_RESULT_OK) { @@ -161,7 +161,7 @@ int do_avb_read_rb(struct cmd_tbl *cmdtp, int flag, int argc, if (argc != 2) return CMD_RET_USAGE; - index = (size_t)simple_strtoul(argv[1], NULL, 16); + index = (size_t)hextoul(argv[1], NULL); if (avb_ops->read_rollback_index(avb_ops, index, &rb_idx) == AVB_IO_RESULT_OK) { @@ -188,8 +188,8 @@ int do_avb_write_rb(struct cmd_tbl *cmdtp, int flag, int argc, if (argc != 3) return CMD_RET_USAGE; - index = (size_t)simple_strtoul(argv[1], NULL, 16); - rb_idx = simple_strtoul(argv[2], NULL, 16); + index = (size_t)hextoul(argv[1], NULL); + rb_idx = hextoul(argv[2], NULL); if (avb_ops->write_rollback_index(avb_ops, index, rb_idx) == AVB_IO_RESULT_OK) -- cgit v1.2.3 From 0b1284eb52578e15ec611adc5fee1a9ae68dadea Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sat, 24 Jul 2021 09:03:30 -0600 Subject: 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 --- cmd/avb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/avb.c') diff --git a/cmd/avb.c b/cmd/avb.c index 02b4b1f022c..783f51b8169 100644 --- a/cmd/avb.c +++ b/cmd/avb.c @@ -366,7 +366,7 @@ int do_avb_read_pvalue(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; name = argv[1]; - bytes = simple_strtoul(argv[2], &endp, 10); + bytes = dectoul(argv[2], &endp); if (*endp && *endp != '\n') return CMD_RET_USAGE; -- cgit v1.2.3