default: return ERROR_COMMAND_SYNTAX_ERROR;
}
- u32 address = strtoul(args[0], NULL, 0);
+ u32 address;
+ int retval = parse_u32(args[0], &address);
+ if (ERROR_OK != retval)
+ return retval;
unsigned count = 1;
if (argc == 2)
- count = strtoul(args[1], NULL, 0);
+ {
+ retval = parse_uint(args[1], &count);
+ if (ERROR_OK != retval)
+ return retval;
+ }
u8 *buffer = calloc(count, size);
target_t *target = get_current_target(cmd_ctx);
- int retval = target_read_memory(target,
+ retval = target_read_memory(target,
address, size, count, buffer);
if (ERROR_OK == retval)
handle_md_output(cmd_ctx, target, address, size, count, buffer);
static int handle_mw_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
- u32 address = 0;
- u32 value = 0;
- int count = 1;
- int i;
- int wordsize;
- target_t *target = get_current_target(cmd_ctx);
- u8 value_buf[4];
-
if ((argc < 2) || (argc > 3))
return ERROR_COMMAND_SYNTAX_ERROR;
- address = strtoul(args[0], NULL, 0);
- value = strtoul(args[1], NULL, 0);
+ u32 address;
+ int retval = parse_u32(args[0], &address);
+ if (ERROR_OK != retval)
+ return retval;
+
+ u32 value;
+ retval = parse_u32(args[1], &value);
+ if (ERROR_OK != retval)
+ return retval;
+
+ unsigned count = 1;
if (argc == 3)
- count = strtoul(args[2], NULL, 0);
+ {
+ retval = parse_uint(args[2], &count);
+ if (ERROR_OK != retval)
+ return retval;
+ }
+ target_t *target = get_current_target(cmd_ctx);
+ unsigned wordsize;
+ u8 value_buf[4];
switch (cmd[2])
{
case 'w':
default:
return ERROR_COMMAND_SYNTAX_ERROR;
}
- for (i=0; i<count; i++)
+ for (unsigned i = 0; i < count; i++)
{
- int retval = target_write_memory(target,
+ retval = target_write_memory(target,
address + i * wordsize, wordsize, 1, value_buf);
if (ERROR_OK != retval)
return retval;
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
if (argc >= 2)
{
+ u32 addr;
+ retval = parse_u32(args[1], &addr);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ image.base_address = addr;
image.base_address_set = 1;
- image.base_address = strtoul(args[1], NULL, 0);
}
else
{
if (argc>=4)
{
- min_address=strtoul(args[3], NULL, 0);
+ retval = parse_u32(args[3], &min_address);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
}
if (argc>=5)
{
- max_address=strtoul(args[4], NULL, 0)+min_address;
+ retval = parse_u32(args[4], &max_address);
+ if (ERROR_OK != retval)
+ return ERROR_COMMAND_SYNTAX_ERROR;
+ // use size (given) to find max (required)
+ max_address += min_address;
}
if (min_address>max_address)