Commit 92d2873b authored by Alice Ryhl's avatar Alice Ryhl Committed by Miguel Ojeda
Browse files

print: use new #[export] macro for rust_fmt_argument



This moves the rust_fmt_argument function over to use the new #[export]
macro, which will verify at compile-time that the function signature
matches what is in the header file.

Reviewed-by: default avatarAndreas Hindborg <a.hindborg@kernel.org>
Reviewed-by: default avatarTamir Duberstein <tamird@gmail.com>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
Acked-by: default avatarPetr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20250303-export-macro-v3-4-41fbad85a27f@google.com


[ Removed period as requested by Andy. - Miguel ]
Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent 44e333fe
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -24,4 +24,7 @@ __scanf(2, 0) int vsscanf(const char *, const char *, va_list);
extern bool no_hash_pointers;
int no_hash_pointers_enable(char *str);

/* Used for Rust formatting ('%pA') */
char *rust_fmt_argument(char *buf, char *end, const void *ptr);

#endif	/* _LINUX_KERNEL_SPRINTF_H */
+0 −3
Original line number Diff line number Diff line
@@ -2284,9 +2284,6 @@ int __init no_hash_pointers_enable(char *str)
}
early_param("no_hash_pointers", no_hash_pointers_enable);

/* Used for Rust formatting ('%pA'). */
char *rust_fmt_argument(char *buf, char *end, const void *ptr);

/*
 * Show a '%p' thing.  A kernel extension is that the '%p' is followed
 * by an extra set of alphanumeric characters that are extended format
+2 −1
Original line number Diff line number Diff line
@@ -8,13 +8,14 @@

use crate::{
    ffi::{c_char, c_void},
    prelude::*,
    str::RawFormatter,
};
use core::fmt;

// Called from `vsprintf` with format specifier `%pA`.
#[expect(clippy::missing_safety_doc)]
#[no_mangle]
#[export]
unsafe extern "C" fn rust_fmt_argument(
    buf: *mut c_char,
    end: *mut c_char,