From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932875AbdKFXz2 (ORCPT ); Mon, 6 Nov 2017 18:55:28 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:52807 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932840AbdKFXyn (ORCPT ); Mon, 6 Nov 2017 18:54:43 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Arnd Bergmann" , "Pablo Neira Ayuso" , "David Miller" Date: Mon, 06 Nov 2017 23:03:02 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 257/294] netfilter: Fix switch statement warnings with recent gcc. In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.50-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: David Miller 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 Acked-by: Pablo Neira Ayuso Signed-off-by: Arnd Bergmann Signed-off-by: Ben Hutchings --- net/ipv4/netfilter/nft_reject_ipv4.c | 2 ++ net/ipv6/netfilter/nft_reject_ipv6.c | 2 ++ net/netfilter/nft_compat.c | 6 +++--- net/netfilter/nft_ct.c | 8 ++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) --- a/net/ipv4/netfilter/nft_reject_ipv4.c +++ b/net/ipv4/netfilter/nft_reject_ipv4.c @@ -33,6 +33,8 @@ void nft_reject_ipv4_eval(const struct n case NFT_REJECT_TCP_RST: nf_send_reset(pkt->skb, pkt->ops->hooknum); break; + default: + break; } data[NFT_REG_VERDICT].verdict = NF_DROP; --- a/net/ipv6/netfilter/nft_reject_ipv6.c +++ b/net/ipv6/netfilter/nft_reject_ipv6.c @@ -34,6 +34,8 @@ void nft_reject_ipv6_eval(const struct n case NFT_REJECT_TCP_RST: nf_send_reset6(net, pkt->skb, pkt->ops->hooknum); break; + default: + break; } data[NFT_REG_VERDICT].verdict = NF_DROP; --- a/net/netfilter/nft_compat.c +++ b/net/netfilter/nft_compat.c @@ -295,11 +295,11 @@ static void nft_match_eval(const struct 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; } --- a/net/netfilter/nft_ct.c +++ b/net/netfilter/nft_ct.c @@ -56,6 +56,8 @@ static void nft_ct_get_eval(const struct 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 return; } #endif + default: + break; } tuple = &ct->tuplehash[priv->dir].tuple; @@ -141,6 +145,8 @@ static void nft_ct_get_eval(const struct 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 } break; #endif + default: + break; } }