summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko2018-12-16 23:18:28 +0100
committerDenys Vlasenko2018-12-16 23:18:28 +0100
commit8e7686e4577ac7b07845d16fd95a39a4ce0af3c1 (patch)
tree6168406424e4c89d921df3d64f93b895d505a1f8 /miscutils
parentde24e9d3669e43a5419c7990ad13368ae51ced96 (diff)
downloadbusybox-8e7686e4577ac7b07845d16fd95a39a4ce0af3c1.zip
busybox-8e7686e4577ac7b07845d16fd95a39a4ce0af3c1.tar.gz
bc: p->exits.func is never zero, do not check for that
function old new delta zbc_parse_stmt_possibly_auto 1978 1967 -11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-11) Total: -11 bytes text data bss dec hex filename 981948 485 7296 989729 f1a21 busybox_old 981937 485 7296 989718 f1a16 busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/bc.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index af57b3d..ca14c1b 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -4232,7 +4232,6 @@ static BC_STATUS zbc_parse_for(BcParse *p)
BcInstPtr ip;
size_t *label;
size_t cond_idx, exit_idx, body_idx, update_idx;
- size_t n;
dbg_lex("%s:%d p->l.t.t:%d", __func__, __LINE__, p->l.t.t);
s = zbc_lex_next(&p->l);
@@ -4305,16 +4304,10 @@ static BC_STATUS zbc_parse_for(BcParse *p)
s = zbc_parse_stmt_fail_if_bare_NLINE(p, false, "for");
if (s) RETURN_STATUS(s);
- n = *((size_t *) bc_vec_top(&p->conds));
- bc_parse_push(p, BC_INST_JUMP);
- bc_parse_pushIndex(p, n);
-
- label = bc_vec_top(&p->conds);
-
//TODO: commonalize?
- dbg_lex("%s:%d BC_INST_JUMP to %d", __func__, __LINE__, *label);
+ dbg_lex("%s:%d BC_INST_JUMP to %d", __func__, __LINE__, update_idx);
bc_parse_push(p, BC_INST_JUMP);
- bc_parse_pushIndex(p, *label);
+ bc_parse_pushIndex(p, update_idx);
label = bc_vec_item(&p->func->labels, ip.idx);
dbg_lex("%s:%d rewriting label: %d -> %d", __func__, __LINE__, *label, p->func->code.len);
@@ -4337,18 +4330,13 @@ static BC_STATUS zbc_parse_break_or_continue(BcParse *p, BcLexType type)
if (type == BC_LEX_KEY_BREAK) {
BcInstPtr *ipp;
- i = p->exits.len;
- for (;;) {
- if (i == 0) // none of the enclosing blocks is a loop
- RETURN_STATUS(bc_error_bad_token());
- ipp = bc_vec_item(&p->exits, --i);
- if (ipp->func != 0)
- break;
- }
+ if (p->exits.len == 0) // none of the enclosing blocks is a loop
+ RETURN_STATUS(bc_error_bad_token());
+ ipp = bc_vec_top(&p->exits);
i = ipp->idx;
- }
- else
+ } else {
i = *((size_t *) bc_vec_top(&p->conds));
+ }
bc_parse_push(p, BC_INST_JUMP);
bc_parse_pushIndex(p, i);