Skip to content

Commit c682e4c

Browse files
sulixojeda
authored andcommitted
rust: kernel: Mark rust_fmt_argument as extern "C"
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]> Reviewed-by: Gary Guo <[email protected]> Reviewed-by: Björn Roy Baron <[email protected]> Reviewed-by: Vincenzo Palazzo <[email protected]> [Applied `rustfmt`] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent e5e8657 commit c682e4c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: rust/kernel/print.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ use crate::bindings;
1818

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

0 commit comments

Comments
 (0)