All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: Avoid shadowing a previous local
@ 2021-10-27  2:42 ` Qian Cai
  0 siblings, 0 replies; 9+ messages in thread
From: Qian Cai @ 2021-10-27  2:42 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, Catalin Marinas,
	Will Deacon, linux-arm-kernel, kvmarm, linux-kernel, Qian Cai

It is less-prone to have a different variable name from the one in a wider
scope. This is also flagged by GCC (W=2):

In file included from ./include/linux/kvm_host.h:39,
                 from arch/arm64/kvm/arm.c:12:
arch/arm64/kvm/arm.c: In function 'kvm_arch_vcpu_ioctl_run':
./arch/arm64/include/asm/kvm_host.h:638:26: warning: declaration of 'ret' shadows a previous local [-Wshadow]
  638 |   typeof(f(__VA_ARGS__)) ret;    \
      |                          ^~~
arch/arm64/kvm/arm.c:852:9: note: in expansion of macro 'kvm_call_hyp_ret'
  852 |   ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);
      |         ^~~~~~~~~~~~~~~~
arch/arm64/kvm/arm.c:773:6: note: shadowed declaration is here
  773 |  int ret;
      |      ^~~

Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
---
 arch/arm64/include/asm/kvm_host.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 4be8486042a7..4693d84ccd95 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -635,16 +635,16 @@ void kvm_arm_resume_guest(struct kvm *kvm);
 
 #define kvm_call_hyp_ret(f, ...)					\
 	({								\
-		typeof(f(__VA_ARGS__)) ret;				\
+		typeof(f(__VA_ARGS__)) __ret;				\
 									\
 		if (has_vhe()) {					\
-			ret = f(__VA_ARGS__);				\
+			__ret = f(__VA_ARGS__);				\
 			isb();						\
 		} else {						\
-			ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
+			__ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
 		}							\
 									\
-		ret;							\
+		__ret;							\
 	})
 #else /* __KVM_NVHE_HYPERVISOR__ */
 #define kvm_call_hyp(f, ...) f(__VA_ARGS__)
-- 
2.30.2


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

* [PATCH] KVM: arm64: Avoid shadowing a previous local
@ 2021-10-27  2:42 ` Qian Cai
  0 siblings, 0 replies; 9+ messages in thread
From: Qian Cai @ 2021-10-27  2:42 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, Catalin Marinas,
	Will Deacon, linux-arm-kernel, kvmarm, linux-kernel, Qian Cai

It is less-prone to have a different variable name from the one in a wider
scope. This is also flagged by GCC (W=2):

In file included from ./include/linux/kvm_host.h:39,
                 from arch/arm64/kvm/arm.c:12:
arch/arm64/kvm/arm.c: In function 'kvm_arch_vcpu_ioctl_run':
./arch/arm64/include/asm/kvm_host.h:638:26: warning: declaration of 'ret' shadows a previous local [-Wshadow]
  638 |   typeof(f(__VA_ARGS__)) ret;    \
      |                          ^~~
arch/arm64/kvm/arm.c:852:9: note: in expansion of macro 'kvm_call_hyp_ret'
  852 |   ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);
      |         ^~~~~~~~~~~~~~~~
