All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aditya Rajan" <adi.dev.github@gmail.com>
To: "Gary Guo" <gary@garyguo.net>, "Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Alice Ryhl" <aliceryhl@google.com>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Nathan Chancellor" <nathan@kernel.org>,
	"Nicolas Schier" <nsc@kernel.org>
Cc: <rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-kbuild@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] rust: add projection infrastructure
Date: Sat, 28 Feb 2026 15:38:29 -0800	[thread overview]
Message-ID: <DGQZOLAH72HC.2OE3REDD7M7U7@gmail.com> (raw)
In-Reply-To: <20260226154656.3241736-2-gary@kernel.org>

On Thu Feb 26, 2026 at 7:46 AM PST, Gary Guo wrote:
> From: Gary Guo <gary@garyguo.net>
> diff --git a/rust/kernel/projection.rs b/rust/kernel/projection.rs
> new file mode 100644
> index 000000000000..186ec194f2b8
> --- /dev/null
> +++ b/rust/kernel/projection.rs
> +unsafe impl<T> ProjectIndex<[T]> for usize {
> +    type Output = T;
> +
> +    #[inline(always)]
> +    fn get(self, slice: *mut [T]) -> Option<*mut T> {
> +        if self > slice.len() {
I am not sure but shouldn't this be `self >= slice.len()` ? I could be wrong but `slice.get(n)` should return `None` for slice 0..n ?
There is a similar condition somewhere else in the code as well.

[...]

> +                // Check unaligned field. Not all users (e.g. DMA) can handle unaligned
> +                // projections. (e.g. DMA).
Nit: Comment mentions (e.g. DMA) twice

One question regarding the `in bounds` check otherwise LGTM

Thanks
Aditya


  reply	other threads:[~2026-02-28 23:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 15:46 [PATCH v2 0/2] rust: add pointer projection infrastructure and convert DMA Gary Guo
2026-02-26 15:46 ` [PATCH v2 1/2] rust: add projection infrastructure Gary Guo
2026-02-28 23:38   ` Aditya Rajan [this message]
2026-03-01 13:10     ` Gary Guo
2026-03-02  4:41       ` Aditya Rajan
2026-02-26 15:46 ` [PATCH v2 2/2] rust: dma: use pointer projection infra for `dma_{read,write}` macro Gary Guo
2026-02-26 15:46   ` [PATCH v2 2/2] rust: dma: use pointer projection infra for `dma_{read, write}` macro Gary Guo

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=DGQZOLAH72HC.2OE3REDD7M7U7@gmail.com \
    --to=adi.dev.github@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nsc@kernel.org \
    --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 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.