]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables_error() does not return
authorPhil Sutter <phil@nwl.cc>
Tue, 17 Sep 2019 15:53:31 +0000 (17:53 +0200)
committerPhil Sutter <phil@nwl.cc>
Wed, 25 Sep 2019 21:46:14 +0000 (23:46 +0200)
It's a define which resolves into a callback which in turn is declared
with noreturn attribute. It will never return, therefore drop all
explicit exit() calls or other dead code immediately following it.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
iptables/iptables-restore.c
iptables/iptables-xml.c
iptables/nft.c
iptables/xshared.c
iptables/xtables-restore.c

index 430be18b3c30044de8a2e4df6afa4087e9e58629..6bc182bfae4a29f8544ebaf33d8805b8d0308a28 100644 (file)
@@ -82,11 +82,10 @@ create_handle(struct iptables_restore_cb *cb, const char *tablename)
                handle = cb->ops->init(tablename);
        }
 
-       if (!handle) {
+       if (!handle)
                xtables_error(PARAMETER_PROBLEM, "%s: unable to initialize "
                        "table '%s'\n", xt_params->program_name, tablename);
-               exit(1);
-       }
+
        return handle;
 }
 
@@ -207,12 +206,11 @@ ip46tables_restore_main(struct iptables_restore_cb *cb, int argc, char *argv[])
 
                        table = strtok(buffer+1, " \t\n");
                        DEBUGP("line %u, table '%s'\n", line, table);
-                       if (!table) {
+                       if (!table)
                                xtables_error(PARAMETER_PROBLEM,
                                        "%s: line %u table name invalid\n",
                                        xt_params->program_name, line);
-                               exit(1);
-                       }
+
                        strncpy(curtable, table, XT_TABLE_MAXNAMELEN);
                        curtable[XT_TABLE_MAXNAMELEN] = '\0';
 
@@ -248,12 +246,10 @@ ip46tables_restore_main(struct iptables_restore_cb *cb, int argc, char *argv[])
 
                        chain = strtok(buffer+1, " \t\n");
                        DEBUGP("line %u, chain '%s'\n", line, chain);
-                       if (!chain) {
+                       if (!chain)
                                xtables_error(PARAMETER_PROBLEM,
                                           "%s: line %u chain name invalid\n",
                                           xt_params->program_name, line);
-                               exit(1);
-                       }
 
                        if (strlen(chain) >= XT_EXTENSION_MAXNAMELEN)
                                xtables_error(PARAMETER_PROBLEM,
@@ -281,12 +277,10 @@ ip46tables_restore_main(struct iptables_restore_cb *cb, int argc, char *argv[])
 
                        policy = strtok(NULL, " \t\n");
                        DEBUGP("line %u, policy '%s'\n", line, policy);
-                       if (!policy) {
+                       if (!policy)
                                xtables_error(PARAMETER_PROBLEM,
                                           "%s: line %u policy invalid\n",
                                           xt_params->program_name, line);
-                               exit(1);
-                       }
 
                        if (strcmp(policy, "-") != 0) {
                                struct xt_counters count = {};
index 9d9ce6d4a13eea04c4dd41d158f1d7240821ae1f..36ad78450b1efaf295292eb9099fdf1e30e65618 100644 (file)
@@ -208,12 +208,11 @@ needChain(char *chain)
 static void
 saveChain(char *chain, char *policy, struct xt_counters *ctr)
 {
-       if (nextChain >= maxChains) {
+       if (nextChain >= maxChains)
                xtables_error(PARAMETER_PROBLEM,
                           "%s: line %u chain name invalid\n",
                           prog_name, line);
-               exit(1);
-       };
+
        chains[nextChain].chain = strdup(chain);
        chains[nextChain].policy = strdup(policy);
        chains[nextChain].count = *ctr;
@@ -606,12 +605,11 @@ iptables_xml_main(int argc, char *argv[])
 
                        table = strtok(buffer + 1, " \t\n");
                        DEBUGP("line %u, table '%s'\n", line, table);
-                       if (!table) {
+                       if (!table)
                                xtables_error(PARAMETER_PROBLEM,
                                           "%s: line %u table name invalid\n",
                                           prog_name, line);
-                               exit(1);
-                       }
+
                        openTable(table);
 
                        ret = 1;
@@ -623,23 +621,19 @@ iptables_xml_main(int argc, char *argv[])
 
                        chain = strtok(buffer + 1, " \t\n");
                        DEBUGP("line %u, chain '%s'\n", line, chain);
-                       if (!chain) {
+                       if (!chain)
                                xtables_error(PARAMETER_PROBLEM,
                                           "%s: line %u chain name invalid\n",
                                           prog_name, line);
-                               exit(1);
-                       }
 
                        DEBUGP("Creating new chain '%s'\n", chain);
 
                        policy = strtok(NULL, " \t\n");
                        DEBUGP("line %u, policy '%s'\n", line, policy);
-                       if (!policy) {
+                       if (!policy)
                                xtables_error(PARAMETER_PROBLEM,
                                           "%s: line %u policy invalid\n",
                                           prog_name, line);
-                               exit(1);
-                       }
 
                        ctrs = strtok(NULL, " \t\n");
                        parse_counters(ctrs, &count);
@@ -735,13 +729,11 @@ iptables_xml_main(int argc, char *argv[])
                                             param_buffer[1] != '-' &&
                                             strchr(param_buffer, 't')) ||
                                            (!strncmp(param_buffer, "--t", 3) &&
-                                            !strncmp(param_buffer, "--table", strlen(param_buffer)))) {
+                                            !strncmp(param_buffer, "--table", strlen(param_buffer))))
                                                xtables_error(PARAMETER_PROBLEM,
                                                           "Line %u seems to have a "
                                                           "-t table option.\n",
                                                           line);
