* [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* Re: [PATCH nft] mnl: silence compiler warning
2025-08-20 12:44 [PATCH nft] mnl: silence compiler warning Florian Westphal
@ 2025-08-20 13:22 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2025-08-20 13:22 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Wed, Aug 20, 2025 at 02:44:43PM +0200, Florian Westphal wrote:
> 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>
Thanks for this fix.
Reviewed-by: Pablo Neira Ayuso <pablo@netfilter.org>
^ permalink raw reply [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.