Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965892AbcJYN1n (ORCPT ); Tue, 25 Oct 2016 09:27:43 -0400 Received: from smtp-out4.electric.net ([192.162.216.183]:53188 "EHLO smtp-out4.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933363AbcJYN1k (ORCPT ); Tue, 25 Oct 2016 09:27:40 -0400 From: David Laight To: "'Arnd Bergmann'" , Solomon Peachy , Kalle Valo CC: Johannes Berg , "linux-wireless@vger.kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH] cw1200: fix bogus maybe-uninitialized warning Thread-Topic: [PATCH] cw1200: fix bogus maybe-uninitialized warning Thread-Index: AQHSLg0BeGcNVlf5j0ql1Jx31gjYvqC5KdSA Date: Tue, 25 Oct 2016 13:24:55 +0000 Message-ID: <063D6719AE5E284EB5DD2968C1650D6DB0209E9A@AcuExch.aculab.com> References: <20161024154215.2863586-1-arnd@arndb.de> In-Reply-To: <20161024154215.2863586-1-arnd@arndb.de> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.202.99.200] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 213.249.233.130 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuExch.aculab.com X-TLS: TLSv1:AES128-SHA:128 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id u9PDS4j9022151 Content-Length: 1821 Lines: 55 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 > --- > 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