diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2020-02-20 10:33:38 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2020-02-20 10:37:30 +0100 |
commit | e2dd2afc8e4dbcf1061818adc68d2e74a1fa64d3 (patch) | |
tree | 9dc1fb145d22ad8c80796bc771e43578b899b507 | |
parent | 3e729102a86b1fb536f61c6ebcd95321ba98528d (diff) | |
download | busybox-w32-e2dd2afc8e4dbcf1061818adc68d2e74a1fa64d3.tar.gz busybox-w32-e2dd2afc8e4dbcf1061818adc68d2e74a1fa64d3.tar.bz2 busybox-w32-e2dd2afc8e4dbcf1061818adc68d2e74a1fa64d3.zip |
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>
-rw-r--r-- | shell/ash.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/shell/ash.c b/shell/ash.c index 5bb10e5cb..81d2422d6 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -9722,18 +9722,23 @@ poplocalvars(int keep) | |||
9722 | * Create a new localvar environment. | 9722 | * Create a new localvar environment. |
9723 | */ | 9723 | */ |
9724 | static struct localvar_list * | 9724 | static struct localvar_list * |
9725 | pushlocalvars(void) | 9725 | pushlocalvars(int push) |
9726 | { | 9726 | { |
9727 | struct localvar_list *ll; | 9727 | struct localvar_list *ll; |
9728 | struct localvar_list *top; | ||
9729 | |||
9730 | top = localvar_stack; | ||
9731 | if (!push) | ||
9732 | goto out; | ||
9728 | 9733 | ||
9729 | INT_OFF; | 9734 | INT_OFF; |
9730 | ll = ckzalloc(sizeof(*ll)); | 9735 | ll = ckzalloc(sizeof(*ll)); |
9731 | /*ll->lv = NULL; - zalloc did it */ | 9736 | /*ll->lv = NULL; - zalloc did it */ |
9732 | ll->next = localvar_stack; | 9737 | ll->next = top; |
9733 | localvar_stack = ll; | 9738 | localvar_stack = ll; |
9734 | INT_ON; | 9739 | INT_ON; |
9735 | 9740 | out: | |
9736 | return ll->next; | 9741 | return top; |
9737 | } | 9742 | } |
9738 | 9743 | ||
9739 | static void | 9744 | static void |
@@ -10217,6 +10222,8 @@ evalcommand(union node *cmd, int flags) | |||
10217 | vflags = VEXPORT; | 10222 | vflags = VEXPORT; |
10218 | } | 10223 | } |
10219 | 10224 | ||
10225 | localvar_stop = pushlocalvars(vlocal); | ||
10226 | |||
10220 | /* Reserve one extra spot at the front for shellexec. */ | 10227 | /* Reserve one extra spot at the front for shellexec. */ |
10221 | nargv = stalloc(sizeof(char *) * (argc + 2)); | 10228 | nargv = stalloc(sizeof(char *) * (argc + 2)); |
10222 | argv = ++nargv; | 10229 | argv = ++nargv; |
@@ -10245,7 +10252,6 @@ evalcommand(union node *cmd, int flags) | |||
10245 | status = redirectsafe(cmd->ncmd.redirect, REDIR_PUSH | REDIR_SAVEFD2); | 10252 | status = redirectsafe(cmd->ncmd.redirect, REDIR_PUSH | REDIR_SAVEFD2); |
10246 | 10253 | ||
10247 | if (status) { | 10254 | if (status) { |
10248 | vlocal = 0; | ||
10249 | bail: | 10255 | bail: |
10250 | exitstatus = status; | 10256 | exitstatus = status; |
10251 | 10257 | ||
@@ -10256,10 +10262,6 @@ evalcommand(union node *cmd, int flags) | |||
10256 | goto out; | 10262 | goto out; |
10257 | } | 10263 | } |
10258 | 10264 | ||
10259 | localvar_stop = NULL; | ||
10260 | if (vlocal) | ||
10261 | localvar_stop = pushlocalvars(); | ||
10262 | |||
10263 | for (argp = cmd->ncmd.assign; argp; argp = argp->narg.next) { | 10265 | for (argp = cmd->ncmd.assign; argp; argp = argp->narg.next) { |
10264 | struct strlist **spp; | 10266 | struct strlist **spp; |
10265 | 10267 | ||
@@ -10410,8 +10412,7 @@ evalcommand(union node *cmd, int flags) | |||
10410 | popredir(/*drop:*/ cmd_is_exec); | 10412 | popredir(/*drop:*/ cmd_is_exec); |
10411 | unwindredir(redir_stop); | 10413 | unwindredir(redir_stop); |
10412 | unwindfiles(file_stop); | 10414 | unwindfiles(file_stop); |
10413 | if (vlocal) | 10415 | unwindlocalvars(localvar_stop); |
10414 | unwindlocalvars(localvar_stop); | ||
10415 | if (lastarg) { | 10416 | if (lastarg) { |
10416 | /* dsl: I think this is intended to be used to support | 10417 | /* dsl: I think this is intended to be used to support |
10417 | * '_' in 'vi' command mode during line editing... | 10418 | * '_' in 'vi' command mode during line editing... |