-
Notifications
You must be signed in to change notification settings - Fork 211
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
esp-storage: Fix incorrect usage of MaybeUninit #1902
base: main
Are you sure you want to change the base?
Conversation
I am not sure how to run the tests, can someone help please |
You need to add an entry to the changelog for CI to continue. |
Do I need to bump the version then? |
No, just add an entry for your PR |
e69eb4e
to
5973d8e
Compare
I just renamed the commit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esp-storage/src/buffer.rs
Outdated
#[repr(C)] | ||
pub union FlashBuffer<const N: usize, const M: usize> { | ||
bytes: [MaybeUninit<u8>; M], | ||
words: [MaybeUninit<u32>; N], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something but is the words
field ever really used? (Yes, by the accessors but those seem to be unused?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do end up sticking with the union, we also need to make sure its #[repr(C, align(4))]
. I checked on the rust playground, and it does currently have an align of 4 anyways, but I think that it's best to be explicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think specifying the alignment is needed according to this: https://doc.rust-lang.org/reference/type-layout.html#reprc-unions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm missing something but is the
words
field ever really used? (Yes, by the accessors but those seem to be unused?)
I have a following PR coming that uses those. I split in two to make more focused PR.
a60ce55
to
384b70c
Compare
Wonder what's the status on this? Just checking in :) |
I've been busy, I finish this soon 🙂 |
Converted to draft for now - set it to Read-for-Review when it's updated |
Just checking in here, @DBLouis would you like one of us to take over here to wrap this up? Or do you expect to be able to get back to this in the next couple weeks? No worries either way, would just like to get this across the finish line :) |
Yes it is probably better that someone takes over, I will not have time soon, life got in the way :) |
I think the easier solution to get the perf required and to avoid unsafe is to store the flash buffer inside @bjoernQ are you aware of any reason not to do it like this instead? |
Submission Checklist 📝
cargo xtask fmt-packages
command to ensure that all changed code is formatted correctly.CHANGELOG.md
in the proper section.Extra:
Pull Request Details 📖
Description
I found incorrect usage of
MaybeUninit
while browsing the source that might cause UB. Specifically, callingassume_init_mut
on aMaybeUninit
that has not been initialized ref.Testing
WIP