All of lore.kernel.org
 help / color / mirror / Atom feed
From: Uday Shankar <ushankar@purestorage.com>
To: Ming Lei <ming.lei@redhat.com>
Cc: Shuah Khan <shuah@kernel.org>,
	linux-block@vger.kernel.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] selftests: ublk: kublk: build with -Werror iff CONFIG_WERROR=y
Date: Tue, 29 Apr 2025 16:46:14 -0600	[thread overview]
Message-ID: <aBFWtvHv84aPTMvi@dev-ushankar.dev.purestorage.com> (raw)
In-Reply-To: <aBAnKZCUZWyEJhfS@fedora>

On Tue, Apr 29, 2025 at 09:11:05AM +0800, Ming Lei wrote:
> On Mon, Apr 28, 2025 at 05:10:20PM -0600, Uday Shankar wrote:
> > Compiler warnings can catch bugs at compile time. They can also produce
> > annoying false positives. Due to this duality, the kernel provides
> > CONFIG_WERROR so that the developer can choose whether or not they want
> > compiler warnings to fail the build. Use this same config options to
> > control whether or not warnings in building kublk fail its build.
> > 
> > Signed-off-by: Uday Shankar <ushankar@purestorage.com>
> > ---
> >  tools/testing/selftests/ublk/Makefile | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/tools/testing/selftests/ublk/Makefile b/tools/testing/selftests/ublk/Makefile
> > index ec4624a283bce2ebeed80509be6573c1b7a3623d..86474cfe8d03b2df3f8c9bc1a5902701a0f72f58 100644
> > --- a/tools/testing/selftests/ublk/Makefile
> > +++ b/tools/testing/selftests/ublk/Makefile
> > @@ -1,6 +1,8 @@
> >  # SPDX-License-Identifier: GPL-2.0
> >  
> > -CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir)
> > +CONFIG = $(top_srcdir)/include/config/auto.conf
> > +WERROR = $(if $(shell grep CONFIG_WERROR=y ${CONFIG}),-Werror,)
> > +CFLAGS += -O3 -Wl,-no-as-needed -Wall ${WERROR} -I $(top_srcdir)
> >  LDLIBS += -lpthread -lm -luring
> 
> I think it isn't good to reuse kernel CONFIG_WERROR for test code.
> 
> But it can be done in the following way by passing 'WERROR=1' to make
> command line:
> 
> +ifneq ($(WERROR),0)
> +       CFLAGS += -Werror
> +endif

I've taken this approach in [1]. It actually passes -Werror by default,
but it gives the developer a way to disable it with

make WERROR=0 TARGETS=ublk kselftest

[1] https://lore.kernel.org/linux-block/20250429-ublk_selftests-v2-1-e970b6d9e4f4@purestorage.com/


  reply	other threads:[~2025-04-29 22:46 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-28 23:10 [PATCH 0/3] selftests: ublk: more misc fixes Uday Shankar
2025-04-28 23:10 ` [PATCH 1/3] selftests: ublk: kublk: build with -Werror iff CONFIG_WERROR=y Uday Shankar
2025-04-29  1:11   ` Ming Lei
2025-04-29 22:46     ` Uday Shankar [this message]
2025-04-28 23:10 ` [PATCH 2/3] selftests: ublk: make test_generic_06 silent on success Uday Shankar
2025-04-29  1:12   ` Ming Lei
2025-04-28 23:10 ` [PATCH 3/3] selftests: ublk: kublk: fix include path Uday Shankar
2025-04-29  1:14   ` Caleb Sander Mateos
2025-04-29 22:43     ` Uday Shankar
2025-04-29  1:22   ` Ming Lei
2025-05-05 20:31 ` [PATCH 0/3] selftests: ublk: more misc fixes Uday Shankar
2025-05-05 20:34   ` Uday Shankar
2025-05-05 22:44     ` Jens Axboe
2025-05-05 22:53       ` Uday Shankar
2025-05-05 22:55         ` Jens Axboe

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=aBFWtvHv84aPTMvi@dev-ushankar.dev.purestorage.com \
    --to=ushankar@purestorage.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=shuah@kernel.org \
    /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 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.