All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xfsprogs: enable sparse checking with "make C=[12]"
@ 2018-10-11 16:10 Eric Sandeen
  2018-10-11 16:12 ` [PATCH 1/2] xfsprogs: enable sparse checking with make C=1 Eric Sandeen
  2018-10-11 16:14 ` PATCH 2/2] xfsprogs: enable sparse checking with "make C=2" Eric Sandeen
  0 siblings, 2 replies; 7+ messages in thread
From: Eric Sandeen @ 2018-10-11 16:10 UTC (permalink / raw)
  To: linux-xfs

Ok one more pass at this, trying to mimic kernel behavior for C=1 & C=2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] xfsprogs: enable sparse checking with make C=1
  2018-10-11 16:10 [PATCH 0/2] xfsprogs: enable sparse checking with "make C=[12]" Eric Sandeen
@ 2018-10-11 16:12 ` Eric Sandeen
  2018-10-12  8:22   ` Carlos Maiolino
  2018-10-14 17:08   ` Christoph Hellwig
  2018-10-11 16:14 ` PATCH 2/2] xfsprogs: enable sparse checking with "make C=2" Eric Sandeen
  1 sibling, 2 replies; 7+ messages in thread
From: Eric Sandeen @ 2018-10-11 16:12 UTC (permalink / raw)
  To: linux-xfs

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.

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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
--- 

diff --git a/Makefile b/Makefile
index d031a60..05fe609 100644
--- 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 = .
diff --git a/doc/sparse.txt b/doc/sparse.txt
index 36a34a0..c6d1fe7 100644
--- a/doc/sparse.txt
+++ b/doc/sparse.txt
@@ -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
 
diff --git a/include/buildrules b/include/buildrules
index c57fdfc..297e598 100644
--- a/include/buildrules
+++ b/include/buildrules
@@ -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
 

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* PATCH 2/2] xfsprogs: enable sparse checking with "make C=2"
  2018-10-11 16:10 [PATCH 0/2] xfsprogs: enable sparse checking with "make C=[12]" Eric Sandeen
  2018-10-11 16:12 ` [PATCH 1/2] xfsprogs: enable sparse checking with make C=1 Eric Sandeen
@ 2018-10-11 16:14 ` Eric Sandeen
  2018-10-12  8:23   ` Carlos Maiolino
  2018-10-14 17:09   ` Christoph Hellwig
  1 sibling, 2 replies; 7+ messages in thread
From: Eric Sandeen @ 2018-10-11 16:14 UTC (permalink / raw)
  To: linux-xfs

Enable "make C=2" sparse checking of all files without rebuilding them.

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.

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

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
--- 

diff --git a/Makefile b/Makefile
index 05fe609..9204bed 100644
--- 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)
 
diff --git a/doc/sparse.txt b/doc/sparse.txt
index c6d1fe7..75b24e0 100644
--- a/doc/sparse.txt
+++ b/doc/sparse.txt
@@ -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:
diff --git a/include/buildrules b/include/buildrules
index 297e598..c207a16 100644
--- a/include/buildrules
+++ b/include/buildrules
@@ -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)

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] xfsprogs: enable sparse checking with make C=1
  2018-10-11 16:12 ` [PATCH 1/2] xfsprogs: enable sparse checking with make C=1 Eric Sandeen
@ 2018-10-12  8:22   ` Carlos Maiolino
  2018-10-14 17:08   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Carlos Maiolino @ 2018-10-12  8:22 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Thu, Oct 11, 2018 at 11:12:52AM -0500, Eric Sandeen wrote:
> 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.
> 
> Note, this requires unreleased sparse after v0.5, which enables the
> CHAR_BIT definition; otherwise it chokes.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> --- 
> 
> diff --git a/Makefile b/Makefile
> index d031a60..05fe609 100644
> --- 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)

Looks good
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

>  
>  TOPDIR = .
> diff --git a/doc/sparse.txt b/doc/sparse.txt
> index 36a34a0..c6d1fe7 100644
> --- a/doc/sparse.txt
> +++ b/doc/sparse.txt
> @@ -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
>  
> diff --git a/include/buildrules b/include/buildrules
> index c57fdfc..297e598 100644
> --- a/include/buildrules
> +++ b/include/buildrules
> @@ -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
>  
> 

-- 
Carlos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH 2/2] xfsprogs: enable sparse checking with "make C=2"
  2018-10-11 16:14 ` PATCH 2/2] xfsprogs: enable sparse checking with "make C=2" Eric Sandeen
@ 2018-10-12  8:23   ` Carlos Maiolino
  2018-10-14 17:09   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Carlos Maiolino @ 2018-10-12  8:23 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Thu, Oct 11, 2018 at 11:14:14AM -0500, Eric Sandeen wrote:
> Enable "make C=2" sparse checking of all files without rebuilding them.
> 
> 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.
> 
> Note, this requires unreleased sparse after v0.5, which enables the
> CHAR_BIT definition; otherwise it chokes.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> --- 
> 
> diff --git a/Makefile b/Makefile
> index 05fe609..9204bed 100644
> --- 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

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

>  
> -export CHECK_CMD
> +export CHECK_CMD CHECKSRC
>  
>  MAKEOPTS = --no-print-directory Q=$(Q)
>  
> diff --git a/doc/sparse.txt b/doc/sparse.txt
> index c6d1fe7..75b24e0 100644
> --- a/doc/sparse.txt
> +++ b/doc/sparse.txt
> @@ -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:
> diff --git a/include/buildrules b/include/buildrules
> index 297e598..c207a16 100644
> --- a/include/buildrules
> +++ b/include/buildrules
> @@ -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)
> 

-- 
Carlos

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] xfsprogs: enable sparse checking with make C=1
  2018-10-11 16:12 ` [PATCH 1/2] xfsprogs: enable sparse checking with make C=1 Eric Sandeen
  2018-10-12  8:22   ` Carlos Maiolino
@ 2018-10-14 17:08   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2018-10-14 17:08 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Thu, Oct 11, 2018 at 11:12:52AM -0500, Eric Sandeen wrote:
> 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.
> 
> Note, this requires unreleased sparse after v0.5, which enables the
> CHAR_BIT definition; otherwise it chokes.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH 2/2] xfsprogs: enable sparse checking with "make C=2"
  2018-10-11 16:14 ` PATCH 2/2] xfsprogs: enable sparse checking with "make C=2" Eric Sandeen
  2018-10-12  8:23   ` Carlos Maiolino
@ 2018-10-14 17:09   ` Christoph Hellwig
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2018-10-14 17:09 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs

On Thu, Oct 11, 2018 at 11:14:14AM -0500, Eric Sandeen wrote:
> Enable "make C=2" sparse checking of all files without rebuilding them.
> 
> 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.
> 
> Note, this requires unreleased sparse after v0.5, which enables the
> CHAR_BIT definition; otherwise it chokes.

This seems to duplicate much of the previous commit message..

Except for that it looks fine to me:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-10-15  0:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-11 16:10 [PATCH 0/2] xfsprogs: enable sparse checking with "make C=[12]" Eric Sandeen
2018-10-11 16:12 ` [PATCH 1/2] xfsprogs: enable sparse checking with make C=1 Eric Sandeen
2018-10-12  8:22   ` Carlos Maiolino
2018-10-14 17:08   ` Christoph Hellwig
2018-10-11 16:14 ` PATCH 2/2] xfsprogs: enable sparse checking with "make C=2" Eric Sandeen
2018-10-12  8:23   ` Carlos Maiolino
2018-10-14 17:09   ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.