Cleanup the handle_jtag_khz_command routine:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 8 Jun 2009 10:54:41 +0000 (10:54 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Mon, 8 Jun 2009 10:54:41 +0000 (10:54 +0000)
- Separate retval assignments from logical tests.
- Simplify logical tests.

git-svn-id: svn://svn.berlios.de/openocd/trunk@2110 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/jtag.c

index f58c90e19c1cfc788768ad331dffcb0be022a1e6..113c9610f24edb6b2780e0dc9ba6cde460d783a3 100644 (file)
@@ -2167,41 +2167,39 @@ static int handle_jtag_speed_command(struct command_context_s *cmd_ctx, char *cm
 
 static int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
-       int retval=ERROR_OK;
-       LOG_DEBUG("handle jtag khz");
+       if (argc > 1)
+               return ERROR_COMMAND_SYNTAX_ERROR;
 
+       int retval = ERROR_OK;
        int cur_speed = 0;
-       if(argc == 1)
+       if (argc == 1)
        {
+               LOG_DEBUG("handle jtag khz");
+
                jtag_set_speed_khz(strtoul(args[0], NULL, 0));
                if (jtag != NULL)
                {
                        LOG_DEBUG("have interface set up");
                        int speed_div1;
-                       if ((retval=jtag->khz(jtag_get_speed_khz(), &speed_div1))!=ERROR_OK)
+                       retval = jtag->khz(jtag_get_speed_khz(), &speed_div1);
+                       if (ERROR_OK != retval)
                        {
                                jtag_set_speed_khz(0);
                                return retval;
                        }
-
                        cur_speed = jtag_speed = speed_div1;
 
-                       retval=jtag->speed(cur_speed);
-               } else
-               {
-                       hasKHz = true;
+                       retval = jtag->speed(cur_speed);
                }
-       } else if (argc==0)
-       {
-       } else
-       {
-               return ERROR_COMMAND_SYNTAX_ERROR;
+               else
+                       hasKHz = true;
        }
-       cur_speed = jtag_get_speed_khz();
 
-       if (jtag!=NULL)
+       cur_speed = jtag_get_speed_khz();
+       if (jtag != NULL)
        {
-               if ((retval=jtag->speed_div(jtag_speed, &cur_speed))!=ERROR_OK)
+               retval = jtag->speed_div(jtag_speed, &cur_speed);
+               if (ERROR_OK != retval)
                        return retval;
        }
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)