* [PATCH] avoid using undefined handler
@ 2011-05-25 12:30 Jim Meyering
2011-07-08 8:30 ` Herbert Xu
0 siblings, 1 reply; 2+ messages in thread
From: Jim Meyering @ 2011-05-25 12:30 UTC (permalink / raw)
To: dash
Clang had some legitimate warnings:
2011-05-25 Jim Meyering <meyering@redhat.com>
avoid using undefined handler
* src/eval.c (evalbltin, evalfun): Set savehandler before calling
setjmp with the possible "goto *done", where savehandler is used.
Otherwise, clang warns that "Assigned value is garbage or undefined"
at the point where "savehandler" is used on the RHS.
From 067f8b4da3005ab226652b19ed796d67bf1fa6d4 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Wed, 25 May 2011 14:27:14 +0200
Subject: [PATCH] avoid using undefined handler
* src/eval.c (evalbltin, evalfun): Set savehandler before calling
setjmp with the possible "goto *done", where savehandler is used.
Otherwise, clang warns that "Assigned value is garbage or undefined"
at the point where "savehandler" is used on the RHS.
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
src/eval.c | 4 ++--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/eval.c b/src/eval.c
index 426c03a..911fb2c 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -911,76 +911,76 @@ out:
if (lastarg)
/* dsl: I think this is intended to be used to support
* '_' in 'vi' command mode during line editing...
* However I implemented that within libedit itself.
*/
setvar("_", lastarg, 0);
popstackmark(&smark);
}
STATIC int
evalbltin(const struct builtincmd *cmd, int argc, char **argv, int flags)
{
char *volatile savecmdname;
struct jmploc *volatile savehandler;
struct jmploc jmploc;
int status;
int i;
savecmdname = commandname;
+ savehandler = handler;
if ((i = setjmp(jmploc.loc)))
goto cmddone;
- savehandler = handler;
handler = &jmploc;
commandname = argv[0];
argptr = argv + 1;
optptr = NULL; /* initialize nextopt */
if (cmd == EVALCMD)
status = evalcmd(argc, argv, flags);
else
status = (*cmd->builtin)(argc, argv);
flushall();
status |= outerr(out1);
exitstatus = status;
cmddone:
freestdout();
commandname = savecmdname;
handler = savehandler;
return i;
}
STATIC int
evalfun(struct funcnode *func, int argc, char **argv, int flags)
{
volatile struct shparam saveparam;
struct jmploc *volatile savehandler;
struct jmploc jmploc;
int e;
int savefuncline;
saveparam = shellparam;
savefuncline = funcline;
+ savehandler = handler;
if ((e = setjmp(jmploc.loc))) {
goto funcdone;
}
INTOFF;
- savehandler = handler;
handler = &jmploc;
shellparam.malloc = 0;
func->count++;
funcline = func->n.ndefun.linno;
INTON;
shellparam.nparam = argc - 1;
shellparam.p = argv + 1;
shellparam.optind = 1;
shellparam.optoff = -1;
pushlocalvars();
evaltree(func->n.ndefun.body, flags & EV_TESTED);
poplocalvars(0);
funcdone:
INTOFF;
funcline = savefuncline;
freefunc(func);
freeparam(&shellparam);
shellparam = saveparam;
handler = savehandler;
--
1.7.5.2.609.g6dbbf
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] avoid using undefined handler
2011-05-25 12:30 [PATCH] avoid using undefined handler Jim Meyering
@ 2011-07-08 8:30 ` Herbert Xu
0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2011-07-08 8:30 UTC (permalink / raw)
To: Jim Meyering; +Cc: dash
On Wed, May 25, 2011 at 12:30:53PM +0000, Jim Meyering wrote:
> Clang had some legitimate warnings:
>
> 2011-05-25 Jim Meyering <meyering@redhat.com>
>
> avoid using undefined handler
Indeed this looks like a real bug.
Patch applied. Thanks Jim!
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-08 8:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-25 12:30 [PATCH] avoid using undefined handler Jim Meyering
2011-07-08 8:30 ` Herbert Xu
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).