From: "Darrick J. Wong" <djwong@kernel.org>
To: Eric Sandeen <sandeen@redhat.com>
Cc: fstests@vger.kernel.org
Subject: Re: [PATCH 1/7] fstests: enable sparse checking with make C=[12]
Date: Thu, 6 Feb 2025 14:36:27 -0800 [thread overview]
Message-ID: <20250206223627.GN21799@frogsfrogsfrogs> (raw)
In-Reply-To: <20250206212145.7732-2-sandeen@redhat.com>
On Thu, Feb 06, 2025 at 03:19:56PM -0600, Eric Sandeen wrote:
> 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>
Looks just like the one in xfsprogs and the kernel!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> Makefile | 14 ++++++++++++++
> include/buildrules | 19 +++++++++++++++++++
> 2 files changed, 33 insertions(+)
>
> diff --git a/Makefile b/Makefile
> index f6f91a4d..79779d5e 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-02-06 22:36 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-02-07 4:56 ` Christoph Hellwig
2025-02-06 21:19 ` [PATCH 2/7] builddefs: define linux Eric Sandeen
2025-02-06 22:39 ` Darrick J. Wong
2025-02-07 1:09 ` Eric Sandeen
2025-02-07 2:01 ` Darrick J. Wong
2025-02-07 4:57 ` Christoph Hellwig
2025-02-07 5:06 ` Darrick J. Wong
2025-02-06 21:19 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen
2025-02-06 22:39 ` Darrick J. Wong
2025-02-07 4:59 ` Christoph Hellwig
2025-02-06 21:19 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen
2025-02-06 22:45 ` Darrick J. Wong
2025-02-07 4:59 ` Christoph Hellwig
2025-02-06 21:20 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen
2025-02-06 22:46 ` Darrick J. Wong
2025-02-07 5:00 ` Christoph Hellwig
2025-02-06 21:20 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen
2025-02-06 22:46 ` Darrick J. Wong
2025-02-07 5:00 ` Christoph Hellwig
2025-02-06 21:20 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
2025-02-06 22:47 ` Darrick J. Wong
2025-02-07 5:01 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
2025-03-10 18:29 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen
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=20250206223627.GN21799@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=fstests@vger.kernel.org \
--cc=sandeen@redhat.com \
/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