Re: [PATCH v2 2/4] selftests: riscv: Add braces around EXPECT_EQ()

Joe Perches
2026-03-10T03:50:41Z

(adding Kees Cook as he originally submitted this __EXPECT macro)

On Mon, 2026-03-09 at 18:52 -0700, Charlie Jenkins via B4 Relay wrote:
> From: Charlie Jenkins <[thecharlesjenkins@gmail.com](mailto:thecharlesjenkins@gmail.com)>
>
> EXPECT_EQ() expands to multiple lines, breaking up one-line if
> statements. This issue was not present in the patch on the mailing list
> but was instead introduced by the maintainer when attempting to fix up
> checkpatch warnings. Add braces around EXPECT_EQ() to avoid the error
> even though checkpatch suggests them to be removed:

The __EXPECT macro definition is a multistatement
"do { ... } while (0); OPTIONAL_HANDLER(_assert)

Perhaps the multistatement __EXPECT should have another
do {} while (0) around both statments like:

do {
do { ... } while (0);
OPTIONAL_HANDLER(_assert);
} while (0)

so if else blocks without braces would work.

Perhaps the same for the __EXPECT_STR macro definition.