summaryrefslogtreecommitdiff
path: root/rust/kernel/debugfs
diff options
context:
space:
mode:
authorKe Sun <sunke@kylinos.cn>2026-01-20 16:38:20 +0800
committerDanilo Krummrich <dakr@kernel.org>2026-01-25 20:53:30 +0100
commitae3bf7612220ac8a8020a285142e0d918543a408 (patch)
tree98a8a42d433cb49d749353a4c2f23c8f13616116 /rust/kernel/debugfs
parentf8ed7a49d40aea7769d80e05a3b7b14594cb3aef (diff)
rust: debugfs: use pin_init::zeroed() for file_operations
Replace unsafe core::mem::zeroed() with pin_init::zeroed() for file_operations initialization in all debugfs file operation implementations. Suggested-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Ke Sun <sunke@kylinos.cn> Link: https://github.com/Rust-for-Linux/linux/issues/1189 Link: https://patch.msgid.link/20260120083824.477339-5-sunke@kylinos.cn Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/debugfs')
-rw-r--r--rust/kernel/debugfs/file_ops.rs18
1 files changed, 6 insertions, 12 deletions
diff --git a/rust/kernel/debugfs/file_ops.rs b/rust/kernel/debugfs/file_ops.rs
index ad19360540ba..f15908f71c4a 100644
--- a/rust/kernel/debugfs/file_ops.rs
+++ b/rust/kernel/debugfs/file_ops.rs
@@ -135,8 +135,7 @@ impl<T: Writer + Sync> ReadFile<T> for T {
llseek: Some(bindings::seq_lseek),
release: Some(bindings::single_release),
open: Some(writer_open::<Self>),
- // SAFETY: `file_operations` supports zeroes in all fields.
- ..unsafe { core::mem::zeroed() }
+ ..pin_init::zeroed()
};
// SAFETY: `operations` is all stock `seq_file` implementations except for `writer_open`.
// `open`'s only requirement beyond what is provided to all open functions is that the
@@ -188,8 +187,7 @@ impl<T: Writer + Reader + Sync> ReadWriteFile<T> for T {
write: Some(write::<T>),
llseek: Some(bindings::seq_lseek),
release: Some(bindings::single_release),
- // SAFETY: `file_operations` supports zeroes in all fields.
- ..unsafe { core::mem::zeroed() }
+ ..pin_init::zeroed()
};
// SAFETY: `operations` is all stock `seq_file` implementations except for `writer_open`
// and `write`.
@@ -244,8 +242,7 @@ impl<T: Reader + Sync> WriteFile<T> for T {
open: Some(write_only_open),
write: Some(write_only_write::<T>),
llseek: Some(bindings::noop_llseek),
- // SAFETY: `file_operations` supports zeroes in all fields.
- ..unsafe { core::mem::zeroed() }
+ ..pin_init::zeroed()
};
// SAFETY:
// * `write_only_open` populates the file private data with the inode private data
@@ -297,8 +294,7 @@ impl<T: BinaryWriter + Sync> BinaryReadFile<T> for T {
read: Some(blob_read::<T>),
llseek: Some(bindings::default_llseek),
open: Some(bindings::simple_open),
- // SAFETY: `file_operations` supports zeroes in all fields.
- ..unsafe { core::mem::zeroed() }
+ ..pin_init::zeroed()
};
// SAFETY:
@@ -352,8 +348,7 @@ impl<T: BinaryReader + Sync> BinaryWriteFile<T> for T {
write: Some(blob_write::<T>),
llseek: Some(bindings::default_llseek),
open: Some(bindings::simple_open),
- // SAFETY: `file_operations` supports zeroes in all fields.
- ..unsafe { core::mem::zeroed() }
+ ..pin_init::zeroed()
};
// SAFETY:
@@ -378,8 +373,7 @@ impl<T: BinaryWriter + BinaryReader + Sync> BinaryReadWriteFile<T> for T {
write: Some(blob_write::<T>),
llseek: Some(bindings::default_llseek),
open: Some(bindings::simple_open),
- // SAFETY: `file_operations` supports zeroes in all fields.
- ..unsafe { core::mem::zeroed() }
+ ..pin_init::zeroed()
};
// SAFETY: