From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MKz+Tg6H; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 613425A0262 for ; Sat, 16 May 2026 11:27:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1778923641; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hB25EFcpw3fmJODp+x2CuIC3Awk3u56pMGxuryHZIp0=; b=MKz+Tg6H/oZjOk5SqAK6E87qcW5GadYeA5IAHnJ/AMufywMtovZTZwA1Z++mjKhzk24ny+ c8p1Ppn3A0SPMaNVdvRqdRrhJ4fenr9buxZVIaH2W75kuypqIHbD08YQgS85R0R6YErljy zl//IJyMAoV1R1zKi6JpO/WxzIAWclU= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-90-FHtqdXZSO4KBNdUyoQxxFQ-1; Sat, 16 May 2026 05:27:20 -0400 X-MC-Unique: FHtqdXZSO4KBNdUyoQxxFQ-1 X-Mimecast-MFC-AGG-ID: FHtqdXZSO4KBNdUyoQxxFQ_1778923639 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-43fe791a398so457444f8f.0 for ; Sat, 16 May 2026 02:27:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778923639; x=1779528439; h=date:content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hB25EFcpw3fmJODp+x2CuIC3Awk3u56pMGxuryHZIp0=; b=Wu1b0imbyyMJMrUIsIh84aLiHV0hBDXcvst/bMb8Lr2puv+TzOP6IJVa6pdEPXA701 ovXBolJAux3m5CinhlDuQncCwcR7Z6G2gZ0/o2i98p/UxguDs4TKvvbZEXXlKo2OOVUf 3d8t2xO6gRgD0JeMj5VFqBdz4F3PeJ/gjpISyAGtuzJEZDIuKWgkO0YAYcZak7tbW7Y0 /CZ2aTFBrzsa0eLTFJy05ydDpSVBOyQ+yTWdIsIUyvcPwrDpXg15QnU7P8Npk5SYXHqI V+PB5MAIH2NH1yd43W96WvWZgi11tHfK1k8vuyP9bg9J67wK+uLa4tmwikkXB/7Bv63e mPBg== X-Forwarded-Encrypted: i=1; AFNElJ81z2WNpLT3jk8r6K9q/b4wyj5dpwu7Eoexa4t3u2fICjF8t05L3JCa9/gaK/3NCWM3qIKsLM8OCkA=@passt.top X-Gm-Message-State: AOJu0YxSndc1y0Gyr5KrVmVUM5Br7decvcUt8FWreHlRhNZG/ShjgsSr vnNNgEOEkNccVgCHc8WbEo5ZMOLVxMgDPgBOQvJMiIVb2qIFkySYy0tUQWoNvjiZLnKSNQdPrw+ I79JRkLvuCc/nkMtkW1I0sa7VD1gFbUObbQihnPjem7vHogt4bVDZzQ== X-Gm-Gg: Acq92OFw7tz8MFfyci2VOsOyAHWi+gRjmkWyYTTCsPp9XKkd4btLqMwZ+yBjay1ZaRE DpgkAvEkjIXGS1kf+qNP07XZ2F8pwPuOgFkth2aMEnzz1ybu7eBtEGhpXqW+GPp0sj1nlOftEXW IUyZ6iJ5n3lrwpYHovVukm3Y3MIJGFbNoNC2dYjZEnv5LrT2kWGmOoSfAk0dcjJcTfDVTWv94r2 jubgXehuV96m2NUvQxbV9de9+3Uo1VEKrhnowtLSkY+Ke36w051phKkoTfxKnR/FQQzfE4HuXhx 20HYXFD67dKP5tu4nV7PryQD3NxPuiIYsVP8COtI8wvsgdTQ/qxde4NqD2fod4kQUkT+hzFI5uZ m/TudPWRGgGSD9wI/JlSqNBZ8etmwC+lm X-Received: by 2002:a05:6000:1acd:b0:45a:dd99:96c8 with SMTP id ffacd0b85a97d-45e5c613125mr10703958f8f.41.1778923638646; Sat, 16 May 2026 02:27:18 -0700 (PDT) X-Received: by 2002:a05:6000:1acd:b0:45a:dd99:96c8 with SMTP id ffacd0b85a97d-45e5c613125mr10703911f8f.41.1778923638076; Sat, 16 May 2026 02:27:18 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-45d9e768bcesm22315660f8f.4.2026.05.16.02.27.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2026 02:27:17 -0700 (PDT) From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 2/3] Fix build with -DNDEBUG Message-ID: <20260516112715.6e3d2730@elisabeth> In-Reply-To: References: <20260515041312.317644-1-david@gibson.dropbear.id.au> <20260515041312.317644-3-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 Date: Sat, 16 May 2026 11:27:16 +0200 (CEST) X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: OWg2kfh4dbevDzJSzEitUiMPeGn8Eh9_b6tBPM95G0Y_1778923639 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: ZH4TPL2VV4NCIS55TVFHWMSXYV2CRIKW X-Message-ID-Hash: ZH4TPL2VV4NCIS55TVFHWMSXYV2CRIKW X-MailFrom: sbrivio@redhat.com 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: Jan Palus , 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: On Sat, 16 May 2026 16:28:52 +1000 David Gibson wrote: > On Fri, May 15, 2026 at 01:05:50PM +0200, Jan Palus wrote: > > On 15.05.2026 14:13, David Gibson wrote: > > > Since bc872d91765d, our assert() statements are omitted if we compile with > > > -DNDEBUG, like the standard library assert(3). Unfortunately a trivial but > > > embarrassing mistake in that patch means that instead of never aborting in > > > this case, assert_with_msg() *always* aborts, breaking pretty much > > > everything. > > > > > > There's also a missing #include that breaks the build with -DNDEBUG on at > > > least some library versions. > > > > > > Reported-by: Jan Palus > > > Fixes: bc872d91765d ("treewide: Spell ASSERT() as assert()") > > > Signed-off-by: David Gibson > > > --- > > > util.h | 3 ++- > > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > > > diff --git a/util.h b/util.h > > > index 70aadeba..11f71d45 100644 > > > --- a/util.h > > > +++ b/util.h > > > @@ -6,6 +6,7 @@ > > > #ifndef UTIL_H > > > #define UTIL_H > > > > > > +#include > > > #include > > > #include > > > #include > > > @@ -60,7 +61,7 @@ void abort_with_msg(const char *fmt, ...) > > > __func__, __FILE__, __LINE__, STRINGIFY(expr)) > > > #else > > > #define assert_with_msg(expr, ...) \ > > > - ((void)(expr), 0 ? (void)0 : abort_with_msg(__VA_ARGS__)) > > > + ((void)(expr), 1 ? (void)0 : abort_with_msg(__VA_ARGS__)) > > > > There is a slight semantic difference between assert() and > > assert_with_msg() when building with -DNDEBUG -- `expr` is still being > > evaluated in abort_with_msg() although likely optimized out in most > > builds. > > Right, I'm expecting the compiler to optimise this away. That won't > be the case if the expression has side effects, but side effects in an > assert() expression is already a bug, precisely because of the > possibility NDEBUG. > > > I'm assuming you'd prefer to avoid cppcheck suppressions. > > cppcheck suppressions would be acceptable if we could put them inside > the macro. But these are unused variable warnings, which show up at > the site of variable declaration not (obviously) at the place the > variable... isn't used. Putting suppressions on variables because > they might become unused depending on a macro definition certainly > isn't acceptable. Both for aesthetics, and because it means if we > removed the assert we'd no longer get a warning that the variable now > really isn't used. > > > How > > about moving `expr` into branch which is never evaluated then? Would it > > keep cppcheck happy? > > > > + (1 ? (void)0 : ((void)(expr), abort_with_msg(__VA_ARGS__))) > > That does work. Not sure if it's worth the bother of a respin. > Stefano, any opinion? I think it would be worth changing that given that the only reason why PLD Linux enables NDEBUG is to avoid evaluating those expressions. I can also change it on merge though, it's trivial enough. I'll do that if everybody is fine with it. -- Stefano