]> git.hungrycats.org Git - linux/commitdiff
netfilter: Fix switch statement warnings with recent gcc.
authorDavid Miller <davem@davemloft.net>
Wed, 8 Apr 2015 03:05:42 +0000 (23:05 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 11 Nov 2017 13:33:54 +0000 (13:33 +0000)
commit c1f866767777d1c6abae0ec57effffcb72017c00 upstream.

More recent GCC warns about two kinds of switch statement uses:

1) Switching on an enumeration, but not having an explicit case
   statement for all members of the enumeration.  To show the
   compiler this is intentional, we simply add a default case
   with nothing more than a break statement.

2) Switching on a boolean value.  I think this warning is dumb
   but nevertheless you get it wholesale with -Wswitch.

This patch cures all such warnings in netfilter.

Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ipv4/netfilter/nft_reject_ipv4.c
net/ipv6/netfilter/nft_reject_ipv6.c
net/netfilter/nft_compat.c
net/netfilter/nft_ct.c

index e79718a382f2e373890bc5fbb2be4fa2468162c8..292783018da557e09beb2dc4a1462236ab36ab2f 100644 (file)
@@ -33,6 +33,8 @@ void nft_reject_ipv4_eval(const struct nft_expr *expr,
        case NFT_REJECT_TCP_RST:
                nf_send_reset(pkt->skb, pkt->ops->hooknum);
                break;
+       default:
+               break;
        }
 
        data[NFT_REG_VERDICT].verdict = NF_DROP;
index 0bc19fa878213318943039eee1a9dc86c9b42510..367bd4841a0c33fca2a09afe31de3a3c1af5df00 100644 (file)
@@ -34,6 +34,8 @@ void nft_reject_ipv6_eval(const struct nft_expr *expr,
        case NFT_REJECT_TCP_RST:
                nf_send_reset6(net, pkt->skb, pkt->ops->hooknum);
                break;
+       default:
+               break;
        }
 
        data[NFT_REG_VERDICT].verdict = NF_DROP;
index 62097fda49dc182cfe9bc5505c8f935ec2f23b52..55be1e0a4a7f9c77e84b11ccd18b6d3b0f2b4d92 100644 (file)
@@ -295,11 +295,11 @@ static void nft_match_eval(const struct nft_expr *expr,
                return;
        }
 
-       switch(ret) {
-       case true:
+       switch (ret ? 1 : 0) {
+       case 1:
                data[NFT_REG_VERDICT].verdict = NFT_CONTINUE;
                break;
-       case false:
+       case 0:
                data[NFT_REG_VERDICT].verdict = NFT_BREAK;
                break;
        }
index cc5603016242ea8e1f5cdce1d633e3a2687276ae..18d520e0ca0a73cadeb8cb8efa2565e1169e9980 100644 (file)
@@ -56,6 +56,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
                        state = NF_CT_STATE_BIT(ctinfo);
                dest->data[0] = state;
                return;
+       default:
+               break;
        }
 
        if (ct == NULL)
@@ -117,6 +119,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
                return;
        }
 #endif
+       default:
+               break;
        }
 
        tuple = &ct->tuplehash[priv->dir].tuple;
@@ -141,6 +145,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
        case NFT_CT_PROTO_DST:
                dest->data[0] = (__force __u16)tuple->dst.u.all;
                return;
+       default:
+               break;
        }
        return;
 err:
@@ -172,6 +178,8 @@ static void nft_ct_set_eval(const struct nft_expr *expr,
                }
                break;
 #endif
+       default:
+               break;
        }
 }