]> git.sur5r.net Git - openocd/commitdiff
drivers/jtag: usb_blaster: make command handlers more strict
authorAntony Pavlov <antonynpavlov@gmail.com>
Sat, 8 Feb 2014 20:11:42 +0000 (00:11 +0400)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 24 Feb 2014 12:09:15 +0000 (12:09 +0000)
If user used wrong argument number for some usb_blaster_* commands
then openocd show just warning message.
This commit makes command handler's behaviour more strict and
openocd treats wrong argument number as an error.

In addition we already have 'help' and 'usage' information in
struct command_registration ublast_command_handlers[],
so we can drop redundancy messages in command handlers.

Change-Id: I73b8c75ec60a18e5258a4bdffe972e8a1afc1066
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Reviewed-on: http://openocd.zylin.com/1942
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/jtag/drivers/usb_blaster/usb_blaster.c

index 1a43f588f8182294576aa4471859bcda257bb301..5335ce4e9ed8136fa6d279d135bba7c5652e143e 100644 (file)
@@ -881,11 +881,10 @@ static int ublast_quit(void)
 
 COMMAND_HANDLER(ublast_handle_device_desc_command)
 {
-       if (CMD_ARGC == 1)
-               info.ublast_device_desc = strdup(CMD_ARGV[0]);
-       else
-               LOG_ERROR("require exactly one argument to "
-                                 "ublast_device_desc <description>");
+       if (CMD_ARGC != 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       info.ublast_device_desc = strdup(CMD_ARGV[0]);
 
        return ERROR_OK;
 }
@@ -983,21 +982,20 @@ COMMAND_HANDLER(ublast_handle_pin_command)
 
 COMMAND_HANDLER(ublast_handle_lowlevel_drv_command)
 {
-       if (CMD_ARGC == 1)
-               info.lowlevel_name = strdup(CMD_ARGV[0]);
-       else
-               LOG_ERROR("require exactly one argument to "
-                                 "usb_blaster_lowlevel_driver (ftdi|ftd2xx)");
+       if (CMD_ARGC != 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       info.lowlevel_name = strdup(CMD_ARGV[0]);
+
        return ERROR_OK;
 }
 
 COMMAND_HANDLER(ublast_firmware_command)
 {
-       if (CMD_ARGC == 1)
-               info.firmware_path = strdup(CMD_ARGV[0]);
-       else
-               LOG_ERROR("require exactly one argument to "
-                                 "ublast_firmware_command <path>");
+       if (CMD_ARGC != 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
+
+       info.firmware_path = strdup(CMD_ARGV[0]);
 
        return ERROR_OK;
 }