All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hsiu Che Yu <yu.whisper.personal@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: "Hsiu Che Yu" <yu.whisper.personal@gmail.com>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: num: bounded: add safety comment for Bounded::__new
Date: Mon, 1 Dec 2025 21:26:32 +0800	[thread overview]
Message-ID: <692d978b.170a0220.b1da0.297a@mx.google.com> (raw)
In-Reply-To: <aS1qC_ol2XEpZ44b@google.com>

On Mon, Dec 01, 2025 at 10:12:27AM +0000, Alice Ryhl wrote:
>I disagree. For the same reasons as str::from_utf8_unchecked, this
>should also be unsafe. It creates a value that violates invariants,
>which may be used to trigger UB combined with other safe code.
>
>Alice

I understand. Once the caller passes a value that cannot be represented 
with N bits, the type invariant is violated. Keeping this function safe 
could allow callers to overlook this critical requirement.

Thank you for the feedback. I will submit v2 with the necessary changes 
and improved documentation.

Best regards,
Hsiu Che Yu

  reply	other threads:[~2025-12-01 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01  6:25 [PATCH] rust: num: bounded: add safety comment for Bounded::__new Hsiu Che Yu
2025-12-01 10:12 ` Alice Ryhl
2025-12-01 13:26   ` Hsiu Che Yu [this message]
2025-12-01 12:44 ` Miguel Ojeda
2025-12-01 13:35   ` Hsiu Che Yu
2025-12-01 16:05     ` 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=692d978b.170a0220.b1da0.297a@mx.google.com \
    --to=yu.whisper.personal@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=yury.norov@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.