mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: lustre: fixed shadowed variable in socklnd_cb.c
@ 2016-11-03 21:54 Andrew Kanner
  2016-11-03 22:12 ` Dilger, Andreas
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Kanner @ 2016-11-03 21:54 UTC (permalink / raw)
  To: oleg.drokin
  Cc: andreas.dilger, jsimmons, gregkh, viro, bevans, bhaktipriya96,
	lustre-devel, devel, linux-kernel

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

Signed-off-by: Andrew Kanner <andrew.kanner@gmail.com>
---
 drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index c1c6f60..03fe4e5 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -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);
 
-- 
2.1.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: lustre: fixed shadowed variable in socklnd_cb.c
  2016-11-03 21:54 [PATCH] staging: lustre: fixed shadowed variable in socklnd_cb.c Andrew Kanner
@ 2016-11-03 22:12 ` Dilger, Andreas
  2016-11-03 22:22   ` Andrew Kanner
  0 siblings, 1 reply; 3+ messages in thread
From: Dilger, Andreas @ 2016-11-03 22:12 UTC (permalink / raw)
  To: Andrew Kanner
  Cc: Drokin, Oleg, James Simmons, Greg Kroah-Hartman, Alexander Viro,
	bevans, bhaktipriya96, lustre-devel, devel, linux-kernel

On Nov 3, 2016, at 15:54, Andrew Kanner <andrew.kanner@gmail.com> wrote:
> 
> 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

> Signed-off-by: Andrew Kanner <andrew.kanner@gmail.com>
> ---
> drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> index c1c6f60..03fe4e5 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
> @@ -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);
> 
> -- 
> 2.1.4
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] staging: lustre: fixed shadowed variable in socklnd_cb.c
  2016-11-03 22:12 ` Dilger, Andreas
@ 2016-11-03 22:22   ` Andrew Kanner
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Kanner @ 2016-11-03 22:22 UTC (permalink / raw)
  To: Dilger, Andreas
  Cc: Drokin, Oleg, James Simmons, Greg Kroah-Hartman, Alexander Viro,
	bevans, bhaktipriya96, lustre-devel, devel, linux-kernel

2016-11-04 1:12 GMT+03:00 Dilger, Andreas <andreas.dilger@intel.com>:
> On Nov 3, 2016, at 15:54, Andrew Kanner <andrew.kanner@gmail.com> wrote:
>>
>> 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

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-03 22:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-03 21:54 [PATCH] staging: lustre: fixed shadowed variable in socklnd_cb.c Andrew Kanner
2016-11-03 22:12 ` Dilger, Andreas
2016-11-03 22:22   ` Andrew Kanner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®