Skip to content

Commit b3ed3e0

Browse files
committed
rust: enable clippy::unnecessary_safety_comment lint
commit c28bfe7 upstream. In Rust 1.67.0, Clippy added the `unnecessary_safety_comment` lint [1], which is the "inverse" of `undocumented_unsafe_blocks`: it finds places where safe code has a `// SAFETY` comment attached. The lint currently finds 3 places where we had such mistakes, thus it seems already quite useful. Thus clean those and enable it. Link: https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_safety_comment [1] Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Trevor Gross <tmgross@umich.edu> Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com> Tested-by: Gary Guo <gary@garyguo.net> Reviewed-by: Gary Guo <gary@garyguo.net> Link: https://lore.kernel.org/r/20240904204347.168520-6-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent 3240248 commit b3ed3e0

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ export rust_common_flags := --edition=2021 \
459459
-Aclippy::needless_lifetimes \
460460
-Wclippy::no_mangle_with_rust_abi \
461461
-Wclippy::undocumented_unsafe_blocks \
462+
-Wclippy::unnecessary_safety_comment \
462463
-Wrustdoc::missing_crate_level_docs
463464

464465
KBUILD_HOSTCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(HOST_LFS_CFLAGS) \

rust/kernel/sync/arc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ impl<T: 'static> ForeignOwnable for Arc<T> {
338338
}
339339

340340
unsafe fn borrow<'a>(ptr: *const core::ffi::c_void) -> ArcBorrow<'a, T> {
341-
// SAFETY: By the safety requirement of this function, we know that `ptr` came from
341+
// By the safety requirement of this function, we know that `ptr` came from
342342
// a previous call to `Arc::into_foreign`.
343343
let inner = NonNull::new(ptr as *mut ArcInner<T>).unwrap();
344344

rust/kernel/workqueue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ where
526526
T: HasWork<T, ID>,
527527
{
528528
unsafe extern "C" fn run(ptr: *mut bindings::work_struct) {
529-
// SAFETY: The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
529+
// The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
530530
let ptr = ptr as *mut Work<T, ID>;
531531
// SAFETY: This computes the pointer that `__enqueue` got from `Arc::into_raw`.
532532
let ptr = unsafe { T::work_container_of(ptr) };
@@ -573,7 +573,7 @@ where
573573
T: HasWork<T, ID>,
574574
{
575575
unsafe extern "C" fn run(ptr: *mut bindings::work_struct) {
576-
// SAFETY: The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
576+
// The `__enqueue` method always uses a `work_struct` stored in a `Work<T, ID>`.
577577
let ptr = ptr as *mut Work<T, ID>;
578578
// SAFETY: This computes the pointer that `__enqueue` got from `Arc::into_raw`.
579579
let ptr = unsafe { T::work_container_of(ptr) };

0 commit comments

Comments
 (0)