All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH nft] mnl: silence compiler warning
@ 2025-08-20 12:44 Florian Westphal
  2025-08-20 13:22 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2025-08-20 12:44 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Florian Westphal

gcc 14.3.0 reports this:

src/mnl.c: In function 'mnl_nft_chain_add':
src/mnl.c:916:25: warning: 'nest' may be used uninitialized [-Wmaybe-uninitialized]
  916 |                         mnl_attr_nest_end(nlh, nest);

I guess its because compiler can't know that the conditions cannot change
in-between and assumes nest_end() can be called without nest_start().

Fixes: 01277922fede ("src: ensure chain policy evaluation when specified")
Signed-off-by: Florian Westphal <fw@strlen.de>
---
 src/mnl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/mnl.c b/src/mnl.c
index ceb43b06690c..6684029606e5 100644
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -890,7 +890,7 @@ int mnl_nft_chain_add(struct netlink_ctx *ctx, struct cmd *cmd,
 	nftnl_chain_nlmsg_build_payload(nlh, nlc);
 
 	if (cmd->chain && cmd->chain->flags & CHAIN_F_BASECHAIN) {
-		struct nlattr *nest;
+		struct nlattr *nest = NULL;
 
 		if (cmd->chain->type.str) {
 			cmd_add_loc(cmd, nlh, &cmd->chain->type.loc);
@@ -911,8 +911,7 @@ int mnl_nft_chain_add(struct netlink_ctx *ctx, struct cmd *cmd,
 		if (cmd->chain && cmd->chain->dev_expr)
 			mnl_nft_chain_devs_build(nlh, cmd);
 
-		if (cmd->chain->type.str ||
-		    (cmd->chain && cmd->chain->dev_expr))
+		if (nest)
 			mnl_attr_nest_end(nlh, nest);
 	}
 
-- 
2.49.1


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

end of thread, other threads:[~2025-08-20 13:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-20 12:44 [PATCH nft] mnl: silence compiler warning Florian Westphal
2025-08-20 13:22 ` Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.