Skip to content

Commit f55745c

Browse files
Merge pull request #507 from timrobertsdev/nonnull-event
Change `Event` to be FFI-safe using `NonNull`
2 parents 5fbf98f + 19ecdb3 commit f55745c

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
`Address` always take a 64-bit value, regardless of target platform.
1313
- The conversion methods on `DevicePathToText` and `DevicePathFromText`
1414
now return a `uefi::Result` instead of an `Option`.
15+
- `Event` is now a newtype around `NonNull<c_void>` instead of `*mut c_void`.
1516

1617
## uefi-macros - [Unreleased]
1718

Diff for: src/data_types/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ impl Handle {
3737
}
3838
}
3939

40-
/// Handle to an event structure
40+
/// Handle to an event structure, guaranteed to be non-null.
41+
///
42+
/// If you need to have a nullable event, use `Option<Event>`.
4143
#[repr(transparent)]
42-
pub struct Event(*mut c_void);
44+
pub struct Event(NonNull<c_void>);
4345

4446
impl Event {
4547
/// Clone this `Event`

Diff for: src/proto/media/disk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl DiskIo {
7474
#[repr(C)]
7575
pub struct DiskIo2Token {
7676
/// Event to be signalled when an asynchronous disk I/O operation completes.
77-
pub event: Event,
77+
pub event: Option<Event>,
7878
/// Transaction status code.
7979
pub transaction_status: Status,
8080
}

Diff for: uefi-test-runner/src/proto/media/known_disk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn test_raw_disk_io2(handle: Handle, bt: &BootServices) {
214214
// Initialise the task context
215215
let mut task = DiskIoTask {
216216
token: DiskIo2Token {
217-
event: event.unsafe_clone(),
217+
event: Some(event.unsafe_clone()),
218218
transaction_status: uefi::Status::NOT_READY,
219219
},
220220
buffer: [0; 512],

0 commit comments

Comments
 (0)