]> git.sur5r.net Git - openocd/commitdiff
misc code review updates
authorDavid Brownell <dbrownell@users.sourceforge.net>
Sat, 5 Dec 2009 22:40:06 +0000 (14:40 -0800)
committerDavid Brownell <dbrownell@users.sourceforge.net>
Sat, 5 Dec 2009 22:40:06 +0000 (14:40 -0800)
More updates from the code review by Steve Grubb <sgrubb@redhat.com>.
The Jim float-comparision bug just gets a comment not a fix, though.

Cc: Steve Grubb <sgrubb@redhat.com>.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
src/flash/mflash.c
src/helper/jim.c
src/jtag/core.c
src/svf/svf.c

index aa02e15759fa935388b782e76a6858b6b430c505..123d61ce82e1afd5d69f5186a593f8dd7085e7ff 100644 (file)
@@ -342,7 +342,8 @@ static int mg_dsk_drv_info(void)
        if ((ret =  mg_dsk_io_cmd(0, 1, mg_io_cmd_identify)) != ERROR_OK)
                return ret;
 
-       if ((ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL)) != ERROR_OK)
+       ret = mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL);
+       if (ret != ERROR_OK)
                return ret;
 
        LOG_INFO("mflash: read drive info");
@@ -350,7 +351,8 @@ static int mg_dsk_drv_info(void)
        if (! mflash_bank->drv_info)
                mflash_bank->drv_info = malloc(sizeof(struct mg_drv_info));
 
-       target_read_memory(target, mg_buff, 2, sizeof(mg_io_type_drv_info) >> 1,
+       ret = target_read_memory(target, mg_buff, 2,
+                       sizeof(mg_io_type_drv_info) >> 1,
                        (uint8_t *)&mflash_bank->drv_info->drv_id);
        if (ret != ERROR_OK)
                return ret;
index 117ec56f42b390591bef8a45045feb6e8ba0b006..c04acf09f870273e0392d9ae2c174615a2996b56 100644 (file)
@@ -6077,7 +6077,7 @@ int SetIndexFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
             index = INT_MAX;
         else
             index = -(index + 1);
-    } else if (!end && index < 0)
+    } else if (index < 0)
         index = -INT_MAX;
     /* Free the old internal repr and set the new one. */
     Jim_FreeIntRep(interp, objPtr);
@@ -7063,7 +7063,6 @@ trydouble:
                     "Got floating-point value where integer was expected", -1);
                 error = 1;
                 goto err;
-                break;
             case JIM_EXPROP_ADD: dC = dA + dB; break;
             case JIM_EXPROP_SUB: dC = dA-dB; break;
             case JIM_EXPROP_MUL: dC = dA*dB; break;
@@ -7071,6 +7070,7 @@ trydouble:
             case JIM_EXPROP_GT: dC = dA > dB; break;
             case JIM_EXPROP_LTE: dC = dA <= dB; break;
             case JIM_EXPROP_GTE: dC = dA >= dB; break;
+           /* FIXME comparing floats for equality/inequality is bad juju */
             case JIM_EXPROP_NUMEQ: dC = dA == dB; break;
             case JIM_EXPROP_NUMNE: dC = dA != dB; break;
             case JIM_EXPROP_LOGICAND_LEFT:
@@ -9889,8 +9889,7 @@ static int Jim_WhileCoreCommand(Jim_Interp *interp, int argc,
                         Jim_GetWide(interp, objPtr, &wideValueB) != JIM_OK)
                     {
                         Jim_DecrRefCount(interp, varAObjPtr);
-                        if (varBObjPtr)
-                            Jim_DecrRefCount(interp, varBObjPtr);
+                        Jim_DecrRefCount(interp, varBObjPtr);
                         goto noopt;
                     }
                 }
index 433b50bf03e0e561b989c083b2bbf4859038af78..373dd7e28deaf380f32bee8b64efa6f2bcec2b42 100644 (file)
@@ -762,8 +762,7 @@ static int jtag_check_value_inner(uint8_t *captured, uint8_t *in_check_value,
                uint8_t *in_check_mask, int num_bits)
 {
        int retval = ERROR_OK;
-
-       int compare_failed = 0;
+       int compare_failed;
 
        if (in_check_mask)
                compare_failed = buf_cmp_mask(captured, in_check_value, in_check_mask, num_bits);
index e6d842b7a5edb2175837f3c5454b95a65b172d73..1c746f382c724042b9a1448d3223b94ef1cee67e 100644 (file)
@@ -1350,12 +1350,9 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str)
                                        return ERROR_FAIL;
                                }
                        }
-                       // no need to keep this memory, in jtag_add_pathmove, path will be duplicated
-                       if (NULL != path)
-                       {
-                               free(path);
-                               path = NULL;
-                       }
+
+                       free(path);
+                       path = NULL;
                }
                else
                {