Skip to content

Commit 92d2873

Browse files
Darksonnojeda
authored andcommitted
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: Andreas Hindborg <[email protected]> Reviewed-by: Tamir Duberstein <[email protected]> Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Acked-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected] [ Removed period as requested by Andy. - Miguel ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 44e333f commit 92d2873

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/linux/sprintf.h

+3
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,7 @@ __scanf(2, 0) int vsscanf(const char *, const char *, va_list);
2424
extern bool no_hash_pointers;
2525
int no_hash_pointers_enable(char *str);
2626

27+
/* Used for Rust formatting ('%pA') */
28+
char *rust_fmt_argument(char *buf, char *end, const void *ptr);
29+
2730
#endif /* _LINUX_KERNEL_SPRINTF_H */

lib/vsprintf.c

-3
Original file line numberDiff line numberDiff line change
@@ -2284,9 +2284,6 @@ int __init no_hash_pointers_enable(char *str)
22842284
}
22852285
early_param("no_hash_pointers", no_hash_pointers_enable);
22862286

2287-
/* Used for Rust formatting ('%pA'). */
2288-
char *rust_fmt_argument(char *buf, char *end, const void *ptr);
2289-
22902287
/*
22912288
* Show a '%p' thing. A kernel extension is that the '%p' is followed
22922289
* by an extra set of alphanumeric characters that are extended format

rust/kernel/print.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
99
use crate::{
1010
ffi::{c_char, c_void},
11+
prelude::*,
1112
str::RawFormatter,
1213
};
1314
use core::fmt;
1415

1516
// Called from `vsprintf` with format specifier `%pA`.
1617
#[expect(clippy::missing_safety_doc)]
17-
#[no_mangle]
18+
#[export]
1819
unsafe extern "C" fn rust_fmt_argument(
1920
buf: *mut c_char,
2021
end: *mut c_char,

0 commit comments

Comments
 (0)