arch/arm64/kvm/arm.c:773:6: note: shadowed declaration is here
  773 |  int ret;
      |      ^~~

Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
---
 arch/arm64/include/asm/kvm_host.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 4be8486042a7..4693d84ccd95 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -635,16 +635,16 @@ void kvm_arm_resume_guest(struct kvm *kvm);
 
 #define kvm_call_hyp_ret(f, ...)					\
 	({								\
-		typeof(f(__VA_ARGS__)) ret;				\
+		typeof(f(__VA_ARGS__)) __ret;				\
 									\
 		if (has_vhe()) {					\
-			ret = f(__VA_ARGS__);				\
+			__ret = f(__VA_ARGS__);				\
 			isb();						\
 		} else {						\
-			ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
+			__ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
 		}							\
 									\
-		ret;							\
+		__ret;							\
 	})
 #else /* __KVM_NVHE_HYPERVISOR__ */
 #define kvm_call_hyp(f, ...) f(__VA_ARGS__)
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] KVM: arm64: Avoid shadowing a previous local
@ 2021-10-27  2:42 ` Qian Cai
  0 siblings, 0 replies; 9+ messages in thread
From: Qian Cai @ 2021-10-27  2:42 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Will Deacon, Catalin Marinas, Qian Cai, linux-kernel, kvmarm,
	linux-arm-kernel

It is less-prone to have a different variable name from the one in a wider
scope. This is also flagged by GCC (W=2):

In file included from ./include/linux/kvm_host.h:39,
                 from arch/arm64/kvm/arm.c:12:
arch/arm64/kvm/arm.c: In function 'kvm_arch_vcpu_ioctl_run':
./arch/arm64/include/asm/kvm_host.h:638:26: warning: declaration of 'ret' shadows a previous local [-Wshadow]
  638 |   typeof(f(__VA_ARGS__)) ret;    \
      |                          ^~~
arch/arm64/kvm/arm.c:852:9: note: in expansion of macro 'kvm_call_hyp_ret'
  852 |   ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);
      |         ^~~~~~~~~~~~~~~~
arch/arm64/kvm/arm.c:773:6: note: shadowed declaration is here
  773 |  int ret;
      |      ^~~

Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
---
 arch/arm64/include/asm/kvm_host.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
index 4be8486042a7..4693d84ccd95 100644
--- a/arch/arm64/include/asm/kvm_host.h
+++ b/arch/arm64/include/asm/kvm_host.h
@@ -635,16 +635,16 @@ void kvm_arm_resume_guest(struct kvm *kvm);
 
 #define kvm_call_hyp_ret(f, ...)					\
 	({								\
-		typeof(f(__VA_ARGS__)) ret;				\
+		typeof(f(__VA_ARGS__)) __ret;				\
 									\
 		if (has_vhe()) {					\
-			ret = f(__VA_ARGS__);				\
+			__ret = f(__VA_ARGS__);				\
 			isb();						\
 		} else {						\
-			ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
+			__ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
 		}							\
 									\
-		ret;							\
+		__ret;							\
 	})
 #else /* __KVM_NVHE_HYPERVISOR__ */
 #define kvm_call_hyp(f, ...) f(__VA_ARGS__)
-- 
2.30.2

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Re: [PATCH] KVM: arm64: Avoid shadowing a previous local
  2021-10-27  2:42 ` Qian Cai
  (?)
