Skip to content

Commit

Permalink
rust: kernel: Mark rust_fmt_argument as extern "C"
Browse files Browse the repository at this point in the history
The rust_fmt_argument function is called from printk() to handle the %pA
format specifier.

Since it's called from C, we should mark it extern "C" to make sure it's
ABI compatible.

Cc: [email protected]
Fixes: 247b365 ("rust: add `kernel` crate")
Signed-off-by: David Gow <[email protected]>
  • Loading branch information
sulix committed Feb 14, 2023
1 parent 9c0096c commit 175a53c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rust/kernel/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::bindings;

// Called from `vsprintf` with format specifier `%pA`.
#[no_mangle]
unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
unsafe extern "C" fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
use fmt::Write;
// SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
Expand Down

0 comments on commit 175a53c

Please sign in to comment.