Kernel adds Clang attribute to force explicit struct init
Mandatory seq_file callbacks are the first annotated fields so missing initializers become compile-time warnings.
The Linux kernel is gaining a compiler attribute that requires certain struct fields to be initialized explicitly, turning omitted mandatory callbacks into build-time warnings instead of silent runtime hazards.
Ian Rogers added a __require_explicit_initialization wrapper around Clang's require_explicit_initialization attribute (Clang 20 and later). Annotated fields that are left out of an aggregate initializer, or left unset on an uninitialized variable, trigger Clang's default -Wuninitialized-explicit-init warning. Kees Cook proposed the series and applied the attribute first to seq_operations in the seq_file code, whose start, stop, next, and show callbacks are invoked without NULL checks. Every existing instance in the tree already sets all four members, and Cook reported no new warnings across broad allmodconfig builds with recent Clang and GCC.
The goal is a reusable tool for error-prone patterns such as required function pointers and cleanup handlers, following earlier discussion at the Linux Plumbers Conference. Cook aims to expose the attribute in the v7.4-rc1 window while related kobject release work continues separately.
Greg Kroah-Hartman supported the idea but found the long attribute spelling awkward beside function-pointer declarations. Miguel Ojeda suggested a shorter name such as __explicit_init, and Cook said he was open to renaming it.