shell: flash: use base 0 to use base 10 by default or base 16 when a 0x prefix is used

This commit is contained in:
S.J.R. van Schaik 2017-08-01 16:20:04 +02:00
parent 7c44691059
commit b1d94ce1d0

View file

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