helper: command: drop radix parameter from command_parse_str_to_buf()
Commit 53b94fad58 ("binarybuffer: Fix str_to_buf() parsing
function") introduces the helper command_parse_str_to_buf() to
parse as number a string on TCL command-line.
The parameter 'radix' can specify the base (decimal, octal,
hexadecimal, or auto-detected).
TCL is supposed to use decimal numbers by default, while octal and
hexadecimal numbers must be prefixed respectively with '0' and
'0x' (or '0X').
This would require the helper to always run auto-detection of the
base, thus always set the 'radix' parameter to zero. This makes
the parameter useless.
Keeping the 'radix' parameter can open the door to future abuse of
TCL syntax, E.g. a command can require an octal value without the
mandatory TCL '0' prefix; the octal value cannot be the result of
TCL expression.
To prevent any future abuse of the 'radix' parameter, drop it.
Change-Id: I88855bd83b4e08e8fdcf86a2fa5ef3269dd4ad57
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8393
Tested-by: jenkins
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
This commit is contained in:
@@ -3133,7 +3133,7 @@ COMMAND_HANDLER(handle_reg_command)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
int retval = CALL_COMMAND_HANDLER(command_parse_str_to_buf, CMD_ARGV[1], buf, reg->size, 0);
|
||||
int retval = CALL_COMMAND_HANDLER(command_parse_str_to_buf, CMD_ARGV[1], buf, reg->size);
|
||||
if (retval != ERROR_OK) {
|
||||
free(buf);
|
||||
return retval;
|
||||
@@ -4835,8 +4835,7 @@ COMMAND_HANDLER(handle_set_reg_command)
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
int retval = CALL_COMMAND_HANDLER(command_parse_str_to_buf,
|
||||
reg_value, buf, reg->size, 0);
|
||||
int retval = CALL_COMMAND_HANDLER(command_parse_str_to_buf, reg_value, buf, reg->size);
|
||||
if (retval != ERROR_OK) {
|
||||
free(buf);
|
||||
return retval;
|
||||
|
||||
Reference in New Issue
Block a user