Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: unused variables
On Sun, 19 Jun 2011 00:56:43 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> gcc 4.6.0 is producing a range of "value set but not used" warnings that
> will want looking at.
All these seem to be trivially pukka: they are local or static variables
we are never referring to apart from the points where I've made the
changes. One case needed some conditional compilation, the rest just
stripping out.
It's probably too late to be able to tell if any of these actually
should be being referred to later.
Watch carefully in case I've removed the right hand side of an
assignment with side effects, but I think I've checked for that...
In such cases I've used a cast to void in case we ever want to run
lint. Joke.
Index: Src/glob.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/glob.c,v
retrieving revision 1.76
diff -p -u -r1.76 glob.c
--- Src/glob.c 9 May 2011 09:49:09 -0000 1.76
+++ Src/glob.c 19 Jun 2011 00:14:15 -0000
@@ -1801,7 +1801,7 @@ zglob(LinkList list, LinkNode np, int no
Eprog prog;
if ((prog = parse_string(sortp->exec, 0))) {
- int ef = errflag, lv = lastval, ret;
+ int ef = errflag, lv = lastval;
/* Parsed OK, execute for each name */
for (tmpptr = matchbuf; tmpptr < matchptr; tmpptr++) {
@@ -1814,7 +1814,6 @@ zglob(LinkList list, LinkNode np, int no
tmpptr->sortstrs[iexec] = tmpptr->name;
}
- ret = lastval;
errflag = ef;
lastval = lv;
} else {
Index: Src/lex.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/lex.c,v
retrieving revision 1.66
diff -p -u -r1.66 lex.c
--- Src/lex.c 19 May 2011 16:10:48 -0000 1.66
+++ Src/lex.c 19 Jun 2011 00:14:15 -0000
@@ -1698,7 +1698,7 @@ parse_subscript(char *s, int sub, int en
mod_export int
parse_subst_string(char *s)
{
- int c, l = strlen(s), err, olen, lexstop_ret;
+ int c, l = strlen(s), err;
char *ptr;
if (!*s || !strcmp(s, nulstring))
@@ -1711,13 +1711,11 @@ parse_subst_string(char *s)
bptr = tokstr = s;
bsiz = l + 1;
c = hgetc();
- lexstop_ret = lexstop;
c = gettokstr(c, 1);
err = errflag;
strinend();
inpop();
DPUTS(cmdsp, "BUG: parse_subst_string: cmdstack not empty.");
- olen = len;
lexrestore();
errflag = err;
if (c == LEXERR) {
@@ -1726,8 +1724,9 @@ parse_subst_string(char *s)
}
#ifdef DEBUG
/*
- * Historical note: we used to check here for olen == l, but
- * that's not necessarily the case if we stripped an RCQUOTE.
+ * Historical note: we used to check here for olen (the value of len
+ * before lexrestore()) == l, but that's not necessarily the case if
+ * we stripped an RCQUOTE.
*/
if (c != STRING || (errflag && !noerrs)) {
fprintf(stderr, "Oops. Bug in parse_subst_string: %s\n",
Index: Src/math.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/math.c,v
retrieving revision 1.40
diff -p -u -r1.40 math.c
--- Src/math.c 27 May 2011 01:42:30 -0000 1.40
+++ Src/math.c 19 Jun 2011 00:14:15 -0000
@@ -969,7 +969,6 @@ void
op(int what)
{
mnumber a, b, c, *spval;
- char *lv;
int tp = type[what];
if (errflag)
@@ -1155,7 +1154,6 @@ op(int what)
}
if (tp & (OP_E2|OP_E2IO)) {
struct mathvalue *mvp = stack + sp + 1;
- lv = stack[sp+1].lval;
c = setmathvar(mvp, c);
push(c, mvp->lval, 0);
} else
Index: Src/params.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/params.c,v
retrieving revision 1.172
diff -p -u -r1.172 params.c
--- Src/params.c 19 May 2011 16:10:48 -0000 1.172
+++ Src/params.c 19 Jun 2011 00:14:15 -0000
@@ -655,7 +655,10 @@ createparamtable(void)
char **new_environ;
int envsize;
#endif
- char **envp, **envp2, **sigptr, **t;
+#ifndef USE_SET_UNSET_ENV
+ char **envp;
+#endif
+ char **envp2, **sigptr, **t;
char buf[50], *str, *iname, *ivalue, *hostnam;
int oae = opts[ALLEXPORT];
#ifdef HAVE_UNAME
@@ -721,7 +724,11 @@ createparamtable(void)
/* Now incorporate environment variables we are inheriting *
* into the parameter hash table. Copy them into dynamic *
* memory so that we can free them if needed */
- for (envp = envp2 = environ; *envp2; envp2++) {
+ for (
+#ifndef USE_SET_UNSET_ENV
+ envp =
+#endif
+ envp2 = environ; *envp2; envp2++) {
if (split_env_string(*envp2, &iname, &ivalue)) {
if (!idigit(*iname) && isident(iname) && !strchr(iname, '[')) {
if ((!(pm = (Param) paramtab->getnode(paramtab, iname)) ||
@@ -993,9 +1000,7 @@ mod_export int
isident(char *s)
{
char *ss;
- int ne;
- ne = noeval; /* save the current value of noeval */
if (!*s) /* empty string is definitely not valid */
return 0;
Index: Src/parse.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/parse.c,v
retrieving revision 1.86
diff -p -u -r1.86 parse.c
--- Src/parse.c 20 Dec 2010 10:28:43 -0000 1.86
+++ Src/parse.c 19 Jun 2011 00:14:16 -0000
@@ -1709,11 +1709,11 @@ par_simple(int *complex, int nr)
}
zshlex();
} else {
- int ll, sl, pl, c = 0;
+ int ll, sl, c = 0;
ll = ecadd(0);
sl = ecadd(0);
- pl = ecadd(WCB_PIPE(WC_PIPE_END, 0));
+ (void)ecadd(WCB_PIPE(WC_PIPE_END, 0));
if (!par_cmd(&c)) {
cmdpop();
Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.258
diff -p -u -r1.258 utils.c
--- Src/utils.c 9 May 2011 09:49:09 -0000 1.258
+++ Src/utils.c 19 Jun 2011 00:14:16 -0000
@@ -4689,7 +4689,7 @@ addunprintable(char *v, const char *u, c
mod_export char *
quotestring(const char *s, char **e, int instring)
{
- const char *u, *tt;
+ const char *u;
char *v;
int alloclen;
char *buf;
@@ -4740,7 +4740,7 @@ quotestring(const char *s, char **e, int
break;
}
- tt = quotestart = v = buf = zshcalloc(alloclen);
+ quotestart = v = buf = zshcalloc(alloclen);
DPUTS(instring < QT_BACKSLASH || instring == QT_BACKTICK ||
instring > QT_SINGLE_OPTIONAL,
Index: Src/Modules/db_gdbm.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Modules/db_gdbm.c,v
retrieving revision 1.6
diff -p -u -r1.6 db_gdbm.c
--- Src/Modules/db_gdbm.c 30 Sep 2008 08:59:18 -0000 1.6
+++ Src/Modules/db_gdbm.c 19 Jun 2011 00:14:16 -0000
@@ -39,7 +39,9 @@
#include <gdbm.h>
+#if 0 /* what is this for? */
static char *backtype = "db/gdbm";
+#endif
static const struct gsu_scalar gdbm_gsu =
{ gdbmgetfn, gdbmsetfn, gdbmunsetfn };
@@ -138,7 +140,6 @@ static void
gdbmsetfn(Param pm, char *val)
{
datum key, content;
- int ret;
GDBM_FILE dbf;
key.dptr = pm->node.nam;
@@ -147,7 +148,7 @@ gdbmsetfn(Param pm, char *val)
content.dsize = strlen(content.dptr) + 1;
dbf = (GDBM_FILE)(pm->u.hash->tmpdata);
- ret = gdbm_store(dbf, key, content, GDBM_REPLACE);
+ (void)gdbm_store(dbf, key, content, GDBM_REPLACE);
}
/**/
@@ -155,14 +156,13 @@ static void
gdbmunsetfn(Param pm, int um)
{
datum key;
- int ret;
GDBM_FILE dbf;
key.dptr = pm->node.nam;
key.dsize = strlen(key.dptr) + 1;
dbf = (GDBM_FILE)(pm->u.hash->tmpdata);
- ret = gdbm_delete(dbf, key);
+ (void)gdbm_delete(dbf, key);
}
/**/
@@ -171,12 +171,10 @@ getgdbmnode(HashTable ht, const char *na
{
int len;
char *nameu;
- datum key;
Param pm = NULL;
nameu = dupstring(name);
unmetafy(nameu, &len);
- key.dptr = nameu;
pm = (Param) hcalloc(sizeof(struct param));
pm->node.nam = nameu;
Index: Src/Zle/compcore.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/compcore.c,v
retrieving revision 1.109
diff -p -u -r1.109 compcore.c
--- Src/Zle/compcore.c 4 Jun 2011 21:32:06 -0000 1.109
+++ Src/Zle/compcore.c 19 Jun 2011 00:14:16 -0000
@@ -1477,7 +1477,7 @@ set_comp_sep(void)
* when stripping single quotes: 1 for RCQUOTES, 3 otherwise
* (because we leave a "'" in the final string).
*/
- int dq = 0, odq, sq = 0, osq, qttype, sqq = 0, lsq = 0, qa = 0;
+ int dq = 0, odq, sq = 0, qttype, sqq = 0, lsq = 0, qa = 0;
/* dolq: like sq and dq but for dollars quoting. */
int dolq = 0;
/* remember some global variable values (except lp is local) */
@@ -1582,7 +1582,6 @@ set_comp_sep(void)
}
odq = dq;
- osq = sq;
inpush(dupstrspace(tmp), 0, NULL);
zlemetaline = tmp;
/*
@@ -3306,7 +3305,7 @@ dupmatch(Cmatch m, int nbeg, int nend)
mod_export int
permmatches(int last)
{
- Cmgroup g = amatches, n, opm;
+ Cmgroup g = amatches, n;
Cmatch *p, *q;
Cexpl *ep, *eq, e, o;
LinkList mlist;
@@ -3320,7 +3319,6 @@ permmatches(int last)
}
newmatches = fi = 0;
- opm = pmatches;
pmatches = lmatches = NULL;
nmatches = smatches = diffmatches = 0;
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.126
diff -p -u -r1.126 complist.c
--- Src/Zle/complist.c 14 May 2011 00:07:42 -0000 1.126
+++ Src/Zle/complist.c 19 Jun 2011 00:14:16 -0000
@@ -1369,8 +1369,6 @@ compprintlist(int showall)
}
#endif
if ((e = g->expls)) {
- int l;
-
if (!lastused && lasttype == 1) {
e = lastexpl;
ml = lastml;
@@ -1393,9 +1391,9 @@ compprintlist(int showall)
}
if (mlbeg < 0 && mfirstl < 0)
mfirstl = ml;
- l = compprintfmt((*e)->str,
- ((*e)->always ? -1 : (*e)->count),
- dolist(ml), 1, ml, &stop);
+ (void)compprintfmt((*e)->str,
+ ((*e)->always ? -1 : (*e)->count),
+ dolist(ml), 1, ml, &stop);
if (mselect >= 0) {
int mm = (mcols * ml), i;
Index: Src/Zle/zle_refresh.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_refresh.c,v
retrieving revision 1.86
diff -p -u -r1.86 zle_refresh.c
--- Src/Zle/zle_refresh.c 9 May 2011 09:49:09 -0000 1.86
+++ Src/Zle/zle_refresh.c 19 Jun 2011 00:14:17 -0000
@@ -2418,8 +2418,6 @@ singlerefresh(ZLE_STRING_T tmpline, int
all_atr_off = TXT_ATTR_OFF_FROM_ON(all_atr_on);
if (tmpline[t0] == ZWC('\t')) {
- REFRESH_ELEMENT sp = zr_sp;
- sp.atr = base_atr_on;
for (*vp++ = zr_sp; (vp - vbuf) & 7; )
*vp++ = zr_sp;
vp[-1].atr |= base_atr_off;
Index: Src/Zle/zle_tricky.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_tricky.c,v
retrieving revision 1.108
diff -p -u -r1.108 zle_tricky.c
--- Src/Zle/zle_tricky.c 9 May 2011 09:49:09 -0000 1.108
+++ Src/Zle/zle_tricky.c 19 Jun 2011 00:14:17 -0000
@@ -529,7 +529,7 @@ parambeg(char *s)
* or $'...').
*/
char *b = p + 1, *e = b;
- int n = 0, br = 1, nest = 0;
+ int n = 0, br = 1;
if (*b == Inbrace) {
char *tb = b;
@@ -543,8 +543,6 @@ parambeg(char *s)
n = skipparens(Inpar, Outpar, &b);
for (tb = p - 1; tb > s && *tb != Outbrace && *tb != Inbrace; tb--);
- if (tb > s && *tb == Inbrace && (tb[-1] == String || *tb == Qstring))
- nest = 1;
}
/* Ignore the stuff before the parameter name. */
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author