From: Eric Sandeen <sandeen@redhat.com>
To: fstests@vger.kernel.org
Cc: djwong@kernel.org, hch@infradead.org,
Eric Sandeen <sandeen@redhat.com>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 1/7] fstests: enable sparse checking with make C=[12]
Date: Mon, 10 Mar 2025 13:29:03 -0500 [thread overview]
Message-ID: <20250310182954.1396724-2-sandeen@redhat.com> (raw)
In-Reply-To: <20250310182954.1396724-1-sandeen@redhat.com>
Enable "make C=1" sparse checking when files get rebuilt. To check
all files, run "make clean" first.
Enable "make C=2" sparse checking of all files without rebuilding them.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
Makefile | 14 ++++++++++++++
include/buildrules | 19 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/Makefile b/Makefile
index f955f0d3..a48d8d62 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,20 @@ else
Q = @
endif
+CHECK=sparse
+CHECK_OPTS=-Wsparse-all -Wbitwise -Wno-transparent-union -Wno-return-void -Wno-undef \
+ -Wno-non-pointer-null -D__CHECK_ENDIAN__ -D__linux__
+
+ifeq ("$(origin C)", "command line")
+ CHECK_CMD=$(CHECK) $(CHECK_OPTS)
+ CHECKSRC=$(C)
+else
+ CHECK_CMD=@true
+ CHECKSRC=0
+endif
+
+export CHECK_CMD CHECKSRC
+
MAKEOPTS = --no-print-directory Q=$(Q)
TOPDIR = .
diff --git a/include/buildrules b/include/buildrules
index bf187662..6c2b7e18 100644
--- a/include/buildrules
+++ b/include/buildrules
@@ -35,6 +35,21 @@ endif
# Standard targets
#
+ifeq ($(CHECKSRC),2)
+
+# Check every .c file with sparse CHECK_CMD, do not call compiler
+$(LTCOMMAND) $(LTLIBRARY) : $(SUBDIRS) $(OBJECTS)
+.PHONY: $(LTCOMMAND) $(LTLIBRARY)
+
+%.lo %.o : %.c FORCE
+ @echo " [CHECK] $<"
+ $(Q)$(CHECK_CMD) $(CFLAGS) $<
+
+FORCE:
+
+else
+# Regular build, possibly calling sparse CHECK_CMD as well
+
ifdef LTCOMMAND
$(LTCOMMAND) : $(SUBDIRS) $(OBJECTS) $(LTDEPENDENCIES)
@echo " [LD] $*"
@@ -49,12 +64,16 @@ $(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS)
%.lo: %.c
@echo " [CC] $@"
$(Q)$(LTCOMPILE) -c $<
+ $(Q)$(CHECK_CMD) $(CFLAGS) $<
else
+
%.o: %.c
@echo " [CC] $@"
$(Q)$(CC) $(CFLAGS) -c $<
+ $(Q)$(CHECK_CMD) $(CFLAGS) $<
endif
+endif
ifdef POTHEAD
%.pot: $(XGETTEXTFILES)
--
2.48.0
next prev parent reply other threads:[~2025-03-10 18:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
2025-03-10 18:29 ` Eric Sandeen [this message]
2025-03-10 18:29 ` [PATCH 2/7] treewide: check for #ifdef __linux__ not linux Eric Sandeen
2025-03-11 7:37 ` Christoph Hellwig
2025-03-11 13:44 ` Eric Sandeen
2025-03-11 13:46 ` [PATCH 2/7 V3] " Eric Sandeen
2025-03-11 15:25 ` Darrick J. Wong
2025-03-10 18:29 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen
2025-03-10 18:29 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen
2025-03-10 18:29 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen
2025-03-10 18:29 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen
2025-03-10 18:29 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
2025-03-16 14:54 ` Zorro Lang
2025-03-16 15:48 ` Eric Sandeen
2025-03-16 16:40 ` Darrick J. Wong
2025-03-16 18:06 ` Eric Sandeen
2025-03-16 16:42 ` Zorro Lang
-- strict thread matches above, loose matches on Subject: below --
2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen
2025-02-06 21:19 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen
2025-02-06 22:36 ` Darrick J. Wong
2025-02-07 4:56 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250310182954.1396724-2-sandeen@redhat.com \
--to=sandeen@redhat.com \
--cc=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=hch@infradead.org \
--cc=hch@lst.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox