public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: David Gow <davidgow@google.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
	"Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C"
Date: Wed, 15 Feb 2023 07:28:39 +0000	[thread overview]
Message-ID: <20230215072839.6cb94bbb.gary@garyguo.net> (raw)
In-Reply-To: <20230214224735.264894-1-davidgow@google.com>

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()) };


  reply	other threads:[~2023-02-15  7:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-14 22:47 [PATCH] rust: kernel: Mark rust_fmt_argument as extern "C" David Gow
2023-02-15  7:28 ` Gary Guo [this message]
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

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=20230215072839.6cb94bbb.gary@garyguo.net \
    --to=gary@garyguo.net \
    --cc=alex.gaynor@gmail.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=davidgow@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=wedsonaf@gmail.com \
    /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