Skip to content

Conversation

@phip1611
Copy link
Member

@phip1611 phip1611 commented Dec 1, 2025

Improve ergonomics of Events. Closes #1839

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

There is nothing unsafe here. `NonNull` properly covers null pointers by returning
`None`.
@phip1611 phip1611 self-assigned this Dec 1, 2025
For all three functions, it is the normal / good case to be there. We can
also see this in the edk2 implementations of the corresponding functions.
pub unsafe fn from_ptr(ptr: *mut c_void) -> Option<Self> {
/// Create an [`Event`] from a raw pointer. Returns [`None`] if the pointer
/// null.
pub fn from_ptr(ptr: *mut c_void) -> Option<Self> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be a safe operation. While it's true that the body of the function doesn't do anything unsafe, if you create an Event from an invalid pointer and pass it into some other function that expects a valid Event, it may crash or lead to some other UB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wait_*_event() -> Event functions should return Result instead of Option

3 participants