Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: auxiliary: fix false positive warning for missing a safety comment

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")
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://patch.msgid.link/20251103203932.2361660-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

+2 -3
+2 -3
rust/kernel/auxiliary.rs
··· 341 341 return Err(Error::from_errno(ret)); 342 342 } 343 343 344 - // SAFETY: `adev` is guaranteed to be non-null, since the `KBox` was allocated 345 - // successfully. 346 - // 347 344 // INVARIANT: The device will remain registered until `auxiliary_device_delete()` is 348 345 // called, which happens in `Self::drop()`. 349 346 Ok(Devres::new( 350 347 parent, 348 + // SAFETY: `adev` is guaranteed to be non-null, since the `KBox` was allocated 349 + // successfully. 351 350 Self(unsafe { NonNull::new_unchecked(adev) }), 352 351 )) 353 352 })