lib: typecheck: initialize const variable to avoid Clang warning
PATCH 1/1 lib: typecheck: initialize const variable to avoid Clang warning
Building the kernel with newer Clang versions triggers -Wdefault-const-init-var-unsafe in the typecheck() macro:
error: default initialization of an object of type 'const unsigned long' leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
The warning originates from the following declaration in typecheck():
typeof(x) __dummy2;
When 'x' has a const-qualified type (e.g. 'const unsigned long'), Clang warns that the variable is declared const but not initialized. With -Werror enabled this causes the build to fail.
Initialize the temporary variable to zero to silence the warning:
typeof(x) __dummy2 = (typeof(x))0;
This variable is only used for compile-time type checking and its value is never read, so the initialization has no functional impact on the generated code.
--- include/linux/typecheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/typecheck.h +1 -1
@@ -8,7 +8,7 @@*/ #define typecheck (type,x) \ ({ type __dummy; \ - typeof(x) __dummy2; \ + typeof(x) __dummy2 = (typeof(x))0; \ (void)(&__dummy == &__dummy2); \ 1; \ })
Signature · 1 line
2.53.0
kernel test robot
build botkernel test robot noticed the following build errors:
Hi hamjin,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.0-rc3 next-20260313]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/hamjin/lib-typecheck-initialize-const-variable-to-avoid-Clang-warning/20260315-165617 base: linus/master patch link: https://lore.kernel.org/r/tencent_274FD06231C70768C2C28FD13673A24C2B08%40qq.com patch subject: [PATCH] lib: typecheck: initialize const variable to avoid Clang warning config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20260315/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260315/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/bitops.h:7,
from include/linux/log2.h:12,
from include/asm-generic/getorder.h:8,
from arch/x86/include/asm/page.h:84,
from arch/x86/include/asm/processor.h:20,
from include/linux/sched.h:13,
from include/linux/ratelimit.h:6,
from include/linux/dev_printk.h:16,
from include/linux/device.h:15,
from include/linux/dma-mapping.h:5,
from drivers/net/wireless/ralink/rt2x00/rt2x00mmio.c:13:
drivers/net/wireless/ralink/rt2x00/rt2x00mmio.c: In function 'rt2x00mmio_regbusy_read':
>> drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:254:33: error: conversion to non-scalar type requested
254 | GET_FIELD(__reg, struct rt2x00_field32, __field)
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:10:9: note: in definition of macro 'typecheck'
10 | ({ type __dummy; \
| ^~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:254:9: note: in expansion of macro 'GET_FIELD'
254 | GET_FIELD(__reg, struct rt2x00_field32, __field)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00mmio.c:36:22: note: in expansion of macro 'rt2x00_get_field32'
36 | if (!rt2x00_get_field32(*reg, field))
| ^~~~~~~~~~~~~~~~~~
--
In file included from include/linux/bitops.h:7,
from include/linux/kernel.h:23,
from drivers/net/wireless/ralink/rt2x00/rt2x00usb.c:14:
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c: In function 'rt2x00usb_regbusy_read':
>> drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:254:33: error: conversion to non-scalar type requested
254 | GET_FIELD(__reg, struct rt2x00_field32, __field)
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:10:9: note: in definition of macro 'typecheck'
10 | ({ type __dummy; \
| ^~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:254:9: note: in expansion of macro 'GET_FIELD'
254 | GET_FIELD(__reg, struct rt2x00_field32, __field)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00usb.c:157:22: note: in expansion of macro 'rt2x00_get_field32'
157 | if (!rt2x00_get_field32(*reg, field))
| ^~~~~~~~~~~~~~~~~~
--
2173 | rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_CTRL, gf40_mode);
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:1539:41: note: in expansion of macro 'FIELD32'
1539 | #define GF40_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2173:34: note: in expansion of macro 'GF40_PROT_CFG_PROTECT_CTRL'
2173 | rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_CTRL, gf40_mode);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_config_erp':
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2184:17: note: in expansion of macro 'rt2x00_set_field32'
2184 | rt2x00_set_field32(®, AUTO_RSP_CFG_AR_PREAMBLE,
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:1790:41: note: in expansion of macro 'FIELD32'
1790 | #define AUTO_RSP_CFG_AR_PREAMBLE FIELD32(0x00000010)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2184:42: note: in expansion of macro 'AUTO_RSP_CFG_AR_PREAMBLE'
2184 | rt2x00_set_field32(®, AUTO_RSP_CFG_AR_PREAMBLE,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2191:17: note: in expansion of macro 'rt2x00_set_field32'
2191 | rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_CTRL,
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:1475:41: note: in expansion of macro 'FIELD32'
1475 | #define OFDM_PROT_CFG_PROTECT_CTRL FIELD32(0x00030000)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2191:42: note: in expansion of macro 'OFDM_PROT_CFG_PROTECT_CTRL'
2191 | rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_CTRL,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2204:17: note: in expansion of macro 'rt2x00_set_field32'
2204 | rt2x00_set_field32(®, BKOFF_SLOT_CFG_SLOT_TIME,
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:918:41: note: in expansion of macro 'FIELD32'
918 | #define BKOFF_SLOT_CFG_SLOT_TIME FIELD32(0x000000ff)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2204:42: note: in expansion of macro 'BKOFF_SLOT_CFG_SLOT_TIME'
2204 | rt2x00_set_field32(®, BKOFF_SLOT_CFG_SLOT_TIME,
| ^~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2209:17: note: in expansion of macro 'rt2x00_set_field32'
2209 | rt2x00_set_field32(®, XIFS_TIME_CFG_EIFS, erp->eifs);
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:911:41: note: in expansion of macro 'FIELD32'
911 | #define XIFS_TIME_CFG_EIFS FIELD32(0x1ff00000)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2209:42: note: in expansion of macro 'XIFS_TIME_CFG_EIFS'
2209 | rt2x00_set_field32(®, XIFS_TIME_CFG_EIFS, erp->eifs);
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2215:17: note: in expansion of macro 'rt2x00_set_field32'
2215 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL,
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:958:41: note: in expansion of macro 'FIELD32'
958 | #define BCN_TIME_CFG_BEACON_INTERVAL FIELD32(0x0000ffff)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2215:42: note: in expansion of macro 'BCN_TIME_CFG_BEACON_INTERVAL'
2215 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_wait_bbp_rf_ready':
>> drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:254:33: error: conversion to non-scalar type requested
254 | GET_FIELD(__reg, struct rt2x00_field32, __field)
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:10:9: note: in definition of macro 'typecheck'
10 | ({ type __dummy; \
| ^~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:254:9: note: in expansion of macro 'GET_FIELD'
254 | GET_FIELD(__reg, struct rt2x00_field32, __field)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2233:22: note: in expansion of macro 'rt2x00_get_field32'
2233 | if (!rt2x00_get_field32(reg, mask))
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c: In function 'rt2800_config_3572bt_ant':
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2275:17: note: in expansion of macro 'rt2x00_set_field32'
2275 | rt2x00_set_field32(®, GPIO_SWITCH_0, 1);
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:697:41: note: in expansion of macro 'FIELD32'
697 | #define GPIO_SWITCH_0 FIELD32(0x00000001)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2275:42: note: in expansion of macro 'GPIO_SWITCH_0'
2275 | rt2x00_set_field32(®, GPIO_SWITCH_0, 1);
| ^~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2276:17: note: in expansion of macro 'rt2x00_set_field32'
2276 | rt2x00_set_field32(®, GPIO_SWITCH_1, 1);
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:698:41: note: in expansion of macro 'FIELD32'
698 | #define GPIO_SWITCH_1 FIELD32(0x00000002)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2276:42: note: in expansion of macro 'GPIO_SWITCH_1'
2276 | rt2x00_set_field32(®, GPIO_SWITCH_1, 1);
| ^~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2278:17: note: in expansion of macro 'rt2x00_set_field32'
2278 | rt2x00_set_field32(®, GPIO_SWITCH_0, 0);
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:697:41: note: in expansion of macro 'FIELD32'
697 | #define GPIO_SWITCH_0 FIELD32(0x00000001)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2278:42: note: in expansion of macro 'GPIO_SWITCH_0'
2278 | rt2x00_set_field32(®, GPIO_SWITCH_0, 0);
| ^~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:252:9: note: in expansion of macro 'SET_FIELD'
252 | SET_FIELD(__reg, struct rt2x00_field32, __field, __value)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2279:17: note: in expansion of macro 'rt2x00_set_field32'
2279 | rt2x00_set_field32(®, GPIO_SWITCH_1, 0);
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:698:41: note: in expansion of macro 'FIELD32'
698 | #define GPIO_SWITCH_1 FIELD32(0x00000002)
| ^~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2279:42: note: in expansion of macro 'GPIO_SWITCH_1'
2279 | rt2x00_set_field32(®, GPIO_SWITCH_1, 0);
| ^~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:230:17: error: conversion to non-scalar type requested
230 | (struct rt2x00_field32) { \
| ^~~~~~~~~~~~~~
include/linux/typecheck.h:11:38: note: in definition of macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^
drivers/net/wireless/ralink/rt2x00/rt2x00reg.h:254:9: note: in expansion of macro 'GET_FIELD'
254 | GET_FIELD(__reg, struct rt2x00_field32, __field)
| ^~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2284:22: note: in expansion of macro 'rt2x00_get_field32'
2284 | led_g_mode = rt2x00_get_field32(reg, LED_CFG_LED_POLAR) ? 3 : 0;
| ^~~~~~~~~~~~~~~~~~
drivers/net/wireless/ralink/rt2x00/rt2800.h:871:41: note: in expansion of macro 'FIELD32'
871 | #define LED_CFG_LED_POLAR FIELD32(0x40000000)
| ^~~~~~~ drivers/net/wireless/ralink/rt2x00/rt2800lib.c:2284:46: note: in expansion of macro 'LED_CFG_LED_POLAR'
vim +254 drivers/net/wireless/ralink/rt2x00/rt2x00reg.h
c483bb4cbdeb24 drivers/net/wireless/rt2x00/rt2x00reg.h Ivo van Doorn 2008-06-03 250 c483bb4cbdeb24 drivers/net/wireless/rt2x00/rt2x00reg.h Ivo van Doorn 2008-06-03 251 #define rt2x00_set_field32(__reg, __field, __value) \ c483bb4cbdeb24 drivers/net/wireless/rt2x00/rt2x00reg.h Ivo van Doorn 2008-06-03 252 SET_FIELD(__reg, struct rt2x00_field32, __field, __value) c483bb4cbdeb24 drivers/net/wireless/rt2x00/rt2x00reg.h Ivo van Doorn 2008-06-03 253 #define rt2x00_get_field32(__reg, __field) \
c483bb4cbdeb24 drivers/net/wireless/rt2x00/rt2x00reg.h Ivo van Doorn 2008-06-03 @254 GET_FIELD(__reg, struct rt2x00_field32, __field)c483bb4cbdeb24 drivers/net/wireless/rt2x00/rt2x00reg.h Ivo van Doorn 2008-06-03 255
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi hamjin,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.0-rc5 next-20260324]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/hamjin/lib-typecheck-initialize-const-variable-to-avoid-Clang-warning/20260315-165617 base: linus/master patch link: https://lore.kernel.org/r/tencent_274FD06231C70768C2C28FD13673A24C2B08%40qq.com patch subject: [PATCH] lib: typecheck: initialize const variable to avoid Clang warning config: s390-allnoconfig (https://download.01.org/0day-ci/archive/20260325/[email protected]/config) compiler: clang version 23.0.0git (https://github.com/llvm/llvm-project 054e11d1a17e5ba88bb1a8ef32fad3346e80b186) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260325/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from arch/s390/kernel/asm-offsets.c:10:
In file included from include/linux/sched.h:12:
In file included from arch/s390/include/asm/current.h:13:
In file included from arch/s390/include/asm/lowcore.h:14:
>> arch/s390/include/asm/ptrace.h:224:9: error: used type 'typeof (regs->psw)' (aka 'const psw_t') where arithmetic or pointer type is required
224 | return psw_bits(regs->psw).pstate;
| ^~~~~~~~~~~~~~~~~~~
arch/s390/include/asm/ptrace.h:98:2: note: expanded from macro 'psw_bits'
98 | typecheck(psw_t, __psw); \
| ^~~~~~~~~~~~~~~~~~~~~~~
include/linux/typecheck.h:11:23: note: expanded from macro 'typecheck'
11 | typeof(x) __dummy2 = (typeof(x))0; \
| ^ ~
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
98 | return (set->sig[3] | set->sig[2] |
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
99 | set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds]
101 | return (set->sig[1] | set->sig[0]) == 0;
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:114:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
114 | return (set1->sig[3] == set2->sig[3]) &&
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:115:5: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
115 | (set1->sig[2] == set2->sig[2]) &&
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:115:21: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
115 | (set1->sig[2] == set2->sig[2]) &&
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^
In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
In file included from include/linux/ptrace.h:7:
In file included from include/linux/sched/signal.h:6:
include/linux/signal.h:116:5: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds]
116 | (set1->sig[1] == set2->sig[1]) &&
| ^ ~
arch/s390/include/asm/signal.h:22:9: note: array 'sig' declared here
22 | unsigned long sig[_NSIG_WORDS];
| ^ In file included from arch/s390/kernel/asm-offsets.c:15:
In file included from arch/s390/include/asm/stacktrace.h:7:
vim +224 arch/s390/include/asm/ptrace.h
952974ac61f686 Heiko Carstens 2010-02-12 221
afa8fa52a42c31 Jens Remus 2025-12-11 222 static __always_inline bool user_mode(const struct pt_regs *regs)
afa8fa52a42c31 Jens Remus 2025-12-11 223 {
afa8fa52a42c31 Jens Remus 2025-12-11 @224 return psw_bits(regs->psw).pstate;
afa8fa52a42c31 Jens Remus 2025-12-11 225 }
afa8fa52a42c31 Jens Remus 2025-12-11 226 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi hamjin,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v7.0-rc5 next-20260324]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/hamjin/lib-typecheck-initialize-const-variable-to-avoid-Clang-warning/20260315-165617 base: linus/master patch link: https://lore.kernel.org/r/tencent_274FD06231C70768C2C28FD13673A24C2B08%40qq.com patch subject: [PATCH] lib: typecheck: initialize const variable to avoid Clang warning config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20260325/[email protected]/config) compiler: s390-linux-gcc (GCC) 15.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260325/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from arch/s390/include/asm/lowcore.h:14,
from arch/s390/include/asm/current.h:13,
from include/linux/sched.h:12,
from arch/s390/kernel/asm-offsets.c:10:
arch/s390/include/asm/ptrace.h: In function 'user_mode':
>> arch/s390/include/asm/ptrace.h:224:9: error: conversion to non-scalar type requested
224 | return psw_bits(regs->psw).pstate;
| ^~~~~~ make[3]: *** [scripts/Makefile.build:184: arch/s390/kernel/asm-offsets.s] Error 1 make[3]: Target 'prepare' not remade because of errors.
make[2]: *** [Makefile:1337: prepare0] Error 2
make[2]: Target 'prepare' not remade because of errors.
make[1]: *** [Makefile:248: __sub-make] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2
make: Target 'prepare' not remade because of errors.
vim +224 arch/s390/include/asm/ptrace.h
952974ac61f686 Heiko Carstens 2010-02-12 221
afa8fa52a42c31 Jens Remus 2025-12-11 222 static __always_inline bool user_mode(const struct pt_regs *regs)
afa8fa52a42c31 Jens Remus 2025-12-11 223 {
afa8fa52a42c31 Jens Remus 2025-12-11 @224 return psw_bits(regs->psw).pstate;
afa8fa52a42c31 Jens Remus 2025-12-11 225 }
afa8fa52a42c31 Jens Remus 2025-12-11 226 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 44 lines · hamjin
Building the kernel with newer Clang versions triggers -Wdefault-const-init-var-unsafe in the
typecheck()macro:error: default initialization of an object of type 'const unsigned long' leaves the object uninitialized [-Wdefault-const-init-var-unsafe]
The warning originates from the following declaration in
typecheck():typeof(x) __dummy2;When 'x' has a const-qualified type (e.g. 'const unsigned long'), Clang warns that the variable is declared const but not initialized. With -Werror enabled this causes the build to fail.
Initialize the temporary variable to zero to silence the warning:
typeof(x) __dummy2 = (typeof(x))0;This variable is only used for compile-time type checking and its value is never read, so the initialization has no functional impact on the generated code.
Fixes e0deaff47090 ("split the typecheck macros out of include/linux/kernel.h")Signed-off-by hamjin <[email protected]>--- include/linux/typecheck.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/typecheck.h +1
-1@@ -8,7 +8,7 @@*/ #define typecheck (type,x) \ ({ type __dummy; \ - typeof(x) __dummy2; \ + typeof(x) __dummy2 = (typeof(x))0; \ (void)(&__dummy == &__dummy2); \ 1; \ })Signature · 1 line
2.53.0
As you can see from the build reports, this does not work. Are you missing commit d0afcfeb9e38 ("kbuild: Disable -Wdefault-const-init-unsafe") in your tree? Or does this appear in somewhere that uses its own KBUILD_CFLAGS, in which case a fix like
5ba35a6c13ff ("s390/boot: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS") b4780fe4ddf0 ("s390/purgatory: Add -Wno-default-const-init-unsafe to KBUILD_CFLAGS")
will be needed? I do not see any instances of this warning in Linus's tree unless I am missing some configuration in my build tests.
Cheers,
Nathan