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

Remove uses of core::mem::uninitialized from ufmt. #306

Merged
merged 1 commit into from
May 20, 2021

Conversation

jrvanwhy
Copy link
Collaborator

According to the current Rust Reference [1], storing an uninitialized u8 is undefined behavior. This may change in the future [2], but for now we should continue to assume it is undefined behavior.

Every use of core::mem::uninitialized in ufmt is to create a local [u8; _], and therefore is an example of this undefined behavior. I removed the undefined behavior in the simplest way possible, which is to replace the initializers with [u8; _].

[1] https://doc.rust-lang.org/reference/behavior-considered-undefined.html
[2] rust-lang/unsafe-code-guidelines#77

According to the current Rust Reference [1], storing an uninitialized `u8` is undefined behavior. This may change in the future [2], but for now we should continue to assume it is undefined behavior.

Every use of `core::mem::uninitialized` in `ufmt` is to create a local `[u8; _]`, and therefore is an example of this undefined behavior. I removed the undefined behavior in the simplest way possible, which is to replace the initializers with `[u8; _]`.

[1] https://doc.rust-lang.org/reference/behavior-considered-undefined.html
[2] rust-lang/unsafe-code-guidelines#77
@jrvanwhy jrvanwhy added the upkeep Indicates a PR is upkeep as defined by the code review policy. label May 20, 2021
@jrvanwhy
Copy link
Collaborator Author

bors: r+

@bors
Copy link
Contributor

bors bot commented May 20, 2021

Build succeeded:

@bors bors bot merged commit c153cd1 into tock:master May 20, 2021
@jrvanwhy jrvanwhy deleted the ufmt-fixes branch September 4, 2021 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upkeep Indicates a PR is upkeep as defined by the code review policy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants