Skip to content

Commit 1d40cb0

Browse files
tamirdAndreas Hindborg
authored andcommitted
rust: configfs: replace kernel::c_str! with C-Strings
C-String literals were added in Rust 1.77. Replace instances of `kernel::c_str!` with C-String literals where possible. Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Tamir Duberstein <tamird@gmail.com> Acked-by: Andreas Hindborg <a.hindborg@kernel.org> Link: https://lore.kernel.org/r/20251222-cstr-configfs-v1-1-cc1665c51c43@gmail.com Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
1 parent 9ace475 commit 1d40cb0

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

rust/kernel/configfs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
//!
2222
//! ```ignore
2323
//! use kernel::alloc::flags;
24-
//! use kernel::c_str;
2524
//! use kernel::configfs_attrs;
2625
//! use kernel::configfs;
2726
//! use kernel::new_mutex;
@@ -50,7 +49,7 @@
5049
//!
5150
//! try_pin_init!(Self {
5251
//! config <- configfs::Subsystem::new(
53-
//! c_str!("rust_configfs"), item_type, Configuration::new()
52+
//! c"rust_configfs", item_type, Configuration::new()
5453
//! ),
5554
//! })
5655
//! }
@@ -66,7 +65,7 @@
6665
//! impl Configuration {
6766
//! fn new() -> impl PinInit<Self, Error> {
6867
//! try_pin_init!(Self {
69-
//! message: c_str!("Hello World\n"),
68+
//! message: c"Hello World\n",
7069
//! bar <- new_mutex!((KBox::new([0; PAGE_SIZE], flags::GFP_KERNEL)?, 0)),
7170
//! })
7271
//! }
@@ -1000,7 +999,9 @@ macro_rules! configfs_attrs {
1000999
static [< $data:upper _ $name:upper _ATTR >]:
10011000
$crate::configfs::Attribute<$attr, $data, $data> =
10021001
unsafe {
1003-
$crate::configfs::Attribute::new(c_str!(::core::stringify!($name)))
1002+
$crate::configfs::Attribute::new(
1003+
$crate::c_str!(::core::stringify!($name)),
1004+
)
10041005
};
10051006
)*
10061007

samples/rust/rust_configfs.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
//! Rust configfs sample.
44
55
use kernel::alloc::flags;
6-
use kernel::c_str;
76
use kernel::configfs;
87
use kernel::configfs::configfs_attrs;
98
use kernel::new_mutex;
@@ -35,7 +34,7 @@ struct Configuration {
3534
impl Configuration {
3635
fn new() -> impl PinInit<Self, Error> {
3736
try_pin_init!(Self {
38-
message: c_str!("Hello World\n"),
37+
message: c"Hello World\n",
3938
bar <- new_mutex!((KBox::new([0; PAGE_SIZE], flags::GFP_KERNEL)?, 0)),
4039
})
4140
}
@@ -61,7 +60,7 @@ impl kernel::InPlaceModule for RustConfigfs {
6160

6261
try_pin_init!(Self {
6362
config <- configfs::Subsystem::new(
64-
c_str!("rust_configfs"), item_type, Configuration::new()
63+
c"rust_configfs", item_type, Configuration::new()
6564
),
6665
})
6766
}

0 commit comments

Comments
 (0)