]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfsprogs: enable sparse checking with make C=2
authorEric Sandeen <sandeen@redhat.com>
Wed, 17 Oct 2018 18:27:44 +0000 (13:27 -0500)
committerEric Sandeen <sandeen@redhat.com>
Wed, 17 Oct 2018 18:27:44 +0000 (13:27 -0500)
Enable "make C=2" sparse checking of all files without rebuilding them.

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 05fe6096189741cba4ae60aa6e5b46cba78c535b..9204bed834fe92762c7da2a86f5729c152e82220 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -21,14 +21,14 @@ CHECK_OPTS=-Wsparse-all -Wbitwise -Wno-transparent-union -Wno-return-void -Wno-u
        -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
+  CHECK_CMD=$(CHECK) $(CHECK_OPTS)
+  CHECKSRC=$(C)
+else
+  CHECK_CMD=@true
+  CHECKSRC=0
 endif
 
-export CHECK_CMD
+export CHECK_CMD CHECKSRC
 
 MAKEOPTS = --no-print-directory Q=$(Q)
 
index c6d1fe76c7bdf4f5f48f4489710b73812feefaa1..75b24e0333f3053ad9be606e2cf2d98c927bacdc 100644 (file)
@@ -5,15 +5,12 @@ 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/.
 
-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:
+Then, run make with "make C=1" to run sparse on all the C files that get
+recompiled, or use "make C=2" to run sparse on the files whether they need to
+be recompiled or not.  The latter is a fast way to check the whole tree if you
+have already built it.
 
-       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")
+See the top-level Makefile for a list of which sparse flags are enabled.
 
 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:
index 297e5983371ef3e66d8b1a52b01fdaaeddb4311f..c207a16805fc2c2d5fdf85487747f445c9ae4f48 100644 (file)
@@ -40,6 +40,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]     $@"
@@ -63,6 +78,7 @@ else
        $(Q)$(CHECK_CMD) $(CFLAGS) $<
 
 endif
+endif
 
 ifdef POTHEAD
 $(POTHEAD): $(XGETTEXTFILES)