public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
Cc: David Sterba <dsterba@suse.com>,
	"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH 1/5] btrfs: add verbose version of ASSERT
Date: Wed, 16 Apr 2025 21:30:32 +0200	[thread overview]
Message-ID: <20250416193032.GF13877@suse.cz> (raw)
In-Reply-To: <6a1ad2ef-67d0-4aa2-83af-2a31856c1440@wdc.com>

On Wed, Apr 16, 2025 at 03:03:18PM +0000, Johannes Thumshirn wrote:
> On 16.04.25 11:09, David Sterba wrote:
> > +
> > +/* Verbose assert, use to print any relevant values of the condition. */
> > +#define VASSERT(expr, fmt, ...)					\
> > +	(likely(expr) ? (void)0 : btrfs_assertfail_verbose(#expr, __FILE__, __LINE__, \
> > +							   fmt, __VA_ARGS__))
> >   #else
> >   #define ASSERT(expr)	(void)(expr)
> > +#define VASSERT(expr, fmt, ...)		(void)(expr)
> >   #endif
> 
> Ahm stupid question (applies for ASSERT() as well), doesn't that 
> generate code as well when CONFIG_BTRFS_ASSERT=n? So we're doing a lot 
> of potentially unneeded tests?

It should not generate any code. It's parsed, syntax-checked and as the
result is cast to void it's thrown out and optimized out (-O2).

  reply	other threads:[~2025-04-16 19:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16  9:08 [PATCH 0/5] Assertion and debugging helpers David Sterba
2025-04-16  9:08 ` [PATCH 1/5] btrfs: add verbose version of ASSERT David Sterba
2025-04-16 15:03   ` Johannes Thumshirn
2025-04-16 19:30     ` David Sterba [this message]
2025-04-16  9:08 ` [PATCH 2/5] btrfs: example use of VASSERT() in volumes.c David Sterba
2025-04-16  9:08 ` [PATCH 3/5] btrfs: add debug build only WARN David Sterba
2025-04-16  9:08 ` [PATCH 4/5] btrfs: convert WARN_ON(IS_ENABLED(CONFIG_BTRFS_DEBUG)) to DEBUG_WARN David Sterba
2025-04-16  9:08 ` [PATCH 5/5] btrfs: convert ASSERT(0) to DEBUG_WARN() David Sterba
2025-04-16 10:55 ` [PATCH 0/5] Assertion and debugging helpers Qu Wenruo
2025-04-16 20:20   ` David Sterba
2025-04-16 22:30     ` David Sterba
2025-04-16 22:44       ` Qu Wenruo

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=20250416193032.GF13877@suse.cz \
    --to=dsterba@suse.cz \
    --cc=Johannes.Thumshirn@wdc.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox