Commit c1f86676 authored by David Miller's avatar David Miller Committed by David S. Miller

netfilter: Fix switch statement warnings with recent gcc.

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: default avatarDavid S. Miller <davem@davemloft.net>
Acked-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent e85e85c8
...@@ -371,6 +371,8 @@ static int nft_reject_bridge_dump(struct sk_buff *skb, ...@@ -371,6 +371,8 @@ static int nft_reject_bridge_dump(struct sk_buff *skb,
if (nla_put_u8(skb, NFTA_REJECT_ICMP_CODE, priv->icmp_code)) if (nla_put_u8(skb, NFTA_REJECT_ICMP_CODE, priv->icmp_code))
goto nla_put_failure; goto nla_put_failure;
break; break;
default:
break;
} }
return 0; return 0;
......
...@@ -33,6 +33,8 @@ static void nft_reject_ipv4_eval(const struct nft_expr *expr, ...@@ -33,6 +33,8 @@ static void nft_reject_ipv4_eval(const struct nft_expr *expr,
case NFT_REJECT_TCP_RST: case NFT_REJECT_TCP_RST:
nf_send_reset(pkt->skb, pkt->ops->hooknum); nf_send_reset(pkt->skb, pkt->ops->hooknum);
break; break;
default:
break;
} }
data[NFT_REG_VERDICT].verdict = NF_DROP; data[NFT_REG_VERDICT].verdict = NF_DROP;
......
...@@ -34,6 +34,8 @@ static void nft_reject_ipv6_eval(const struct nft_expr *expr, ...@@ -34,6 +34,8 @@ static void nft_reject_ipv6_eval(const struct nft_expr *expr,
case NFT_REJECT_TCP_RST: case NFT_REJECT_TCP_RST:
nf_send_reset6(net, pkt->skb, pkt->ops->hooknum); nf_send_reset6(net, pkt->skb, pkt->ops->hooknum);
break; break;
default:
break;
} }
data[NFT_REG_VERDICT].verdict = NF_DROP; data[NFT_REG_VERDICT].verdict = NF_DROP;
......
...@@ -321,11 +321,11 @@ static void nft_match_eval(const struct nft_expr *expr, ...@@ -321,11 +321,11 @@ static void nft_match_eval(const struct nft_expr *expr,
return; return;
} }
switch(ret) { switch (ret ? 1 : 0) {
case true: case 1:
data[NFT_REG_VERDICT].verdict = NFT_CONTINUE; data[NFT_REG_VERDICT].verdict = NFT_CONTINUE;
break; break;
case false: case 0:
data[NFT_REG_VERDICT].verdict = NFT_BREAK; data[NFT_REG_VERDICT].verdict = NFT_BREAK;
break; break;
} }
......
...@@ -56,6 +56,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr, ...@@ -56,6 +56,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
state = NF_CT_STATE_BIT(ctinfo); state = NF_CT_STATE_BIT(ctinfo);
dest->data[0] = state; dest->data[0] = state;
return; return;
default:
break;
} }
if (ct == NULL) if (ct == NULL)
...@@ -117,6 +119,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr, ...@@ -117,6 +119,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
return; return;
} }
#endif #endif
default:
break;
} }
tuple = &ct->tuplehash[priv->dir].tuple; tuple = &ct->tuplehash[priv->dir].tuple;
...@@ -141,6 +145,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr, ...@@ -141,6 +145,8 @@ static void nft_ct_get_eval(const struct nft_expr *expr,
case NFT_CT_PROTO_DST: case NFT_CT_PROTO_DST:
dest->data[0] = (__force __u16)tuple->dst.u.all; dest->data[0] = (__force __u16)tuple->dst.u.all;
return; return;
default:
break;
} }
return; return;
err: err:
...@@ -172,6 +178,8 @@ static void nft_ct_set_eval(const struct nft_expr *expr, ...@@ -172,6 +178,8 @@ static void nft_ct_set_eval(const struct nft_expr *expr,
} }
break; break;
#endif #endif
default:
break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment