From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202602 header.b=Bf0cK+it; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 7F3935A0265 for ; Tue, 17 Mar 2026 01:49:00 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202602; t=1773708536; bh=sqDVwy++q8m2fdTSAPAZgXdOd0mSa2/dollNtn1IjoM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Bf0cK+itKzrPy1a7QDjhMEZBcTWMsNiDXa36kacj/m68UAPdG8dXcWnXku9ScXWOJ KGS1z2FmW/60tLahwvu/BC0ngf1f+OUbFjnJvvymK8kVlgHHjb+8y8jWorDwPnNvCz iWFw9v1LsCNPIOB9gsb5GwudBHqjvAC8t9G1tHw7rLxesMyQDt9vNZDjuvVqzWj7A/ uvCFjHiUFn+vjZZylUpUM5A0+O+9hVz+VrboGiUntFxPTZjHi1h7imYtcitKHYEqM0 XUjpQfDIhrGkZmJ0q2Uch63C+Mg2fiu3NFJpIyw2TxnsE2zgVg/3hvUDqr2CWHfhKG XIiGlf4YbDcUQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4fZYHX5dvhz4wCm; Tue, 17 Mar 2026 11:48:56 +1100 (AEDT) Date: Tue, 17 Mar 2026 11:39:42 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 4/5] treewide: Spell ASSERT() as assert() Message-ID: References: <20260316054629.239002-1-david@gibson.dropbear.id.au> <20260316054629.239002-5-david@gibson.dropbear.id.au> <20260317010233.0723ea6d@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JfcVJMzcoez3zDcB" Content-Disposition: inline In-Reply-To: <20260317010233.0723ea6d@elisabeth> Message-ID-Hash: C2AKV76BSFC7QVCE6TAM75FQFJOKUTHQ X-Message-ID-Hash: C2AKV76BSFC7QVCE6TAM75FQFJOKUTHQ X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --JfcVJMzcoez3zDcB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 17, 2026 at 01:02:34AM +0100, Stefano Brivio wrote: > On Mon, 16 Mar 2026 16:46:28 +1100 > David Gibson wrote: >=20 > > +++ 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 t= he 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 befo= re 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)) >=20 > 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: >=20 > https://pubs.opengroup.org/onlinepubs/9799919799/functions/assert.html >=20 > 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 statement, shall stop assertions from > being compiled into the program. >=20 > ...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)? I like the idea in principle. Actually implementing it turns out to be kind of a pain in the arse, because if we actually try to compile with -DNDEBUG then we get a much of warnings due to reaching the end of functions (assert(0) stopped us otherwise) or unused variables (they're only used in the assert expression or message). A project for some other time, I think. > 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. >=20 > --=20 > Stefano >=20 --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --JfcVJMzcoez3zDcB Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmm4osAACgkQzQJF27ox 2GfESQ//aB7OglLNp4L4VS/F76tuizekYL7CLMiYf/gwpFtKcK8pzXDRchIDDqcC NkjMW3LO+3ld9TcUcKN7lIGJ1ZVLbxLr12efpYvsn7KTVqzR4aKXOEk9As/b97ZI lsM3QKey62K4yTxCTfH7Roe7Mov8dDH7L7lUyi8JKFIBrZLNeCF1ABrHunhISNYU IWei+5xKromzi4iCyAv5mjowDBel0KCi7dzLeD4qO8Vfub4rRinK2M6jUMHGyEuu AVIPA/rU1zKo1xdMhOY4A+3OepuegkryUNpiVJoMYuUcdjM/2AqXMWy15ACUXRjz 4wZiryLDIf+LCxIPXAU9lx2B+ScSPAJ5GKSUQCxBLx3Cn7sFtziJHqoAgEKpNIDd nnKy+tS/DPL9Y8VNeP0embbAz5KozOp//4zdfOw2wQgQkkVuXHiLHmkuJaLU5MSJ cwJXtm5U6OJXEWHrpYGbHQTfeuwsgJ9X2vdY6OnoH2uMRHh0HHWuRQRO2Oa/qReV KTtWwnKW9iq1pyWdWysgMwye1+OyE2eyv7xGQA2JKRz2fgL+eG0OBIwLeT8s0pg6 f7/JGO2qOhKYInKlqcuwN1lg/jK1WyQDF3SFS6e+J4GwdIaFKpylpMtMxE4Q8Kjj konzmyCDojf9lWIV6Entf/RjohBssk6IaE0ovMHGNZJJF3RdMqU= =iami -----END PGP SIGNATURE----- --JfcVJMzcoez3zDcB--