Re: [PATCH 11/11] MIPS: Declare various variables & functions static

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

 



Hi Marcin,

On Tuesday, 29 August 2017 03:05:55 PDT Marcin Nowakowski wrote:
> On 23.08.2017 20:17, Paul Burton wrote:
> > We currently have various variables & functions which are only used
> > within a single translation unit, but which we don't declare static.
> > 
> > This causes various sparse warnings of the form:
> >    arch/mips/kernel/mips-r2-to-r6-emul.c:49:1: warning: symbol
> >    
> >      'mipsr2emustats' was not declared. Should it be static?
> >    
> >    arch/mips/kernel/unaligned.c:1381:11: warning: symbol 'reg16to32st'
> >    
> >      was not declared. Should it be static?
> >    
> >    arch/mips/mm/mmap.c:146:15: warning: symbol 'arch_mmap_rnd' was not
> >    
> >      declared. Should it be static?
> > 
> > Fix these & others by declaring various affected variables & functions
> > static, avoiding the sparse warnings & redundant symbols.
> > 
> > Signed-off-by: Paul Burton <paul.burton@xxxxxxxxxx>
> > Cc: Ralf Baechle <ralf@xxxxxxxxxxxxxx>
> > Cc: linux-mips@xxxxxxxxxxxxxx
> > 
> > ---
> > 
> >   arch/mips/kernel/cpu-probe.c          | 2 +-
> >   arch/mips/kernel/mips-r2-to-r6-emul.c | 6 +++---
> >   arch/mips/kernel/pm-cps.c             | 2 +-
> >   arch/mips/kernel/unaligned.c          | 2 +-
> >   arch/mips/mm/dma-default.c            | 4 ++--
> >   5 files changed, 8 insertions(+), 8 deletions(-)
> > 
> > diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c
> > b/arch/mips/kernel/mips-r2-to-r6-emul.c index ae64c8f56a8c..ac23b4f09f02
> > 100644
> > --- a/arch/mips/kernel/mips-r2-to-r6-emul.c
> > +++ b/arch/mips/kernel/mips-r2-to-r6-emul.c
> > @@ -46,9 +46,9 @@
> > 
> >   #define LL	"ll "
> >   #define SC	"sc "
> > 
> > -DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2emustats);
> > -DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2bdemustats);
> > -DEFINE_PER_CPU(struct mips_r2br_emulator_stats, mipsr2bremustats);
> > +static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2emustats);
> > +static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2bdemustats);
> > +static DEFINE_PER_CPU(struct mips_r2br_emulator_stats, mipsr2bremustats);
> 
> This leads to the following:
> ../arch/mips/kernel/mips-r2-to-r6-emul.c:51:56: error:
> ‘mipsr2bremustats’ defined but not used [-Werror=unused-variable]
>   static DEFINE_PER_CPU(struct mips_r2br_emulator_stats, mipsr2bremustats);
>                                                          ^
> ../include/linux/percpu-defs.h:105:19: note: in definition of macro
> ‘DEFINE_PER_CPU_SECTION’
>    __typeof__(type) name
>                     ^~~~
> ../arch/mips/kernel/mips-r2-to-r6-emul.c:51:8: note: in expansion of
> macro ‘DEFINE_PER_CPU’
>   static DEFINE_PER_CPU(struct mips_r2br_emulator_stats, mipsr2bremustats);
>          ^~~~~~~~~~~~~~
> ../arch/mips/kernel/mips-r2-to-r6-emul.c:50:54: error:
> ‘mipsr2bdemustats’ defined but not used [-Werror=unused-variable]
>   static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2bdemustats);
>                                                        ^
> ../include/linux/percpu-defs.h:105:19: note: in definition of macro
> ‘DEFINE_PER_CPU_SECTION’
>    __typeof__(type) name
>                     ^~~~
> ../arch/mips/kernel/mips-r2-to-r6-emul.c:50:8: note: in expansion of
> macro ‘DEFINE_PER_CPU’
>   static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2bdemustats);
>          ^~~~~~~~~~~~~~
> ../arch/mips/kernel/mips-r2-to-r6-emul.c:49:54: error: ‘mipsr2emustats’
> defined but not used [-Werror=unused-variable]
>   static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2emustats);
>                                                        ^
> ../include/linux/percpu-defs.h:105:19: note: in definition of macro
> ‘DEFINE_PER_CPU_SECTION’
>    __typeof__(type) name
>                     ^~~~
> ../arch/mips/kernel/mips-r2-to-r6-emul.c:49:8: note: in expansion of
> macro ‘DEFINE_PER_CPU’
>   static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2emustats);
> 
> 
> when CONFIG_DEBUG_FS=n (eg. malta_qemu_32r6_defconfig)
> 
> Since these are not used without DEBUG_FS then I guess the following
> patch should be ok:
> 
> diff --git a/arch/mips/kernel/mips-r2-to-r6-emul.c
> b/arch/mips/kernel/mips-r2-to-r6-emul.c
> index 3bd721c..eb18b18 100644
> --- a/arch/mips/kernel/mips-r2-to-r6-emul.c
> +++ b/arch/mips/kernel/mips-r2-to-r6-emul.c
> @@ -46,9 +46,11 @@
>   #define LL     "ll "
>   #define SC     "sc "
> 
> +#ifdef CONFIG_DEBUG_FS
>   static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2emustats);
>   static DEFINE_PER_CPU(struct mips_r2_emulator_stats, mipsr2bdemustats);
>   static DEFINE_PER_CPU(struct mips_r2br_emulator_stats, mipsr2bremustats);
> +#endif
> 
> if you're OK with it then I guess it may be best for Ralf to fold this
> change into your patch?

D'oh! That looks like a reasonable fix to me - could you fold it in Ralf?

Thanks,
    Paul

Attachment: signature.asc
Description: This is a digitally signed message part.


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux