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 | 324 | #[no_mangle] |
| 325 | 325 | #[used] |
| 326 | 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 | 327 | let ops = kernel::bindings::file_operations { |
| 331 | 328 | owner: THIS_MODULE.as_ptr(), |
| 332 | 329 | poll: Some(rust_binder_poll), |
| @@ -336,7 +333,7 @@ pub static rust_binder_fops: AssertSync<kernel::bindings::file_operations> = { · 3 unmodified lines | ||
| 336 | 333 | open: Some(rust_binder_open), |
| 337 | 334 | release: Some(rust_binder_release), |
| 338 | 335 | flush: Some(rust_binder_flush), |
| 339 | − ..zeroed_ops | |
| 336 | + ..pin_init::zeroed() | |
| 340 | 337 | }; |
| 341 | 338 | AssertSync(ops) |
| 342 | 339 | }; |