From: Rasmus Villemoes <ravi@prevas.dk>
To: Konstantin Andrikopoulos <kernel@mandragore.io>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"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>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v2] rust: add safety comment in rust_fmt_argument
Date: Tue, 26 Nov 2024 10:07:30 +0100 [thread overview]
Message-ID: <87y116icrx.fsf@prevas.dk> (raw)
In-Reply-To: <caEePXpz3dyKABs5ReUO5NGlpbqf98_Aw_8tz9ADE6c1c8hYp523uGk7l9EcfSD0u-YLtozTD4wwgLEytbzzm6gnd3r6jQeXqr0Fo3YEYtM=@mandragore.io> (Konstantin Andrikopoulos's message of "Sat, 23 Nov 2024 21:56:46 +0000")
On Sat, Nov 23 2024, Konstantin Andrikopoulos <kernel@mandragore.io> wrote:
> On Thursday, November 21st, 2024 at 10:42 AM, Rasmus Villemoes <ravi@prevas.dk> wrote:
>
>> Nit: The file implementing this is vsprintf.c, but the actual workhorse
>> is vsnprintf() (note the n); all other *printf() variants are wrappers
>> around that, and I'm pretty sure no code path called from Rust ends up
>> passing through sprintf() or vsprintf(). Yes, I see that the original
>> code said vsprintf, but please fix while here.
>>
>
> Thanks for the comments! Going through the code again, I see that
> rust_fmt_argument is directly called from the pointer function in vsprintf.c
>
> But pointer is not only called from vsnprintf. It is also called in
> vbin_printf and bstr_printf. Should this be reflected in rust_fmt_argument's
> documentation, or are these functions unreachable from rust code?
As for the latter, I think they are used by the tracing code, so
probably they are or will be reachable from rust (Alice?).
> Perhaps the docs should just mention pointer()? Maybe the original comment
> used "vsprintf" to refer collectively to all these functions?
That's certainly possible, I didn't think about that possibility. If so,
my comments should be ignored :)
The occurrence of vsprintf that triggered me was
`vsprintf` guarantees that `buf` and `end` will uphold their
requirements.
because while this could perhaps be read as
vsprintf-the-translation-unit, vsprintf-the-function blindly assumes
that its caller has passed a large enough buffer and fakes a len
argument of INT_MAX to vsnprintf().
So I dunno. If the intention is to refer to vsprintf.c as a whole,
perhaps it would be better to actually include that .c extension when
referring to it, to avoid the ambiguity.
Rasmus
next prev parent reply other threads:[~2024-11-26 9:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 3:14 [PATCH v2] rust: add safety comment in rust_fmt_argument Konstantin Andrikopoulos
2024-11-19 19:41 ` Alice Ryhl
2024-11-21 9:42 ` Rasmus Villemoes
2024-11-23 21:56 ` Konstantin Andrikopoulos
2024-11-26 9:07 ` Rasmus Villemoes [this message]
2024-12-01 15:37 ` 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=87y116icrx.fsf@prevas.dk \
--to=ravi@prevas.dk \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=kernel@mandragore.io \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tmgross@umich.edu \
/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;
as well as URLs for NNTP newsgroup(s).