-                                               exit(1);
-                                       }
 
                                        add_argv(param_buffer, quoted);
                                        if (newargc >= 2
index 8047a51f00493b80f37e4d1e41ea494e7d06c93f..90bb0c63c025ac09d494c7e7a7f35352af950dc7 100644 (file)
@@ -2517,10 +2517,8 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
 
        ops = nft_family_ops_lookup(h->family);
 
-       if (!nft_is_table_compatible(h, table)) {
+       if (!nft_is_table_compatible(h, table))
                xtables_error(OTHER_PROBLEM, "table `%s' is incompatible, use 'nft' tool.\n", table);
-               return 0;
-       }
 
        list = nft_chain_list_get(h, table);
        if (!list)
@@ -2620,10 +2618,8 @@ int nft_rule_list_save(struct nft_handle *h, const char *chain,
 
        nft_xt_builtin_init(h, table);
 
-       if (!nft_is_table_compatible(h, table)) {
+       if (!nft_is_table_compatible(h, table))
                xtables_error(OTHER_PROBLEM, "table `%s' is incompatible, use 'nft' tool.\n", table);
-               return 0;
-       }
 
        list = nft_chain_list_get(h, table);
        if (!list)
index 36a2ec5f193d32a4b7ffee9db83f327330b80ba2..5e6cd4ae7c908dc3661bdcf0cad10cb9eb80526e 100644 (file)
@@ -181,7 +181,6 @@ int command_default(struct iptables_command_state *cs,
                xtables_error(PARAMETER_PROBLEM, "unknown option "
                              "\"%s\"", cs->argv[optind-1]);
        xtables_error(PARAMETER_PROBLEM, "Unknown arg \"%s\"", optarg);
-       return 0;
 }
 
 static mainfunc_t subcmd_get(const char *cmd, const struct subcommand *cb)
index f930f5ba2d167526b35f128f19024c2f9127b4e9..27e65b971727e775306e727ccc67824c3f680240 100644 (file)
@@ -131,12 +131,11 @@ void xtables_restore_parse(struct nft_handle *h,
 
                        table = strtok(buffer+1, " \t\n");
                        DEBUGP("line %u, table '%s'\n", line, table);
-                       if (!table) {
+                       if (!table)
                                xtables_error(PARAMETER_PROBLEM,
                                        "%s: line %u table name invalid\n",
                                        xt_params->program_name, line);
-                               exit(1);
-                       }
+
                        curtable = nft_table_builtin_find(h, table);
                        if (!curtable)
                                xtables_error(PARAMETER_PROBLEM,
@@ -168,12 +167,10 @@ void xtables_restore_parse(struct nft_handle *h,
 
                        chain = strtok(buffer+1, " \t\n");
                        DEBUGP("line %u, chain '%s'\n", line, chain);
-                       if (!chain) {
+                       if (!chain)
                                xtables_error(PARAMETER_PROBLEM,
                                           "%s: line %u chain name invalid\n",
                                           xt_params->program_name, line);
-                               exit(1);
-                       }
 
                        if (strlen(chain) >= XT_EXTENSION_MAXNAMELEN)
                                xtables_error(PARAMETER_PROBLEM,
@@ -183,12 +180,10 @@ void xtables_restore_parse(struct nft_handle *h,
 
                        policy = strtok(NULL, " \t\n");
                        DEBUGP("line %u, policy '%s'\n", line, policy);
-                       if (!policy) {
+                       if (!policy)
                                xtables_error(PARAMETER_PROBLEM,
                                           "%s: line %u policy invalid\n",
                                           xt_params->program_name, line);
-                               exit(1);
-                       }
 
                        if (nft_chain_builtin_find(curtable, chain)) {
                                if (counters) {