]> git.itanic.dy.fi Git - linux-stable/commitdiff
rust: kernel: Mark rust_fmt_argument as extern "C"
authorDavid Gow <davidgow@google.com>
Tue, 14 Feb 2023 22:47:35 +0000 (06:47 +0800)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 6 Apr 2023 21:11:04 +0000 (23:11 +0200)
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: stable@vger.kernel.org
Fixes: 247b365dc8dc ("rust: add `kernel` crate")
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
[Applied `rustfmt`]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/print.rs

index 30103325696d801df5458f7f398a997835fbe8fe..8009184bf6d768539507c6a0fc543655d2f671fa 100644 (file)
 
 // 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()) };