All types in `bindings` implement `Zeroable` if they can. This enables using `pin_init::zeroed()` for `file_operations` initialization instead of relying on `unsafe { core::mem::MaybeUninit::zeroed().assume_init() }`. This change improves readability and removes an unnecessary unsafe block.
Unified · Split
| @@ -324,9 +324,6 @@ unsafe impl<T> Sync for AssertSync<T> {} · 323 unmodified lines | |||
| 324 | #[no_mangle] | 324 | #[no_mangle] |
| 325 | #[used] | 325 | #[used] |
| 326 | pub static rust_binder_fops: AssertSync<kernel::bindings::file_operations> = { | 326 | pub static rust_binder_fops: AssertSync<kernel::bindings::file_operations> = { |
| 327 | // SAFETY: All zeroes is safe for the `file_operations` type. | ||
| 328 | let zeroed_ops = unsafe { core::mem::MaybeUninit::zeroed().assume_init() }; | ||
| 329 | |||
| 330 | let ops = kernel::bindings::file_operations { | 327 | let ops = kernel::bindings::file_operations { |
| 331 | owner: THIS_MODULE.as_ptr(), | 328 | owner: THIS_MODULE.as_ptr(), |
| 332 | poll: Some(rust_binder_poll), | 329 | poll: Some(rust_binder_poll), |
| @@ -336,7 +333,7 @@ pub static rust_binder_fops: AssertSync<kernel::bindings::file_operations> = { · 3 unmodified lines | |||
| 336 | open: Some(rust_binder_open), | 333 | open: Some(rust_binder_open), |
| 337 | release: Some(rust_binder_release), | 334 | release: Some(rust_binder_release), |
| 338 | flush: Some(rust_binder_flush), | 335 | flush: Some(rust_binder_flush), |
| 339 | ..zeroed_ops | 336 | ..pin_init::zeroed() |
| 340 | }; | 337 | }; |
| 341 | AssertSync(ops) | 338 | AssertSync(ops) |
| 342 | }; | 339 | }; |