summaryrefslogtreecommitdiffstats
path: root/net/ncsi
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-07-21 15:28:34 -0400
committerDavid S. Miller <davem@davemloft.net>2016-07-25 13:32:59 -0400
commita1b43eddaec5a3fea55e1581caf217abda2d3147 (patch)
treee2cb2091dd2df3d107ba67eda2ddb0d9989d998c /net/ncsi
parent974b996345e152752807b0d322aa43f21e49a21a (diff)
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: Arnd Bergmann <arnd@arndb.de> Acked-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ncsi')
-rw-r--r--net/ncsi/ncsi-manage.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/net/ncsi/ncsi-manage.c b/net/ncsi/ncsi-manage.c
index d627a39ddcd0..ef017b871857 100644
--- a/net/ncsi/ncsi-manage.c
+++ b/net/ncsi/ncsi-manage.c
@@ -982,23 +982,18 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp)
982 spin_lock_irqsave(&ndp->lock, flags); 982 spin_lock_irqsave(&ndp->lock, flags);
983 nc = list_first_or_null_rcu(&ndp->channel_queue, 983 nc = list_first_or_null_rcu(&ndp->channel_queue,
984 struct ncsi_channel, link); 984 struct ncsi_channel, link);
985 if (nc) { 985 if (!nc) {
986 old_state = xchg(&nc->state, NCSI_CHANNEL_INVISIBLE); 986 spin_unlock_irqrestore(&ndp->lock, flags);
987 list_del_init(&nc->link); 987 goto out;
988 } 988 }
989
990 old_state = xchg(&nc->state, NCSI_CHANNEL_INVISIBLE);
991 list_del_init(&nc->link);
992
989 spin_unlock_irqrestore(&ndp->lock, flags); 993 spin_unlock_irqrestore(&ndp->lock, flags);
990 994
991 ndp->active_channel = nc; 995 ndp->active_channel = nc;
992 ndp->active_package = nc ? nc->package : NULL; 996 ndp->active_package = nc->package;
993 if (!nc) {
994 if (ndp->flags & NCSI_DEV_RESHUFFLE) {
995 ndp->flags &= ~NCSI_DEV_RESHUFFLE;
996 return ncsi_choose_active_channel(ndp);
997 }
998
999 ncsi_report_link(ndp, false);
1000 return -ENODEV;
1001 }
1002 997
1003 switch (old_state) { 998 switch (old_state) {
1004 case NCSI_CHANNEL_INACTIVE: 999 case NCSI_CHANNEL_INACTIVE:
@@ -1017,6 +1012,17 @@ int ncsi_process_next_channel(struct ncsi_dev_priv *ndp)
1017 } 1012 }
1018 1013
1019 return 0; 1014 return 0;
1015
1016out:
1017 ndp->active_channel = NULL;
1018 ndp->active_package = NULL;
1019 if (ndp->flags & NCSI_DEV_RESHUFFLE) {
1020 ndp->flags &= ~NCSI_DEV_RESHUFFLE;
1021 return ncsi_choose_active_channel(ndp);
1022 }
1023
1024 ncsi_report_link(ndp, false);
1025 return -ENODEV;
1020} 1026}
1021 1027
1022#if IS_ENABLED(CONFIG_IPV6) 1028#if IS_ENABLED(CONFIG_IPV6)