From patchwork Thu Nov 10 16:44:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 693337 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tF88g3Tp8z9vDt for ; Fri, 11 Nov 2016 03:46:57 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4sV5-0003iJ-Vf; Thu, 10 Nov 2016 16:46:55 +0000 Received: from mout.kundenserver.de ([212.227.126.135]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4sUn-0003Ig-SW for linux-snps-arc@lists.infradead.org; Thu, 10 Nov 2016 16:46:43 +0000 Received: from wuerfel.lan ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0LoMri-1cl7FT0QTi-00gbaX; Thu, 10 Nov 2016 17:45:45 +0100 From: Arnd Bergmann To: Linus Torvalds Subject: [PATCH v2 09/11] [v3] infiniband: shut up a maybe-uninitialized warning Date: Thu, 10 Nov 2016 17:44:52 +0100 Message-Id: <20161110164454.293477-10-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161110164454.293477-1-arnd@arndb.de> References: <20161110164454.293477-1-arnd@arndb.de> X-Provags-ID: V03:K0:S7m3FaVgPzrWtSVAMhnD0cxIkMlj1cjoKJ064YuZsirZIVjYDNR 4MmtU4yu3/ZkSU1VK/nUVWr4t76jU1fgTqhsED9tqV4bZgbbnesRjN7+0D+nF9yGIF/Tyvx EZjbhiaUMJsmJNCJ4QyCeT4rWfWFqhXcGakismITuqmhhg3DLRy/i+MBWMeWZcwhex1Arx4 5oqdZFF8XcCR7RjRkgwsQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:m10LbQcS4zk=:uIRPS18UDd2aLMI3m8KP9Y KdhPir5grrutN4VP+RCetLQ7lQN5CURg3d7M4bnCRxd/um9NcbzXU/qFo33uZyBiskwANQI0j O0UqcDgztx45Xi+XOnU6A03hhNbmv4KfIFndnRFa4kk73+H8n6b/T5pZL6w46LTgKX1khmpGn qOWnliZVy/oozpXyD1zgcDx9mnGycUdjfHS83AVIn7xdGujjFYDIQBMlGHjApaYXAm9O1slDp o11ywnQtVyJSYJbIfoU7bib+OB95sQXYXusd9DG2wahtah7ZW7DM7EWOAPUiqxZJchfG3+W6k 7I+aW1jMtNk1mHX2Gb3mVgaBeEvGDf76j/CpJjdj1WPnTy5WL0W7h39CfeTUT99fPVaqDvdx/ MKdgWtb2aBqHTF1xjDzGnKfmJAAWEj852gfOTd1T76tnJdkEcuSUrnGmUR8vV8hV/0bN5GP1k x2o6sO5A/4GojlysjLEFYp9MJPVHYUTY6V9D8BZxtz6+W5SH04ttdkkEyoH0PvLP7qcBQdSjn 4PgEyaQGJX4lOyo+jyk58eOW04LRhfGN1Ej/XCoUyvo1Aw1KFSQEEkl0YDnhfvdIaSHjGkC3v 0y0J+HuH4rXpeHaZvsWDyZx3GNYOYDcs004NPx5GoAvdbENmgdm55hDfHcaSYUqqldJ/g6U2c x6te+V61JFd7oLh1eUW38idIBwRfptZoOa8uDwcWQgEPzLeRTUs9NXPFYO5q4X5sejbo= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161110_084638_488205_463A7E7B X-CRM114-Status: GOOD ( 13.66 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [212.227.126.135 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [212.227.126.135 listed in wl.mailspike.net] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sean Young , Trond Myklebust , linux-s390@vger.kernel.org, Herbert Xu , x86@kernel.org, Sebastian Ott , Russell King , Javier Martinez Canillas , Ilya Dryomov , linux-snps-arc@lists.infradead.org, linux-media@vger.kernel.org, Arnd Bergmann , linux-kbuild@vger.kernel.org, Jiri Kosina , Michal Marek , nios2-dev@lists.rocketboards.org, Mauro Carvalho Chehab , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Anna Schumaker , "Luis R . Rodriguez" , linux-crypto@vger.kernel.org, Martin Schwidefsky , Ley Foon Tan , Andrew Morton , "David S. Miller" , Jonathan Cameron MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Some configurations produce this harmless warning when built with gcc -Wmaybe-uninitialized: infiniband/core/cma.c: In function 'cma_get_net_dev': infiniband/core/cma.c:1242:12: warning: 'src_addr_storage.sin_addr.s_addr' may be used uninitialized in this function [-Wmaybe-uninitialized] I previously reported this for the powerpc64 defconfig, but have now reproduced the same thing for x86 as well, using gcc-5 or higher. The code looks correct to me, and this change just rearranges it by making sure we alway initialize the entire address structure to make the warning disappear. My first approach added an initialization at the time of the declaration, which Doug commented may be too costly, so I hope this version doesn't add overhead. Link: http://arm-soc.lixom.net/buildlogs/mainline/v4.7-rc6/buildall.powerpc.ppc64_defconfig.log.passed Link: https://patchwork.kernel.org/patch/9212825/ Acked-by: Haggai Eran Signed-off-by: Arnd Bergmann --- This is marked v2 as the rest of the series but is actually version three of the patch as I had to do some other changes already. v3: remove accidental leftover change of the original patch drivers/infiniband/core/cma.c | 54 ++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 36bf50e..89a6b05 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1094,47 +1094,47 @@ static void cma_save_ib_info(struct sockaddr *src_addr, } } -static void cma_save_ip4_info(struct sockaddr *src_addr, - struct sockaddr *dst_addr, +static void cma_save_ip4_info(struct sockaddr_in *src_addr, + struct sockaddr_in *dst_addr, struct cma_hdr *hdr, __be16 local_port) { - struct sockaddr_in *ip4; - if (src_addr) { - ip4 = (struct sockaddr_in *)src_addr; - ip4->sin_family = AF_INET; - ip4->sin_addr.s_addr = hdr->dst_addr.ip4.addr; - ip4->sin_port = local_port; + *src_addr = (struct sockaddr_in) { + .sin_family = AF_INET, + .sin_addr.s_addr = hdr->dst_addr.ip4.addr, + .sin_port = local_port, + }; } if (dst_addr) { - ip4 = (struct sockaddr_in *)dst_addr; - ip4->sin_family = AF_INET; - ip4->sin_addr.s_addr = hdr->src_addr.ip4.addr; - ip4->sin_port = hdr->port; + *dst_addr = (struct sockaddr_in) { + .sin_family = AF_INET, + .sin_addr.s_addr = hdr->src_addr.ip4.addr, + .sin_port = hdr->port, + }; } } -static void cma_save_ip6_info(struct sockaddr *src_addr, - struct sockaddr *dst_addr, +static void cma_save_ip6_info(struct sockaddr_in6 *src_addr, + struct sockaddr_in6 *dst_addr, struct cma_hdr *hdr, __be16 local_port) { - struct sockaddr_in6 *ip6; - if (src_addr) { - ip6 = (struct sockaddr_in6 *)src_addr; - ip6->sin6_family = AF_INET6; - ip6->sin6_addr = hdr->dst_addr.ip6; - ip6->sin6_port = local_port; + *src_addr = (struct sockaddr_in6) { + .sin6_family = AF_INET6, + .sin6_addr = hdr->dst_addr.ip6, + .sin6_port = local_port, + }; } if (dst_addr) { - ip6 = (struct sockaddr_in6 *)dst_addr; - ip6->sin6_family = AF_INET6; - ip6->sin6_addr = hdr->src_addr.ip6; - ip6->sin6_port = hdr->port; + *dst_addr = (struct sockaddr_in6) { + .sin6_family = AF_INET6, + .sin6_addr = hdr->src_addr.ip6, + .sin6_port = hdr->port, + }; } } @@ -1159,10 +1159,12 @@ static int cma_save_ip_info(struct sockaddr *src_addr, switch (cma_get_ip_ver(hdr)) { case 4: - cma_save_ip4_info(src_addr, dst_addr, hdr, port); + cma_save_ip4_info((struct sockaddr_in *)src_addr, + (struct sockaddr_in *)dst_addr, hdr, port); break; case 6: - cma_save_ip6_info(src_addr, dst_addr, hdr, port); + cma_save_ip6_info((struct sockaddr_in6 *)src_addr, + (struct sockaddr_in6 *)dst_addr, hdr, port); break; default: return -EAFNOSUPPORT;