drivers/gpu/drm/radeon/pptable.h:442:5: warning: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an e...

From: kernel test robot
Date: Mon May 27 2024 - 10:08:14 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0
commit: 781d41fed19caf900c8405064676813dc9921d32 drm/radeon: silence UBSAN warning (v3)
date: 6 weeks ago
config: riscv-defconfig (https://download.01.org/0day-ci/archive/20240527/202405272123.cPznVWDF-lkp@xxxxxxxxx/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project bafda89a0944d947fc4b3b5663185e07a397ac30)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240527/202405272123.cPznVWDF-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405272123.cPznVWDF-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from drivers/gpu/drm/radeon/radeon_device.c:30:
In file included from include/linux/efi.h:20:
In file included from include/linux/rtc.h:17:
In file included from include/linux/interrupt.h:21:
In file included from arch/riscv/include/asm/sections.h:9:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from drivers/gpu/drm/radeon/radeon_device.c:48:
In file included from drivers/gpu/drm/radeon/atom.h:165:
In file included from drivers/gpu/drm/radeon/atombios.h:7980:
>> drivers/gpu/drm/radeon/pptable.h:442:5: warning: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an error in a future compiler version [-Wbounds-safety-counted-by-elt-type-unknown-size]
442 | ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
--
In file included from drivers/gpu/drm/radeon/r100.c:31:
In file included from include/linux/pci.h:38:
In file included from include/linux/interrupt.h:21:
In file included from arch/riscv/include/asm/sections.h:9:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from drivers/gpu/drm/radeon/r100.c:42:
In file included from drivers/gpu/drm/radeon/atom.h:165:
In file included from drivers/gpu/drm/radeon/atombios.h:7980:
>> drivers/gpu/drm/radeon/pptable.h:442:5: warning: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an error in a future compiler version [-Wbounds-safety-counted-by-elt-type-unknown-size]
442 | ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/radeon/r100.c:43:10: fatal error: 'r100_reg_safe.h' file not found
43 | #include "r100_reg_safe.h"
| ^~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.
--
In file included from drivers/gpu/drm/radeon/r420.c:29:
In file included from include/linux/pci.h:38:
In file included from include/linux/interrupt.h:21:
In file included from arch/riscv/include/asm/sections.h:9:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from drivers/gpu/drm/radeon/r420.c:36:
In file included from drivers/gpu/drm/radeon/atom.h:165:
In file included from drivers/gpu/drm/radeon/atombios.h:7980:
>> drivers/gpu/drm/radeon/pptable.h:442:5: warning: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an error in a future compiler version [-Wbounds-safety-counted-by-elt-type-unknown-size]
442 | ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/radeon/r420.c:38:10: fatal error: 'r420_reg_safe.h' file not found
38 | #include "r420_reg_safe.h"
| ^~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.
--
In file included from drivers/gpu/drm/radeon/rs600.c:40:
In file included from include/linux/pci.h:38:
In file included from include/linux/interrupt.h:21:
In file included from arch/riscv/include/asm/sections.h:9:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from drivers/gpu/drm/radeon/rs600.c:47:
In file included from drivers/gpu/drm/radeon/atom.h:165:
In file included from drivers/gpu/drm/radeon/atombios.h:7980:
>> drivers/gpu/drm/radeon/pptable.h:442:5: warning: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an error in a future compiler version [-Wbounds-safety-counted-by-elt-type-unknown-size]
442 | ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/radeon/rs600.c:51:10: fatal error: 'rs600_reg_safe.h' file not found
51 | #include "rs600_reg_safe.h"
| ^~~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.
--
In file included from drivers/gpu/drm/radeon/rv515.c:33:
In file included from include/drm/drm_file.h:39:
In file included from include/drm/drm_prime.h:37:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:2208:
include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
522 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
In file included from drivers/gpu/drm/radeon/rv515.c:35:
In file included from drivers/gpu/drm/radeon/atom.h:165:
In file included from drivers/gpu/drm/radeon/atombios.h:7980:
>> drivers/gpu/drm/radeon/pptable.h:442:5: warning: 'counted_by' should not be applied to an array with element of unknown size because 'ATOM_PPLIB_STATE_V2' (aka 'struct _ATOM_PPLIB_STATE_V2') is a struct type with a flexible array member. This will be an error in a future compiler version [-Wbounds-safety-counted-by-elt-type-unknown-size]
442 | ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/gpu/drm/radeon/rv515.c:38:10: fatal error: 'rv515_reg_safe.h' file not found
38 | #include "rv515_reg_safe.h"
| ^~~~~~~~~~~~~~~~~~
2 warnings and 1 error generated.


vim +442 drivers/gpu/drm/radeon/pptable.h

437
438 typedef struct _StateArray{
439 //how many states we have
440 UCHAR ucNumEntries;
441
> 442 ATOM_PPLIB_STATE_V2 states[] __counted_by(ucNumEntries);
443 }StateArray;
444
445

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki