rust: sync: replace `kernel::c_str!` with C-Strings
Tamir Duberstein
reviewerPATCH v4 1/1 rust: sync: replace `kernel::c_str!` with C-Strings
From: Tamir Duberstein <[email protected]>
C-String literals were added in Rust 1.77. Replace instances of kernel::c_str! with C-String literals where possible.
---
This intentionally includes only those changes that can be taken through
the Rust tree. I will send separate patches after rc1 for the remaining changes.
---
Changes in v4:
- Drop applied patches.
- Drop rust/kernel/net/phy.rs patch; will send to netdev after rc1.
- Drop changes to new_spinlock!; allow callers to pass plain string
literals rather than C-string literals.
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Include all patches that can be taken through the rust tree.
- Split "sync" patch into "sync" and "workqueue". Kept the tags on both.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Rebase.
- Add two patches to address new code.
- Drop incorrectly applied Acked-by tags from Danilo.
- Link to v1: https://lore.kernel.org/r/[email protected]
--- rust/kernel/sync.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
rust/kernel/sync.rs +1 -2
@@ -48,7 +48,6 @@ impl LockClassKey {/// /// # Examples /// ``` -/// # use kernel::c_str; /// # use kernel::alloc::KBox; /// # use kernel::types::ForeignOwnable; /// # use kernel::sync::{LockClassKey, SpinLock};
@@ -60,7 +59,7 @@ impl LockClassKey {/// { /// stack_pin_init!(let num: SpinLock<u32> = SpinLock::new( /// 0, -/// c_str!("my_spinlock"), +/// c"my_spinlock", /// // SAFETY: `key_ptr` is returned by the above `into_foreign()`, whose /// // `from_foreign()` has not yet been called. /// unsafe { <Pin<KBox<LockClassKey>> as ForeignOwnable>::borrow(key_ptr) }
---
base-commit: bf724be7f00cf2cbafc105422476f6242e917a90
change-id: 20250710-core-cstr-cstrings-1faaa632f0fd
Best regards,
Signature · 1 line
Tamir Duberstein <[email protected]>
Miguel Ojeda
AppliedQuoted 10 lines · Tamir Duberstein
From: Tamir Duberstein <[email protected]>
C-String literals were added in Rust 1.77. Replace instances of
kernel::c_str!with C-String literals where possible.Reviewed-by Alice Ryhl <[email protected]>Reviewed-by Benno Lossin <[email protected]>Signed-off-by Tamir Duberstein <[email protected]>
Applied to rust-next -- thanks everyone!
Cheers,
Miguel