tipc: avoid a clang -Wuninitialized warning
Subsystems (3)
PATCH 1/1 tipc: avoid a clang -Wuninitialized warning
clang notices that we pass 'maddr' into the tipc_bearer_xmit() function without having initialized it first:
net/tipc/node.c:831:6: error: variable 'maddr' is used uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (!tipc_link_is_establishing(l)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/tipc/node.c:847:46: note: uninitialized use occurs here
tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr);
^~~~~
net/tipc/node.c:831:2: note: remove the 'if' if its condition is always true
if (!tipc_link_is_establishing(l)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net/tipc/node.c:821:31: note: initialize the variable 'maddr' to silence this warning
struct tipc_media_addr *maddr;
^
= NULLThis is harmless because it won't use 'maddr' if the queue is empty, but it's better to make that explicit and not even call the function in that case.
As clang is able to inline the check, it then notices that the code is safe.
--- net/tipc/node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/tipc/node.c +2 -1
@@ -844,7 +844,8 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete)tipc_node_write_unlock (n);if (delete)tipc_mon_remove_peer (n->net, n->addr, old_bearer_id); -tipc_bearer_xmit (n->net, bearer_id, &xmitq, maddr); +if (!skb_queue_empty (&xmitq)) +tipc_bearer_xmit (n->net, bearer_id, &xmitq, maddr);tipc_sk_rcv (n->net, &le->inputq); }
Signature · 1 line
2.20.0
Quoted 18 lines · Arnd Bergmann
clang notices that we pass 'maddr' into the
tipc_bearer_xmit()function without having initialized it first:
net/tipc/node.c:831:6: error: variable 'maddr' is used uninitialized whenever 'if' condition is false[-Werror,-Wsometimes-uninitialized] if (!tipc_link_is_establishing(l)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ net/tipc/node.c:847:46: note: uninitialized use occurs here tipc_bearer_xmit(n->net, bearer_id, &xmitq, maddr); ^~~~~ net/tipc/node.c:831:2: note: remove the 'if' if its condition is always true if (!tipc_link_is_establishing(l)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ net/tipc/node.c:821:31: note: initialize the variable 'maddr' to silence this warning struct tipc_media_addr *maddr; ^ = NULL
Quoted 8 lines
This is harmless because it won't use 'maddr' if the queue is empty, but it's better to make that explicit and not even call the function in that case.
As clang is able to inline the check, it then notices that the code is safe.
Signed-off-by Arnd Bergmann <[email protected]>
Thanks for looking into this and fixing it!
Quoted 21 lines
--- net/tipc/node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/tipc/node.c +2
-1@@ -844,7 +844,8 @@ static void tipc_node_link_down(struct tipc_node *n, int bearer_id, bool delete)tipc_node_write_unlock (n);if (delete)tipc_mon_remove_peer (n->net, n->addr, old_bearer_id); -tipc_bearer_xmit (n->net, bearer_id, &xmitq, maddr); +if (!skb_queue_empty (&xmitq)) +tipc_bearer_xmit (n->net, bearer_id, &xmitq, maddr);tipc_sk_rcv (n->net, &le->inputq); }Signature · 1 line
2.20.0
David Miller
maintainerFrom: Arnd Bergmann <[email protected]>
Date: Fri, 22 Mar 2019 15:18:13 +0100
Quoted 2 lines
clang notices that we pass 'maddr' into the
tipc_bearer_xmit()function without having initialized it first:
...
Quoted 8 lines
This is harmless because it won't use 'maddr' if the queue is empty, but it's better to make that explicit and not even call the function in that case.
As clang is able to inline the check, it then notices that the code is safe.
Signed-off-by Arnd Bergmann <[email protected]>
It looks like Jon's patch took care of this.