* [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C"
@ 2023-02-14 22:47 David Gow
2023-02-15 7:28 ` Gary Guo
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: David Gow @ 2023-02-14 22:47 UTC (permalink / raw)
To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron
Cc: David Gow, rust-for-linux, linux-kernel, stable
The rust_fmt_argument function is called from printk() to handle the %pA
format specifier.
Since it's called from C, we should mark it extern "C" to make sure it's
ABI compatible.
Cc: stable@vger.kernel.org
Fixes: 247b365dc8dc ("rust: add `kernel` crate")
Signed-off-by: David Gow <davidgow@google.com>
---
See discussion in:
https://github.com/Rust-for-Linux/linux/pull/967
and
https://github.com/Rust-for-Linux/linux/pull/966
---
rust/kernel/print.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs
index 30103325696d..ec457f0952fe 100644
--- a/rust/kernel/print.rs
+++ b/rust/kernel/print.rs
@@ -18,7 +18,7 @@ use crate::bindings;
// Called from `vsprintf` with format specifier `%pA`.
#[no_mangle]
-unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
+unsafe extern "C" fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
use fmt::Write;
// SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
--
2.39.1.581.gbfd45094c4-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C"
2023-02-14 22:47 [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C" David Gow
@ 2023-02-15 7:28 ` Gary Guo
2023-02-15 17:55 ` Björn Roy Baron
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Gary Guo @ 2023-02-15 7:28 UTC (permalink / raw)
To: David Gow
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Björn Roy Baron, rust-for-linux, linux-kernel, stable
On Wed, 15 Feb 2023 06:47:35 +0800
David Gow <davidgow@google.com> wrote:
> The rust_fmt_argument function is called from printk() to handle the %pA
> format specifier.
>
> Since it's called from C, we should mark it extern "C" to make sure it's
> ABI compatible.
>
> Cc: stable@vger.kernel.org
> Fixes: 247b365dc8dc ("rust: add `kernel` crate")
> Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
> ---
>
> See discussion in:
> https://github.com/Rust-for-Linux/linux/pull/967
> and
> https://github.com/Rust-for-Linux/linux/pull/966
>
> ---
> rust/kernel/print.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs
> index 30103325696d..ec457f0952fe 100644
> --- a/rust/kernel/print.rs
> +++ b/rust/kernel/print.rs
> @@ -18,7 +18,7 @@ use crate::bindings;
>
> // Called from `vsprintf` with format specifier `%pA`.
> #[no_mangle]
> -unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
> +unsafe extern "C" fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
> use fmt::Write;
> // SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
> let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C"
2023-02-14 22:47 [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C" David Gow
2023-02-15 7:28 ` Gary Guo
@ 2023-02-15 17:55 ` Björn Roy Baron
2023-02-15 19:17 ` Miguel Ojeda
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Björn Roy Baron @ 2023-02-15 17:55 UTC (permalink / raw)
To: David Gow
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, rust-for-linux, linux-kernel, stable
On Tuesday, February 14th, 2023 at 23:47, David Gow <davidgow@google.com> wrote:
> The rust_fmt_argument function is called from printk() to handle the %pA
> format specifier.
>
> Since it's called from C, we should mark it extern "C" to make sure it's
> ABI compatible.
>
> Cc: stable@vger.kernel.org
> Fixes: 247b365dc8dc ("rust: add `kernel` crate")
> Signed-off-by: David Gow davidgow@google.com
Reviewed-by: Björn Roy Baron <bjorn3_gh@protonmail.com>
>
> ---
>
> See discussion in:
> https://github.com/Rust-for-Linux/linux/pull/967
> and
> https://github.com/Rust-for-Linux/linux/pull/966
>
> ---
> rust/kernel/print.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/rust/kernel/print.rs b/rust/kernel/print.rs
> index 30103325696d..ec457f0952fe 100644
> --- a/rust/kernel/print.rs
> +++ b/rust/kernel/print.rs
> @@ -18,7 +18,7 @@ use crate::bindings;
>
> // Called from `vsprintf` with format specifier `%pA`.
> #[no_mangle]
> -unsafe fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
> +unsafe extern "C" fn rust_fmt_argument(buf: *mut c_char, end: *mut c_char, ptr: *const c_void) -> *mut c_char {
> use fmt::Write;
> // SAFETY: The C contract guarantees that `buf` is valid if it's less than `end`.
> let mut w = unsafe { RawFormatter::from_ptrs(buf.cast(), end.cast()) };
> --
> 2.39.1.581.gbfd45094c4-goog
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C"
2023-02-14 22:47 [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C" David Gow
2023-02-15 7:28 ` Gary Guo
2023-02-15 17:55 ` Björn Roy Baron
@ 2023-02-15 19:17 ` Miguel Ojeda
2023-02-15 22:30 ` Vincenzo Palazzo
2023-04-06 21:09 ` Miguel Ojeda
4 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2023-02-15 19:17 UTC (permalink / raw)
To: David Gow
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron, rust-for-linux, linux-kernel,
stable
On Tue, Feb 14, 2023 at 11:47 PM David Gow <davidgow@google.com> wrote:
>
> The rust_fmt_argument function is called from printk() to handle the %pA
> format specifier.
>
> Since it's called from C, we should mark it extern "C" to make sure it's
> ABI compatible.
>
> Cc: stable@vger.kernel.org
> Fixes: 247b365dc8dc ("rust: add `kernel` crate")
> Signed-off-by: David Gow <davidgow@google.com>
Thanks David -- I will apply `rustfmt` on my side.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C"
2023-02-14 22:47 [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C" David Gow
` (2 preceding siblings ...)
2023-02-15 19:17 ` Miguel Ojeda
@ 2023-02-15 22:30 ` Vincenzo Palazzo
2023-04-06 21:09 ` Miguel Ojeda
4 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Palazzo @ 2023-02-15 22:30 UTC (permalink / raw)
To: David Gow, Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho,
Boqun Feng, Gary Guo, Björn Roy Baron
Cc: rust-for-linux, linux-kernel, stable
> The rust_fmt_argument function is called from printk() to handle the %pA
> format specifier.
>
> Since it's called from C, we should mark it extern "C" to make sure it's
> ABI compatible.
>
> Cc: stable@vger.kernel.org
> Fixes: 247b365dc8dc ("rust: add `kernel` crate")
> Signed-off-by: David Gow <davidgow@google.com>
> ---
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C"
2023-02-14 22:47 [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C" David Gow
` (3 preceding siblings ...)
2023-02-15 22:30 ` Vincenzo Palazzo
@ 2023-04-06 21:09 ` Miguel Ojeda
4 siblings, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2023-04-06 21:09 UTC (permalink / raw)
To: David Gow
Cc: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
Gary Guo, Björn Roy Baron, rust-for-linux, linux-kernel,
stable
On Tue, Feb 14, 2023 at 11:47 PM David Gow <davidgow@google.com> wrote:
>
> The rust_fmt_argument function is called from printk() to handle the %pA
> format specifier.
>
> Since it's called from C, we should mark it extern "C" to make sure it's
> ABI compatible.
Applied to `rust-fixes`, thanks!
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-04-06 21:09 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-14 22:47 [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C" David Gow
2023-02-15 7:28 ` Gary Guo
2023-02-15 17:55 ` Björn Roy Baron
2023-02-15 19:17 ` Miguel Ojeda
2023-02-15 22:30 ` Vincenzo Palazzo
2023-04-06 21:09 ` Miguel Ojeda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox