linux-yocto/scripts
Nathan Chancellor b0630d1845 kbuild: Disable -Wdefault-const-init-unsafe
commit d0afcfeb9e3810ec89d1ffde1a0e36621bb75dca upstream.

A new on by default warning in clang [1] aims to flags instances where
const variables without static or thread local storage or const members
in aggregate types are not initialized because it can lead to an
indeterminate value. This is quite noisy for the kernel due to
instances originating from header files such as:

  drivers/gpu/drm/i915/gt/intel_ring.h:62:2: error: default initialization of an object of type 'typeof (ring->size)' (aka 'const unsigned int') leaves the object uninitialized [-Werror,-Wdefault-const-init-var-unsafe]
     62 |         typecheck(typeof(ring->size), next);
        |         ^
  include/linux/typecheck.h:10:9: note: expanded from macro 'typecheck'
     10 | ({      type __dummy; \
        |              ^

  include/net/ip.h:478:14: error: default initialization of an object of type 'typeof (rt->dst.expires)' (aka 'const unsigned long') leaves the object uninitialized [-Werror,-Wdefault-const-init-var-unsafe]
    478 |                 if (mtu && time_before(jiffies, rt->dst.expires))
        |                            ^
  include/linux/jiffies.h:138:26: note: expanded from macro 'time_before'
    138 | #define time_before(a,b)        time_after(b,a)
        |                                 ^
  include/linux/jiffies.h:128:3: note: expanded from macro 'time_after'
    128 |         (typecheck(unsigned long, a) && \
        |          ^
  include/linux/typecheck.h:11:12: note: expanded from macro 'typecheck'
     11 |         typeof(x) __dummy2; \
        |                   ^

  include/linux/list.h:409:27: warning: default initialization of an object of type 'union (unnamed union at include/linux/list.h:409:27)' with const member leaves the object uninitialized [-Wdefault-const-init-field-unsafe]
    409 |         struct list_head *next = smp_load_acquire(&head->next);
        |                                  ^
  include/asm-generic/barrier.h:176:29: note: expanded from macro 'smp_load_acquire'
    176 | #define smp_load_acquire(p) __smp_load_acquire(p)
        |                             ^
  arch/arm64/include/asm/barrier.h:164:59: note: expanded from macro '__smp_load_acquire'
    164 |         union { __unqual_scalar_typeof(*p) __val; char __c[1]; } __u;   \
        |                                                                  ^
  include/linux/list.h:409:27: note: member '__val' declared 'const' here

  crypto/scatterwalk.c:66:22: error: default initialization of an object of type 'struct scatter_walk' with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
     66 |         struct scatter_walk walk;
        |                             ^
  include/crypto/algapi.h:112:15: note: member 'addr' declared 'const' here
    112 |                 void *const addr;
        |                             ^

  fs/hugetlbfs/inode.c:733:24: error: default initialization of an object of type 'struct vm_area_struct' with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe]
    733 |         struct vm_area_struct pseudo_vma;
        |                               ^
  include/linux/mm_types.h:803:20: note: member 'vm_flags' declared 'const' here
    803 |                 const vm_flags_t vm_flags;
        |                                  ^

Silencing the instances from typecheck.h is difficult because '= {}' is
not available in older but supported compilers and '= {0}' would cause
warnings about a literal 0 being treated as NULL. While it might be
possible to come up with a local hack to silence the warning for
clang-21+, it may not be worth it since -Wuninitialized will still
trigger if an uninitialized const variable is actually used.

In all audited cases of the "field" variant of the warning, the members
are either not used in the particular call path, modified through other
means such as memset() / memcpy() because the containing object is not
const, or are within a union with other non-const members.

Since this warning does not appear to have a high signal to noise ratio,
just disable it.

Cc: stable@vger.kernel.org
Link: 576161cb60 [1]
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Closes: https://lore.kernel.org/CA+G9fYuNjKcxFKS_MKPRuga32XbndkLGcY-PVuoSwzv6VWbY=w@mail.gmail.com/
Reported-by: Marcus Seyfarth <m.seyfarth@gmail.com>
Closes: https://github.com/ClangBuiltLinux/linux/issues/2088
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-06-19 15:28:45 +02:00
..
atomic locking/atomic: scripts: fix ${atomic}_sub_and_test() kerneldoc 2024-06-27 13:49:11 +02:00
basic kbuild: implement CONFIG_TRIM_UNUSED_KSYMS without recursion 2023-06-22 21:21:06 +09:00
clang-tools gen_compile_commands: fix invalid escape sequence warning 2024-03-26 18:19:11 -04:00
coccinelle Revert "debugfs, coccinelle: check for obsolete DEFINE_SIMPLE_ATTRIBUTE() usage" 2023-07-29 11:05:31 -04:00
dtc dt: dt-extract-compatibles: Don't follow symlinks when walking tree 2023-12-13 18:45:03 +01:00
dummy-tools kbuild: dummy-tools: make MPROFILE_KERNEL checks work on BE 2023-09-01 16:38:04 +09:00
gcc-plugins randstruct: gcc-plugin: Fix attribute addition 2025-06-19 15:28:25 +02:00
gdb scripts/gdb: fix aarch64 userspace detection in get_current_task 2025-02-17 09:40:39 +01:00
genksyms genksyms: fix memory leak when the same symbol is read from *.symref file 2025-02-08 09:52:32 +01:00
kconfig kconfig: merge_config: use an empty file as initfile 2025-06-04 14:41:53 +02:00
ksymoops
mod modpost: fix the missed iteration for the max bit in do_input() 2025-01-09 13:32:06 +01:00
package kbuild: remove stale code for 'source' symlink in packaging scripts 2023-10-01 23:06:06 +09:00
selinux selinux: Chain up tool resolving errors in install_policy.sh 2025-04-10 14:37:26 +02:00
tracing tracing: Always use canonical ftrace path 2023-02-18 14:34:09 -05:00
.gitignore rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
as-version.sh kbuild: Update assembler calls to use proper flags and language target 2023-01-26 12:41:38 +09:00
asn1_compiler.c ASN.1: Fix check for strdup() success 2023-04-21 08:58:00 -07:00
bloat-o-meter scripts/bloat-o-meter: count weak symbol sizes 2023-08-21 13:46:25 -07:00
bootgraph.pl
bpf_doc.py scripts/bpf_doc: Use silent mode when exec make cmd 2024-04-10 16:35:40 +02:00
cc-can-link.sh
cc-version.sh scripts: Remove ICC-related dead code 2023-04-24 10:18:32 -07:00
check_extable.sh
check-git kbuild: use git-archive for source package creation 2023-03-16 22:46:12 +09:00
check-sysctl-docs sysctl: Remove register_sysctl_table 2023-05-23 21:43:26 -07:00
checkdeclares.pl
checkincludes.pl
checkkconfigsymbols.py scripts: handle BrokenPipeError for python scripts 2023-01-26 12:43:33 +09:00
checkpatch.pl checkpatch: always parse orig_commit in fixes tag 2024-12-09 10:32:18 +01:00
checkstack.pl scripts/checkstack.pl: match all stack sizes for s390 2023-12-20 17:01:59 +01:00
checksyscalls.sh checksyscalls: ignore fstat to silence build warning on LoongArch 2023-03-23 17:18:32 -07:00
checkversion.pl
cleanfile
cleanpatch
coccicheck scripts: coccicheck: Use /usr/bin/env 2023-02-25 20:11:06 +01:00
config kbuild: fix argument parsing in scripts/config 2025-06-04 14:41:58 +02:00
const_structs.checkpatch const_structs.checkpatch.pl: add kobj_type 2023-02-08 13:33:29 +01:00
decode_stacktrace.sh scripts/decode_stacktrace.sh: optionally use LLVM utilities 2024-01-20 11:51:49 +01:00
decodecode scripts/decodecode: Add support for RISC-V 2023-02-21 16:53:54 -08:00
depmod.sh kbuild: move depmod rule to scripts/Makefile.modinst 2023-08-29 22:38:23 +09:00
dev-needs.sh
diffconfig scripts: handle BrokenPipeError for python scripts 2023-01-26 12:43:33 +09:00
documentation-file-ref-check
export_report.pl
extract_xc3028.pl
extract-ikconfig
extract-module-sig.pl
extract-sys-certs.pl
extract-vmlinux
faddr2line scripts/faddr2line: Fix regression in name resolution on ppc64le 2022-11-16 10:42:10 +01:00
file-size.sh
find-unused-docs.sh
gcc-x86_32-has-stack-protector.sh kbuild: Fix '-S -c' in x86 stack protector scripts 2024-08-03 08:54:24 +02:00
gcc-x86_64-has-stack-protector.sh kbuild: Fix '-S -c' in x86 stack protector scripts 2024-08-03 08:54:24 +02:00
gen-randstruct-seed.sh
generate_initcall_order.pl
generate_rust_analyzer.py scripts: generate_rust_analyzer: add missing macros deps 2025-03-22 12:50:48 -07:00
generate_rust_target.rs
get_abi.pl scripts/get_abi: fix source path leak 2024-01-31 16:18:55 -08:00
get_dvb_firmware
get_feat.pl
get_maintainer.pl
gfp-translate scripts: fix the gfp flags header path in gfp-translate 2023-06-19 13:19:32 -07:00
head-object-list.txt powerpc/64: Rename entry_64.S to prom_entry_64.S 2023-06-15 14:04:19 +10:00
headerdep.pl
headers_install.sh x86: Remove the arch_calc_vm_prot_bits() macro from the UAPI 2023-09-06 23:50:46 +02:00
insert-sys-cert.c
install.sh
jobserver-exec scripts: support GNU make 4.4 in jobserver-exec 2023-01-16 20:15:20 +09:00
kallsyms.c scripts/kallsyms: Fix build failure by setting errno before calling getline() 2023-07-29 15:57:32 +09:00
Kbuild.include kbuild: replace $(dot-target).tmp in filechk with $(tmp-target) 2023-01-22 23:43:33 +09:00
Kconfig.include x86/kconfig: Add as-instr64 macro to properly evaluate AS_WRUSS 2024-08-03 08:53:21 +02:00
kernel-doc scripts: kernel-doc: fix macro handling in enums 2023-08-18 11:14:08 -06:00
ld-version.sh kbuild: Make ld-version.sh more robust against version string changes 2024-07-18 13:21:27 +02:00
leaking_addresses.pl leaking_addresses: also skip canonical ftrace path 2023-03-29 06:52:08 -04:00
Lindent
link-vmlinux.sh kbuild: fix short log for AS in link-vmlinux.sh 2024-07-11 12:49:21 +02:00
Makefile rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
Makefile.asm-generic kbuild: add kbuild-file macro 2022-11-22 23:40:02 +09:00
Makefile.build kbuild: rust: force alloc extern to allow "empty" Rust files 2024-05-02 16:32:42 +02:00
Makefile.clang Kbuild updates for v6.5 2023-07-01 09:24:31 -07:00
Makefile.clean kbuild: make clean rule robust against too long argument error 2023-06-25 23:12:20 +09:00
Makefile.compiler kbuild: Add -Wa,--fatal-warnings to as-instr invocation 2024-03-06 14:48:41 +00:00
Makefile.debug Makefile.debug: support for -gz=zstd 2022-11-21 10:18:39 +09:00
Makefile.defconf kbuild: Provide a version of merge_into_defconfig without override warnings 2023-02-13 20:18:28 +01:00
Makefile.dtbinst kbuild: Install dtb files as 0644 in Makefile.dtbinst 2024-07-05 09:34:02 +02:00
Makefile.extrawarn kbuild: Disable -Wdefault-const-init-unsafe 2025-06-19 15:28:45 +02:00
Makefile.gcc-plugins
Makefile.headersinst
Makefile.host kbuild: rust: avoid creating temporary files 2023-07-24 03:15:31 +09:00
Makefile.kasan kasan: remove hwasan-kernel-mem-intrinsic-prefix=1 for clang-14 2023-04-18 16:29:43 -07:00
Makefile.kcov
Makefile.kcsan
Makefile.kmsan
Makefile.lib objtool: Silence more KCOV warnings, part 2 2025-05-02 07:51:04 +02:00
Makefile.modfinal kbuild: Disable KCSAN for autogenerated *.mod.c intermediaries 2024-05-17 12:02:12 +02:00
Makefile.modinst kbuild: Use CRC32 and a 1MiB dictionary for XZ compressed modules 2023-09-25 16:01:05 +09:00
Makefile.modpost linux/export.h: make <linux/export.h> independent of CONFIG_MODULES 2023-07-25 00:59:32 +09:00
Makefile.package kbuild: Fix build target deb-pkg: ln: failed to create hard link 2024-07-05 09:33:56 +02:00
Makefile.randstruct
Makefile.ubsan ubsan: Tighten UBSAN_BOUNDS on GCC 2023-05-16 13:57:14 -07:00
Makefile.userprogs
Makefile.vdsoinst s390/vdso: Create .build-id links for unstripped vdso files 2024-06-12 11:12:33 +02:00
Makefile.vmlinux x86/retpoline: Make sure there are no unconverted return thunks due to KCSAN 2023-11-28 17:19:36 +00:00
Makefile.vmlinux_o x86/srso: Fix unret validation dependencies 2023-11-20 11:58:52 +01:00
makelst
markup_oops.pl
min-tool-version.sh rust: upgrade to Rust 1.73.0 2024-02-16 19:10:43 +01:00
misc-check kbuild: make W=1 warn files that are tracked but ignored by git 2023-01-22 23:43:33 +09:00
mkcompile_h
mksysmap kallsyms: ignore ARMv4 thunks along with others 2024-02-23 09:24:59 +01:00
mkuboot.sh
module.lds.S modules: Drop the .export_symbol section from the final modules 2024-06-12 11:12:12 +02:00
modules-check.sh kbuild: change module.order to list *.o instead of *.ko 2022-12-14 15:42:40 +09:00
nsdeps
objdiff
objdump-func scripts/objdump-func: Support multiple functions 2023-04-14 16:08:28 +02:00
orc_hash.sh x86/unwind/orc: Add ELF section with ORC version identifier 2023-06-16 17:17:42 +02:00
pahole-flags.sh bpf: Add --skip_encoding_btf_inconsistent_proto, --btf_gen_optimized to pahole flags for v1.25 2023-05-12 11:47:05 -07:00
pahole-version.sh
parse-maintainers.pl
patch-kernel
profile2linkerlist.pl
prune-kernel
recordmcount.c recordmcount: Fix memory leaks in the uwrite function 2023-04-25 21:10:20 -04:00
recordmcount.h
recordmcount.pl
relocs_check.sh powerpc: Move script to check relocations at compile time in scripts/ 2023-04-19 07:46:31 -07:00
remove-stale-files kbuild: rpm-pkg: rename binkernel.spec to kernel.spec 2023-07-25 00:59:33 +09:00
rust_is_available_bindgen_libclang.h
rust_is_available_test.py kbuild: rust_is_available: add test suite 2023-08-10 01:18:34 +02:00
rust_is_available.sh rust: work around bindgen 0.69.0 issue 2024-08-29 17:33:29 +02:00
rustdoc_test_builder.rs rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
rustdoc_test_gen.rs rust: support running Rust documentation tests as KUnit ones 2023-07-19 09:32:53 -06:00
setlocalversion setlocalversion: work around "git describe" performance 2024-12-14 20:00:17 +01:00
show_delta
sign-file.c sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3 2025-04-25 10:45:58 +02:00
sorttable.c LoongArch: extable: Add type and data fields 2022-12-14 08:36:11 +08:00
sorttable.h scripts/sorttable: fix orc_sort_cmp() to maintain symmetry and transitivity 2025-01-09 13:32:07 +01:00
spdxcheck-test.sh
spdxcheck.py
spdxexclude
spelling.txt scripts/spelling.txt: remove 'thead' as a typo 2023-07-27 13:07:04 -07:00
sphinx-pre-install
split-man.pl
ssl-common.h sign-file,extract-cert: avoid using deprecated ERR_get_error_line() 2025-04-25 10:45:58 +02:00
stackdelta
stackusage
subarch.include
syscallhdr.sh
syscallnr.sh
syscalltbl.sh
tags.sh Char/Misc and other driver subsystem updates for 6.5-rc1 2023-07-03 12:46:47 -07:00
test_fortify.sh
tools-support-relr.sh Makefile: use -z pack-relative-relocs 2023-04-17 11:23:06 +09:00
unifdef.c
ver_linux
xen-hypercalls.sh
xz_wrap.sh