From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 4/5] treewide: Spell ASSERT() as assert()
Date: Tue, 17 Mar 2026 01:02:34 +0100 (CET) [thread overview]
Message-ID: <20260317010233.0723ea6d@elisabeth> (raw)
In-Reply-To: <20260316054629.239002-5-david@gibson.dropbear.id.au>
On Mon, 16 Mar 2026 16:46:28 +1100
David Gibson <david@gibson.dropbear.id.au> wrote:
> +++ b/util.h
> @@ -73,10 +73,14 @@ void abort_with_msg(const char *fmt, ...)
> * Therefore, avoid using the usual do while wrapper we use to force the macro
> * to act like a single statement requiring a ';'.
> */
> -#define ASSERT_WITH_MSG(expr, ...) \
> +#define assert_with_msg(expr, ...) \
> ((expr) ? (void)0 : abort_with_msg(__VA_ARGS__))
> -#define ASSERT(expr) \
> - ASSERT_WITH_MSG((expr), "ASSERTION FAILED in %s (%s:%d): %s", \
> +/* The standard library assert() hits our seccomp filter and dies before it can
> + * actually print a message. So, replace it with our own version.
> + */
> +#undef assert
> +#define assert(expr) \
> + assert_with_msg((expr), "ASSERTION FAILED in %s (%s:%d): %s", \
> __func__, __FILE__, __LINE__, STRINGIFY(expr))
While looking this up to make sure it's specified as a macro (it is,
and this builds against musl as well), I realised that POSIX.1-2024
says:
https://pubs.opengroup.org/onlinepubs/9799919799/functions/assert.html
Forcing a definition of the name NDEBUG, either from the compiler
command line or with the preprocessor control statement #define NDEBUG
ahead of the #include <assert.h> statement, shall stop assertions from
being compiled into the program.
...so, I wonder, now that it's called assert(), should we define it as
"do { } while(0)" #ifdef NDEBUG, for correctness (and maybe somebody
has obscure usages for NDEBUG which we shouldn't sabotage)?
This will conflict with "[PATCH v2 3/3] vu_common: Move iovec management
into vu_collect()" by the way, but I'll take care of it, if it still
conflicts by the time I merge it.
--
Stefano
next prev parent reply other threads:[~2026-03-17 0:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-16 5:46 [PATCH 0/5] RFC: Stub dynamic update implementation David Gibson
2026-03-16 5:46 ` [PATCH 1/5] Makefile: Use $^ to avoid duplication in static checker rules David Gibson
2026-03-16 5:46 ` [PATCH 2/5] doc: Fix formatting of (DEPRECATED) notes in man page David Gibson
2026-03-16 5:46 ` [PATCH 3/5] pif: Remove unused PIF_NAMELEN David Gibson
2026-03-16 5:46 ` [PATCH 4/5] treewide: Spell ASSERT() as assert() David Gibson
2026-03-17 0:02 ` Stefano Brivio [this message]
2026-03-17 0:39 ` David Gibson
2026-03-17 9:36 ` Stefano Brivio
2026-03-16 5:46 ` [PATCH 5/5] pesto: Introduce stub configuration interface and tool David Gibson
2026-03-17 0:02 ` Stefano Brivio
2026-03-17 0:48 ` David Gibson
2026-03-17 9:36 ` Stefano Brivio
2026-03-17 0:02 ` [PATCH 0/5] RFC: Stub dynamic update implementation Stefano Brivio
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=20260317010233.0723ea6d@elisabeth \
--to=sbrivio@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=passt-dev@passt.top \
/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.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).