Skip to content

Commit

Permalink
net: xgene: avoid bogus maybe-uninitialized warning
Browse files Browse the repository at this point in the history
In some configurations, gcc cannot trace the state of variables
across a spin_unlock() barrier, leading to a warning about
correct code:

xgene_enet_main.c: In function 'xgene_enet_start_xmit':
../../../phy/mdio-xgene.h:112:14: error: 'mss_index' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Here we can trivially move the assignment before that spin_unlock,
which reliably avoids the warning.

Fixes: e397867 ("drivers: net: xgene: Fix MSS programming")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Arnd Bergmann authored and David S. Miller committed Dec 9, 2016
1 parent dece303 commit f006b2c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/net/ethernet/apm/xgene/xgene_enet_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,11 @@ static int xgene_enet_setup_mss(struct net_device *ndev, u32 mss)
}
}

spin_unlock(&pdata->mss_lock);

/* No slots with ref_count = 0 available, return busy */
if (!mss_index_found)
return -EBUSY;
mss_index = -EBUSY;

spin_unlock(&pdata->mss_lock);

return mss_index;
}
Expand Down

0 comments on commit f006b2c

Please sign in to comment.