public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Qian Cai <quic_qiancai@quicinc.com>
Cc: James Morse <james.morse@arm.com>,
	Alexandru Elisei <alexandru.elisei@arm.com>,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KVM: arm64: Avoid shadowing a previous local
Date: Wed, 27 Oct 2021 08:34:31 +0100	[thread overview]
Message-ID: <da6be00d39c37ad26bfad9e75e814cb1@kernel.org> (raw)
In-Reply-To: <20211027024212.64842-1-quic_qiancai@quicinc.com>

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...

  reply	other threads:[~2021-10-27  7:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-27  2:42 [PATCH] KVM: arm64: Avoid shadowing a previous local Qian Cai
2021-10-27  7:34 ` Marc Zyngier [this message]
2021-10-27 15:13   ` Qian Cai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da6be00d39c37ad26bfad9e75e814cb1@kernel.org \
    --to=maz@kernel.org \
    --cc=alexandru.elisei@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=james.morse@arm.com \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_qiancai@quicinc.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox