Commit a1b43edd authored by Arnd Bergmann's avatar Arnd Bergmann Committed by David S. Miller

net/ncsi: avoid maybe-uninitialized warning

gcc-4.9 and higher warn about the newly added NSCI code:

net/ncsi/ncsi-manage.c: In function 'ncsi_process_next_channel':
net/ncsi/ncsi-manage.c:1003:2: error: 'old_state' may be used uninitialized in this function [-Werror=maybe-uninitialized]

The warning is a false positive and therefore harmless, but it would be good to
avoid it anyway. I have determined that the barrier in the spin_unlock_irqsave()
is what confuses gcc to the point that it cannot track whether the variable
was unused or not.

This rearranges the code in a way that makes it obvious to gcc that old_state
is always initialized at the time of use, functionally this should not
change anything.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 974b9963
...@@ -982,23 +982,18 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp) ...@@ -982,23 +982,18 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp)
spin_lock_irqsave(&ndp->lock, flags); spin_lock_irqsave(&ndp->lock, flags);
nc = list_first_or_null_rcu(&ndp->channel_queue, nc = list_first_or_null_rcu(&ndp->channel_queue,
struct ncsi_channel, link); struct ncsi_channel, link);
if (nc) { if (!nc) {
spin_unlock_irqrestore(&ndp->lock, flags);
goto out;
}
old_state = xchg(&nc->state, NCSI_CHANNEL_INVISIBLE); old_state = xchg(&nc->state, NCSI_CHANNEL_INVISIBLE);
list_del_init(&nc->link); list_del_init(&nc->link);
}
spin_unlock_irqrestore(&ndp->lock, flags); spin_unlock_irqrestore(&ndp->lock, flags);
ndp->active_channel = nc; ndp->active_channel = nc;
ndp->active_package = nc ? nc->package : NULL; ndp->active_package = nc->package;
if (!nc) {
if (ndp->flags & NCSI_DEV_RESHUFFLE) {
ndp->flags &= ~NCSI_DEV_RESHUFFLE;
return ncsi_choose_active_channel(ndp);
}
ncsi_report_link(ndp, false);
return -ENODEV;
}
switch (old_state) { switch (old_state) {
case NCSI_CHANNEL_INACTIVE: case NCSI_CHANNEL_INACTIVE:
...@@ -1017,6 +1012,17 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp) ...@@ -1017,6 +1012,17 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp)
} }
return 0; return 0;
out:
ndp->active_channel = NULL;
ndp->active_package = NULL;
if (ndp->flags & NCSI_DEV_RESHUFFLE) {
ndp->flags &= ~NCSI_DEV_RESHUFFLE;
return ncsi_choose_active_channel(ndp);
}
ncsi_report_link(ndp, false);
return -ENODEV;
} }
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
......
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