]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cw1200: fix bogus maybe-uninitialized warning
authorArnd Bergmann <arnd@arndb.de>
Tue, 25 Oct 2016 20:21:04 +0000 (22:21 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 17 Nov 2016 06:47:58 +0000 (08:47 +0200)
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]

We have already checked that 'count' is larger than 0 here, so
we know that 'ret' is initialized. Changing the 'for' loop
into do/while also makes this clear to the compiler.

Suggested-by: David Laight <David.Laight@ACULAB.COM>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/st/cw1200/wsm.c

index ffb245e941bbed6a5552ccc5855eaf86e7ed86c4..be4c22e0d9021f99db69faef2bcfc41dbeaf8b9f 100644 (file)
@@ -379,7 +379,6 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv,
 {
        int ret;
        int count;
-       int i;
 
        count = WSM_GET32(buf);
        if (WARN_ON(count <= 0))
@@ -395,11 +394,10 @@ static int wsm_multi_tx_confirm(struct cw1200_common *priv,
        }
 
        cw1200_debug_txed_multi(priv, count);
-       for (i = 0; i < count; ++i) {
+       do {
                ret = wsm_tx_confirm(priv, buf, link_id);
-               if (ret)
-                       return ret;
-       }
+       } while (!ret && --count);
+
        return ret;
 
 underflow: