From: Alice Ryhl <aliceryhl@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Miguel Ojeda <ojeda@kernel.org>
Cc: "Petr Mladek" <pmladek@suse.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
"Sergey Senozhatsky" <senozhatsky@chromium.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Trevor Gross" <tmgross@umich.edu>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
dri-devel@lists.freedesktop.org,
"Alice Ryhl" <aliceryhl@google.com>
Subject: [PATCH v2 4/5] print: use new #[export] macro for rust_fmt_argument
Date: Fri, 28 Feb 2025 12:39:33 +0000 [thread overview]
Message-ID: <20250228-export-macro-v2-4-569cc7e8926c@google.com> (raw)
In-Reply-To: <20250228-export-macro-v2-0-569cc7e8926c@google.com>
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@kernel.org>
Signed-off-by: Alice Ryhl <aliceryhl@google.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
next prev parent reply other threads:[~2025-02-28 12:40 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 12:39 [PATCH v2 0/5] Check Rust signatures at compile time Alice Ryhl
2025-02-28 12:39 ` [PATCH v2 1/5] rust: fix signature of rust_fmt_argument Alice Ryhl
2025-02-28 15:13 ` Tamir Duberstein
2025-02-28 12:39 ` [PATCH v2 2/5] rust: macros: support additional tokens in quote! Alice Ryhl
2025-02-28 15:25 ` Tamir Duberstein
2025-03-03 8:17 ` Alice Ryhl
2025-02-28 18:51 ` Andreas Hindborg
2025-02-28 12:39 ` [PATCH v2 3/5] rust: add #[export] macro Alice Ryhl
2025-02-28 15:40 ` Tamir Duberstein
2025-02-28 15:49 ` Miguel Ojeda
2025-02-28 15:51 ` Tamir Duberstein
2025-03-03 8:28 ` Alice Ryhl
2025-02-28 18:53 ` Andreas Hindborg
2025-02-28 12:39 ` Alice Ryhl [this message]
2025-02-28 15:36 ` [PATCH v2 4/5] print: use new #[export] macro for rust_fmt_argument Andy Shevchenko
2025-02-28 17:11 ` Alice Ryhl
2025-02-28 15:48 ` Tamir Duberstein
2025-02-28 12:39 ` [PATCH v2 5/5] panic_qr: use new #[export] macro Alice Ryhl
2025-02-28 15:34 ` Andy Shevchenko
2025-02-28 17:06 ` Alice Ryhl
2025-02-28 15:54 ` Tamir Duberstein
2025-02-28 17:08 ` Alice Ryhl
2025-02-28 17:15 ` Tamir Duberstein
2025-03-03 8:52 ` Alice Ryhl
2025-02-28 17:06 ` Simona Vetter
2025-02-28 12:45 ` [PATCH v2 0/5] Check Rust signatures at compile time Andy Shevchenko
2025-02-28 13:12 ` Miguel Ojeda
2025-02-28 13:17 ` Alice Ryhl
2025-03-01 4:43 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250228-export-macro-v2-4-569cc7e8926c@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@kernel.org \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=ojeda@kernel.org \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=senozhatsky@chromium.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox