* [PATCH] rust: auxiliary: fix false positive warning for missing a safety comment
@ 2025-11-03 20:39 Danilo Krummrich
2025-11-03 22:56 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Danilo Krummrich @ 2025-11-03 20:39 UTC (permalink / raw)
To: gregkh, rafael, david.m.ertman, ira.weiny, leon, ojeda,
alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
aliceryhl, tmgross
Cc: linux-kernel, rust-for-linux, Danilo Krummrich
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: auxiliary: fix false positive warning for missing a safety comment
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
2025-11-04 8:43 ` Alice Ryhl
2025-11-05 0:31 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2025-11-03 22:56 UTC (permalink / raw)
To: Danilo Krummrich
Cc: rafael, david.m.ertman, ira.weiny, leon, ojeda, alex.gaynor,
boqun.feng, gary, bjorn3_gh, lossin, a.hindborg, aliceryhl,
tmgross, linux-kernel, rust-for-linux
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>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: auxiliary: fix false positive warning for missing a safety comment
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
@ 2025-11-04 8:43 ` Alice Ryhl
2025-11-05 0:31 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Alice Ryhl @ 2025-11-04 8:43 UTC (permalink / raw)
To: Danilo Krummrich
Cc: gregkh, rafael, david.m.ertman, ira.weiny, leon, ojeda,
alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
tmgross, linux-kernel, rust-for-linux
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>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] rust: auxiliary: fix false positive warning for missing a safety comment
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
2025-11-04 8:43 ` Alice Ryhl
@ 2025-11-05 0:31 ` Danilo Krummrich
2 siblings, 0 replies; 4+ messages in thread
From: Danilo Krummrich @ 2025-11-05 0:31 UTC (permalink / raw)
To: gregkh, rafael, david.m.ertman, ira.weiny, leon, ojeda,
alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin, a.hindborg,
aliceryhl, tmgross
Cc: linux-kernel, rust-for-linux
On Mon Nov 3, 2025 at 9:39 PM CET, 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>
Applied to driver-core-testing, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-05 0:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2025-11-04 8:43 ` Alice Ryhl
2025-11-05 0:31 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).