Re: [PATCH v2] kvm: Avoid shadowing a local in search_memslots()

From: Sean Christopherson
Date: Wed Oct 27 2021 - 10:23:18 EST


On Tue, Oct 26, 2021, Qian Cai wrote:
> It is less error-prone to use a different variable name from the existing
> one in a wider scope. This is also flagged by GCC (W=2):
>
> ./include/linux/kvm_host.h: In function 'search_memslots':
> ./include/linux/kvm_host.h:1246:7: warning: declaration of 'slot' shadows a previous local [-Wshadow]
> 1246 | int slot = start + (end - start) / 2;
> | ^~~~
> ./include/linux/kvm_host.h:1240:26: note: shadowed declaration is here
> 1240 | struct kvm_memory_slot *slot;
> | ^~~~
>
> Signed-off-by: Qian Cai <quic_qiancai@xxxxxxxxxxx>
> ---

Reviewed-by: Sean Christopherson <seanjc@xxxxxxxxxx>