@ 2021-10-27  7:34   ` Marc Zyngier
  -1 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2021-10-27  7:34 UTC (permalink / raw)
  To: Qian Cai
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, Catalin Marinas,
	Will Deacon, linux-arm-kernel, kvmarm, linux-kernel

On 2021-10-27 03:42, Qian Cai wrote:
> It is less-prone to have a different variable name from the one in a 
> wider
> scope. This is also flagged by GCC (W=2):
> 
> In file included from ./include/linux/kvm_host.h:39,
>                  from arch/arm64/kvm/arm.c:12:
> arch/arm64/kvm/arm.c: In function 'kvm_arch_vcpu_ioctl_run':
> ./arch/arm64/include/asm/kvm_host.h:638:26: warning: declaration of
> 'ret' shadows a previous local [-Wshadow]
>   638 |   typeof(f(__VA_ARGS__)) ret;    \
>       |                          ^~~
> arch/arm64/kvm/arm.c:852:9: note: in expansion of macro 
> 'kvm_call_hyp_ret'
>   852 |   ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);
>       |         ^~~~~~~~~~~~~~~~
> arch/arm64/kvm/arm.c:773:6: note: shadowed declaration is here
>   773 |  int ret;
>       |      ^~~
> 
> Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
> ---
>  arch/arm64/include/asm/kvm_host.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h
> b/arch/arm64/include/asm/kvm_host.h
> index 4be8486042a7..4693d84ccd95 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -635,16 +635,16 @@ void kvm_arm_resume_guest(struct kvm *kvm);
> 
>  #define kvm_call_hyp_ret(f, ...)					\
>  	({								\
> -		typeof(f(__VA_ARGS__)) ret;				\
> +		typeof(f(__VA_ARGS__)) __ret;				\
>  									\
>  		if (has_vhe()) {					\
> -			ret = f(__VA_ARGS__);				\
> +			__ret = f(__VA_ARGS__);				\
>  			isb();						\
>  		} else {						\
> -			ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
> +			__ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
>  		}							\
>  									\
> -		ret;							\
> +		__ret;							\
>  	})
>  #else /* __KVM_NVHE_HYPERVISOR__ */
>  #define kvm_call_hyp(f, ...) f(__VA_ARGS__)

I don't think this makes much sense. This is bound to eventually clash
with another variable, and you're back to square one.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

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

* Re: [PATCH] KVM: arm64: Avoid shadowing a previous local
@ 2021-10-27  7:34   ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2021-10-27  7:34 UTC (permalink / raw)
  To: Qian Cai
  Cc: Will Deacon, Catalin Marinas, linux-kernel, kvmarm, linux-arm-kernel

On 2021-10-27 03:42, Qian Cai wrote:
> It is less-prone to have a different variable name from the one in a 
> wider
> scope. This is also flagged by GCC (W=2):
> 
> In file included from ./include/linux/kvm_host.h:39,
>                  from arch/arm64/kvm/arm.c:12:
> arch/arm64/kvm/arm.c: In function 'kvm_arch_vcpu_ioctl_run':
> ./arch/arm64/include/asm/kvm_host.h:638:26: warning: declaration of
> 'ret' shadows a previous local [-Wshadow]
>   638 |   typeof(f(__VA_ARGS__)) ret;    \
>       |                          ^~~
> arch/arm64/kvm/arm.c:852:9: note: in expansion of macro 
> 'kvm_call_hyp_ret'
>   852 |   ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);
>       |         ^~~~~~~~~~~~~~~~
> arch/arm64/kvm/arm.c:773:6: note: shadowed declaration is here
>   773 |  int ret;
>       |      ^~~
> 
> Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
> ---
>  arch/arm64/include/asm/kvm_host.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h
> b/arch/arm64/include/asm/kvm_host.h
> index 4be8486042a7..4693d84ccd95 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -635,16 +635,16 @@ void kvm_arm_resume_guest(struct kvm *kvm);
> 
>  #define kvm_call_hyp_ret(f, ...)					\
>  	({								\
> -		typeof(f(__VA_ARGS__)) ret;				\
> +		typeof(f(__VA_ARGS__)) __ret;				\
>  									\
>  		if (has_vhe()) {					\
> -			ret = f(__VA_ARGS__);				\
> +			__ret = f(__VA_ARGS__);				\
>  			isb();						\
>  		} else {						\
> -			ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
> +			__ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
>  		}							\
>  									\
> -		ret;							\
> +		__ret;							\
>  	})
>  #else /* __KVM_NVHE_HYPERVISOR__ */
>  #define kvm_call_hyp(f, ...) f(__VA_ARGS__)

I don't think this makes much sense. This is bound to eventually clash
with another variable, and you're back to square one.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

* Re: [PATCH] KVM: arm64: Avoid shadowing a previous local
@ 2021-10-27  7:34   ` Marc Zyngier
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Zyngier @ 2021-10-27  7:34 UTC (permalink / raw)
  To: Qian Cai
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, Catalin Marinas,
	Will Deacon, linux-arm-kernel, kvmarm, linux-kernel

