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: 9421581 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 02B6960512 for ; Thu, 10 Nov 2016 16:50:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08A9129772 for ; Thu, 10 Nov 2016 16:50:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F112329783; Thu, 10 Nov 2016 16:50:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8EF7B29772 for ; Thu, 10 Nov 2016 16:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964944AbcKJQuS (ORCPT ); Thu, 10 Nov 2016 11:50:18 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:49928 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935225AbcKJQqu (ORCPT ); Thu, 10 Nov 2016 11:46:50 -0500 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 Cc: Andrew Morton , Arnd Bergmann , Anna Schumaker , "David S. Miller" , Herbert Xu , Ilya Dryomov , Javier Martinez Canillas , Jiri Kosina , Jonathan Cameron , Ley Foon Tan , "Luis R . Rodriguez" , Martin Schwidefsky , Mauro Carvalho Chehab , Michal Marek , Russell King , Sean Young , Sebastian Ott , Trond Myklebust , x86@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, nios2-dev@lists.rocketboards.org, linux-s390@vger.kernel.org, linux-crypto@vger.kernel.org, linux-media@vger.kernel.org, linux-nfs@vger.kernel.org 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= Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;