From: Florian Westphal <fw@strlen.de>
To: <netfilter-devel@vger.kernel.org>
Cc: Florian Westphal <fw@strlen.de>
Subject: [PATCH nft] mnl: silence compiler warning
Date: Wed, 20 Aug 2025 14:44:43 +0200 [thread overview]
Message-ID: <20250820124447.31695-1-fw@strlen.de> (raw)
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
next reply other threads:[~2025-08-20 12:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-20 12:44 Florian Westphal [this message]
2025-08-20 13:22 ` [PATCH nft] mnl: silence compiler warning Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250820124447.31695-1-fw@strlen.de \
--to=fw@strlen.de \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.