From: Andreas Hindborg <a.hindborg@kernel.org>
To: "Younes Akhouayri via B4 Relay"
<devnull+git.younes.io@kernel.org>,
"Miguel Ojeda" <ojeda@kernel.org>,
"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Daniel Gomez" <da.gomez@kernel.org>
Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
Younes Akhouayri <git@younes.io>
Subject: Re: [PATCH v2 0/2] rust: str: parse_int: match kstrtol() sign and newline handling
Date: Mon, 02 Nov 2026 13:37:40 +0100 [thread overview]
Message-ID: <87wlqvmmsr.fsf@t14s.mail-host-address-is-not-set> (raw)
In-Reply-To: <20261101-b4-parse-int-sign-v2-0-0fd827f52070@younes.io>
"Younes Akhouayri via B4 Relay" <devnull+git.younes.io@kernel.org>
writes:
> The documentation of `ParseInt` says that any string parsed by
> `kstrtol()` or `kstrtoul()` is also parsed by `from_str()`. That does
> not hold today, and `from_str()` also accepts strings that `kstrtol()`
> rejects:
>
> input kstrtol() i32::from_str()
> "0x-5" -EINVAL Ok(-5)
> "0x+5" -EINVAL Ok(5)
> "-+5" -EINVAL Ok(-5)
> "+0x5" 5 Err(EINVAL)
> "5\n" 5 Err(EINVAL)
The documentation says that `from_str` will parse at least the set
parsed by `kstrtol`, so the first three cases are in line with the
documentation.
For the last two lines, we can strip leading "+" and trailing newline
before invoking the existing implementation.
Best regards,
Andreas Hindborg
prev parent reply other threads:[~2026-11-02 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <PGNAQEojwnccOLf5-V1Qu8OYULewlWcavisB7AXtAvg8nGRfqVufK3xLJpXjalzS1JGhaSf5YhYkiQbz9yjejg==@protonmail.internalid>
2026-11-01 15:47 ` Younes Akhouayri via B4 Relay
2026-11-01 15:47 ` [PATCH v2 1/2] rust: str: parse_int: only accept a sign before the radix prefix Younes Akhouayri via B4 Relay
2026-11-01 15:47 ` [PATCH v2 2/2] rust: str: parse_int: accept a trailing newline like kstrtol() Younes Akhouayri via B4 Relay
2026-11-02 12:37 ` Andreas Hindborg [this message]
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=87wlqvmmsr.fsf@t14s.mail-host-address-is-not-set \
--to=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=da.gomez@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=devnull+git.younes.io@kernel.org \
--cc=gary@garyguo.net \
--cc=git@younes.io \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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
all inboxes | Powered by JetHome®