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

Use UnsafeCell instead of static-mut #817

Open
jonathanpallant opened this issue Mar 7, 2024 · 2 comments
Open

Use UnsafeCell instead of static-mut #817

jonathanpallant opened this issue Mar 7, 2024 · 2 comments
Labels
type: enhancement Enhancement or feature request

Comments

@jonathanpallant
Copy link
Contributor

The code at

static mut BUFFER: [u8; BUF_SIZE] = [0; BUF_SIZE];
uses a static mut. It goes to some trouble to ensure that the handle() function cannot be called twice, but perhaps we can use the type system to guarantee that is the case. Or if not, maybe we should use an UnsafeCell.

Also, the buffer is placed in an uninit section but we don't use the MaybeUninit type for the buffer. If there's a reason, we should perhaps explain why.

@Urhengulas
Copy link
Member

@japaric Can you shed some light on if there is a reason it should be implemented like it is right now?

@Urhengulas Urhengulas added the type: enhancement Enhancement or feature request label Mar 7, 2024
@evading
Copy link

evading commented Apr 19, 2024

Also, the buffer is placed in an uninit section but we don't use the MaybeUninit type for the buffer. If there's a reason, we should perhaps explain why.

I was just about to file an issue about that. In the commit that introduced the uninit section in cortex-m-rt it says that MaybeUninit is the only correct way to use that section 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

3 participants