Skip to content

Commit 5ba95b6

Browse files
ojedajfvogel
authored andcommitted
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 <[email protected]> Reviewed-by: Trevor Gross <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> Tested-by: Gary Guo <[email protected]> Reviewed-by: Gary Guo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit c778ec35c3ccd90503648d4cf9274b5995aa1023) Signed-off-by: Jack Vogel <[email protected]>
1 parent 30cb07f commit 5ba95b6

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
@@ -461,6 +461,7 @@ export rust_common_flags := --edition=2021 \
461461
-Aclippy::needless_lifetimes \
462462
-Wclippy::no_mangle_with_rust_abi \
463463
-Wclippy::undocumented_unsafe_blocks \
464+
-Wclippy::unnecessary_safety_comment \
464465
-Wrustdoc::missing_crate_level_docs
465466

466467
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)