[tip: locking/core] rust: atomic: Update a safety comment in impl of `fetch_add()`
From: tip-bot2 for Andreas Hindborg
Date: Mon Mar 09 2026 - 15:52:57 EST
The following commit has been merged into the locking/core branch of tip:
Commit-ID: b91d5d4bcf1266257a9e0199e1b4ad7fa8771baa
Gitweb: https://git.kernel.org/tip/b91d5d4bcf1266257a9e0199e1b4ad7fa8771baa
Author: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
AuthorDate: Tue, 03 Mar 2026 12:17:01 -08:00
Committer: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
CommitterDate: Sun, 08 Mar 2026 11:06:51 +01:00
rust: atomic: Update a safety comment in impl of `fetch_add()`
The safety comment used in the implementation of `fetch_add()` could be
read as just saying something it is true without justifying it. Update
the safety comment to include justification.
Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
Signed-off-by: Boqun Feng <boqun@xxxxxxxxxx>
Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>
Link: https://patch.msgid.link/20260220-atomic-sub-v3-3-e63cbed1d2aa@xxxxxxxxxx
Link: https://patch.msgid.link/20260303201701.12204-14-boqun@xxxxxxxxxx
---
rust/kernel/sync/atomic/internal.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/sync/atomic/internal.rs b/rust/kernel/sync/atomic/internal.rs
index b762dbd..ad810c2 100644
--- a/rust/kernel/sync/atomic/internal.rs
+++ b/rust/kernel/sync/atomic/internal.rs
@@ -337,7 +337,7 @@ declare_and_impl_atomic_methods!(
/// Atomically updates `*a` to `(*a).wrapping_add(v)`, and returns the value of `*a`
/// before the update.
fn fetch_add[acquire, release, relaxed](a: &AtomicRepr<Self>, v: Self::Delta) -> Self {
- // SAFETY: `a.as_ptr()` is valid and properly aligned.
+ // SAFETY: `a.as_ptr()` guarantees the returned pointer is valid and properly aligned.
unsafe { bindings::#call(v, a.as_ptr().cast()) }
}