lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aBEXUG7QH0ymRuLm@pollux>
Date: Tue, 29 Apr 2025 20:15:44 +0200
From: Danilo Krummrich <dakr@...nel.org>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"Rafael J. Wysocki" <rafael@...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>,
	Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
	rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
	patches@...ts.linux.dev
Subject: Re: [PATCH] rust: device: allow `dead_code` for `Device<>::parent()`

On Tue, Apr 29, 2025 at 05:03:46PM +0200, Miguel Ojeda wrote:
> When `CONFIG_AUXILIARY_BUS` is disabled, `parent()` is still dead code:
> 
>     error: method `parent` is never used
>       --> rust/kernel/device.rs:71:19
>        |
>     64 | impl<Ctx: DeviceContext> Device<Ctx> {
>        | ------------------------------------ method in this implementation
>     ...
>     71 |     pub(crate) fn parent(&self) -> Option<&Self> {
>        |                   ^^^^^^
>        |
>        = note: `-D dead-code` implied by `-D warnings`
>        = help: to override `-D warnings` add `#[allow(dead_code)]`
> 
> Thus reintroduce the `expect`, but now as an `allow`, and do so as
> `dead_code` since that is narrower.
> 
> Fixes: ce735e73dd59 ("rust: auxiliary: add auxiliary device / driver abstractions")
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

Good catch, thanks!

I wonder if for such or similar cases we want something like

	macro_rules! cfg_expect {
	    (not($cfg:meta) => $lint:ident, $item:item) => {
		#[cfg(not($cfg))]
		#[expect($lint)]
		$item

		#[cfg($cfg)]
		$item
	    };
	}

which could be used like this:

    cfg_expect!(not(CONFIG_FEATURE) => dead_code,
        pub(crate) fn foo(&self) {
            // noop
        }
    );

Maybe there is a much better solution I don't know about.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