Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

kbuild: uapi: validate that headers do not use libc

The UAPI headers should be self-contained. That means they should not
use other headers from libc. Currently this is not enforced and various
dependencies have crept in.

Add a check to make sure no new ones are added.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://patch.msgid.link/20251223-uapi-nostdinc-v1-1-d91545d794f7@linutronix.de
Signed-off-by: Nathan Chancellor <nathan@kernel.org>

authored by

Thomas Weißschuh and committed by
Nathan Chancellor
6059b880 76df6815

+77
+77
usr/include/Makefile
··· 68 68 # asm-generic/*.h is used by asm/*.h, and should not be included directly 69 69 no-header-test += asm-generic/% 70 70 71 + # The following are using libc header and types. 72 + # 73 + # Do not add a new header to the list without legitimate reason. 74 + # Please consider to fix the header first. 75 + # 76 + # Sorted alphabetically. 77 + uses-libc += linux/a.out.h 78 + uses-libc += linux/atmbr2684.h 79 + uses-libc += linux/auto_dev-ioctl.h 80 + uses-libc += linux/auto_fs.h 81 + uses-libc += linux/auto_fs4.h 82 + uses-libc += linux/btrfs_tree.h 83 + uses-libc += linux/cec-funcs.h 84 + uses-libc += linux/cec.h 85 + uses-libc += linux/dvb/dmx.h 86 + uses-libc += linux/dvb/video.h 87 + uses-libc += linux/ethtool.h 88 + uses-libc += linux/ethtool_netlink.h 89 + uses-libc += linux/fuse.h 90 + uses-libc += linux/gsmmux.h 91 + uses-libc += linux/icmp.h 92 + uses-libc += linux/idxd.h 93 + uses-libc += linux/if.h 94 + uses-libc += linux/if_arp.h 95 + uses-libc += linux/if_bonding.h 96 + uses-libc += linux/if_pppox.h 97 + uses-libc += linux/if_tunnel.h 98 + uses-libc += linux/input.h 99 + uses-libc += linux/ip6_tunnel.h 100 + uses-libc += linux/joystick.h 101 + uses-libc += linux/llc.h 102 + uses-libc += linux/mctp.h 103 + uses-libc += linux/mdio.h 104 + uses-libc += linux/mii.h 105 + uses-libc += linux/mptcp.h 106 + uses-libc += linux/netdevice.h 107 + uses-libc += linux/netfilter/xt_RATEEST.h 108 + uses-libc += linux/netfilter/xt_hashlimit.h 109 + uses-libc += linux/netfilter/xt_physdev.h 110 + uses-libc += linux/netfilter/xt_rateest.h 111 + uses-libc += linux/netfilter_arp/arp_tables.h 112 + uses-libc += linux/netfilter_arp/arpt_mangle.h 113 + uses-libc += linux/netfilter_bridge.h 114 + uses-libc += linux/netfilter_bridge/ebtables.h 115 + uses-libc += linux/netfilter_ipv4.h 116 + uses-libc += linux/netfilter_ipv4/ip_tables.h 117 + uses-libc += linux/netfilter_ipv6.h 118 + uses-libc += linux/netfilter_ipv6/ip6_tables.h 119 + uses-libc += linux/route.h 120 + uses-libc += linux/shm.h 121 + uses-libc += linux/soundcard.h 122 + uses-libc += linux/string.h 123 + uses-libc += linux/tipc_config.h 124 + uses-libc += linux/uhid.h 125 + uses-libc += linux/uinput.h 126 + uses-libc += linux/vhost.h 127 + uses-libc += linux/vhost_types.h 128 + uses-libc += linux/virtio_ring.h 129 + uses-libc += linux/wireless.h 130 + uses-libc += regulator/regulator.h 131 + uses-libc += scsi/fc/fc_els.h 132 + 133 + ifeq ($(SRCARCH),hexagon) 134 + uses-libc += asm/sigcontext.h 135 + endif 136 + 137 + ifeq ($(SRCARCH),nios2) 138 + uses-libc += asm/ptrace.h 139 + uses-libc += linux/bpf_perf_event.h 140 + endif 141 + 142 + ifeq ($(SRCARCH),s390) 143 + uses-libc += asm/chpid.h 144 + uses-libc += asm/chsc.h 145 + endif 146 + 71 147 always-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null)) 72 148 73 149 # Include the header twice to detect missing include guard. 74 150 quiet_cmd_hdrtest = HDRTEST $< 75 151 cmd_hdrtest = \ 76 152 $(CC) $(c_flags) -fsyntax-only -Werror -x c /dev/null \ 153 + $(if $(filter-out $(uses-libc), $*.h), -nostdinc) \ 77 154 $(if $(filter-out $(no-header-test), $*.h), -include $< -include $<); \ 78 155 $(PERL) $(src)/headers_check.pl $(obj) $<; \ 79 156 touch $@