[LTP] [PATCH] tools: Check headers with checkpatch.pl
Richard Palethorpe
rpalethorpe@suse.com
Tue Jul 26 13:52:34 CEST 2022
checkpatch.pl doesn't load included headers so they must be passed to
it specifically. This change automatically includes headers from the
current directory. Manual intervention is still required if a test
author changes a header located elsewhere. However you can now write
'make check-header.h', once in the correct directory.
Note that our Sparse based tool (amongst others) loads headers and
checks at least some of the content.
Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
Suggested-by: Petr Vorel <pvorel@suse.cz>
---
include/mk/env_post.mk | 1 +
include/mk/generic_leaf_target.inc | 2 +-
include/mk/rules.mk | 9 +++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/mk/env_post.mk b/include/mk/env_post.mk
index dc4df41d3..a00f31b08 100644
--- a/include/mk/env_post.mk
+++ b/include/mk/env_post.mk
@@ -92,6 +92,7 @@ endif
CHECK_TARGETS ?= $(addprefix check-,$(notdir $(patsubst %.c,%,$(sort $(wildcard $(abs_srcdir)/*.c)))))
CHECK_TARGETS := $(filter-out $(addprefix check-, $(FILTER_OUT_MAKE_TARGETS)), $(CHECK_TARGETS))
+CHECK_HEADER_TARGETS ?= $(addprefix check-,$(notdir $(sort $(wildcard $(abs_srcdir)/*.h))))
CHECK ?= $(abs_top_srcdir)/tools/sparse/sparse-ltp
CHECK_NOFLAGS ?= $(abs_top_srcdir)/scripts/checkpatch.pl -f --no-tree --terse --no-summary --ignore CONST_STRUCT,VOLATILE,SPLIT_STRING
SHELL_CHECK ?= $(abs_top_srcdir)/scripts/checkbashisms.pl --force --extra
diff --git a/include/mk/generic_leaf_target.inc b/include/mk/generic_leaf_target.inc
index 33e9c9ea0..565a282bb 100644
--- a/include/mk/generic_leaf_target.inc
+++ b/include/mk/generic_leaf_target.inc
@@ -110,6 +110,6 @@ $(INSTALL_FILES): | $(INSTALL_DEPS)
install: $(INSTALL_FILES)
$(CHECK_TARGETS): | $(CHECK_DEPS)
-check: $(CHECK_TARGETS) $(SHELL_CHECK_TARGETS)
+check: $(CHECK_HEADER_TARGETS) $(CHECK_TARGETS) $(SHELL_CHECK_TARGETS)
# vim: syntax=make
diff --git a/include/mk/rules.mk b/include/mk/rules.mk
index 32d8d05a7..517863c04 100644
--- a/include/mk/rules.mk
+++ b/include/mk/rules.mk
@@ -57,6 +57,15 @@ else
@-$(CHECK) $(CHECK_FLAGS) $(CPPFLAGS) $(CFLAGS) $<
endif
+.PHONY: $(CHECK_HEADER_TARGETS)
+$(CHECK_HEADER_TARGETS): check-%.h: %.h
+ifdef VERBOSE
+ -$(CHECK_NOFLAGS) $<
+else
+ @echo CHECK $(target_rel_dir)$<
+ @-$(CHECK_NOFLAGS) $<
+endif
+
.PHONY: $(SHELL_CHECK_TARGETS)
$(SHELL_CHECK_TARGETS): check-%.sh: %.sh
ifdef VERBOSE
--
2.36.1
More information about the ltp
mailing list