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

tags/0.1.0
S.J.R. van Schaik 7 years ago
parent 7c44691059
commit b1d94ce1d0
  1. 24
      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;
}

Loading…
Cancel
Save