nfnetlink warnings
Subsystems (2)
Hey,
so I keep getting those since recently:
net/netfilter/nfnetlink_queue.c:519:19: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (ct && nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
^
net/netfilter/nfnetlink_queue.c:316:23: note: ‘nfnl_ct’ was declared here
struct nfnl_ct_hook *nfnl_ct;
^
net/netfilter/nfnetlink_queue.c: In function ‘nfqnl_recv_verdict’:
net/netfilter/nfnetlink_queue.c:1083:11: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized]
nfnl_ct->seq_adjust(entry->skb, ct, ctinfo, diff);
^and was thinking can we shut them up like this? I know, it is ugly :-\
I mean, it is obvious in both cases that nfnl_ct won't be used if ct is not set but apparently gcc can't see that far...
---
net/netfilter/nfnetlink_queue.c +4 -0
@@ -372,6 +372,8 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,if (ct !=NULL ) size += nfnl_ct->build_size (ct); } + }else { + nfnl_ct =NULL ; }if (queue->flags &NFQA_CFG_F_UID_GID ) {
@@ -1069,6 +1071,8 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb, nfnl_ct =rcu_dereference (nfnl_ct_hook);if (nfnl_ct !=NULL ) ct =nfqnl_ct_parse (nfnl_ct, nlh, nfqa, entry, &ctinfo); + }else { + nfnl_ct =NULL ; }if (nfqa[NFQA_PAYLOAD ]) {
Signature · 8 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.htmlHi, Borislav
Why not just initialized it as NULL, or mark it as uninitialized_var()?
Regards,
Michael Wang
Quoted 44 lines · Borislav Petkov
Hey,
so I keep getting those since recently:
net/netfilter/nfnetlink_queue.c:519:19: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (ct &&nfnl_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO)< 0)^ net/netfilter/nfnetlink_queue.c:316:23: note: ‘nfnl_ct’ was declared here struct nfnl_ct_hook *nfnl_ct; ^ net/netfilter/nfnetlink_queue.c: In function ‘nfqnl_recv_verdict’: net/netfilter/nfnetlink_queue.c:1083:11: warning: ‘nfnl_ct’ may be used uninitialized in this function [-Wmaybe-uninitialized] nfnl_ct->seq_adjust(entry->skb, ct, ctinfo, diff); ^and was thinking can we shut them up like this? I know, it is ugly :-\
I mean, it is obvious in both cases that
nfnl_ctwon't be used if ct is not set but apparently gcc can't see that far...---
net/netfilter/nfnetlink_queue.c +4
-0@@ -372,6 +372,8 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,if (ct !=NULL ) size += nfnl_ct->build_size (ct); } + }else { + nfnl_ct =NULL ; }if (queue->flags &NFQA_CFG_F_UID_GID ) {@@ -1069,6 +1071,8 @@ nfqnl_recv_verdict(struct sock *ctnl, struct sk_buff *skb, nfnl_ct =rcu_dereference (nfnl_ct_hook);if (nfnl_ct !=NULL ) ct =nfqnl_ct_parse (nfnl_ct, nlh, nfqa, entry, &ctinfo); + }else { + nfnl_ct =NULL ; }if (nfqa[NFQA_PAYLOAD ]) {
Hi Michael,
Quoted 1 line · Michael Wang
Why not just initialized it as NULL, or mark it as
uninitialized_var()?
because I'd like us to save us the redundant NULL initialization in the if-case.
I'm not saying any of the approaches are good visually, though. Who knows, someone might have a better idea like, maybe "Oh, I wanted to rewrite that code and this handlong is going to be different anyway ..." or so. Or something to that effect.
Btw, please do not top-post.
Thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 7 lines · Borislav Petkov
Hi Michael,
Quoted 1 line · Michael Wang
Why not just initialized it as NULL, or mark it as
uninitialized_var()?because I'd like us to save us the redundant NULL initialization in the if-case.
Well, I would vote initialized with NULL, rather than use another else branch to do the same thing.
Quoted 5 lines
I'm not saying any of the approaches are good visually, though. Who knows, someone might have a better idea like, maybe "Oh, I wanted to rewrite that code and this handlong is going to be different anyway ..." or so. Or something to that effect.
Who want to do that would take responsibility to make an else branch at that time, but reserve the branch at this moment sounds unnecessary, and not that pretty frankly speaking.
Quoted 2 lines
Btw, please do not top-post.
Enjoy ;-)
Regards,
Michael Wang
Quoted 3 lines
Thanks.
Pablo Neira Ayuso
maintainerI have just applied this patch to resolve this issue.
Thanks.
Quoted 3 lines · Michael Wang
Who want to do that would take responsibility to make an else branch at that time, but reserve the branch at this moment sounds unnecessary, and not that pretty frankly speaking.
Actually, I was looking for the better idea which doesn't uglify the code. And here it is:
https://lkml.kernel.org/r/5585663.OcpAQiytKY@wuerfel
:-)
Signature · 4 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.Quoted 9 lines · Borislav Petkov
Quoted 3 lines · Michael Wang
Who want to do that would take responsibility to make an else branch at that time, but reserve the branch at this moment sounds unnecessary, and not that pretty frankly speaking.
Actually, I was looking for the better idea which doesn't uglify the code. And here it is:
Looks even better :-)
Regards,
Michael Wang
Quoted 3 lines
:-)