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 repr C to suppress not-ffi-safe when used with extern handler functions #94

Merged
merged 1 commit into from
Nov 18, 2019

Conversation

cmsd2
Copy link
Contributor

@cmsd2 cmsd2 commented Nov 18, 2019

the interrupt handler functions are extern to allow for the special calling convention.
rust warns about using this struct with extern functions.
this patch suppresses the warning by fixing the struct layout.

i think in this case the warning is correctly pointing out that while the nested InterruptStackFrameValue is repr(C), the wrapper type is not. it seems incredibly unlikely that the compiler would do anything wrong here but adding repr(C) guards against it.

example warning:

   Compiling libkernel v0.1.0 (/Users/cmsd2/Development/ostoo/libkernel)
warning: `extern` fn uses type `x86_64::structures::idt::InterruptStackFrame`, which is not FFI-safe
  --> libkernel/src/interrupts.rs:70:18
   |
70 |     stack_frame: &mut InterruptStackFrame)
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe
   |
   = note: `#[warn(improper_ctypes)]` on by default
   = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct
   = note: this struct has unspecified layout

@phil-opp
Copy link
Member

Thanks a lot!

@phil-opp phil-opp merged commit d082e7b into rust-osdev:master Nov 18, 2019
phil-opp added a commit that referenced this pull request Nov 18, 2019
@phil-opp
Copy link
Member

Published as version 0.7.6

phil-opp pushed a commit that referenced this pull request Dec 13, 2019
phil-opp added a commit that referenced this pull request Dec 13, 2019
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