jim-nvp: Make Jim_GetOpt_String const-correct 78/3178/2
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Sun, 13 Dec 2015 21:18:14 +0000 (22:18 +0100)
committerAndreas Fritiofson <andreas.fritiofson@gmail.com>
Mon, 29 Feb 2016 20:32:31 +0000 (20:32 +0000)
Change-Id: Iae9824f6ff47a1944e674e59bfaa970904645082
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/3178
Tested-by: jenkins
src/helper/jim-nvp.c
src/helper/jim-nvp.h
src/jtag/aice/aice_transport.c
src/jtag/hla/hla_tcl.c
src/jtag/tcl.c
src/rtos/rtos.c
src/target/nds32_cmd.c
src/target/target.c

index 4602a8db944b3334e0f5496dc028a66071930a04..d13bdfba4caea1c4328efd510cf263a0214c068a 100644 (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;
index 05d79c4a7d899d5c519f908853c70bfa9895221c..ca382dd02cb8ff0e4f46ad5d94232f061dc36b5e 100644 (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.
  *
index f3012bb22335941f9c1011c974b208a67ba9b79f..4c2f343f5f1e6fb83b2991785d9c22827f8fa3fb 100644 (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;
index 20082f3858f258a4cd4f36328f253673605657a8..7b7ae0a046f08c467a6a1c01fe1ab32c600b3f11 100644 (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;
index c916fb1ca186126b99f3c2566eace86f59664081..ac3f4deb7d853241ef6e2a527123ea3abe576195 100644 (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;
index 528546eaa3473f6700a3c1e442257e628df4d674..a84e6e0527fe19fd3f786a3982155ffdae6cfe62 100644 (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) {
index faf9e0aef7527639873a5a75014f46743864317f..ffd606129e94f196f7f4c06b65648fe6953baec5 100644 (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)
index 6df8d8b97124b50d28c832a535aad326e472ff1c..b6442c5e1ca1bb725a2a48a211103b307ce4d8ea 100644 (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);

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)