From: FUJITA Tomonori <tomo@flapping.org>
To: gary@garyguo.net
Cc: tomo@flapping.org, ojeda@kernel.org, a.hindborg@kernel.org,
acourbot@nvidia.com, aliceryhl@google.com,
bjorn3_gh@protonmail.com, boqun@kernel.org, dakr@kernel.org,
daniel.almeida@collabora.com, lossin@kernel.org,
tamird@kernel.org, tmgross@umich.edu, work@onurozkan.dev,
rust-for-linux@vger.kernel.org, fujita.tomonori@gmail.com
Subject: Re: [PATCH v1] rust: bug: prevent dead_code warning from warn_on!'s flags constant
Date: Fri, 24 Jul 2026 13:08:53 +0900 (JST) [thread overview]
Message-ID: <20260724.130853.1719089301624801198.tomo@flapping.org> (raw)
In-Reply-To: <DK6CISNRMHJD.391EZL08Z6HM0@garyguo.net>
On Fri, 24 Jul 2026 00:40:04 +0100
"Gary Guo" <gary@garyguo.net> wrote:
>> diff --git a/rust/kernel/bug.rs b/rust/kernel/bug.rs
>> index ed943960f851..2fd7ee25abcb 100644
>> --- a/rust/kernel/bug.rs
>> +++ b/rust/kernel/bug.rs
>> @@ -123,9 +123,9 @@ macro_rules! warn_on {
>> const _COND_STR: &str = file!();
>>
>> if cond {
>> - const WARN_ON_FLAGS: u32 = $crate::bug::bugflag_taint($crate::bindings::TAINT_WARN);
>> + const _WARN_ON_FLAGS: u32 = $crate::bug::bugflag_taint($crate::bindings::TAINT_WARN);
>>
>> - $crate::warn_flags!(_COND_STR, WARN_ON_FLAGS);
>> + $crate::warn_flags!(_COND_STR, _WARN_ON_FLAGS);
>
> Hmm, why bother adding a const for this rather than just invoke
>
> $crate::warn_flags!(
> _COND_STR,
> const { ... }
> )
>
> ?
Ah, `(const { ... })` works.
> Also, the proper fix would be to mark it as used in the `warn_flags` macro
> that discard the expression.
>
> if false {
> _ = $flags;
> }
Yeah, having the callee that discards the argument consume it is more
logical than working around it at the caller. I'll send v2 shortly.
The same reasoning applies to `$file`. Since there is no warning right
now, I'll rename `_COND_STR` to `COND_STR` and consume `$file` in a
separate patch for consistency.
next prev parent reply other threads:[~2026-07-24 4:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 3:55 [PATCH v1] rust: bug: prevent dead_code warning from warn_on!'s flags constant FUJITA Tomonori
2026-07-20 5:54 ` Boqun Feng
2026-07-20 6:05 ` FUJITA Tomonori
2026-07-20 15:27 ` Paul E. McKenney
2026-07-23 23:40 ` Gary Guo
2026-07-24 4:08 ` FUJITA Tomonori [this message]
2026-07-24 13:23 ` Gary Guo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260724.130853.1719089301624801198.tomo@flapping.org \
--to=tomo@flapping.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox