]> git.sur5r.net Git - openocd/commitdiff
fix 'nand info' command
authorZachary T Welch <zw@superlucidity.net>
Fri, 27 Nov 2009 17:57:25 +0000 (09:57 -0800)
committerZachary T Welch <zw@superlucidity.net>
Fri, 27 Nov 2009 19:11:26 +0000 (11:11 -0800)
Move device argument parsing after check for number of arguments;
otherwise, calling this command without any arguments would access
argv[0] before checking whether it even existed.

src/flash/nand.c

index 1e28ba2697151318a15fb91f4bceaa080d509422..895abe31016a57bd69f722ff8dbf3c79fff49edc 100644 (file)
@@ -1121,11 +1121,6 @@ COMMAND_HANDLER(handle_nand_info_command)
        int first = -1;
        int last = -1;
 
-       struct nand_device *p;
-       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
-       if (ERROR_OK != retval)
-               return retval;
-
        switch (CMD_ARGC) {
        default:
                return ERROR_COMMAND_SYNTAX_ERROR;
@@ -1144,6 +1139,11 @@ COMMAND_HANDLER(handle_nand_info_command)
                break;
        }
 
+       struct nand_device *p;
+       int retval = CALL_COMMAND_HANDLER(nand_command_get_device, 0, &p);
+       if (ERROR_OK != retval)
+               return retval;
+
        if (NULL == p->device)
        {
                command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]);