Commit ecf244f753e09486707843f2b7b1874f33027038
Committed by
David S. Miller
1 parent
52ccd63184
rocker: fix maybe-uninitialized warning
In some rare configurations, we get a warning about the 'index' variable being used without an initialization: drivers/net/ethernet/rocker/rocker_ofdpa.c: In function ‘ofdpa_port_fib_ipv4.isra.16.constprop’: drivers/net/ethernet/rocker/rocker_ofdpa.c:2425:92: warning: ‘index’ may be used uninitialized in this function [-Wmaybe-uninitialized] This is a false positive, the logic is just a bit too complex for gcc to follow here. Moving the intialization of 'index' a little further down makes it clear to gcc that the function always returns an error if it is not initialized. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
drivers/net/ethernet/rocker/rocker_ofdpa.c
... | ... | @@ -1493,8 +1493,6 @@ |
1493 | 1493 | spin_lock_irqsave(&ofdpa->neigh_tbl_lock, lock_flags); |
1494 | 1494 | |
1495 | 1495 | found = ofdpa_neigh_tbl_find(ofdpa, ip_addr); |
1496 | - if (found) | |
1497 | - *index = found->index; | |
1498 | 1496 | |
1499 | 1497 | updating = found && adding; |
1500 | 1498 | removing = found && !adding; |
1501 | 1499 | |
... | ... | @@ -1508,9 +1506,11 @@ |
1508 | 1506 | resolved = false; |
1509 | 1507 | } else if (removing) { |
1510 | 1508 | ofdpa_neigh_del(trans, found); |
1509 | + *index = found->index; | |
1511 | 1510 | } else if (updating) { |
1512 | 1511 | ofdpa_neigh_update(found, trans, NULL, false); |
1513 | 1512 | resolved = !is_zero_ether_addr(found->eth_dst); |
1513 | + *index = found->index; | |
1514 | 1514 | } else { |
1515 | 1515 | err = -ENOENT; |
1516 | 1516 | } |