Re: [char-misc:char-misc-next 12/23] drivers/counter/ti-ecap-capture.c:380:8: sparse: sparse: symbol 'ecap_cnt_pol_array' was not declared. Should it be static?

From: William Breathitt Gray
Date: Sat Oct 01 2022 - 20:05:02 EST


On Sun, Oct 02, 2022 at 07:04:27AM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-next
> head: 7cd04013fbf3e6dcb67ca6b59aa813269a2ad9ce
> commit: 4e2f42aa00b67605938173a61d07a44fe13bad68 [12/23] counter: ti-ecap-capture: capture driver support for ECAP
> config: parisc-randconfig-s041-20221002
> compiler: hppa-linux-gcc (GCC) 12.1.0
> reproduce:
> wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> # apt-get install sparse
> # sparse version: v0.6.4-39-gce1a6720-dirty
> # https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git/commit/?id=4e2f42aa00b67605938173a61d07a44fe13bad68
> git remote add char-misc https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
> git fetch --no-tags char-misc char-misc-next
> git checkout 4e2f42aa00b67605938173a61d07a44fe13bad68
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=parisc SHELL=/bin/bash drivers/counter/
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@xxxxxxxxx>
>
> sparse warnings: (new ones prefixed by >>)
> >> drivers/counter/ti-ecap-capture.c:380:8: sparse: sparse: symbol 'ecap_cnt_pol_array' was not declared. Should it be static?
>
> vim +/ecap_cnt_pol_array +380 drivers/counter/ti-ecap-capture.c
>
> 379
> > 380 static DEFINE_COUNTER_ARRAY_POLARITY(ecap_cnt_pol_array, ecap_cnt_pol_avail, ECAP_NB_CEVT);
> 381
>
> --
> 0-DAY CI Kernel Test Service
> https://01.org/lkp

The first argument to the DEFINE_COUNTER_ARRAY_POLARITY() macro is a
token serving as the symbol name in the definition of a new
struct counter_array structure. However, this macro actually expands to
two statements:

#define DEFINE_COUNTER_ARRAY_POLARITY(_name, _enums, _length) \
DEFINE_COUNTER_AVAILABLE(_name##_available, _enums); \
struct counter_array _name = { \
.type = COUNTER_COMP_SIGNAL_POLARITY, \
.avail = &(_name##_available), \
.length = (_length), \
}

Because of this, the "static" on line 380 only applies to the first
statement. It might be best to take the DEFINE_COUNTER_AVAILABLE() line
out and leave DEFINE_COUNTER_ARRAY_POLARITY() as a simple structure
definition to avoid issues like this.

I'll submit a fix tomorrow to do such.

Thanks,

William Breathitt Gray

Attachment: signature.asc
Description: PGP signature