Re: [PATCH] kbuild: add header check facility as a manually run static analyzer

From: Jason Gunthorpe

Date: Thu Sep 17 2026 - 08:09:48 EST


On Thu, Sep 17, 2026 at 11:05:32AM +0200, Thomas Weißschuh wrote:
> For instance the example from above:
>
> ./../include/uapi/linux/input.h:29:6: warning: ‘__BITS_PER_LONG’ is not defined, evaluates to ‘0’ [-Wundef]
> 29 | #if (__BITS_PER_LONG != 32 || !defined(__USE_TIME_BITS64)) && !defined(__KERNEL__)
> | ^~~~~~~~~~~~~~~
> ./../include/uapi/linux/input.h:34:9: error: unknown type name ‘__kernel_ulong_t’
> 34 | __kernel_ulong_t __sec;
> | ^~~~~~~~~~~~~~~~
>
> These are legitimate issues, the inclusion of the necessary header is
> gated behind #ifndef __KERNEL__ although it should not be.

Yeah, if the header is included by a kernel file then this makefile
test should evaluate it under those conditions, and it should still be
self-contained within the kernel environment.. Wasn't that one of the
problems with earlier draft that it did not figure out the right
compilation options for the context the header is included in?

FWIW I think this is a reasonable compromise too

Jason