]> asedeno.scripts.mit.edu Git - linux.git/commit
tipc: tipc clang warning
authorJon Maloy <jon.maloy@ericsson.com>
Fri, 22 Mar 2019 14:03:51 +0000 (15:03 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 24 Mar 2019 01:45:59 +0000 (21:45 -0400)
commit737889efe9713a0f20a75fd0de952841d9275e6b
tree4682a26dffe0a2265321dbfe1ba0ce4660cabe88
parent064c5d6881e897077639e04973de26440ee205e6
tipc: tipc clang warning

When checking the code with clang -Wsometimes-uninitialized we get the
following warning:

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;

We fix this by initializing 'maddr' to NULL. For the matter of clarity,
we also test if 'xmitq' is non-empty before we use it and 'maddr'
further down in the  function. It will never happen that 'xmitq' is non-
empty at the same time as 'maddr' is NULL, so this is a sufficient test.

Fixes: 598411d70f85 ("tipc: make resetting of links non-atomic")
Reported-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/node.c