From patchwork Fri Mar 22 14:18:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160904 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp869560jan; Fri, 22 Mar 2019 07:18:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgu5fglU4z3zxji2vpmz0deT95IRZcLTvempP1ptx7DA7sAISlWE8cQ86nMczbbzPJNzsk X-Received: by 2002:a63:5318:: with SMTP id h24mr9239713pgb.76.1553264332847; Fri, 22 Mar 2019 07:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553264332; cv=none; d=google.com; s=arc-20160816; b=PB2Qv3fdFWIiGcDfCRrWoQtcFghWPfng4CjfM/0ThxveP7LUrFkIU5pwSPOmKbS+2l Xbcj2NPkqjtAsdwv5SxpyEcXIoYZ6mDbgH96K4j+FDjl4MZFPV/bXzaPL7gTlE53amtP 4xMQcJrJEEYMUuFEwrgpGVOxHbscJHSysRUf631r0QxU2sHx2vpuUFy8ME6DhepvyRSI SfaZG72Dp8ouQ3gyq20y6o0coM9zG30CBsPSFJTYL+EhTfwP3gj/pN80lEz/IiSyTXaR w596JDCWllBh0y7n1nltllhjqcvAqudSPiJkB+ivAV6VjXvFxiFXyS+E/07yGY7YXNqA U0mA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=I4waVPSC3jnhjm+ZsS63mT0TNJ09BunL5Uj/R0Ug1Pw=; b=KIEYfhdduvd6uijxjtg5rCxopVdtwx1lEk37I3AFjf53R3kahT6NaShdiVTB0O+WIM KSdEPGwlYaZaHzUzAsr8UuMN882KThmTfZJk5jyhhRHp/AadFY07DBNYDQ1cC/3/g0VW 5/TYlTw9CvyMsyEvqODkypcjJzIw55TZXj93TSdawQpiuRZFEvtPyTCbEGYWC9LnrNvG Rrlg+0OZ2JmuPsv1kpM+IZnrup11tA7mL9c9mmQ2EFlfGz0ulZ87FfsHVakFZuRn3kTx q7OCoWJNyiNliLa6RwS14cjbjl3K8T6/8HisNTGk1/MiGjIYC9id0ZK5XYtRugl/KOfK wDdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i67si7294912pfb.117.2019.03.22.07.18.52; Fri, 22 Mar 2019 07:18:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728416AbfCVOSv (ORCPT + 31 others); Fri, 22 Mar 2019 10:18:51 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:53973 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728139AbfCVOSu (ORCPT ); Fri, 22 Mar 2019 10:18:50 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1M2Nm2-1h8yMD23P4-003uZd; Fri, 22 Mar 2019 15:18:23 +0100 From: Arnd Bergmann To: Jon Maloy , Ying Xue , "David S. Miller" Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Tuong Lien , LUU Duc Canh , Tung Nguyen , GhantaKrishnamurthy MohanKrishna , netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] tipc: avoid a clang -Wuninitialized warning Date: Fri, 22 Mar 2019 15:18:13 +0100 Message-Id: <20190322141819.641588-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:isPCzBhvBx3WDuN6GcMetSXY3KKMQE5Qy8ClvkDoQMtqCW2QSCS zJbJGzhns+yFA8NDcWzL5ef9mNt+odyqtu+FbC8CJamiuVm/w7ldWVZaXiop7SSTZaVOL0q g8hmgHk+efsJDBwy8q1nK8e+5JjGzO0DWJcB93LLQ8KNYd1CuNOYXdrdz2WPJwH9+oD7jJZ bRQ3QepvGxgKxEhLCYZRA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:UJWe9zz0h2g=:+i9wq1l6kMcEl2JqILUoLU //5nDcNHN4DOU3RGyaz3NaI4TpNtOV5XEe5DCEfUv1xbSyy3rabT6IvQjV2RLI4MnKeA3M7IB cdry58oT0zf7L8Ag0xXLmgMJABZ1fokBU6fK3aLYbpgJHoQQqladmd8OBChYDW6LS0R8su7c2 b0C9Ag38ZMIfm+4vfOKSU5Sjqu4Wn3YzOJ+sxc9OfRo54JOjRwgwNzF3i18MecgXq2VdPS+57 +/rWPh7e4Xs2CYw3c3fq9bn8hWbUITjuL8hwy0T6Ni1NuxtU7MQx+hq0KrmAJkOgc5mCWEUFk ubHnWmA8ZC/EBktK5U8HpSHPWgRjs8zVZ6ly2phKU0z9tPeoxrA2K/GeN7DJ9wkeRaOTagDFl /VWIwlBtjitxTxPPs99cB9MSElhLX6GtORi4MQPjpi8MAtX7aaRlaAfFtXRenQL1PVCWXBVBj vly/kVIJVfHhtzC38twY3bb6FcFAX+zHWTmIWntUcISTQ6iktansdBgCRp1Pa5KNmblPhHvKK bMma2oGtOKsB8aJBSWaxySV6E/FGUY15FfRL55O6DvO1AnKnaFDrhqNUP7v4169ffDSXdKtZ2 lHHNFMUeNxu7yU1ZyI088ruYRDnFkJxmhCwzdeUfYIs3iCasTWUjPlHsueDVPwV7k4ODg8nYi V6k6psiif8TWsd3ShyM1zRkUfU+xr24wGHa+ADhUREzxL+Nq68jBU2MZRRYFIRfJifUvF+cQN KgUJ1Dl42h/bA9ttf5Jfc6yJuB1cO63PN3ovPw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- net/tipc/node.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.0 Reviewed-by: Nathan Chancellor 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); }