Skip to contentSkip to conversation

staging: lustre: fixed shadowed variable in socklnd_cb.c

PATCH Superseded Andrew Kanner 2 participants 3 messages Nov 3, 2016 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: lustre: fixed shadowed variable in socklnd_cb.c

Changed variable 'tx' name in local scope
Fixed: sparse warning:
socklnd_cb.c:2476:41: warning: symbol 'tx' shadows an earlier one socklnd_cb.c:2435:25: originally declared here

---
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +2 -2
index c1c6f60..03fe4e5 100644
@@ -2473,11 +2473,11 @@ ksocknal_check_peer_timeouts(int idx)
 		 * holding only shared lock
 		 */
 		if (!list_empty(&peer->ksnp_tx_queue)) {
-			struct ksock_tx *tx = list_entry(peer->ksnp_tx_queue.next,
+			struct ksock_tx *_tx = list_entry(peer->ksnp_tx_queue.next,
 						    struct ksock_tx, tx_list);
 
 			if (cfs_time_aftereq(cfs_time_current(),
-					     tx->tx_deadline)) {
+					     _tx->tx_deadline)) {
 				ksocknal_peer_addref(peer);
 				read_unlock(&ksocknal_data.ksnd_global_lock);
 
Signature · 1 line
2.1.4
#1 lore raw
Quoted 5 lines · Andrew Kanner

Changed variable 'tx' name in local scope
Fixed: sparse warning:
socklnd_cb.c:2476:41: warning: symbol 'tx' shadows an earlier one socklnd_cb.c:2435:25: originally declared here

Looking at this more closely (or from a greater distance, hard to say), the outer-scope "tx" is used only after this inner-scope "tx", so in fact there is no benefit to having the inner-scope declaration at all.

Removing it may save a stack variable (depending on how the compiler optimizes), and shouldn't affect functionality.

Cheers, Andreas

Quoted 26 lines

---
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c +2 -2
index c1c6f60..03fe4e5 100644
@@ -2473,11 +2473,11 @@ ksocknal_check_peer_timeouts(int idx)
 		 * holding only shared lock
 		 */
 		if (!list_empty(&peer->ksnp_tx_queue)) {
-			struct ksock_tx *tx = list_entry(peer->ksnp_tx_queue.next,
+			struct ksock_tx *_tx = list_entry(peer->ksnp_tx_queue.next,
 						    struct ksock_tx, tx_list);
 
 			if (cfs_time_aftereq(cfs_time_current(),
-					     tx->tx_deadline)) {
+					     _tx->tx_deadline)) {
 				ksocknal_peer_addref(peer);
 				read_unlock(&ksocknal_data.ksnd_global_lock);
 
Signature · 1 line
2.1.4
#2 lore raw

2016-11-04 1:12 GMT+03:00 Dilger, Andreas <[email protected]>:

Quoted 7 lines · Andrew Kanner
Quoted 5 lines

Changed variable 'tx' name in local scope
Fixed: sparse warning:
socklnd_cb.c:2476:41: warning: symbol 'tx' shadows an earlier one socklnd_cb.c:2435:25: originally declared here

Quoted 8 lines

Looking at this more closely (or from a greater distance, hard to say), the outer-scope "tx" is used only after this inner-scope "tx", so in fact there is no benefit to having the inner-scope declaration at all.

Removing it may save a stack variable (depending on how the compiler optimizes), and shouldn't affect functionality.

Cheers, Andreas

I see, I'll correct it and resend as PATCH v2. Thank you.