Skip to contentSkip to conversation

rust: miscdevice: replace `kernel::c_str!` with C-Strings

PATCH In review Tamir Duberstein 2 participants 2 messages Dec 22, 2025

Subsystems (2)
lore
Share & tools
lore

Tamir Duberstein

author reviewer
#0 lore raw

PATCH 1/1 rust: miscdevice: 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.

---
 samples/rust/rust_misc_device.rs | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
samples/rust/rust_misc_device.rs +1 -2
index d69bc33dbd99..49dd5814e1ab 100644
@@ -98,7 +98,6 @@
 use core::pin::Pin;
 
 use kernel::{
-    c_str,
     device::Device,
     fs::{File, Kiocb},
     ioctl::{_IO, _IOC_SIZE, _IOR, _IOW},
@@ -133,7 +132,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
         pr_info!("Initialising Rust Misc Device Sample\n");
 
         let options = MiscDeviceOptions {
-            name: c_str!("rust-misc-device"),
+            name: c"rust-misc-device",
         };
 
         try_pin_init!(Self {

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-char-misc-0f4144d0a7b2

Best regards,

Signature · 1 line
Tamir Duberstein <[email protected]>
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 43 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.

---
samples/rust/rust_misc_device.rs | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
samples/rust/rust_misc_device.rs +1 -3
index d69bc33dbd99..49dd5814e1ab 100644
@@ -98,7 +98,6 @@
 use core::pin::Pin;
 
 use kernel::{
-    c_str,
    device::Device,
    fs::{File, Kiocb},
    ioctl::{_IO, _IOC_SIZE, _IOR, _IOW},
@@ -133,7 +132,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {
        pr_info!("Initialising Rust Misc Device Sample\n");
 
        let options = MiscDeviceOptions {
-            name: c_str!("rust-misc-device"),
+            name: c"rust-misc-device",
        };
 
        try_pin_init!(Self {
 
---

base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-char-misc-0f4144d0a7b2

Quoted 5 lines

Best regards,

Signature · 1 line
Tamir Duberstein <[email protected]>