]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
rule: replace three conditionals with one
authorJeremy Sowden <jeremy@azazel.net>
Thu, 7 Oct 2021 20:12:22 +0000 (21:12 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 11 Oct 2021 23:06:51 +0000 (01:06 +0200)
When outputting set definitions, merge three consecutive
`if (!list_empty(&set->stmt_list))` conditionals.

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/rule.c

index b566adf07b1f293e4abd3835a8a9f74110802060..7c048fcc1eee722d62666d7c9b0ad86658f55b67 100644 (file)
@@ -366,12 +366,11 @@ static void set_print_declaration(const struct set *set,
                nft_print(octx, "%s", opts->stmt_separator);
        }
 
-       if (!list_empty(&set->stmt_list))
-               nft_print(octx, "%s%s", opts->tab, opts->tab);
-
        if (!list_empty(&set->stmt_list)) {
                unsigned int flags = octx->flags;
 
+               nft_print(octx, "%s%s", opts->tab, opts->tab);
+
                octx->flags |= NFT_CTX_OUTPUT_STATELESS;
                list_for_each_entry(stmt, &set->stmt_list, list) {
                        stmt_print(stmt, octx);
@@ -379,10 +378,9 @@ static void set_print_declaration(const struct set *set,
                                nft_print(octx, " ");
                }
                octx->flags = flags;
-       }
 
-       if (!list_empty(&set->stmt_list))
                nft_print(octx, "%s", opts->stmt_separator);
+       }
 
        if (set->automerge)
                nft_print(octx, "%s%sauto-merge%s", opts->tab, opts->tab,