]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
Review switch statements for unmarked fall through cases
authorPhil Sutter <phil@nwl.cc>
Wed, 28 Feb 2018 15:06:16 +0000 (16:06 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 28 Feb 2018 15:59:19 +0000 (16:59 +0100)
While revisiting all of them, clear a few oddities as well:

- There's no point in marking empty fall through cases: They are easy to
  spot and a common concept when using switch().

- Fix indenting of break statement in one occasion.

- Drop needless braces around one case which doesn't declare variables.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/ct.c
src/evaluate.c
src/hash.c
src/netlink_delinearize.c
src/rule.c

index d5347974bd0d59fd50017c924d2396b3528e6960..bdf50d7a46d6b14a72c6c950bb99c7680e1557e4 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -289,7 +289,7 @@ static void ct_print(enum nft_ct_keys key, int8_t dir, uint8_t nfproto,
        }
 
        switch (key) {
-       case NFT_CT_SRC: /* fallthrough */
+       case NFT_CT_SRC:
        case NFT_CT_DST:
                desc = proto_find_upper(&proto_inet, nfproto);
                if (desc)
index 6be3bf031f58710a9c8ad350e98888ab3cd206e8..54fd6b61dbbdf5a648405a0a90beffc62145f86e 100644 (file)
@@ -2712,6 +2712,7 @@ static int stmt_evaluate_objref_map(struct eval_ctx *ctx, struct stmt *stmt)
 
                map->mappings->set->flags |=
                        map->mappings->set->init->set_flags;
+               /* fall through */
        case EXPR_SYMBOL:
                if (expr_evaluate(ctx, &map->mappings) < 0)
                        return -1;
index 9cd3c8cfa173da510d279ce354c20805b72ba646..3355cadd1df2f38441eb60668ff5b0ff69e180f8 100644 (file)
@@ -20,7 +20,7 @@ static void hash_expr_print(const struct expr *expr, struct output_ctx *octx)
        switch (expr->hash.type) {
        case NFT_HASH_SYM:
                nft_print(octx, "symhash");
-       break;
+               break;
        case NFT_HASH_JENKINS:
        default:
                nft_print(octx, "jhash ");
index a1f0e92310462856504c0ec926e95c81734ba15e..9dbd9141c069e38d680b3ab11a75de721ebd71d0 100644 (file)
@@ -1485,6 +1485,7 @@ static void ct_meta_common_postprocess(struct rule_pp_ctx *ctx,
        case OP_NEQ:
                if (right->ops->type != EXPR_SET && right->ops->type != EXPR_SET_REF)
                        break;
+               /* fall through */
        case OP_LOOKUP:
                expr_set_type(right, left->dtype, left->byteorder);
                break;
index 5b7219e82eaaa5819fdf7dc79ec641336848f9ac..a53908f670c1d113913baab60ea23005c2301582 100644 (file)
@@ -1341,7 +1341,7 @@ static void obj_print_data(const struct obj *obj,
                }
                }
                break;
-       case NFT_OBJECT_CT_HELPER: {
+       case NFT_OBJECT_CT_HELPER:
                nft_print(octx, "ct helper %s {\n", obj->handle.obj);
                nft_print(octx, "\t\ttype \"%s\" protocol ",
                          obj->ct_helper.name);
@@ -1349,7 +1349,6 @@ static void obj_print_data(const struct obj *obj,
                nft_print(octx, "\t\tl3proto %s",
                          family2str(obj->ct_helper.l3proto));
                break;
-               }
        case NFT_OBJECT_LIMIT: {
                bool inv = obj->limit.flags & NFT_LIMIT_F_INV;
                const char *data_unit;
@@ -1661,11 +1660,13 @@ static int do_command_reset(struct netlink_ctx *ctx, struct cmd *cmd)
        switch (cmd->obj) {
        case CMD_OBJ_COUNTERS:
                dump = true;
+               /* fall through */
        case CMD_OBJ_COUNTER:
                type = NFT_OBJECT_COUNTER;
                break;
        case CMD_OBJ_QUOTAS:
                dump = true;
+               /* fall through */
        case CMD_OBJ_QUOTA:
                type = NFT_OBJECT_QUOTA;
                break;