Skip to content

Change Event to be FFI-safe using NonNull #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<c_void>` instead of `*mut c_void`.

## uefi-macros - [Unreleased]

Expand Down
6 changes: 4 additions & 2 deletions src/data_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event>`.
#[repr(transparent)]
pub struct Event(*mut c_void);
pub struct Event(NonNull<c_void>);

impl Event {
/// Clone this `Event`
Expand Down
2 changes: 1 addition & 1 deletion src/proto/media/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Event>,
/// Transaction status code.
pub transaction_status: Status,
}
Expand Down
2 changes: 1 addition & 1 deletion uefi-test-runner/src/proto/media/known_disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down