]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
parser: fix bison warnings
authorEric Leblond <eric@regit.org>
Mon, 10 Jul 2017 22:32:51 +0000 (00:32 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Jul 2017 15:20:34 +0000 (17:20 +0200)
We had the following warnings

parser_bison.y:1089:10: warning: variable 'cmd' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
                                        if (erec != NULL) {
                                            ^~~~~~~~~~~~
parser_bison.y:1095:39: note: uninitialized use occurs here
                                (yyval.cmd) = cmd_alloc(CMD_LIST, cmd, &(yyvsp[0].handle), &(yyloc), NULL);
                                                                  ^~~
parser_bison.y:1089:6: note: remove the 'if' if its condition is always true
                                        if (erec != NULL) {
                                        ^~~~~~~~~~~~~~~~~~
parser_bison.y:1080:12: note: initialize the variable 'cmd' to silence this warning
                                int cmd;
                                       ^
                                        = 0

Signed-off-by: Eric Leblond <eric@regit.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/parser_bison.y

index 45f134a81a89b7e22816aaa998ce26f5b88d5ba3..abc41a6bba398bf5194df3ae299e545f0b2cfe05 100644 (file)
@@ -1093,7 +1093,8 @@ list_cmd          :       TABLE           table_spec
                                        if (erec != NULL) {
                                                erec_queue(erec, state->msgs);
                                                YYERROR;
-                                       }
+                                       } else
+                                               YYERROR;
                                }
 
                                $$ = cmd_alloc(CMD_LIST, cmd, &$4, &@$, NULL);