From: Nathan Chancellor <natechancellor@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Jon Maloy <jon.maloy@ericsson.com>,
Ying Xue <ying.xue@windriver.com>,
"David S. Miller" <davem@davemloft.net>,
clang-built-linux@googlegroups.com,
Nick Desaulniers <ndesaulniers@google.com>,
Tuong Lien <tuong.t.lien@dektech.com.au>,
LUU Duc Canh <canh.d.luu@dektech.com.au>,
Tung Nguyen <tung.q.nguyen@dektech.com.au>,
GhantaKrishnamurthy MohanKrishna
<mohan.krishna.ghanta.krishnamurthy@ericsson.com>,
netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tipc: avoid a clang -Wuninitialized warning
Date: Fri, 22 Mar 2019 09:12:44 -0700 [thread overview]
Message-ID: <20190322161244.GG21978@archlinux-ryzen> (raw)
In-Reply-To: <20190322141819.641588-1-arnd@arndb.de>
On Fri, Mar 22, 2019 at 03:18:13PM +0100, Arnd Bergmann wrote:
> 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
>
> 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 <arnd@arndb.de>
Thanks for looking into this and fixing it!
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
> net/tipc/node.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/tipc/node.c b/net/tipc/node.c
> index 2dc4919ab23c..ca4cafd00a38 100644
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
> @@ -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);
> }
>
> --
> 2.20.0
>
next prev parent reply other threads:[~2019-03-22 16:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-22 14:18 [PATCH] tipc: avoid a clang -Wuninitialized warning Arnd Bergmann
2019-03-22 16:12 ` Nathan Chancellor [this message]
2019-03-24 1:49 ` David Miller
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=20190322161244.GG21978@archlinux-ryzen \
--to=natechancellor@gmail.com \
--cc=arnd@arndb.de \
--cc=canh.d.luu@dektech.com.au \
--cc=clang-built-linux@googlegroups.com \
--cc=davem@davemloft.net \
--cc=jon.maloy@ericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mohan.krishna.ghanta.krishnamurthy@ericsson.com \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.q.nguyen@dektech.com.au \
--cc=tuong.t.lien@dektech.com.au \
--cc=ying.xue@windriver.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).