[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAJ-ks9mUXf2XNRaeftmfGPUvu9Lv3t_Ye+DoVuRhiTxQ5-C7Qw@mail.gmail.com>
Date: Fri, 28 Feb 2025 10:48:14 -0500
From: Tamir Duberstein <tamird@...il.com>
To: Alice Ryhl <aliceryhl@...gle.com>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Miguel Ojeda <ojeda@...nel.org>,
Petr Mladek <pmladek@...e.com>, Steven Rostedt <rostedt@...dmis.org>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>, Sergey Senozhatsky <senozhatsky@...omium.org>,
Andrew Morton <akpm@...ux-foundation.org>, Boqun Feng <boqun.feng@...il.com>,
Gary Guo <gary@...yguo.net>, Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Trevor Gross <tmgross@...ch.edu>, Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v2 4/5] print: use new #[export] macro for rust_fmt_argument
On Fri, Feb 28, 2025 at 7:41 AM Alice Ryhl <aliceryhl@...gle.com> wrote:
>
> 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 <a.hindborg@...nel.org>
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> ---
> I'm not sure which header file to put this in. Any advice?
> ---
> include/linux/sprintf.h | 3 +++
> lib/vsprintf.c | 3 ---
> rust/kernel/print.rs | 3 ++-
> 3 files changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/sprintf.h b/include/linux/sprintf.h
> index 33dcbec71925..029ad83efd74 100644
> --- a/include/linux/sprintf.h
> +++ b/include/linux/sprintf.h
> @@ -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 */
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index a8ac4c4fffcf..1da61c3e011f 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -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
> diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs
> index 61ee36c5e5f5..cf4714242e14 100644
> --- a/rust/kernel/print.rs
> +++ b/rust/kernel/print.rs
> @@ -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,
>
> --
> 2.48.1.711.g2feabab25a-goog
Reviewed-by: Tamir Duberstein <tamird@...il.com>
Powered by blists - more mailing lists