diff options
author | Geert Uytterhoeven <geert@linux-m68k.org> | 2017-02-24 05:30:03 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-24 14:29:09 -0500 |
commit | 1b8c1012142d83229b7d1c960d131e6a30f777a6 (patch) | |
tree | 87b0debde646e0ea29a320e911293d1f9cb7afac | |
parent | 3b5923f0796b13e731802d40faf62d2c59d98e48 (diff) |
drivers: net: xgene: Simplify xgene_enet_setup_mss() to kill warning
With gcc-4.1.2 and -Os:
drivers/net/ethernet/apm/xgene/xgene_enet_main.c: In function ‘xgene_enet_start_xmit’:
drivers/net/ethernet/apm/xgene/xgene_enet_main.c:297: warning: ‘mss_index’ may be used uninitialized in this function
Using a separate variable to track success may confuse the compiler.
Preinitialize mss_index with -EBUSY and check for negative error values
instead to kill the warning.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/apm/xgene/xgene_enet_main.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c index d0d0d12b531f..e536301acfde 100644 --- a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c | |||
@@ -293,36 +293,29 @@ static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring, | |||
293 | static int xgene_enet_setup_mss(struct net_device *ndev, u32 mss) | 293 | static int xgene_enet_setup_mss(struct net_device *ndev, u32 mss) |
294 | { | 294 | { |
295 | struct xgene_enet_pdata *pdata = netdev_priv(ndev); | 295 | struct xgene_enet_pdata *pdata = netdev_priv(ndev); |
296 | bool mss_index_found = false; | 296 | int mss_index = -EBUSY; |
297 | int mss_index; | ||
298 | int i; | 297 | int i; |
299 | 298 | ||
300 | spin_lock(&pdata->mss_lock); | 299 | spin_lock(&pdata->mss_lock); |
301 | 300 | ||
302 | /* Reuse the slot if MSS matches */ | 301 | /* Reuse the slot if MSS matches */ |
303 | for (i = 0; !mss_index_found && i < NUM_MSS_REG; i++) { | 302 | for (i = 0; mss_index < 0 && i < NUM_MSS_REG; i++) { |
304 | if (pdata->mss[i] == mss) { | 303 | if (pdata->mss[i] == mss) { |
305 | pdata->mss_refcnt[i]++; | 304 | pdata->mss_refcnt[i]++; |
306 | mss_index = i; | 305 | mss_index = i; |
307 | mss_index_found = true; | ||
308 | } | 306 | } |
309 | } | 307 | } |
310 | 308 | ||
311 | /* Overwrite the slot with ref_count = 0 */ | 309 | /* Overwrite the slot with ref_count = 0 */ |
312 | for (i = 0; !mss_index_found && i < NUM_MSS_REG; i++) { | 310 | for (i = 0; mss_index < 0 && i < NUM_MSS_REG; i++) { |
313 | if (!pdata->mss_refcnt[i]) { | 311 | if (!pdata->mss_refcnt[i]) { |
314 | pdata->mss_refcnt[i]++; | 312 | pdata->mss_refcnt[i]++; |
315 | pdata->mac_ops->set_mss(pdata, mss, i); | 313 | pdata->mac_ops->set_mss(pdata, mss, i); |
316 | pdata->mss[i] = mss; | 314 | pdata->mss[i] = mss; |
317 | mss_index = i; | 315 | mss_index = i; |
318 | mss_index_found = true; | ||
319 | } | 316 | } |
320 | } | 317 | } |
321 | 318 | ||
322 | /* No slots with ref_count = 0 available, return busy */ | ||
323 | if (!mss_index_found) | ||
324 | mss_index = -EBUSY; | ||
325 | |||
326 | spin_unlock(&pdata->mss_lock); | 319 | spin_unlock(&pdata->mss_lock); |
327 | 320 | ||
328 | return mss_index; | 321 | return mss_index; |