diff options
author | Andreas Fritiofson <andreas.fritiofson@gmail.com> | 2013-09-30 23:16:20 +0200 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2013-10-31 20:42:34 +0000 |
commit | 517ba0690dcc9e859a05df2113ce32401a5ab254 (patch) | |
tree | 7f437e78a54eb7cb6af06ed589c8ceef0c5277bf /src/jtag/tcl.c | |
parent | c044c601213ee800cffb21e1f53a89285b3346c9 (diff) | |
download | riscv-openocd-517ba0690dcc9e859a05df2113ce32401a5ab254.zip riscv-openocd-517ba0690dcc9e859a05df2113ce32401a5ab254.tar.gz riscv-openocd-517ba0690dcc9e859a05df2113ce32401a5ab254.tar.bz2 |
Clean up const usage to avoid excessive casting
Don't use const on pointers that hold heap allocated data, because that
means functions that free them must cast away the const.
Do use const on pointer parameters or fields that needn't be modified.
Remove pointer casts that are no longer needed after fixing the constness.
Change-Id: I5d206f5019982fd1950bc6d6d07b6062dc24e886
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/1668
Tested-by: jenkins
Reviewed-by: Mathias Küster <kesmtp@freenet.de>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Diffstat (limited to 'src/jtag/tcl.c')
-rw-r--r-- | src/jtag/tcl.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index b95bf75..3f63ffc 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -563,7 +563,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi) e = Jim_GetOpt_Nvp(goi, opts, &n); if (e != JIM_OK) { Jim_GetOpt_NvpUnknown(goi, opts, 0); - free((void *)pTap->dotted_name); + free(cp); free(pTap); return e; } @@ -578,7 +578,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi) case NTAP_OPT_EXPECTED_ID: e = jim_newtap_expected_id(n, goi, pTap); if (JIM_OK != e) { - free((void *)pTap->dotted_name); + free(cp); free(pTap); return e; } @@ -588,7 +588,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi) case NTAP_OPT_IRCAPTURE: e = jim_newtap_ir_param(n, goi, pTap); if (JIM_OK != e) { - free((void *)pTap->dotted_name); + free(cp); free(pTap); return e; } @@ -1133,14 +1133,14 @@ COMMAND_HANDLER(handle_irscan_command) } int field_size = tap->ir_length; fields[i].num_bits = field_size; - fields[i].out_value = malloc(DIV_ROUND_UP(field_size, 8)); + uint8_t *v = malloc(DIV_ROUND_UP(field_size, 8)); uint64_t value; retval = parse_u64(CMD_ARGV[i * 2 + 1], &value); if (ERROR_OK != retval) goto error_return; - void *v = (void *)fields[i].out_value; buf_set_u64(v, 0, field_size, value); + fields[i].out_value = v; fields[i].in_value = NULL; } |