Skip to contentSkip to conversation

netfilter: nf_tables: fix compile warnings

PATCH In review Pablo Neira Ayuso 2 participants 3 messages Jan 10, 2022 – Jan 11, 2022

Subsystems (3)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nf_tables: fix compile warnings

Remove unused variable and fix missing initialization.

Quoted 1 line
Quoted 1 line

net/netfilter/nf_tables_api.c:8266:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]

           int i;
               ^
Quoted 1 line
Quoted 1 line

net/netfilter/nf_tables_api.c:8277:4: warning: variable 'data_size' is uninitialized when used here [-Wuninitialized]

                           data_size += sizeof(*prule) + rule->dlen;
                           ^~~~~~~~~
   net/netfilter/nf_tables_api.c:8262:30: note: initialize the variable 'data_size' to silence this warning
           unsigned int size, data_size;
Fixes 2c865a8a28a1 ("netfilter: nf_tables: add rule blob layout")

---
Please, directly apply to net-next, thanks. Otherwise let me know and I'll prepare a pull request with pending fixes once net-next gets merged into net.

 net/netfilter/nf_tables_api.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/netfilter/nf_tables_api.c +1 -3
index eb12fc9b803d..1f80a1fae63b 100644
@@ -8260,18 +8260,16 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
 {
 	const struct nft_expr *expr, *last;
 	struct nft_regs_track track = {};
-	unsigned int size, data_size;
+	unsigned int size, data_size = 0;
 	void *data, *data_boundary;
 	struct nft_rule_dp *prule;
 	struct nft_rule *rule;
-	int i;
 
 	/* already handled or inactive chain? */
 	if (chain->blob_next || !nft_is_active_next(net, chain))
 		return 0;
 
 	rule = list_entry(&chain->rules, struct nft_rule, list);
-	i = 0;
 
 	list_for_each_entry_continue(rule, &chain->rules, list) {
 		if (nft_is_active_next(net, rule)) {
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 11 lines · On Mon, 10 Jan 2022 23:14:19 +0100 Pablo Neira Ayuso wrote:

Remove unused variable and fix missing initialization.

Quoted 1 line
Quoted 1 line

net/netfilter/nf_tables_api.c:8266:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]

           int i;
               ^
Quoted 1 line
Quoted 1 line

net/netfilter/nf_tables_api.c:8277:4: warning: variable 'data_size' is uninitialized when used here [-Wuninitialized]

                           data_size += sizeof(*prule) + rule->dlen;
                           ^~~~~~~~~
   net/netfilter/nf_tables_api.c:8262:30: note: initialize the variable 'data_size' to silence this warning
           unsigned int size, data_size;
Quoted 7 lines
Fixes 2c865a8a28a1 ("netfilter: nf_tables: add rule blob layout")

---
Please, directly apply to net-next, thanks. Otherwise let me know and I'll prepare a pull request with pending fixes once net-next gets merged into net.

As you have probably seen Linus fixed this up himself.

You can take the fix for the other warning thru your tree.

author maintainer
#2 lore raw
Quoted 20 lines · Jakub Kicinski
Quoted 11 lines · On Mon, 10 Jan 2022 23:14:19 +0100 Pablo Neira Ayuso wrote:

Remove unused variable and fix missing initialization.

Quoted 1 line
Quoted 1 line

net/netfilter/nf_tables_api.c:8266:6: warning: variable 'i' set but not used [-Wunused-but-set-variable]

           int i;
               ^
Quoted 1 line
Quoted 1 line

net/netfilter/nf_tables_api.c:8277:4: warning: variable 'data_size' is uninitialized when used here [-Wuninitialized]

                           data_size += sizeof(*prule) + rule->dlen;
                           ^~~~~~~~~
   net/netfilter/nf_tables_api.c:8262:30: note: initialize the variable 'data_size' to silence this warning
           unsigned int size, data_size;
Quoted 7 lines
Fixes 2c865a8a28a1 ("netfilter: nf_tables: add rule blob layout")

---
Please, directly apply to net-next, thanks. Otherwise let me know and I'll prepare a pull request with pending fixes once net-next gets merged into net.

Quoted 3 lines

As you have probably seen Linus fixed this up himself.

You can take the fix for the other warning thru your tree.

That's fine, thanks.