[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20150514.223012.1808412142637659689.davem@davemloft.net>
Date: Thu, 14 May 2015 22:30:12 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: bhelgaas@...gle.com
Cc: ogerlitz@...lanox.com, jackm@....mellanox.co.il,
matanb@...lanox.com, idos@...lanox.com, netdev@...r.kernel.org,
yishaih@...lanox.com, amirv@...lanox.com,
linux-kernel@...r.kernel.org, roland@...estorage.com
Subject: Re: [PATCH] net/mlx4: Avoid 'may be used uninitialized' warnings
From: Bjorn Helgaas <bhelgaas@...gle.com>
Date: Thu, 14 May 2015 18:17:08 -0500
> With a cross-compiler based on gcc-4.9, I see warnings like the following:
>
> drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_CQ_wrapper':
> drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:3048:10: error: 'cq' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> cq->mtt = mtt;
>
> I think the warning is spurious because we only use cq when
> cq_res_start_move_to() returns zero, and it always initializes *cq in that
> case. The srq case is similar. But maybe gcc isn't smart enough to figure
> that out.
>
> Initialize cq and srq explicitly to avoid the warnings.
>
> Signed-off-by: Bjorn Helgaas <bhelgaas@...gle.com>
Applied.
The compiler, generally, is not good at determining use-before-initialized
in situations of the form:
int x;
if (foo)
x = whatever;
...
if (foo)
use(x);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists