From b7b561aae809ab9022b9f213dc5a12b6d58ce2ee Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Thu, 22 Oct 2009 21:05:50 -0700 Subject: Improve jtag command argument parsing. --- src/jtag/vsllink.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/jtag/vsllink.c') diff --git a/src/jtag/vsllink.c b/src/jtag/vsllink.c index ab55a190..1f1b8670 100644 --- a/src/jtag/vsllink.c +++ b/src/jtag/vsllink.c @@ -1407,7 +1407,8 @@ static int vsllink_handle_usb_vid_command(struct command_context_s *cmd_ctx, cha return ERROR_OK; } - return parse_u16(args[0], &vsllink_usb_vid); + COMMAND_PARSE_NUMBER(u16, args[0], vsllink_usb_vid); + return ERROR_OK; } static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1417,7 +1418,8 @@ static int vsllink_handle_usb_pid_command(struct command_context_s *cmd_ctx, cha LOG_ERROR("parameter error, should be one parameter for PID"); return ERROR_OK; } - return parse_u16(args[0], &vsllink_usb_pid); + COMMAND_PARSE_NUMBER(u16, args[0], vsllink_usb_pid); + return ERROR_OK; } static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1428,11 +1430,11 @@ static int vsllink_handle_usb_bulkin_command(struct command_context_s *cmd_ctx, return ERROR_OK; } - int retval = parse_u8(args[0], &vsllink_usb_bulkin); - if (ERROR_OK == retval) - vsllink_usb_bulkin |= 0x80; + COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_bulkin); - return retval; + vsllink_usb_bulkin |= 0x80; + + return ERROR_OK; } static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1443,11 +1445,11 @@ static int vsllink_handle_usb_bulkout_command(struct command_context_s *cmd_ctx, return ERROR_OK; } - int retval = parse_u8(args[0], &vsllink_usb_bulkout); - if (ERROR_OK == retval) - vsllink_usb_bulkout &= ~0x80; + COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_bulkin); - return retval; + vsllink_usb_bulkout &= ~0x80; + + return ERROR_OK; } static int vsllink_handle_usb_interface_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) @@ -1458,7 +1460,8 @@ static int vsllink_handle_usb_interface_command(struct command_context_s *cmd_ct return ERROR_OK; } - return parse_u8(args[0], &vsllink_usb_interface); + COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_interface); + return ERROR_OK; } /***************************************************************************/ -- cgit v1.2.3