[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] [v2] x86: apic: avoid -Wshadow warning in header



On Thu, Oct 29, 2020 at 03:05:31PM +0000, David Laight wrote:
> From: Arnd Bergmann
> > Sent: 28 October 2020 21:21
> > 
> > From: Arnd Bergmann <arnd@xxxxxxxx>
> > 
> > There are hundreds of warnings in a W=2 build about a local
> > variable shadowing the global 'apic' definition:
> > 
> > arch/x86/kvm/lapic.h:149:65: warning: declaration of 'apic' shadows a 
> > global declaration [-Wshadow]
> > 
> > Avoid this by renaming the global 'apic' variable to the more descriptive
> > 'x86_system_apic'. It was originally called 'genapic', but both that
> > and the current 'apic' seem to be a little overly generic for a global
> > variable.
> > 
> > Fixes: c48f14966cc4 ("KVM: inline kvm_apic_present() and 
> > kvm_lapic_enabled()")
> > Fixes: c8d46cf06dc2 ("x86: rename 'genapic' to 'apic'")
> > Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
> > ---
> > v2: rename the global instead of the local variable in the header
> ...
> > diff --git a/arch/x86/hyperv/hv_apic.c b/arch/x86/hyperv/hv_apic.c
> > index 284e73661a18..33e2dc78ca11 100644
> > --- a/arch/x86/hyperv/hv_apic.c
> > +++ b/arch/x86/hyperv/hv_apic.c
> > @@ -259,14 +259,14 @@ void __init hv_apic_init(void)
> >             /*
> >              * Set the IPI entry points.
> >              */
> > -           orig_apic = *apic;
> > -
> > -           apic->send_IPI = hv_send_ipi;
> > -           apic->send_IPI_mask = hv_send_ipi_mask;
> > -           apic->send_IPI_mask_allbutself = hv_send_ipi_mask_allbutself;
> > -           apic->send_IPI_allbutself = hv_send_ipi_allbutself;
> > -           apic->send_IPI_all = hv_send_ipi_all;
> > -           apic->send_IPI_self = hv_send_ipi_self;
> > +           orig_apic = *x86_system_apic;
> > +
> > +           x86_system_apic->send_IPI = hv_send_ipi;
> > +           x86_system_apic->send_IPI_mask = hv_send_ipi_mask;
> > +           x86_system_apic->send_IPI_mask_allbutself = 
> > hv_send_ipi_mask_allbutself;
> > +           x86_system_apic->send_IPI_allbutself = hv_send_ipi_allbutself;
> > +           x86_system_apic->send_IPI_all = hv_send_ipi_all;
> > +           x86_system_apic->send_IPI_self = hv_send_ipi_self;
> >     }
> > 
> >     if (ms_hyperv.hints & HV_X64_APIC_ACCESS_RECOMMENDED) {
> > @@ -285,10 +285,10 @@ void __init hv_apic_init(void)
> >              */
> >             apic_set_eoi_write(hv_apic_eoi_write);
> >             if (!x2apic_enabled()) {
> > -                   apic->read      = hv_apic_read;
> > -                   apic->write     = hv_apic_write;
> > -                   apic->icr_write = hv_apic_icr_write;
> > -                   apic->icr_read  = hv_apic_icr_read;
> > +                   x86_system_apic->read      = hv_apic_read;
> > +                   x86_system_apic->write     = hv_apic_write;
> > +                   x86_system_apic->icr_write = hv_apic_icr_write;
> > +                   x86_system_apic->icr_read  = hv_apic_icr_read;
> >             }
> 
> For those two just add:
>       struct apic *apic = x86_system_apic;
> before all the assignments.
> Less churn and much better code.
> 

Why would it be better code?



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.