Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: xgene: avoid bogus maybe-uninitialized warning

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: e3978673f514 ("drivers: net: xgene: Fix MSS programming")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Arnd Bergmann and committed by
David S. Miller
f006b2c5 dece303f

+3 -3
+3 -3
drivers/net/ethernet/apm/xgene/xgene_enet_main.c
··· 319 319 } 320 320 } 321 321 322 - spin_unlock(&pdata->mss_lock); 323 - 324 322 /* No slots with ref_count = 0 available, return busy */ 325 323 if (!mss_index_found) 326 - return -EBUSY; 324 + mss_index = -EBUSY; 325 + 326 + spin_unlock(&pdata->mss_lock); 327 327 328 328 return mss_index; 329 329 }