From patchwork Wed Nov 16 15:07:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101513 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp204133qge; Wed, 16 Nov 2016 07:08:09 -0800 (PST) X-Received: by 10.99.240.83 with SMTP id s19mr9175870pgj.175.1479308889792; Wed, 16 Nov 2016 07:08:09 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p78si32254413pfj.299.2016.11.16.07.08.09; Wed, 16 Nov 2016 07:08:09 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933661AbcKPPHu (ORCPT + 1 other); Wed, 16 Nov 2016 10:07:50 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:49353 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751564AbcKPPHq (ORCPT ); Wed, 16 Nov 2016 10:07:46 -0500 Received: from wuerfel.lan ([78.43.21.235]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0Mh8jt-1cTDWO38Lp-00MLim; Wed, 16 Nov 2016 16:07:33 +0100 From: Arnd Bergmann To: Greg Kroah-Hartman Cc: Arnd Bergmann , Aditya Shankar , Ganesh Krishna , Glen Lee , Leo Kim , Binoy Jayan , Chris Park , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: wilc1000: simplify vif[i]->ndev accesses Date: Wed, 16 Nov 2016 16:07:10 +0100 Message-Id: <20161116150728.3055415-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:9gfSF+jv8235ZsDL3sPcLU6TH3+SqZ3rccfM48DGAl6uVNKSwY9 I4UBM9gKjmj++TPtB8N6p098O7q7kl1UmNykJeU9ujnhr+mVX50j0+9JhyJtWCjnFxyrtG6 QwjjCZw4cacWuHr7RiP6C+PjSEumpuwC1GKHs7oyY2pJYb01H1S6lETrQC44pbp86RqhaX9 2F1WcGWgTE/lbjti4eMeg== X-UI-Out-Filterresults: notjunk:1; V01:K0:1wzVydFquQM=:XkPjblk7QG7Adw4u+3s2dS hzpn6+T2jV7asZ0rlYfzoAiOpZI4gacVQkuYNukeE/RbcaRDUPN1AlGc2+bPCfqErHFP3D81l 6DGHZXiaPb7uv3HKl3voWV1xo1DdylRHsebyxlvP6xWQ+j48QR4Lxb2kGj2QbbHRg/EP9oNpk XORAuRIOPuqhb7lwuRiJU1yvv6yooYPp6jOzyN+rGEFlOne3V7tPVd3RUF45IMgU/oliXgoZJ a2SCzYjIDhCdOzszBqBWE7HTjF06wMICSl/05yq/rT28ozEwWhJ2Ds8fRftjYa7PlID+lPPys hIUgDQUQ38Myn+c08bdoJ39QvEwtbcTUXnGocN0tS1xCUxil92orar8Daij7e0z9ZslV2+g2Q mIfZWOkel4H9cKvvOgWuTz28/6Ortf8bWbFLZzpPng66ixDhKYklJC+lpv3UkS0AVdOHJcb8y Zfcb3JiVzzwZ6NdWm8QGtf5dvsSCSl8pT5zr/AeMnYibhA9qc8hHj4A4SOg+WkO+3NlSinwUz 6etpeLZeajmc8/drofMSxgs2IF0fB74fdRt++sQW1C1AwQEdCvxjfNOVNw5P0gdQNJCs4jEbt 41QP51OuwTiqHm3hVGhugzWha5LAwLCFaLJTTTm0HpW1TWqlJdQBouCH2xV6B8tFqY/qY5sha ULdI5w/vX4yDztZGcjPyZ5STPOmLDwXP1UwRsC6lrbfqiCStuQBjeF1/OqaQmOzAyO2Q= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org With gcc-7, I got a new warning for this driver: wilc1000/linux_wlan.c: In function 'wilc_netdev_cleanup': wilc1000/linux_wlan.c:1224:15: error: 'vif[1]' may be used uninitialized in this function [-Werror=maybe-uninitialized] wilc1000/linux_wlan.c:1224:15: error: 'vif[0]' may be used uninitialized in this function [-Werror=maybe-uninitialized] A closer look at the function reveals that it's more complex than it needs to be, given that based on how the device is created we always get netdev_priv(vif->ndev) == vif Based on this assumption, I found a few other places in the same file that can be simplified. That code appears to be a relic from times when the assumption above was not valid. Signed-off-by: Arnd Bergmann --- drivers/staging/wilc1000/linux_wlan.c | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) -- 2.9.0 diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 82c602ba3289..3775706578b2 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -260,23 +260,12 @@ static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode) { - int i = 0; - int ret = -1; - struct wilc_vif *vif; - struct wilc *wilc; - - vif = netdev_priv(wilc_netdev); - wilc = vif->wilc; + struct wilc_vif *vif = netdev_priv(wilc_netdev); - for (i = 0; i < wilc->vif_num; i++) - if (wilc->vif[i]->ndev == wilc_netdev) { - memcpy(wilc->vif[i]->bssid, bssid, 6); - wilc->vif[i]->mode = mode; - ret = 0; - break; - } + memcpy(vif->bssid, bssid, 6); + vif->mode = mode; - return ret; + return 0; } int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) @@ -1203,16 +1192,11 @@ void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size) void wilc_netdev_cleanup(struct wilc *wilc) { - int i = 0; - struct wilc_vif *vif[NUM_CONCURRENT_IFC]; + int i; - if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { + if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) unregister_inetaddr_notifier(&g_dev_notifier); - for (i = 0; i < NUM_CONCURRENT_IFC; i++) - vif[i] = netdev_priv(wilc->vif[i]->ndev); - } - if (wilc && wilc->firmware) { release_firmware(wilc->firmware); wilc->firmware = NULL; @@ -1221,7 +1205,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { for (i = 0; i < NUM_CONCURRENT_IFC; i++) if (wilc->vif[i]->ndev) - if (vif[i]->mac_opened) + if (wilc->vif[i]->mac_opened) wilc_mac_close(wilc->vif[i]->ndev); for (i = 0; i < NUM_CONCURRENT_IFC; i++) { @@ -1269,9 +1253,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, vif->idx = wl->vif_num; vif->wilc = *wilc; + vif->ndev = ndev; wl->vif[i] = vif; - wl->vif[wl->vif_num]->ndev = ndev; - wl->vif_num++; + wl->vif_num = i; ndev->netdev_ops = &wilc_netdev_ops; {