Commit 735bb39c authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

staging: wilc1000: simplify vif[i]->ndev accesses

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: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2c52b1ef
...@@ -260,23 +260,12 @@ static struct net_device *get_if_handler(struct wilc *wilc, u8 *mac_header) ...@@ -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 wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid, u8 mode)
{ {
int i = 0; struct wilc_vif *vif = netdev_priv(wilc_netdev);
int ret = -1;
struct wilc_vif *vif;
struct wilc *wilc;
vif = netdev_priv(wilc_netdev);
wilc = vif->wilc;
for (i = 0; i < wilc->vif_num; i++) memcpy(vif->bssid, bssid, 6);
if (wilc->vif[i]->ndev == wilc_netdev) { vif->mode = mode;
memcpy(wilc->vif[i]->bssid, bssid, 6);
wilc->vif[i]->mode = mode;
ret = 0;
break;
}
return ret; return 0;
} }
int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc) 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) ...@@ -1203,16 +1192,11 @@ void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size)
void wilc_netdev_cleanup(struct wilc *wilc) void wilc_netdev_cleanup(struct wilc *wilc)
{ {
int i = 0; int i;
struct wilc_vif *vif[NUM_CONCURRENT_IFC];
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); 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) { if (wilc && wilc->firmware) {
release_firmware(wilc->firmware); release_firmware(wilc->firmware);
wilc->firmware = NULL; wilc->firmware = NULL;
...@@ -1221,7 +1205,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) ...@@ -1221,7 +1205,7 @@ void wilc_netdev_cleanup(struct wilc *wilc)
if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) {
for (i = 0; i < NUM_CONCURRENT_IFC; i++) for (i = 0; i < NUM_CONCURRENT_IFC; i++)
if (wilc->vif[i]->ndev) if (wilc->vif[i]->ndev)
if (vif[i]->mac_opened) if (wilc->vif[i]->mac_opened)
wilc_mac_close(wilc->vif[i]->ndev); wilc_mac_close(wilc->vif[i]->ndev);
for (i = 0; i < NUM_CONCURRENT_IFC; i++) { 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, ...@@ -1269,9 +1253,9 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
vif->idx = wl->vif_num; vif->idx = wl->vif_num;
vif->wilc = *wilc; vif->wilc = *wilc;
vif->ndev = ndev;
wl->vif[i] = vif; wl->vif[i] = vif;
wl->vif[wl->vif_num]->ndev = ndev; wl->vif_num = i;
wl->vif_num++;
ndev->netdev_ops = &wilc_netdev_ops; ndev->netdev_ops = &wilc_netdev_ops;
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment