From: Andreas Fritiofson Date: Sun, 13 Dec 2015 21:18:14 +0000 (+0100) Subject: jim-nvp: Make Jim_GetOpt_String const-correct X-Git-Tag: v0.10.0-rc1~229 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7c957b601f7aeabc537519597057e63f2ae60320;p=openocd jim-nvp: Make Jim_GetOpt_String const-correct Change-Id: Iae9824f6ff47a1944e674e59bfaa970904645082 Signed-off-by: Andreas Fritiofson Reviewed-on: http://openocd.zylin.com/3178 Tested-by: jenkins --- diff --git a/src/helper/jim-nvp.c b/src/helper/jim-nvp.c index 4602a8db..d13bdfba 100644 --- a/src/helper/jim-nvp.c +++ b/src/helper/jim-nvp.c @@ -205,7 +205,7 @@ int Jim_GetOpt_Obj(Jim_GetOptInfo *goi, Jim_Obj **puthere) return JIM_ERR; } -int Jim_GetOpt_String(Jim_GetOptInfo *goi, char **puthere, int *len) +int Jim_GetOpt_String(Jim_GetOptInfo *goi, const char **puthere, int *len) { int r; Jim_Obj *o; @@ -215,8 +215,7 @@ int Jim_GetOpt_String(Jim_GetOptInfo *goi, char **puthere, int *len) if (r == JIM_OK) { cp = Jim_GetString(o, len); if (puthere) { - /* remove const */ - *puthere = (char *)(cp); + *puthere = cp; } } return r; diff --git a/src/helper/jim-nvp.h b/src/helper/jim-nvp.h index 05d79c4a..ca382dd0 100644 --- a/src/helper/jim-nvp.h +++ b/src/helper/jim-nvp.h @@ -245,7 +245,7 @@ int Jim_GetOpt_Obj(Jim_GetOptInfo *goi, Jim_Obj **puthere); * \param puthere - where param is put * \param len - return its length */ -int Jim_GetOpt_String(Jim_GetOptInfo *goi, char **puthere, int *len); +int Jim_GetOpt_String(Jim_GetOptInfo *goi, const char **puthere, int *len); /** Remove argv[0] as double. * diff --git a/src/jtag/aice/aice_transport.c b/src/jtag/aice/aice_transport.c index f3012bb2..4c2f343f 100644 --- a/src/jtag/aice/aice_transport.c +++ b/src/jtag/aice/aice_transport.c @@ -90,11 +90,13 @@ static int jim_aice_newtap_cmd(Jim_GetOptInfo *goi) free(pTap); return JIM_ERR; } - Jim_GetOpt_String(goi, &cp, NULL); - pTap->chip = strdup(cp); - Jim_GetOpt_String(goi, &cp, NULL); - pTap->tapname = strdup(cp); + const char *tmp; + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->chip = strdup(tmp); + + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->tapname = strdup(tmp); /* name + dot + name + null */ x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; diff --git a/src/jtag/hla/hla_tcl.c b/src/jtag/hla/hla_tcl.c index 20082f38..7b7ae0a0 100644 --- a/src/jtag/hla/hla_tcl.c +++ b/src/jtag/hla/hla_tcl.c @@ -100,11 +100,13 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi) free(pTap); return JIM_ERR; } - Jim_GetOpt_String(goi, &cp, NULL); - pTap->chip = strdup(cp); - Jim_GetOpt_String(goi, &cp, NULL); - pTap->tapname = strdup(cp); + const char *tmp; + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->chip = strdup(tmp); + + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->tapname = strdup(tmp); /* name + dot + name + null */ x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index c916fb1c..ac3f4deb 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -533,11 +533,13 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi) free(pTap); return JIM_ERR; } - Jim_GetOpt_String(goi, &cp, NULL); - pTap->chip = strdup(cp); - Jim_GetOpt_String(goi, &cp, NULL); - pTap->tapname = strdup(cp); + const char *tmp; + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->chip = strdup(tmp); + + Jim_GetOpt_String(goi, &tmp, NULL); + pTap->tapname = strdup(tmp); /* name + dot + name + null */ x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1; diff --git a/src/rtos/rtos.c b/src/rtos/rtos.c index 528546ea..a84e6e05 100644 --- a/src/rtos/rtos.c +++ b/src/rtos/rtos.c @@ -104,7 +104,7 @@ static int os_alloc_create(struct target *target, struct rtos_type *ostype) int rtos_create(Jim_GetOptInfo *goi, struct target *target) { int x; - char *cp; + const char *cp; struct Jim_Obj *res; if (!goi->isconfigure && goi->argc != 0) { diff --git a/src/target/nds32_cmd.c b/src/target/nds32_cmd.c index faf9e0ae..ffd60612 100644 --- a/src/target/nds32_cmd.c +++ b/src/target/nds32_cmd.c @@ -846,7 +846,7 @@ static int jim_nds32_read_edm_sr(Jim_Interp *interp, int argc, Jim_Obj * const * } int e; - char *edm_sr_name; + const char *edm_sr_name; int edm_sr_name_len; e = Jim_GetOpt_String(&goi, &edm_sr_name, &edm_sr_name_len); if (e != JIM_OK) @@ -892,7 +892,7 @@ static int jim_nds32_write_edm_sr(Jim_Interp *interp, int argc, Jim_Obj * const } int e; - char *edm_sr_name; + const char *edm_sr_name; int edm_sr_name_len; e = Jim_GetOpt_String(&goi, &edm_sr_name, &edm_sr_name_len); if (e != JIM_OK) diff --git a/src/target/target.c b/src/target/target.c index 6df8d8b9..b6442c5e 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -5186,7 +5186,6 @@ static int target_create(Jim_GetOptInfo *goi) Jim_Obj *new_cmd; Jim_Cmd *cmd; const char *cp; - char *cp2; int e; int x; struct target *target; @@ -5211,10 +5210,9 @@ static int target_create(Jim_GetOptInfo *goi) } /* TYPE */ - e = Jim_GetOpt_String(goi, &cp2, NULL); + e = Jim_GetOpt_String(goi, &cp, NULL); if (e != JIM_OK) return e; - cp = cp2; struct transport *tr = get_current_transport(); if (tr->override_target) { e = tr->override_target(&cp);