Re: [GIT PULL] locking changes for v6.13
From: Linus Torvalds
Date: Tue Nov 19 2024 - 15:57:02 EST
On Mon, 18 Nov 2024 at 01:03, Ingo Molnar <mingo@xxxxxxxxxx> wrote:
>
> - <linux/cleanup.h>:
> - Add if_not_cond_guard() conditional guard helper (David Lechner)
I've pulled this, but I'm unhappy.
This macro generates actively wrong code if it happens to be inside an
if-statement or a loop without a block.
IOW, code like this:
for (iterate-over-something)
if_not_guard(a)
return -BUSY;
looks like will build fine, but will generate completely incorrect code.
Honestly, just switching the order of the BUILD_BUG_ON() and the
CLASS() declaration looks like it would have fixed this (because then
the '_id' won't be in scope of the subsequent if-statement any more),
but I'm unhappy with how apparently nobody even bothered to think
about such a fundamental issue with macros.
Macros that expand to statements absolutely *ALWAYS* need to deal with
"what if we're in a single-statement situation?"
Linus