diff --git a/CHANGELOG.md b/CHANGELOG.md index 5636458e0..596f9f465 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ `Address` always take a 64-bit value, regardless of target platform. - The conversion methods on `DevicePathToText` and `DevicePathFromText` now return a `uefi::Result` instead of an `Option`. +- `Event` is now a newtype around `NonNull` instead of `*mut c_void`. ## uefi-macros - [Unreleased] diff --git a/src/data_types/mod.rs b/src/data_types/mod.rs index f1f8adb45..987d7e95b 100644 --- a/src/data_types/mod.rs +++ b/src/data_types/mod.rs @@ -37,9 +37,11 @@ impl Handle { } } -/// Handle to an event structure +/// Handle to an event structure, guaranteed to be non-null. +/// +/// If you need to have a nullable event, use `Option`. #[repr(transparent)] -pub struct Event(*mut c_void); +pub struct Event(NonNull); impl Event { /// Clone this `Event` diff --git a/src/proto/media/disk.rs b/src/proto/media/disk.rs index 9cf7926a7..56e54b6ef 100644 --- a/src/proto/media/disk.rs +++ b/src/proto/media/disk.rs @@ -74,7 +74,7 @@ impl DiskIo { #[repr(C)] pub struct DiskIo2Token { /// Event to be signalled when an asynchronous disk I/O operation completes. - pub event: Event, + pub event: Option, /// Transaction status code. pub transaction_status: Status, } diff --git a/uefi-test-runner/src/proto/media/known_disk.rs b/uefi-test-runner/src/proto/media/known_disk.rs index 717859811..e0f5bf315 100644 --- a/uefi-test-runner/src/proto/media/known_disk.rs +++ b/uefi-test-runner/src/proto/media/known_disk.rs @@ -214,7 +214,7 @@ fn test_raw_disk_io2(handle: Handle, bt: &BootServices) { // Initialise the task context let mut task = DiskIoTask { token: DiskIo2Token { - event: event.unsafe_clone(), + event: Some(event.unsafe_clone()), transaction_status: uefi::Status::NOT_READY, }, buffer: [0; 512],