Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: fix signature of rust_fmt_argument

Without this change, the rest of this series will emit the following
error message:

error[E0308]: `if` and `else` have incompatible types
--> <linux>/rust/kernel/print.rs:22:22
|
21 | #[export]
| --------- expected because of this
22 | unsafe extern "C" fn rust_fmt_argument(
| ^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
|
= note: expected fn item `unsafe extern "C" fn(*mut u8, *mut u8, *mut c_void) -> *mut u8 {bindings::rust_fmt_argument}`
found fn item `unsafe extern "C" fn(*mut i8, *mut i8, *const c_void) -> *mut i8 {print::rust_fmt_argument}`

The error may be different depending on the architecture.

To fix this, change the void pointer argument to use a const pointer,
and change the imports to use crate::ffi instead of core::ffi for
integer types.

Fixes: 787983da7718 ("vsprintf: add new `%pA` format specifier")
Reviewed-by: Tamir Duberstein <tamird@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20250303-export-macro-v3-1-41fbad85a27f@google.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Alice Ryhl and committed by
Miguel Ojeda
901b3290 0e123d64

+4 -5
+1 -1
lib/vsprintf.c
··· 2285 2285 early_param("no_hash_pointers", no_hash_pointers_enable); 2286 2286 2287 2287 /* Used for Rust formatting ('%pA'). */ 2288 - char *rust_fmt_argument(char *buf, char *end, void *ptr); 2288 + char *rust_fmt_argument(char *buf, char *end, const void *ptr); 2289 2289 2290 2290 /* 2291 2291 * Show a '%p' thing. A kernel extension is that the '%p' is followed
+3 -4
rust/kernel/print.rs
··· 6 6 //! 7 7 //! Reference: <https://docs.kernel.org/core-api/printk-basics.html> 8 8 9 - use core::{ 9 + use crate::{ 10 10 ffi::{c_char, c_void}, 11 - fmt, 11 + str::RawFormatter, 12 12 }; 13 - 14 - use crate::str::RawFormatter; 13 + use core::fmt; 15 14 16 15 // Called from `vsprintf` with format specifier `%pA`. 17 16 #[expect(clippy::missing_safety_doc)]