zsh-workers
 help / color / mirror / code / Atom feed
From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Warnings in compctl
Date: Fri, 23 Mar 2018 12:38:43 +0900	[thread overview]
Message-ID: <46F08EE7-DA1F-49E5-8E74-4D519E47ACBD@kba.biglobe.ne.jp> (raw)
In-Reply-To: <20180321101630.511442a9@camnpupstephen.cam.scsc.local>


> 2018/03/21 19:16, Peter Stephenson <p.stephenson@samsung.com> wrote:
> 
> This removes some warnings from gcc 7.3.0.  Technically I think a
> pointer off the front is in fact invalid 

Which option did you used with gcc?

Three more files (complete.c, computil.c, zle_thingy.c) have the same
"off the front" pointer assignments; these are detected by
"clang -Warray-bounds-pointer-arithmetic".


diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 16f48c958..313dcb92f 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -715,11 +715,10 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 	    case 'E':
                 if (p[1]) {
                     dat.dummies = atoi(p + 1);
-                    p = "" - 1;
+		    p += strlen(p+1);
                 } else if (argv[1]) {
                     argv++;
                     dat.dummies = atoi(*argv);
-                    p = "" - 1;
                 } else {
                     zwarnnam(name, "number expected after -%c", *p);
 		    zsfree(mstr);
@@ -744,13 +743,12 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
 		    /* Pasted argument: -Xfoo. */
 		    if (!*sp)
 			*sp = p + 1;
-		    p = "" - 1;
+		    p += strlen(p+1);
 		} else if (argv[1]) {
 		    /* Argument in a separate word: -X foo. */
 		    argv++;
 		    if (!*sp)
 			*sp = *argv;
-		    p = "" - 1;
 		} else {
 		    /* Missing argument: argv[N] == "-X", argv[N+1] == NULL. */
 		    zwarnnam(name, e, *p);
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 0b1ba58dc..4ce8eeee5 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -1222,7 +1222,7 @@ parse_cadef(char *nam, char **args)
 	    else if (*p == 'A') {
 		if (p[1]) {
 		    nonarg = p + 1;
-		    p = "" - 1;
+		    p += strlen(p+1);
 		} else if (args[1])
 		    nonarg = *++args;
 		else
@@ -1230,7 +1230,7 @@ parse_cadef(char *nam, char **args)
 	    } else if (*p == 'M') {
 		if (p[1]) {
 		    match = p + 1;
-		    p = "" - 1;
+		    p += strlen(p+1);
 		} else if (args[1])
 		    match = *++args;
 		else
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index f7e9829c2..5601c1178 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -731,6 +731,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 	    break;
 	}
 	while (*++(*args)) {
+	    char skip_this_arg[2] = "x";
 	    switch (**args) {
 	    case 'n':
 		num = args[0][1] ? args[0]+1 : args[1];
@@ -741,7 +742,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 		    return 1;
 		}
 		if (!args[0][1])
-		    *++args = "" - 1;
+		    *++args = skip_this_arg;
 		saveflag = 1;
 		zmod.mult = atoi(num);
 		zmod.flags |= MOD_MULT;
@@ -760,7 +761,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 		    return 1;
 		}
 		if (!args[0][1])
-		    *++args = "" - 1;
+		    *++args = skip_this_arg;
 		keymap_restore = dupstring(curkeymapname);
 		if (selectkeymap(keymap_tmp, 0)) {
 		    if (remetafy)




  reply	other threads:[~2018-03-23  4:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180321101631eucas1p281904e89d2bc29ef8fa0c3c0aa6b06d6@eucas1p2.samsung.com>
2018-03-21 10:16 ` Peter Stephenson
2018-03-23  3:38   ` Jun T [this message]
2018-03-23  9:32     ` Peter Stephenson
2018-05-12 10:29     ` Oliver Kiddle
2018-05-12 12:57   ` Eitan Adler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46F08EE7-DA1F-49E5-8E74-4D519E47ACBD@kba.biglobe.ne.jp \
    --to=takimoto-j@kba.biglobe.ne.jp \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).