ash: eval: Always set localvar_stop
Upstream commit: Date: Thu, 31 May 2018 01:15:34 +0800 eval: Always set localvar_stop The variable localvar_stop is set iff vlocal is true. gcc doesn't get this so we get a spurious warning. This patch fixes this by always calling pushlocalvars with vlocal and making it only actually do the push if vlocal is non-zero. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
3e729102a8
commit
e2dd2afc8e
23
shell/ash.c
23
shell/ash.c
@ -9722,18 +9722,23 @@ poplocalvars(int keep)
|
|||||||
* Create a new localvar environment.
|
* Create a new localvar environment.
|
||||||
*/
|
*/
|
||||||
static struct localvar_list *
|
static struct localvar_list *
|
||||||
pushlocalvars(void)
|
pushlocalvars(int push)
|
||||||
{
|
{
|
||||||
struct localvar_list *ll;
|
struct localvar_list *ll;
|
||||||
|
struct localvar_list *top;
|
||||||
|
|
||||||
|
top = localvar_stack;
|
||||||
|
if (!push)
|
||||||
|
goto out;
|
||||||
|
|
||||||
INT_OFF;
|
INT_OFF;
|
||||||
ll = ckzalloc(sizeof(*ll));
|
ll = ckzalloc(sizeof(*ll));
|
||||||
/*ll->lv = NULL; - zalloc did it */
|
/*ll->lv = NULL; - zalloc did it */
|
||||||
ll->next = localvar_stack;
|
ll->next = top;
|
||||||
localvar_stack = ll;
|
localvar_stack = ll;
|
||||||
INT_ON;
|
INT_ON;
|
||||||
|
out:
|
||||||
return ll->next;
|
return top;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -10217,6 +10222,8 @@ evalcommand(union node *cmd, int flags)
|
|||||||
vflags = VEXPORT;
|
vflags = VEXPORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localvar_stop = pushlocalvars(vlocal);
|
||||||
|
|
||||||
/* Reserve one extra spot at the front for shellexec. */
|
/* Reserve one extra spot at the front for shellexec. */
|
||||||
nargv = stalloc(sizeof(char *) * (argc + 2));
|
nargv = stalloc(sizeof(char *) * (argc + 2));
|
||||||
argv = ++nargv;
|
argv = ++nargv;
|
||||||
@ -10245,7 +10252,6 @@ evalcommand(union node *cmd, int flags)
|
|||||||
status = redirectsafe(cmd->ncmd.redirect, REDIR_PUSH | REDIR_SAVEFD2);
|
status = redirectsafe(cmd->ncmd.redirect, REDIR_PUSH | REDIR_SAVEFD2);
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
vlocal = 0;
|
|
||||||
bail:
|
bail:
|
||||||
exitstatus = status;
|
exitstatus = status;
|
||||||
|
|
||||||
@ -10256,10 +10262,6 @@ evalcommand(union node *cmd, int flags)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
localvar_stop = NULL;
|
|
||||||
if (vlocal)
|
|
||||||
localvar_stop = pushlocalvars();
|
|
||||||
|
|
||||||
for (argp = cmd->ncmd.assign; argp; argp = argp->narg.next) {
|
for (argp = cmd->ncmd.assign; argp; argp = argp->narg.next) {
|
||||||
struct strlist **spp;
|
struct strlist **spp;
|
||||||
|
|
||||||
@ -10410,8 +10412,7 @@ evalcommand(union node *cmd, int flags)
|
|||||||
popredir(/*drop:*/ cmd_is_exec);
|
popredir(/*drop:*/ cmd_is_exec);
|
||||||
unwindredir(redir_stop);
|
unwindredir(redir_stop);
|
||||||
unwindfiles(file_stop);
|
unwindfiles(file_stop);
|
||||||
if (vlocal)
|
unwindlocalvars(localvar_stop);
|
||||||
unwindlocalvars(localvar_stop);
|
|
||||||
if (lastarg) {
|
if (lastarg) {
|
||||||
/* dsl: I think this is intended to be used to support
|
/* dsl: I think this is intended to be used to support
|
||||||
* '_' in 'vi' command mode during line editing...
|
* '_' in 'vi' command mode during line editing...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user