xfs
[Top] [All Lists]

[PATCH] xfsprogs: enable sparse checking

To: xfs-oss <xfs@xxxxxxxxxxx>
Subject: [PATCH] xfsprogs: enable sparse checking
From: Eric Sandeen <sandeen@xxxxxxxxxx>
Date: Thu, 23 Oct 2014 18:29:14 -0500
Delivered-to: xfs@xxxxxxxxxxx
Enable "make C=1" or "make C=2" to do sparse checking.
Blatantly ripped off from djwong's patch in e2fsprogs to
do the same.

Note, this requires unreleased sparse after v0.5, which
enables the CHAR_BIT definition; otherwise it chokes.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

diff --git a/Makefile b/Makefile
index f56aebd..bd0f9ee 100644
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,20 @@ else
   Q = @
 endif
 
+CHECK=sparse
+CHECK_OPTS=-Wsparse-all -Wno-transparent-union -Wno-return-void -Wno-undef \
+       -Wno-non-pointer-null -D__linux__
+ifeq ("$(C)", "2")
+  CHECK_CMD=$(CHECK) $(CHECK_OPTS) -Wbitwise -D__CHECK_ENDIAN__ 
+else
+  ifeq ("$(C)", "1")
+    CHECK_CMD=$(CHECK) $(CHECK_OPTS)
+   else
+    CHECK_CMD=@true
+  endif
+endif
+export CHECK_CMD
+
 MAKEOPTS = --no-print-directory Q=$(Q)
 
 TOPDIR = .
diff --git a/include/buildrules b/include/buildrules
index 399635e..feae376 100644
--- a/include/buildrules
+++ b/include/buildrules
@@ -41,10 +41,12 @@ $(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
 

<Prev in Thread] Current Thread [Next in Thread>