[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c30392e2-f0c0-458b-8b14-81661f83c67c@nvidia.com>
Date: Tue, 29 Apr 2025 13:35:20 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Tamir Duberstein <tamird@...il.com>, Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, Benno Lossin <benno.lossin@...ton.me>,
Andreas Hindborg <a.hindborg@...nel.org>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] rust: check type of `$ptr` in `container_of!`
On 4/29/25 1:20 AM, Alice Ryhl wrote:
> On Mon, Apr 28, 2025 at 12:54:19PM -0700, John Hubbard wrote:
...
>>> The `if false` branch is used to trigger a compilation failure when the
>>> macro is used incorrectly. The intent is that the compiler should
>>> optimize it out. I don't think there's anything wrong with that pattern.
>>
>> OK...probably best to either encapsulate that, or at least comment
>> it. I'm accustomed to seeing that pattern in cases where people
>> expected the code to *not* get optimized out, so it triggers me. :)
>
> Okay ... why exactly would people do that? I can't imagine what purpose
> that would serve.
>
lol I know, right? Two things, neither of which gives me joy to recall:
a) Configuration games, in which the dead code is available as an
option that is not configured right now.
b) Binary patching games, sort of the same as above.
And at a slightly higher level, my concern is that when one reads
code like "if false", it sets off "omg, someone is either confused
or doing something questionable...actually, why choose? Probably
both." :)
thanks,
--
John Hubbard
Powered by blists - more mailing lists