Skip to content

Commit

Permalink
kbuild: detect missing include guard for exported headers
Browse files Browse the repository at this point in the history
Adding an include guard to every header file is good practice in case
it is included multiple times.

Exported headers are compile-tested for the comprehensive sanity checks.
Let's include the same header twice. If an include guard is missing,
the header will fail to build due to redefinition of something.

Signed-off-by: Masahiro Yamada <[email protected]>
Reviewed-by: Sam Ravnborg <[email protected]>
  • Loading branch information
masahir0y committed Jan 6, 2020
1 parent c79f46a commit 5511978
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion usr/include/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ header-test- += asm-generic/%

extra-y := $(patsubst $(obj)/%.h,%.hdrtest, $(shell find $(obj) -name '*.h' 2>/dev/null))

# Include the header to detect missing include guard.
quiet_cmd_hdrtest = HDRTEST $<
cmd_hdrtest = \
$(CC) $(c_flags) -S -o /dev/null -x c /dev/null \
$(if $(filter-out $(header-test-), $*.h), -include $<); \
$(if $(filter-out $(header-test-), $*.h), -include $< -include $<); \
$(PERL) $(srctree)/scripts/headers_check.pl $(obj) $(SRCARCH) $<; \
touch $@

Expand Down

0 comments on commit 5511978

Please sign in to comment.