Re: [PATCH] infiniband: shut up a maybe-uninitialized warning
From: Doug Ledford
Date: Tue Aug 02 2016 - 14:27:27 EST
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@xxxxxxxx>
> 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@xxxxxxxxxx>
GPG KeyID: 0E572FDD
Attachment:
signature.asc
Description: This is a digitally signed message part