From patchwork Tue Oct 25 20:21:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9395413 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 50A1060234 for ; Tue, 25 Oct 2016 20:22:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F0F629571 for ; Tue, 25 Oct 2016 20:22:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33CF029767; Tue, 25 Oct 2016 20:22:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D53129571 for ; Tue, 25 Oct 2016 20:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965959AbcJYUVt (ORCPT ); Tue, 25 Oct 2016 16:21:49 -0400 Received: from mout.kundenserver.de ([217.72.192.75]:57241 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965501AbcJYUVq (ORCPT ); Tue, 25 Oct 2016 16:21:46 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue101) with ESMTPA (Nemesis) id 0Lch0h-1cf1gv1Swp-00kB4q; Tue, 25 Oct 2016 22:21:26 +0200 From: Arnd Bergmann To: Solomon Peachy , Kalle Valo Cc: David Laight , Arnd Bergmann , Johannes Berg , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] cw1200: fix bogus maybe-uninitialized warning Date: Tue, 25 Oct 2016 22:21:04 +0200 Message-Id: <20161025202121.1070879-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 MIME-Version: 1.0 X-Provags-ID: V03:K0:n0GOflO3Zkzp4UFbQY1X4/SIq5EDzlDd2GERRznhLAG6QsEEAIW DflSq5bawkafnzWuOtv3jq6m4rkM2DYSOtLNQYOC1vLUAiGJHYxuPWfM6HSUsyM5LPgmb3W BNCnNLAm1MMU8hSOnkWOkNRuiRPjuaHx/dJFU4ckQ+XxH29Qyyun10FQiIzg+AHr12a3kw6 Nq/DMAHvhjHeruDEOUi3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:z9XTNSlyxzU=:/SWReJYnWexHhB6Y2WVDfa FqgKsBQBmVN53GKw0K32GrFDUoq+dszxW8Ou/cDsfV/erl+xiHVcsNtkT+DBR0iMgSO/TuKlS gvk306MOuoraooR3P/JehcXiQSuk2sJrTXYcv5cBXRJDuie8VmuywkQiZ5xh4qitAP6LVNh8b WhlAtGBq1SKn9PkUqpI+ga/BZ/hZ5pPOcKqv84PDwsVH6+tSAuoUNtFje6tV/+TR+T1BFFpj5 U15/Sov/3pdhEUqKU9XB0X/q6EJqNbqfHIscqQwrWgx6ALEcViaLZERhNClxDGfEB7XQvogRn VC/jsol8HeJPHXj/UM3IQIXVoLq3vAn5OeorC5JRhCU54s2ma7HixlJhffwuC6JrbA2TAABKX Dd3HVZWh4Uoprw3Tqu8l9/tcwC09rd+nvg6lCoKRr4wpevqE/cXIL04/nInBIZ00II2YG53z+ xD79EfeR4FB936pwP51+RcAqRqEHQPcDBOY8D4BR1YQ3vLJr9JNf4/lIZHym2KJshubWFqwx5 U5z//hMqpEbgcIWrm9VVF0tFjrgoJhsihCGp9o0OZ0V+C0uDYbGMgTXZ7wzg0JTkL2MFs/XW0 f0JNUsoS5lpCf8zZKLN+hj6RtlfZ9kYyvHBxA6Zo3ertG/K2c5h0u0OFDlfQgqlJ4mgevZVO6 OCKTJqwI2t0K4tlTFG9QHyJl7+TCKS3Q8gQyBnqJ6U7Fg/PC4ViObhqlb9sAERCMRoj90RHJF j1is1N+CLOAxmvGt Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Arnd Bergmann --- drivers/net/wireless/st/cw1200/wsm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) v2: rewrite based on David Laight's suggestion, the first version was completely wrong. diff --git a/drivers/net/wireless/st/cw1200/wsm.c b/drivers/net/wireless/st/cw1200/wsm.c index 680d60eabc75..ed93bf3474ec 100644 --- a/drivers/net/wireless/st/cw1200/wsm.c +++ b/drivers/net/wireless/st/cw1200/wsm.c @@ -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: