Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Warnings in compctl
- X-seq: zsh-workers 42487
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers' list <zsh-workers@xxxxxxx>
- Subject: Warnings in compctl
- Date: Wed, 21 Mar 2018 10:16:30 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180321101633euoutp028ee3877d83a3c3053e3279ae1bf67689~d6A19W8Mu2624926249euoutp02s
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1521627393; bh=KNXaVawaCK1CqIqOugPpnp9tG+TNw1MDLFniHXpbwDI=; h=Date:From:To:Subject:References:From; b=kdpC1UD47suzIX40JGmNwVqoMoob75kvBz4QJE17z5GURh3qetnrFE6l+RRTldRwg iU4LuHAW6eSPA4td4drpq5KvH02+4i1BjIvJSvVVWaINigUZ+af5LrP+OrbXoBmYrI 8lAOiB9HweAMENJBrIa3TGK1YE5qtcKQj9VrncPQ=
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180321101631eucas1p281904e89d2bc29ef8fa0c3c0aa6b06d6@eucas1p2.samsung.com>
This removes some warnings from gcc 7.3.0. Technically I think a
pointer off the front is in fact invalid (one off the end is allowed so
long as it isn't dereferenced).
pws
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index 5414b8f..e9d1657 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -383,7 +383,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
* cct is a temporary just to hold flags; it never needs freeing.
*/
struct compctl cct;
- char **argv = *av;
+ char **argv = *av, argv_end[2] = "x";
int ready = 0, hx = 0;
/* Handle `compctl + foo ...' specially: turn it into
@@ -516,14 +516,14 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
if ((*argv)[1]) {
p = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "retry specification expected after -%c",
**argv);
return 1;
} else {
p = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
switch (*p) {
case '+':
@@ -553,25 +553,25 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
case 'k':
if ((*argv)[1]) {
cct.keyvar = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "variable name expected after -%c", **argv);
return 1;
} else {
cct.keyvar = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'K':
if ((*argv)[1]) {
cct.func = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "function name expected after -%c", **argv);
return 1;
} else {
cct.func = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'Y':
@@ -582,74 +582,74 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
expl:
if ((*argv)[1]) {
cct.explain = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "string expected after -%c", **argv);
return 1;
} else {
cct.explain = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'y':
if ((*argv)[1]) {
cct.ylist = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "function/variable expected after -%c",
**argv);
} else {
cct.ylist = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'P':
if ((*argv)[1]) {
cct.prefix = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "string expected after -%c", **argv);
return 1;
} else {
cct.prefix = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'S':
if ((*argv)[1]) {
cct.suffix = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "string expected after -%c", **argv);
return 1;
} else {
cct.suffix = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'g':
if ((*argv)[1]) {
cct.glob = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "glob pattern expected after -%c", **argv);
return 1;
} else {
cct.glob = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 's':
if ((*argv)[1]) {
cct.str = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "command string expected after -%c",
**argv);
return 1;
} else {
cct.str = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'l':
@@ -658,13 +658,13 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
return 1;
} else if ((*argv)[1]) {
cct.subcmd = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "command name expected after -%c", **argv);
return 1;
} else {
cct.subcmd = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'h':
@@ -673,49 +673,49 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
return 1;
} else if ((*argv)[1]) {
cct.substr = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "command name expected after -%c", **argv);
return 1;
} else {
cct.substr = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'W':
if ((*argv)[1]) {
cct.withd = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "path expected after -%c", **argv);
return 1;
} else {
cct.withd = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'J':
if ((*argv)[1]) {
cct.gname = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "group name expected after -%c", **argv);
return 1;
} else {
cct.gname = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'V':
if ((*argv)[1]) {
cct.gname = (*argv) + 1;
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "group name expected after -%c", **argv);
return 1;
} else {
cct.gname = *++argv;
- *argv = "" - 1;
+ *argv = argv_end;
}
cct.mask2 |= CC_NOSORT;
break;
@@ -738,7 +738,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
cct.mstr = NULL;
return 1;
}
- *argv = "" - 1;
+ *argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "matching specification expected after -%c",
**argv);
@@ -751,7 +751,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
cct.mstr = NULL;
return 1;
}
- *argv = "" - 1;
+ *argv = argv_end;
}
break;
case 'H':
@@ -772,7 +772,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
cct.hnum = 0;
if (*cct.hpat == '*' && !cct.hpat[1])
cct.hpat = "";
- *argv = "" - 1;
+ *argv = argv_end;
break;
case 'C':
if (cl) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author