From b1d94ce1d0c57c896c1000fda4503c9ba215dab0 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Tue, 1 Aug 2017 16:20:04 +0200 Subject: [PATCH] shell: flash: use base 0 to use base 10 by default or base 16 when a 0x prefix is used --- source/shell/flash.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/shell/flash.c b/source/shell/flash.c index 410a49a..6211ad1 100644 --- a/source/shell/flash.c +++ b/source/shell/flash.c @@ -127,17 +127,17 @@ static int do_flash_read(struct console *con, size_t argc, const char **argv) return -1; } - addr = strtoull(argv[0], NULL, 16); + addr = strtoull(argv[0], NULL, 0); if (errno == EINVAL || errno == ERANGE) { - fprintf(con->fp, "error: expected hexadecimal value for addr\n"); + fprintf(con->fp, "error: expected integer value for addr\n"); return -1; } - len = strtoull(argv[1], NULL, 16); + len = strtoull(argv[1], NULL, 0); if (errno == EINVAL || errno == ERANGE) { - fprintf(con->fp, "error: expected hexadecimal value for len\n"); + fprintf(con->fp, "error: expected integer value for len\n"); return -1; } @@ -171,17 +171,17 @@ static int do_flash_write(struct console *con, size_t argc, const char **argv) return -1; } - addr = strtoull(argv[0], NULL, 16); + addr = strtoull(argv[0], NULL, 0); if (errno == EINVAL || errno == ERANGE) { - fprintf(con->fp, "error: expected hexadecimal value for addr\n"); + fprintf(con->fp, "error: expected integer value for addr\n"); return -1; } - len = strtoull(argv[1], NULL, 16); + len = strtoull(argv[1], NULL, 0); if (errno == EINVAL || errno == ERANGE) { - fprintf(con->fp, "error: expected hexadecimal value for len\n"); + fprintf(con->fp, "error: expected integer value for len\n"); return -1; } @@ -219,17 +219,17 @@ static int do_flash_erase(struct console *con, size_t argc, const char **argv) return -1; } - addr = strtoull(argv[0], NULL, 16); + addr = strtoull(argv[0], NULL, 0); if (errno == EINVAL || errno == ERANGE) { - fprintf(con->fp, "error: expected hexadecimal value for addr\n"); + fprintf(con->fp, "error: expected integer value for addr\n"); return -1; } - len = strtoull(argv[1], NULL, 16); + len = strtoull(argv[1], NULL, 0); if (errno == EINVAL || errno == ERANGE) { - fprintf(con->fp, "error: expected hexadecimal value for len\n"); + fprintf(con->fp, "error: expected integer value for len\n"); return -1; }