From: Greg KH <gregkh@linuxfoundation.org>
To: Danilo Krummrich <dakr@kernel.org>
Cc: rafael@kernel.org, david.m.ertman@intel.com, ira.weiny@intel.com,
leon@kernel.org, ojeda@kernel.org, alex.gaynor@gmail.com,
boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com,
lossin@kernel.org, a.hindborg@kernel.org, aliceryhl@google.com,
tmgross@umich.edu, linux-kernel@vger.kernel.org,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: auxiliary: fix false positive warning for missing a safety comment
Date: Tue, 4 Nov 2025 07:56:13 +0900 [thread overview]
Message-ID: <2025110402-careless-upstroke-4d35@gregkh> (raw)
In-Reply-To: <20251103203932.2361660-1-dakr@kernel.org>
On Mon, Nov 03, 2025 at 09:39:18PM +0100, Danilo Krummrich wrote:
> Some older (yet supported) versions of clippy throw a false positive
> warning for missing a safety comment when the safety comment is on a
> multiline statement.
>
> warning: unsafe block missing a safety comment
> --> rust/kernel/auxiliary.rs:351:22
> |
> 351 | Self(unsafe { NonNull::new_unchecked(adev) }),
> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> |
> = help: consider adding a safety comment on the preceding line
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks
> = note: requested on the command line with `-W clippy::undocumented-unsafe-blocks`
>
> warning: 1 warning emitted
>
> Fix this by placing the safety comment right on top of the same line
> introducing the unsafe block.
>
> Fixes: e4e679c8608e ("rust: auxiliary: unregister on parent device unbind")
> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
> ---
> rust/kernel/auxiliary.rs | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/rust/kernel/auxiliary.rs b/rust/kernel/auxiliary.rs
> index cc67fa5ddde3..618eeeec2bd0 100644
> --- a/rust/kernel/auxiliary.rs
> +++ b/rust/kernel/auxiliary.rs
> @@ -341,13 +341,12 @@ pub fn new<'a>(
> return Err(Error::from_errno(ret));
> }
>
> - // SAFETY: `adev` is guaranteed to be non-null, since the `KBox` was allocated
> - // successfully.
> - //
> // INVARIANT: The device will remain registered until `auxiliary_device_delete()` is
> // called, which happens in `Self::drop()`.
> Ok(Devres::new(
> parent,
> + // SAFETY: `adev` is guaranteed to be non-null, since the `KBox` was allocated
> + // successfully.
> Self(unsafe { NonNull::new_unchecked(adev) }),
> ))
> })
> --
> 2.51.0
>
>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
next prev parent reply other threads:[~2025-11-03 22:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-03 20:39 [PATCH] rust: auxiliary: fix false positive warning for missing a safety comment Danilo Krummrich
2025-11-03 22:56 ` Greg KH [this message]
2025-11-04 8:43 ` Alice Ryhl
2025-11-05 0:31 ` Danilo Krummrich
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=2025110402-careless-upstroke-4d35@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dakr@kernel.org \
--cc=david.m.ertman@intel.com \
--cc=gary@garyguo.net \
--cc=ira.weiny@intel.com \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rafael@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.