netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] netfilter: nf_tables: avoid uninitialized variable warning
@ 2016-09-30 16:05 Arnd Bergmann
  2016-09-30 16:05 ` [PATCH 2/3] netfilter: hide reference to nf_hooks_ingress Arnd Bergmann
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Arnd Bergmann @ 2016-09-30 16:05 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Arnd Bergmann, Patrick McHardy, Jozsef Kadlecsik, David S. Miller,
	netfilter-devel, coreteam, netdev, linux-kernel

The newly added nft_range_eval() function handles the two possible
nft range operations, but as the compiler warning points out,
any unexpected value would lead to the 'mismatch' variable being
used without being initialized:

net/netfilter/nft_range.c: In function 'nft_range_eval':
net/netfilter/nft_range.c:45:5: error: 'mismatch' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This can be trivially avoided by added a 'default:' clause.

Fixes: 0f3cd9b36977 ("netfilter: nf_tables: add range expression")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 net/netfilter/nft_range.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c
index c6d5358482d1..72dff5bffca8 100644
--- a/net/netfilter/nft_range.c
+++ b/net/netfilter/nft_range.c
@@ -40,6 +40,8 @@ static void nft_range_eval(const struct nft_expr *expr,
 	case NFT_RANGE_NEQ:
 		mismatch = (d1 >= 0 && d2 <= 0);
 		break;
+	default:
+		mismatch = 0;
 	}
 
 	if (mismatch)
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-09-30 18:21 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-30 16:05 [PATCH 1/3] netfilter: nf_tables: avoid uninitialized variable warning Arnd Bergmann
2016-09-30 16:05 ` [PATCH 2/3] netfilter: hide reference to nf_hooks_ingress Arnd Bergmann
2016-09-30 17:06   ` Aaron Conole
2016-09-30 16:05 ` [PATCH 3/3] netfilter: xt_hashlimit: uses div_u64 for division Arnd Bergmann
2016-09-30 16:38   ` Eric Dumazet
2016-09-30 17:21     ` Vishwanath Pai
2016-09-30 17:39     ` Arnd Bergmann
2016-09-30 17:47 ` [PATCH 1/3] netfilter: nf_tables: avoid uninitialized variable warning Pablo Neira Ayuso
2016-09-30 18:21   ` Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).