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

Paul Walmsley
2026-04-03T17:47:02Z

[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]

On Fri, 20 Mar 2026, Paul Walmsley wrote:

> On Mon, 9 Mar 2026, Charlie Jenkins via B4 Relay wrote:
>
> > From: Charlie Jenkins <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:
> >
> > validate_v_ptrace.c:626:17: error: ‘else’ without a previous ‘if’
>
> That's annoying. Can't the macro body be wrapped in do { ... } while (0);
> instead, rather than adding these permanent checkpatch warnings?

I guess you haven't had the chance to take a look at this. Or maybe you
took a look at the kselftest harness macro mess and just decided not to
say anything ;-) I did look, after not hearing back, and the way those
macros are used would make it a big and painful lift to straighten out -
definitely not something for the -rc time frame.

So in the short term, I'm planning to take this as a fix to deal with the
immediate issue.

checkpatch.pl clearly needs to be patched to assume that these kselftest
harness macros don't follow the rules. Care to take that on?

- Paul