KVM: s390: use ARRAY_SIZE instead of division operation
PATCH 1/1 KVM: s390: use ARRAY_SIZE instead of division operation
This eliminates the following coccicheck warning:
./arch/s390/tools/gen_facilities.c:154:37-38: WARNING: Use ARRAY_SIZE ./arch/s390/tools/gen_opcode_table.c:141:39-40: WARNING: Use ARRAY_SIZE
--- arch/s390/tools/gen_facilities.c | 2 +- arch/s390/tools/gen_opcode_table.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
arch/s390/tools/gen_facilities.c +1 -1
@@ -151,7 +151,7 @@ static void print_facility_lists(void) {unsigned int i; -for (i =0 ; i <sizeof (facility_defs) /sizeof (facility_defs[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (facility_defs); i++)print_facility_list (&facility_defs[i]); }
arch/s390/tools/gen_opcode_table.c +1 -1
@@ -138,7 +138,7 @@ static struct insn_type *insn_format_to_type(char *format)strcpy (tmp, format); base_format = tmp; base_format =strsep (&base_format,"_" ); -for (i =0 ; i <sizeof (insn_type_table) /sizeof (insn_type_table[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (insn_type_table); i++) { ptr = insn_type_table[i].format;while (*ptr) {if (!strcmp (base_format, *ptr))
Signature · 1 line
1.8.3.1
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Yang,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on s390/features]
[also build test ERROR on v5.11 next-20210219]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Yang-Li/KVM-s390-use-ARRAY_SIZE-instead-of-division-operation/20210220-162731 base: https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features config: s390-randconfig-c003-20210220 (attached as .config) compiler: s390-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ce79423dfac31c407de75ffe6d6da451d633f3d3
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yang-Li/KVM-s390-use-ARRAY_SIZE-instead-of-division-operation/20210220-162731 git checkout ce79423dfac31c407de75ffe6d6da451d633f3d3
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=s390
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
arch/s390/tools/gen_facilities.c: In function 'print_facility_lists':
>> arch/s390/tools/gen_facilities.c:154:18: warning: implicit declaration of function 'ARRAY_SIZE' [-Wimplicit-function-declaration]
for (i = 0; i < ARRAY_SIZE(facility_defs); i++)
^~~~~~~~~~
/usr/bin/ld: /tmp/ccZg6NYL.o: in function `main':
>> gen_facilities.c:(.text.startup+0x8a): undefined reference to `ARRAY_SIZE'
collect2: error: ld returned 1 exit status
--
arch/s390/tools/gen_opcode_table.c: In function 'insn_format_to_type':
>> arch/s390/tools/gen_opcode_table.c:141:18: warning: implicit declaration of function 'ARRAY_SIZE' [-Wimplicit-function-declaration]
for (i = 0; i < ARRAY_SIZE(insn_type_table); i++) {
^~~~~~~~~~
/usr/bin/ld: /tmp/ccK5Yn5L.o: in function `main':
>> gen_opcode_table.c:(.text.startup+0xa1): undefined reference to `ARRAY_SIZE'
collect2: error: ld returned 1 exit status
--
arch/s390/tools/gen_opcode_table.c: In function 'insn_format_to_type':
>> arch/s390/tools/gen_opcode_table.c:141:18: warning: implicit declaration of function 'ARRAY_SIZE' [-Wimplicit-function-declaration]
for (i = 0; i < ARRAY_SIZE(insn_type_table); i++) {
^~~~~~~~~~
arch/s390/tools/gen_facilities.c: In function 'print_facility_lists':
>> arch/s390/tools/gen_facilities.c:154:18: warning: implicit declaration of function 'ARRAY_SIZE' [-Wimplicit-function-declaration]
for (i = 0; i < ARRAY_SIZE(facility_defs); i++)
^~~~~~~~~~
/usr/bin/ld: /tmp/ccxTOhkE.o: in function `main':
>> gen_facilities.c:(.text.startup+0x8a): undefined reference to `ARRAY_SIZE'
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:95: arch/s390/tools/gen_facilities] Error 1
/usr/bin/ld: /tmp/cchswEND.o: in function `main':
>> gen_opcode_table.c:(.text.startup+0xa1): undefined reference to `ARRAY_SIZE' collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:95: arch/s390/tools/gen_opcode_table] Error 1 make[2]: Target 'kapi' not remade because of errors.
make[1]: *** [arch/s390/Makefile:170: archprepare] Error 2
make[1]: Target 'modules_prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'modules_prepare' not remade because of errors.
--
arch/s390/tools/gen_facilities.c: In function 'print_facility_lists':
>> arch/s390/tools/gen_facilities.c:154:18: warning: implicit declaration of function 'ARRAY_SIZE' [-Wimplicit-function-declaration]
for (i = 0; i < ARRAY_SIZE(facility_defs); i++)
^~~~~~~~~~
arch/s390/tools/gen_opcode_table.c: In function 'insn_format_to_type':
>> arch/s390/tools/gen_opcode_table.c:141:18: warning: implicit declaration of function 'ARRAY_SIZE' [-Wimplicit-function-declaration]
for (i = 0; i < ARRAY_SIZE(insn_type_table); i++) {
^~~~~~~~~~
/usr/bin/ld: /tmp/ccMuoSEP.o: in function `main':
>> gen_facilities.c:(.text.startup+0x8a): undefined reference to `ARRAY_SIZE'
collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:95: arch/s390/tools/gen_facilities] Error 1
/usr/bin/ld: /tmp/ccQtRcUO.o: in function `main':
>> gen_opcode_table.c:(.text.startup+0xa1): undefined reference to `ARRAY_SIZE' collect2: error: ld returned 1 exit status
make[2]: *** [scripts/Makefile.host:95: arch/s390/tools/gen_opcode_table] Error 1 make[2]: Target 'kapi' not remade because of errors.
make[1]: *** [arch/s390/Makefile:170: archprepare] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:185: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Heiko Carstens
maintainerQuoted 29 lines · Yang Li
This eliminates the following coccicheck warning:
./arch/s390/tools/gen_facilities.c:154:37-38: WARNING: UseARRAY_SIZE./arch/s390/tools/gen_opcode_table.c:141:39-40: WARNING: UseARRAY_SIZEReported-by Abaci Robot <[email protected]>Signed-off-by Yang Li <[email protected]>--- arch/s390/tools/gen_facilities.c | 2 +- arch/s390/tools/gen_opcode_table.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)arch/s390/tools/gen_facilities.c +1
-1@@ -151,7 +151,7 @@ static void print_facility_lists(void) {unsigned int i; -for (i =0 ; i <sizeof (facility_defs) /sizeof (facility_defs[0 ]); i++) +for (i =0 ; i <ARRAY_SIZE (facility_defs); i++)print_facility_list (&facility_defs[i]); }arch/s390/tools/gen_opcode_table.c +0
-0
arch/s390/tools/gen_opcode_table.c static struct insn_type *insn_format_to_type(char *format) · line 141
Quoted 5 lines
arch/s390/tools/gen_opcode_table.c +1
-1@@ -138,7 +138,7 @@ static struct insn_type *insn_format_to_type(char *format)strcpy (tmp, format); base_format = tmp; base_format =strsep (&base_format,"_" ); -for (i =0 ; i <sizeof (insn_type_table) /sizeof (insn_type_table[0 ]); i++) { +for (i =0 ; i <ARRAY_SIZE (insn_type_table); i++) {
There is a reason why this doesn't use ARRAY_SIZE()... Please stop sending trivial patches without even looking at the code.