]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: enable sparse checking with make C=1
authorEric Sandeen <sandeen@redhat.com>
Wed, 17 Oct 2018 18:25:11 +0000 (13:25 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 17 Oct 2018 18:25:11 +0000 (13:25 -0500)
Enable "make C=1" sparse checking when files get rebuilt.  To check
all files, run "make clean" first.

This is a bit simpler than redefining CC for the whole build, which
requires extra commandline definitions and apparently is enough of a
barrier that nobody's doing sparse checking.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Makefile
doc/sparse.txt
include/buildrules

index d031a6035985f3dd24368e309ee270cbab40b4cb..05fe6096189741cba4ae60aa6e5b46cba78c535b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,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")
+  ifeq ("$(C)", "1")
+    CHECK_CMD=$(CHECK) $(CHECK_OPTS)
+  else
+    CHECK_CMD=@true
+  endif
+endif
+
+export CHECK_CMD
+
 MAKEOPTS = --no-print-directory Q=$(Q)
 
 TOPDIR = .
index 36a34a0bb2b91cf32149180b2c2dbe66029ba639..c6d1fe76c7bdf4f5f48f4489710b73812feefaa1 100644 (file)
@@ -5,9 +5,18 @@ to check the source code of the open source XFS commands and utilites
 First you need to install sparse, either from your distribution or from
 source as provided at http://www.kernel.org/pub/software/devel/sparse/.
 
-To simply build the xfsprogs source code while checking the source using
-sparse just set the compiler to cgcc, which is a wrapper that calls both
-sparse and gcc using:
+The xfsprogs Makefile has a convenient shortcut to running sparse, by setting
+the C ("check") variable on the make commandline.  To perform these checks on
+files when they get rebuilt, use:
+
+       make C=1
+
+(Note that xfsprogs does not yet support the kernel convention of checking
+all C files without compilation via "make C=2", so to run sparse on all
+C files, start with a "make clean")
+
+If you'd rather run sparse more manually, just set the compiler to cgcc,
+which is a wrapper that calls both sparse and gcc using:
 
        CC=cgcc ./configure
 
index c57fdfcad6917c3e0bbef5d470f9821bd4346334..297e5983371ef3e66d8b1a52b01fdaaeddb4311f 100644 (file)
@@ -54,10 +54,13 @@ $(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