Re: [PATCH v4 01/21] nvmem: Mark nvmem_type_str array with __maybe_unused
From: Joe Perches
Date: Wed Nov 28 2018 - 19:10:23 EST
On Wed, 2018-11-28 at 21:05 +0200, Andy Shevchenko wrote:
> Since we put static variable to a header file it's copied to each module
> that includes the header. But not all of them are actually using it.
>
> Mark nvmem_type_str array with __maybe_unused to make a compiler happy:
>
> In file included from include/linux/rtc.h:18,
> from drivers/rtc/rtc-proc.c:15:
> include/linux/nvmem-provider.h:29:27: warning: ânvmem_type_strâ defined but not used [-Wunused-const-variable=]
> static const char * const nvmem_type_str[] = {
It would be better to move this definition into
the one file that seems to use it.
$ git grep -w nvmem_type_str
drivers/nvmem/core.c: return sprintf(buf, "%s\n", nvmem_type_str[nvmem->type])
include/linux/nvmem-provider.h:static const char * const nvmem_type_str[] = {