linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] infiniband: shut up a maybe-uninitialized warning
@ 2016-07-04 15:06 Arnd Bergmann
  2016-08-02 17:45 ` Doug Ledford
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2016-07-04 15:06 UTC (permalink / raw)
  To: Doug Ledford
  Cc: Arnd Bergmann, Sean Hefty, Hal Rosenstock, Haggai Eran,
	Matan Barak, Yotam Kenneth, Moni Shoua, linux-rdma, linux-kernel

The powerpc64 default configuration leads to warnings for the infiniband
core code:

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]

The code looks correct to me, and I don't see the warnings on the
other architectures, so this is a dumb change to add an unneeded
initialization to the variables in order to shut up the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: http://arm-soc.lixom.net/buildlogs/mainline/v4.7-rc6/buildall.powerpc.ppc64_defconfig.log.passed
---
 drivers/infiniband/core/cma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index a3c9930f1f93..924ac237310b 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1309,7 +1309,7 @@ static bool validate_net_dev(struct net_device *net_dev,
 static struct net_device *cma_get_net_dev(struct ib_cm_event *ib_event,
 					  const struct cma_req_info *req)
 {
-	struct sockaddr_storage listen_addr_storage, src_addr_storage;
+	struct sockaddr_storage listen_addr_storage = {}, src_addr_storage = {};
 	struct sockaddr *listen_addr = (struct sockaddr *)&listen_addr_storage,
 			*src_addr = (struct sockaddr *)&src_addr_storage;
 	struct net_device *net_dev;
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] infiniband: shut up a maybe-uninitialized warning
  2016-07-04 15:06 [PATCH] infiniband: shut up a maybe-uninitialized warning Arnd Bergmann
@ 2016-08-02 17:45 ` Doug Ledford
  2016-08-02 20:05   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Doug Ledford @ 2016-08-02 17:45 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-rdma, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2005 bytes --]

On Mon, 2016-07-04 at 17:06 +0200, Arnd Bergmann wrote:
> The powerpc64 default configuration leads to warnings for the
> infiniband
> core code:
> 
> 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]
> 
> The code looks correct to me, and I don't see the warnings on the
> other architectures, so this is a dumb change to add an unneeded
> initialization to the variables in order to shut up the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Link: http://arm-soc.lixom.net/buildlogs/mainline/v4.7-
> rc6/buildall.powerpc.ppc64_defconfig.log.passed

I thought about taking this, but I also looked over the code and it
looks correct to me.  This is a semi-hot path in the connection bring
up code, so I'm loathe to put in sizeof(struct sockaddr_storage) * 2 of
needless memory writes.  So, I dropped this patch.  Hopefully, ppc64
compiler will straighten its warnings out soon.

> ---
>  drivers/infiniband/core/cma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/core/cma.c
> b/drivers/infiniband/core/cma.c
> index a3c9930f1f93..924ac237310b 100644
> --- a/drivers/infiniband/core/cma.c
> +++ b/drivers/infiniband/core/cma.c
> @@ -1309,7 +1309,7 @@ static bool validate_net_dev(struct net_device
> *net_dev,
>  static struct net_device *cma_get_net_dev(struct ib_cm_event
> *ib_event,
>  					  const struct cma_req_info
> *req)
>  {
> -	struct sockaddr_storage listen_addr_storage,
> src_addr_storage;
> +	struct sockaddr_storage listen_addr_storage = {},
> src_addr_storage = {};
>  	struct sockaddr *listen_addr = (struct sockaddr
> *)&listen_addr_storage,
>  			*src_addr = (struct sockaddr
> *)&src_addr_storage;
>  	struct net_device *net_dev;

-- 
Doug Ledford <dledford@redhat.com>
              GPG KeyID: 0E572FDD

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] infiniband: shut up a maybe-uninitialized warning
  2016-08-02 17:45 ` Doug Ledford
@ 2016-08-02 20:05   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-08-02 20:05 UTC (permalink / raw)
  To: Doug Ledford; +Cc: linux-rdma, linux-kernel

On Tuesday, August 2, 2016 1:45:25 PM CEST Doug Ledford wrote:
> On Mon, 2016-07-04 at 17:06 +0200, Arnd Bergmann wrote:
> > The powerpc64 default configuration leads to warnings for the
> > infiniband
> > core code:
> > 
> > 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]
> > 
> > The code looks correct to me, and I don't see the warnings on the
> > other architectures, so this is a dumb change to add an unneeded
> > initialization to the variables in order to shut up the warning.
> > 
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > Link: http://arm-soc.lixom.net/buildlogs/mainline/v4.7-
> > rc6/buildall.powerpc.ppc64_defconfig.log.passed
> 
> I thought about taking this, but I also looked over the code and it
> looks correct to me.  This is a semi-hot path in the connection bring
> up code, so I'm loathe to put in sizeof(struct sockaddr_storage) * 2 of
> needless memory writes.  So, I dropped this patch.  Hopefully, ppc64
> compiler will straighten its warnings out soon.

Ok, no worries. Linus just disabled the warning tree-wide for
all compilers, so it's gone from the autobuilder, and newer gcc
versions (4.9 or higher) should be fine too, even if someone
enables the warning manually or by passing W=1.

Thanks for having a look,

	Arnd

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-02 20:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-04 15:06 [PATCH] infiniband: shut up a maybe-uninitialized warning Arnd Bergmann
2016-08-02 17:45 ` Doug Ledford
2016-08-02 20:05   ` Arnd Bergmann

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).