Refining KASSERT

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Mon, 15 Jul 2024 21:35:56 UTC
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