summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Brownell <dbrownell@users.sourceforge.net>2009-12-05 14:40:06 -0800
committerDavid Brownell <dbrownell@users.sourceforge.net>2009-12-05 14:40:06 -0800
commitdd9d1a3459f7b38e2af99bdbafd322cacc9dacc2 (patch)
tree33219999ffbd1aa191ff1a5262364f962a9d60cd /src
parent12b67a2b41557160b8daa23305cbc30a349588c1 (diff)
downloadopenocd+libswd-dd9d1a3459f7b38e2af99bdbafd322cacc9dacc2.tar.gz
openocd+libswd-dd9d1a3459f7b38e2af99bdbafd322cacc9dacc2.tar.bz2
openocd+libswd-dd9d1a3459f7b38e2af99bdbafd322cacc9dacc2.tar.xz
openocd+libswd-dd9d1a3459f7b38e2af99bdbafd322cacc9dacc2.zip
misc code review updates
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>
Diffstat (limited to 'src')
-rw-r--r--src/flash/mflash.c6
-rw-r--r--src/helper/jim.c7
-rw-r--r--src/jtag/core.c3
-rw-r--r--src/svf/svf.c9
4 files changed, 11 insertions, 14 deletions
diff --git a/src/flash/mflash.c b/src/flash/mflash.c
index aa02e157..123d61ce 100644
--- a/src/flash/mflash.c
+++ b/src/flash/mflash.c
@@ -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;
diff --git a/src/helper/jim.c b/src/helper/jim.c
index 117ec56f..c04acf09 100644
--- a/src/helper/jim.c
+++ b/src/helper/jim.c
@@ -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;
}
}
diff --git a/src/jtag/core.c b/src/jtag/core.c
index 433b50bf..373dd7e2 100644
--- a/src/jtag/core.c
+++ b/src/jtag/core.c
@@ -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);
diff --git a/src/svf/svf.c b/src/svf/svf.c
index e6d842b7..1c746f38 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -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
{