Skip to contentSkip to conversation

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

PATCH Applied Tamir Duberstein 5 participants 10 messages Dec 22, 2025 – Jan 30

Subsystems (2)
lore
Share & tools
lore

Tamir Duberstein

author reviewer
#0 lore raw

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

---
 rust/kernel/seq_file.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/seq_file.rs +2 -2
index 855e533813a6..518265558d66 100644
@@ -4,7 +4,7 @@
 //!
 //! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.h)
 
-use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
+use crate::{bindings, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
 
 /// A utility for generating the contents of a seq file.
 #[repr(transparent)]
@@ -36,7 +36,7 @@ pub fn call_printf(&self, args: fmt::Arguments<'_>) {
         unsafe {
             bindings::seq_printf(
                 self.inner.get(),
-                c_str!("%pA").as_char_ptr(),
+                c"%pA".as_char_ptr(),
                 core::ptr::from_ref(&args).cast::<crate::ffi::c_void>(),
             );
         }

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-vfs-55ca2ceca0a4

Best regards,

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

---
rust/kernel/seq_file.rs | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/seq_file.rs +2 -3
index 855e533813a6..518265558d66 100644
@@ -4,7 +4,7 @@
 //!
 //! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.h)
 
-use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
+use crate::{bindings, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
 
 /// A utility for generating the contents of a seq file.
 #[repr(transparent)]
@@ -36,7 +36,7 @@ pub fn call_printf(&self, args: fmt::Arguments<'_>) {
        unsafe {
            bindings::seq_printf(
                self.inner.get(),
-                c_str!("%pA").as_char_ptr(),
+                c"%pA".as_char_ptr(),
                core::ptr::from_ref(&args).cast::<crate::ffi::c_void>(),
            );
        }
 
---

base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-vfs-55ca2ceca0a4

Quoted 5 lines

Best regards,

Signature · 1 line
Tamir Duberstein <[email protected]>
#2 lore raw
In reply to Tamir Duberstein
Quoted 41 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.

---
 rust/kernel/seq_file.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/seq_file.rs +2 -3
index 855e533813a6..518265558d66 100644
@@ -4,7 +4,7 @@
 //!
 //! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.h)
 
-use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
+use crate::{bindings, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
 
 /// A utility for generating the contents of a seq file.
 #[repr(transparent)]
@@ -36,7 +36,7 @@ pub fn call_printf(&self, args: fmt::Arguments<'_>) {
         unsafe {
             bindings::seq_printf(
                 self.inner.get(),
-                c_str!("%pA").as_char_ptr(),
+                c"%pA".as_char_ptr(),
                 core::ptr::from_ref(&args).cast::<crate::ffi::c_void>(),
             );
         }
 
---

base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-vfs-55ca2ceca0a4

Quoted 4 lines

Best regards,
--
Tamir Duberstein <[email protected]>

@Christian could you please have a look?

Cheers.
Tamir

#3 lore raw
Quoted 50 lines · Tamir Duberstein
Quoted 41 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.

---
 rust/kernel/seq_file.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/seq_file.rs +2 -3
index 855e533813a6..518265558d66 100644
@@ -4,7 +4,7 @@
 //!
 //! C header: [`include/linux/seq_file.h`](srctree/include/linux/seq_file.h)
 
-use crate::{bindings, c_str, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
+use crate::{bindings, fmt, str::CStrExt as _, types::NotThreadSafe, types::Opaque};
 
 /// A utility for generating the contents of a seq file.
 #[repr(transparent)]
@@ -36,7 +36,7 @@ pub fn call_printf(&self, args: fmt::Arguments<'_>) {
         unsafe {
             bindings::seq_printf(
                 self.inner.get(),
-                c_str!("%pA").as_char_ptr(),
+                c"%pA".as_char_ptr(),
                 core::ptr::from_ref(&args).cast::<crate::ffi::c_void>(),
             );
         }
 
---

base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251222-cstr-vfs-55ca2ceca0a4

Quoted 4 lines

Best regards,
--
Tamir Duberstein <[email protected]>

@Christian could you please have a look?

Quoted 2 lines

Cheers.
Tamir

Alexander or Christian: could you please take this through vfs or would you be ok with it going through rust-next?

#5 lore raw
Quoted 8 lines · Miguel Ojeda
Quoted 3 lines · Tamir Duberstein

Alexander or Christian: could you please take this through vfs or would you be ok with it going through rust-next?

Either seems good to me, thanks!

Quoted 7 lines

For context, this is part of a long migration:

    https://github.com/Rust-for-Linux/linux/issues/1075
    https://lore.kernel.org/all/[email protected]/

Cheers,
Miguel

Another ping here, folks! Miguel, what can we do if we do not hear from the vfs maintainers?

maintainer Applied
#6 lore raw
In reply to Tamir Duberstein
Quoted 4 lines · Tamir Duberstein

C-String literals were added in Rust 1.77. Replace instances of kernel::c_str! with C-String literals where possible.

Applied to the vfs-7.0.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.0.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.0.misc

[1/1] rust: seq_file: replace kernel::c_str! with C-Strings

      https://git.kernel.org/vfs/vfs/c/40210c2b11a8
author reviewer
#7 lore raw
Quoted 16 lines · Christian Brauner
Quoted 4 lines · Tamir Duberstein

C-String literals were added in Rust 1.77. Replace instances of kernel::c_str! with C-String literals where possible.

Applied to the vfs-7.0.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.0.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Quoted 8 lines

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.0.misc

[1/1] rust: seq_file: replace kernel::c_str! with C-Strings

      https://git.kernel.org/vfs/vfs/c/40210c2b11a8

Thanks Cristian. The commit doesn't seem to exist (with this hash or
any other, see https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-7.0.misc).
Is this expected?

Cheers.
Tamir

author reviewer
#9 lore raw
Quoted 8 lines · Miguel Ojeda
Quoted 4 lines · Tamir Duberstein

Thanks Cristian. The commit doesn't seem to exist (with this hash or
any other, see https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git/log/?h=vfs-7.0.misc).
Is this expected?

Christian may not have pushed the batch yet, given the dates in the repository.

Indeed, and that remains true now. Unfortunately this commit wont land in linux-next until pushed, which is making me a bit worried about discovering last-minute breakage.