From nobody Mon Jul 15 21:35:56 2024 X-Original-To: arch@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WNFr65t56z5QDbx for ; Mon, 15 Jul 2024 21:36:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WNFr64g39z4qSH for ; Mon, 15 Jul 2024 21:36:06 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721079366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=khfVLyVJCIBxop4DcILx7tlQq7QdjWJBupt+Y3eb98k=; b=fVaBfm6PdqLiNHYMH1EVxfPudGWxzyNogtJacWknsx/1aDIA5VAGILBFn5Hy5QaobTBGH4 aq/LOfAGWy5JB1LhwMRia4Y5Iy9Od0hzhXi58492c4jaJVNmKrF4IkxN3IyhcLdQzYPYYL osWZtHaTu9gDa9n1AaVM1rYJiyylmzOWavz6377eqEMS8t6SroONUrDg3y9NWKHCaE2cd3 ZJx18UTKltkAP/cWZNn0JYQh/iLyhOTfLxzkczKKUayy585swl26PEN+VheZqcLx7CBJcb PQIbwm+zoJCucxAawsDfXQwjfPaJu9qfVo6IDo98LCiHEjkQX6EjKP8vWqmJUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721079366; a=rsa-sha256; cv=none; b=Y98IHXsKuBEm7X1umsP7TwMjBxEcS5+arlB2j17c8r7FpXoPAq2DhTUfjPecOxFT9oh6wy 1lA8KNv+0JTZu6sks6U1saGyNQozpRKMVbOmFEXh+jBYzEkhzLcUT0tL1oTg2X6V0978Ah cXYoB/LzpDOIb4JCDdIi1jYGsRnCIFBonTk6zon8UaXt/1BdgbJqQsxI0xMB//wFoIVths 3OgmMLNnu8aUotC4nLukcKzwzO3lEa5hgT21VK6AzykFlfXoYFn0W72kKy9wA+u3oJfgL3 9AisUoGXoV2qAKc30qUcbmlhRx58/Fr+tU+fKdYHG5wfmNICxsX0r0FGtxDPbQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721079366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=khfVLyVJCIBxop4DcILx7tlQq7QdjWJBupt+Y3eb98k=; b=soSDav1WUH+jau4HjPL+qB5FXfbEDvmKXgEmvCuViplMd9o5Po2IOMWLHWihd75/+6QVjW OP1YlOYC83XuPLxZFPpdOCkYcOVnWcHsqmqTzW3QkTjo98AX+kkXYgd6NfQijDFKixaMpV krAAZxveR9bX/cE1OeSNtEYUQVCuVFxQRQxu6AQp3exT7xB6a682a/pSVevvwNijumfptx TBANJ+UyD3Cl7TjSibGLTrkEvFv/kem8N3X7KaIF7eEg912KQ/GXaCqBGGVrC3uTchAg16 en/j/XLdhnjie18LUKV/mBee3TTYQkg6khZFZZbszmDpwhqR0o6P5TOAQ/nTNg== Received: from [IPV6:2601:5c0:4200:b830:28d3:efa9:9f5c:a97f] (unknown [IPv6:2601:5c0:4200:b830:28d3:efa9:9f5c:a97f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 4WNFqy0RMrzFGn for ; Mon, 15 Jul 2024 21:35:57 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Mon, 15 Jul 2024 17:35:56 -0400 List-Id: Discussion related to FreeBSD architecture List-Archive: https://lists.freebsd.org/archives/freebsd-arch List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arch@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US From: John Baldwin To: arch@FreeBSD.org Subject: Refining KASSERT Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit The nested parentheses in KASSERT invocations have been driving me nuts for a long time. In particular, they do not play well with some editors when it comes to auto-formatting, etc. They also read ugly compared to the more standardized assert() and static_assert(). To that end, I've come up with a patch that permits dropping the nested parentheses by making use of __VA_ARGS__. However, it seeks to permit a graceful transition, so it has one caveat which is that the current patch assumes that if exactly 2 arguments are passed to KASSERT, the second argument does use nested parentheses. This means that an assertion message with that is just a constant string must still use nested parentheses for now. If we decide to pursue this route, my thought would be to commit the patch permitting both the old and new forms and merge that to older branches. Then work on purging nested parentheses for assertions with arguments. Finally, we could do a pass in main (not MFC'd) to drop the backwards compat. This commit would have to also remove all the remaining nested parentheses. In addition to removing the need for parentheses, the patch adds a single argument form of KASSERT() identical to MPASS(). The patch in question is here if folks want to comment: https://reviews.freebsd.org/D45981 -- John Baldwin