[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB0209E9A@AcuExch.aculab.com>
Date: Tue, 25 Oct 2016 13:24:55 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Arnd Bergmann' <arnd@...db.de>,
Solomon Peachy <pizza@...ftnet.org>,
Kalle Valo <kvalo@...eaurora.org>
CC: Johannes Berg <johannes.berg@...el.com>,
"linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] cw1200: fix bogus maybe-uninitialized warning
From: Of Arnd Bergmann
> Sent: 24 October 2016 16:42
> On x86, the cw1200 driver produces a rather silly warning about the
> possible use of the 'ret' variable without an initialization
> presumably after being confused by the architecture specific definition
> of WARN_ON:
>
> drivers/net/wireless/st/cw1200/wsm.c: In function wsm_handle_rx:
> drivers/net/wireless/st/cw1200/wsm.c:1457:9: error: ret may be used uninitialized in this function [-
> Werror=maybe-uninitialized]
>
> As the driver just checks the same variable twice here, we can simplify
> it by removing the second condition, which makes it more readable and
> avoids the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
> drivers/net/wireless/st/cw1200/wsm.c | 15 +++++++--------
> 1 file changed, 7 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/st/cw1200/wsm.c b/drivers/net/wireless/st/cw1200/wsm.c
> index 680d60eabc75..094e6637ade2 100644
> --- a/drivers/net/wireless/st/cw1200/wsm.c
> +++ b/drivers/net/wireless/st/cw1200/wsm.c
> @@ -385,14 +385,13 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv,
> if (WARN_ON(count <= 0))
> return -EINVAL;
>
> - if (count > 1) {
> - /* We already released one buffer, now for the rest */
> - ret = wsm_release_tx_buffer(priv, count - 1);
> - if (ret < 0)
> - return ret;
> - else if (ret > 0)
> - cw1200_bh_wakeup(priv);
> - }
> + /* We already released one buffer, now for the rest */
> + ret = wsm_release_tx_buffer(priv, count - 1);
> + if (ret < 0)
> + return ret;
> +
> + if (ret > 0)
> + cw1200_bh_wakeup(priv);
That doesn't look equivalent to me (when count == 1).
>
> cw1200_debug_txed_multi(priv, count);
> for (i = 0; i < count; ++i) {
Convert this loop into a do ... while so the body executes at least once.
David
Powered by blists - more mailing lists