bc: remove unnecessary initializations
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 21 Dec 2018 21:43:53 +0000 (22:43 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 21 Dec 2018 21:43:53 +0000 (22:43 +0100)
function                                             old     new   delta
zdc_program_asciify                                  403     395      -8
zbc_program_print                                    691     683      -8
zbc_program_exec                                    4079    4068     -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-27)             Total: -27 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/bc.c

index 58e3bcb52c35ec6ad939e6df1df1dfd9387cd7ef..cf620f8ece68b9dc6e826d1bc784cd902c0ebc9f 100644 (file)
@@ -5058,6 +5058,7 @@ static BcVec* bc_program_search(char *id, bool var)
        return bc_vec_item(v, ptr->idx);
 }
 
+// 'num' need not be initialized on entry
 static BC_STATUS zbc_program_num(BcResult *r, BcNum **num, bool hex)
 {
        switch (r->t) {
@@ -5082,12 +5083,10 @@ static BC_STATUS zbc_program_num(BcResult *r, BcNum **num, bool hex)
                        hex = hex && len == 1;
                        base_t = hex ? 16 : G.prog.ib_t;
                        s = zbc_num_parse(&r->d.n, str, base_t);
-
                        if (s) {
                                bc_num_free(&r->d.n);
                                RETURN_STATUS(s);
                        }
-
                        *num = &r->d.n;
                        r->t = BC_RESULT_TEMP;
                        break;
@@ -5566,7 +5565,6 @@ static BC_STATUS zbc_program_print(char inst, size_t idx)
                RETURN_STATUS(bc_error_stack_has_too_few_elements());
 
        r = bc_vec_item_rev(&G.prog.results, idx);
-       num = NULL; // is this NULL necessary?
        s = zbc_program_num(r, &num, false);
        if (s) RETURN_STATUS(s);
 
@@ -6203,7 +6201,6 @@ static BC_STATUS zdc_program_asciify(void)
                RETURN_STATUS(bc_error_stack_has_too_few_elements());
        r = bc_vec_top(&G.prog.results);
 
-       num = NULL; // TODO: is this NULL needed?
        s = zbc_program_num(r, &num, false);
        if (s) RETURN_STATUS(s);
 
@@ -6268,7 +6265,6 @@ static BC_STATUS zdc_program_printStream(void)
                RETURN_STATUS(bc_error_stack_has_too_few_elements());
        r = bc_vec_top(&G.prog.results);
 
-       n = NULL; // is this needed?
        s = zbc_program_num(r, &n, false);
        if (s) RETURN_STATUS(s);