From patchwork Fri May 27 15:08:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9138643 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 F029560467 for ; Fri, 27 May 2016 15:09:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E32352830E for ; Fri, 27 May 2016 15:09:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D742528318; Fri, 27 May 2016 15:09:04 +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 68B5C282ED for ; Fri, 27 May 2016 15:09:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755358AbcE0PIl (ORCPT ); Fri, 27 May 2016 11:08:41 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:54109 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751250AbcE0PIk convert rfc822-to-8bit (ORCPT ); Fri, 27 May 2016 11:08:40 -0400 Received: from wuerfel.localnet ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue001) with ESMTPSA (Nemesis) id 0MOo4s-1bCNeK2oI2-006AO8; Fri, 27 May 2016 17:08:22 +0200 From: Arnd Bergmann To: Arnaldo Carvalho de Melo , Kalle Valo Cc: Johannes Berg , Arnd Bergmann , "David S. Miller" , netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] wl3501_cs: avoid bogus gcc-6 warning Date: Fri, 27 May 2016 17:08:33 +0200 Message-ID: <4731273.LDpWBaOjNT@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-22-generic; KDE/5.18.0; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:z3+texODiovwpyLirEzA5eOHo2/jm6Cy4g9v3JEBgfXpPoLMo8d lv8IEi12HhTTGXh97MvEwqf8xd4TuQkPhz2Sq84b79UsqyvYcAnmHI8f3XkofqNCtgTbvDG FbLE5x0yr8m2q6+xUBOtBJtHa9qc502UE6rSemMIE0c5D3vtHkJvDjxPquxNvnBbiK3JpHI FUYEzncw6ZHLvTuixKPJw== X-UI-Out-Filterresults: notjunk:1; V01:K0:TUfuyni5z8c=:TWc5LOU4S4Qta2a8fA7fm/ UkzMBjfS+HhOS37KdLpAZ3hfvGJzDzF4kqFO347iNig0Z8hlS5Pmde/xvmrzpqU55D8yYxszi JGm/5fWsA/UhSlMxA6ZGMm/yQsj/QhmgrH01c8aplMzHeVUeRKxWsems9NAiazJpcYS8tObkn dX0koOSJmB2XeL5P/Kw3ajkDukDJGWO+lNbyRFqCgnN+xlUF/TOL/9xllVoRAMHH4/3x7acvD ym1s+FNO59JUysuLrJMYms8n2yckJIqVQXYGc+lO85xi+6bLr8g/ebSzXVsaUijjFY2QyW1+n QFsOYZoEPYBP143hPgWin/cWi/KaRh1uFJDKkcEjbIxiK+T9SJX5FphdGiU/GmKfQG9oUmunp J81n+jziLn3tKNcpx/agbsoPBMIN3C4+7cS2AQxikIaycusVN74BxCp/zrZ8Qm6BiwBvQWvaA kYLqVFNCMJ4Qm3Ci6f9or42ohcsyL9wasvjD7hR7mirKzNRCewxRe8lyAUBcF+97PfQdScqnx aneFCeOTxCWsqhgCfEmqkRrr3xPQcYyobqIsoNyzXWMUGg8BNlxQ9M3i8pppFLHpjl0nhyIQL BUO49eSxBjjYAaYEYk89MaylI4EXRizTSTsnPGHQKgBhtzj/1d/6LFQc2IkEG1rHISpkH/Ao9 56tFUBwFYb/97D+0meBnhDRyRPr1QzZrjiMy5ozyF0LNlh/5GQGpztq7ICrdBqnXpQuB+yVFh +ihn7kC+CyBG+ZKw 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 gcc-6 on x86 started warning about wl3501_get_encode when building with -O2: drivers/net/wireless/wl3501_cs.c: In function ‘wl3501_get_encode’: drivers/net/wireless/wl3501_cs.c:1769:5: warning: ‘implemented’ may be used uninitialized in this function drivers/net/wireless/wl3501_cs.c:1686:19: warning: ‘threshold’ may be used uninitialized in this function drivers/net/wireless/wl3501_cs.c:1702:20: warning: ‘threshold’ may be used uninitialized in this function drivers/net/wireless/wl3501_cs.c:1719:23: warning: ‘txpow’ may be used uninitialized in this function drivers/net/wireless/wl3501_cs.c:1752:20: warning: ‘retry’ may be used uninitialized in this function drivers/net/wireless/wl3501_cs.c:1806:25: warning: ‘pwr_state’ may be used uninitialized in this function drivers/net/wireless/wl3501_cs.c:1383:24: warning: ‘value’ may be used uninitialized in this function I could not figure out what exactly confuses gcc here, but splitting the wl3501_get_mib_value function into two helps the compiler to figure out that the variables are not actually used uninitialized, and makes it slightly clearer to a human reader what the function actually does and which parts of it are under the spinlock. Signed-off-by: Arnd Bergmann --- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index 13fd734b61ec..82d94f83b6b4 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c @@ -378,8 +378,7 @@ static int wl3501_esbq_exec(struct wl3501_card *this, void *sig, int sig_size) return rc; } -static int wl3501_get_mib_value(struct wl3501_card *this, u8 index, - void *bf, int size) +static int wl3501_request_mib(struct wl3501_card *this, u8 index, void *bf) { struct wl3501_get_req sig = { .sig_id = WL3501_SIG_GET_REQ, @@ -395,20 +394,32 @@ static int wl3501_get_mib_value(struct wl3501_card *this, u8 index, wl3501_set_to_wla(this, ptr, &sig, sizeof(sig)); wl3501_esbq_req(this, &ptr); this->sig_get_confirm.mib_status = 255; - spin_unlock_irqrestore(&this->lock, flags); - rc = wait_event_interruptible(this->wait, - this->sig_get_confirm.mib_status != 255); - if (!rc) - memcpy(bf, this->sig_get_confirm.mib_value, - size); - goto out; + rc = 0; } } spin_unlock_irqrestore(&this->lock, flags); -out: + return rc; } +static int wl3501_get_mib_value(struct wl3501_card *this, u8 index, + void *bf, int size) +{ + int rc; + + rc = wl3501_request_mib(this, index, bf); + if (rc) + return rc; + + rc = wait_event_interruptible(this->wait, + this->sig_get_confirm.mib_status != 255); + if (rc) + return rc; + + memcpy(bf, this->sig_get_confirm.mib_value, size); + return 0; +} + static int wl3501_pwr_mgmt(struct wl3501_card *this, int suspend) { struct wl3501_pwr_mgmt_req sig = {