Skip to content
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

uefi: Remove some uses of MaybeUninit in BootServices #854

Merged

Conversation

nicholasbishop
Copy link
Contributor

While MaybeUninit is useful to avoid unnecessarily initializing large buffers, it's not needed for small values like single pointers and integers.

For Event, Handle, and ProtocolSearchKey, which internally contain a NonNull pointer, we can wrap them in an Option and still have the same layout as a raw pointer. The initial value can then be None rather than MaybeUninit.

This has the nice side effect of removing a little bit of unsafe code.

Checklist

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

While `MaybeUninit` is useful to avoid unnecessarily initializing large buffers,
it's not needed for small values like single pointers and integers.

For `Event`, `Handle`, and `ProtocolSearchKey`, which internally contain a
`NonNull` pointer, we can wrap them in an `Option` and still have the same
layout as a raw pointer. The initial value can then be `None` rather than
`MaybeUninit`.

This has the nice side effect of removing a little bit of `unsafe` code.
@nicholasbishop nicholasbishop merged commit 166ed80 into rust-osdev:main Jun 10, 2023
10 checks passed
@nicholasbishop nicholasbishop deleted the bishop-less-maybeuninit branch June 10, 2023 23:37
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.

None yet

2 participants