On 2021-10-27 03:42, Qian Cai wrote:
> It is less-prone to have a different variable name from the one in a 
> wider
> scope. This is also flagged by GCC (W=2):
> 
> In file included from ./include/linux/kvm_host.h:39,
>                  from arch/arm64/kvm/arm.c:12:
> arch/arm64/kvm/arm.c: In function 'kvm_arch_vcpu_ioctl_run':
> ./arch/arm64/include/asm/kvm_host.h:638:26: warning: declaration of
> 'ret' shadows a previous local [-Wshadow]
>   638 |   typeof(f(__VA_ARGS__)) ret;    \
>       |                          ^~~
> arch/arm64/kvm/arm.c:852:9: note: in expansion of macro 
> 'kvm_call_hyp_ret'
>   852 |   ret = kvm_call_hyp_ret(__kvm_vcpu_run, vcpu);
>       |         ^~~~~~~~~~~~~~~~
> arch/arm64/kvm/arm.c:773:6: note: shadowed declaration is here
>   773 |  int ret;
>       |      ^~~
> 
> Signed-off-by: Qian Cai <quic_qiancai@quicinc.com>
> ---
>  arch/arm64/include/asm/kvm_host.h | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/kvm_host.h
> b/arch/arm64/include/asm/kvm_host.h
> index 4be8486042a7..4693d84ccd95 100644
> --- a/arch/arm64/include/asm/kvm_host.h
> +++ b/arch/arm64/include/asm/kvm_host.h
> @@ -635,16 +635,16 @@ void kvm_arm_resume_guest(struct kvm *kvm);
> 
>  #define kvm_call_hyp_ret(f, ...)					\
>  	({								\
> -		typeof(f(__VA_ARGS__)) ret;				\
> +		typeof(f(__VA_ARGS__)) __ret;				\
>  									\
>  		if (has_vhe()) {					\
> -			ret = f(__VA_ARGS__);				\
> +			__ret = f(__VA_ARGS__);				\
>  			isb();						\
>  		} else {						\
> -			ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
> +			__ret = kvm_call_hyp_nvhe(f, ##__VA_ARGS__);	\
>  		}							\
>  									\
> -		ret;							\
> +		__ret;							\
>  	})
>  #else /* __KVM_NVHE_HYPERVISOR__ */
>  #define kvm_call_hyp(f, ...) f(__VA_ARGS__)

I don't think this makes much sense. This is bound to eventually clash
with another variable, and you're back to square one.

Thanks,

         M.
-- 
Jazz is not dead. It just smells funny...

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] KVM: arm64: Avoid shadowing a previous local
  2021-10-27  7:34   ` Marc Zyngier
  (?)
@ 2021-10-27 15:13     ` Qian Cai
  -1 siblings, 0 replies; 9+ messages in thread
From: Qian Cai @ 2021-10-27 15:13 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, Catalin Marinas,
	Will Deacon, linux-arm-kernel, kvmarm, linux-kernel



On 10/27/21 3:34 AM, Marc Zyngier wrote:
> I don't think this makes much sense. This is bound to eventually clash
> with another variable, and you're back to square one.

Yes, perhaps. We don't have a namespace feature in C. Thanks for taking
a look, Marc.

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

* Re: [PATCH] KVM: arm64: Avoid shadowing a previous local
@ 2021-10-27 15:13     ` Qian Cai
  0 siblings, 0 replies; 9+ messages in thread
From: Qian Cai @ 2021-10-27 15:13 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: James Morse, Alexandru Elisei, Suzuki K Poulose, Catalin Marinas,
	Will Deacon, linux-arm-kernel, kvmarm, linux-kernel



On 10/27/21 3:34 AM, Marc Zyngier wrote:
> I don't think this makes much sense. This is bound to eventually clash
> with another variable, and you're back to square one.

Yes, perhaps. We don't have a namespace feature in C. Thanks for taking
a look, Marc.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] KVM: arm64: Avoid shadowing a previous local
@ 2021-10-27 15:13     ` Qian Cai
  0 siblings, 0 replies; 9+ messages in thread
From: Qian Cai @ 2021-10-27 15:13 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: Will Deacon, Catalin Marinas, linux-kernel, kvmarm, linux-arm-kernel



On 10/27/21 3:34 AM, Marc Zyngier wrote:
> I don't think this makes much sense. This is bound to eventually clash
> with another variable, and you're back to square one.

Yes, perhaps. We don't have a namespace feature in C. Thanks for taking
a look, Marc.
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

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

end of thread, other threads:[~2021-10-27 16:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-27  2:42 [PATCH] KVM: arm64: Avoid shadowing a previous local Qian Cai
2021-10-27  2:42 ` Qian Cai
2021-10-27  2:42 ` Qian Cai
2021-10-27  7:34 ` Marc Zyngier
2021-10-27  7:34   ` Marc Zyngier
2021-10-27  7:34   ` Marc Zyngier
2021-10-27 15:13   ` Qian Cai
2021-10-27 15:13     ` Qian Cai
2021-10-27 15:13     ` Qian Cai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.