Skip to content

Conversation

olback
Copy link
Member

@olback olback commented Dec 2, 2021

No description provided.

@olback olback marked this pull request as draft December 2, 2021 03:55
fn fill(&mut self, dest: &mut [$type]) -> Result<(), ErrorKind> {
let len = dest.len() * (mem::size_of::<$type>() / mem::size_of::<u32>());
let ptr = dest.as_mut_ptr() as *mut u32;
let slice_u32 = unsafe { core::slice::from_raw_parts_mut(ptr, len) };
Copy link
Contributor

Choose a reason for hiding this comment

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

Is alignment an issue?

Copy link
Member Author

Choose a reason for hiding this comment

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

mem::align_of::<u32>() = 4
mem::align_of::<u64>() = 8
mem::align_of::<u128>() = 8

I don't think so. u64/u128 is 8-byte aligned which would be valid for 4-byte aligned values as well. https://doc.rust-lang.org/reference/type-layout.html#size-and-alignment

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh right, I hadn't seen the distinction between rng_core and rng_core_large.

@olback olback marked this pull request as ready for review December 2, 2021 06:01
Copy link
Member

@richardeoin richardeoin left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @olback, and also @AlyoshaVasilieva @mattico for the reviews 🎉

@olback olback requested a review from richardeoin December 5, 2021 05:30
Copy link
Member

@richardeoin richardeoin left a comment

Choose a reason for hiding this comment

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

bors r+

@bors bors bot merged commit d3ff76d into stm32-rs:master Dec 5, 2021
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.

4 participants