cw1200: fix bogus maybe-uninitialized warning
Subsystems (3)
PATCH 1/1 cw1200: fix bogus maybe-uninitialized warning
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.
--- drivers/net/wireless/st/cw1200/wsm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/wireless/st/cw1200/wsm.c +7 -8
@@ -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);cw1200_debug_txed_multi (priv, count);for (i =0 ; i < count; ++i) {
Signature · 1 line
2.9.0
From: Of Arnd Bergmann
Quoted 33 lines
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 functionwsm_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 <[email protected]>--- drivers/net/wireless/st/cw1200/wsm.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)drivers/net/wireless/st/cw1200/wsm.c +0
-5@@ -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;
drivers/net/wireless/st/cw1200/wsm.c static int wsm_multi_tx_confirm(struct cw1200_common *priv, · line 394
Quoted 10 lines
drivers/net/wireless/st/cw1200/wsm.c +7
-3-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).
drivers/net/wireless/st/cw1200/wsm.c static int wsm_multi_tx_confirm(struct cw1200_common *priv, · line 397
Quoted 3 lines
drivers/net/wireless/st/cw1200/wsm.c +0
-0cw1200_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
Quoted 9 lines · David Laight
Quoted 9 lines
drivers/net/wireless/st/cw1200/wsm.c +1
-8-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 */
Quoted 8 lines
drivers/net/wireless/st/cw1200/wsm.c static int wsm_multi_tx_confirm(struct cw1200_common *priv, · line 394
Quoted 6 lines
drivers/net/wireless/st/cw1200/wsm.c +6
-0+ 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).
I concur, this patch should not be applied in its current form.
- Solomon
Signature · 3 lines
Solomon Peachy pizza at shaftnet dot org Delray Beach, FL ^^ (email/xmpp) ^^ Quidquid latine dictum sit, altum viditur.
Quoted 17 lines · CEST David Laight
Quoted 17 lines
drivers/net/wireless/st/cw1200/wsm.c +1
-8@@ -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 */
Quoted 8 lines
drivers/net/wireless/st/cw1200/wsm.c static int wsm_multi_tx_confirm(struct cw1200_common *priv, · line 394
Quoted 6 lines
drivers/net/wireless/st/cw1200/wsm.c +6
-0+ 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).
Ah, that's what I missed, thanks for pointing that out!
Quoted 5 lines
drivers/net/wireless/st/cw1200/wsm.c static int wsm_multi_tx_confirm(struct cw1200_common *priv, · line 397
Quoted 3 lines
drivers/net/wireless/st/cw1200/wsm.c +0
-0cw1200_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.
Good idea. Version 2 coming now.
Arnd