Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Ke Sun and committed by
Danilo Krummrich
ae3bf761 f8ed7a49

+6 -12
+6 -12
rust/kernel/debugfs/file_ops.rs
··· 135 135 llseek: Some(bindings::seq_lseek), 136 136 release: Some(bindings::single_release), 137 137 open: Some(writer_open::<Self>), 138 - // SAFETY: `file_operations` supports zeroes in all fields. 139 - ..unsafe { core::mem::zeroed() } 138 + ..pin_init::zeroed() 140 139 }; 141 140 // SAFETY: `operations` is all stock `seq_file` implementations except for `writer_open`. 142 141 // `open`'s only requirement beyond what is provided to all open functions is that the ··· 187 188 write: Some(write::<T>), 188 189 llseek: Some(bindings::seq_lseek), 189 190 release: Some(bindings::single_release), 190 - // SAFETY: `file_operations` supports zeroes in all fields. 191 - ..unsafe { core::mem::zeroed() } 191 + ..pin_init::zeroed() 192 192 }; 193 193 // SAFETY: `operations` is all stock `seq_file` implementations except for `writer_open` 194 194 // and `write`. ··· 242 244 open: Some(write_only_open), 243 245 write: Some(write_only_write::<T>), 244 246 llseek: Some(bindings::noop_llseek), 245 - // SAFETY: `file_operations` supports zeroes in all fields. 246 - ..unsafe { core::mem::zeroed() } 247 + ..pin_init::zeroed() 247 248 }; 248 249 // SAFETY: 249 250 // * `write_only_open` populates the file private data with the inode private data ··· 294 297 read: Some(blob_read::<T>), 295 298 llseek: Some(bindings::default_llseek), 296 299 open: Some(bindings::simple_open), 297 - // SAFETY: `file_operations` supports zeroes in all fields. 298 - ..unsafe { core::mem::zeroed() } 300 + ..pin_init::zeroed() 299 301 }; 300 302 301 303 // SAFETY: ··· 348 352 write: Some(blob_write::<T>), 349 353 llseek: Some(bindings::default_llseek), 350 354 open: Some(bindings::simple_open), 351 - // SAFETY: `file_operations` supports zeroes in all fields. 352 - ..unsafe { core::mem::zeroed() } 355 + ..pin_init::zeroed() 353 356 }; 354 357 355 358 // SAFETY: ··· 373 378 write: Some(blob_write::<T>), 374 379 llseek: Some(bindings::default_llseek), 375 380 open: Some(bindings::simple_open), 376 - // SAFETY: `file_operations` supports zeroes in all fields. 377 - ..unsafe { core::mem::zeroed() } 381 + ..pin_init::zeroed() 378 382 }; 379 383 380 384 // SAFETY: