jim-nvp: Make Jim_GetOpt_String const-correct

Change-Id: Iae9824f6ff47a1944e674e59bfaa970904645082
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/3178
Tested-by: jenkins
__archive__
Andreas Fritiofson 2015-12-13 22:18:14 +01:00
parent 9721e9dd71
commit 7c957b601f
8 changed files with 25 additions and 22 deletions

View File

@ -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;

View File

@ -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.
*

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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) {

View File

@ -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)

View File

@ -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);