From: Brendan Shephard <bshephar@bne-home.net>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: aliceryhl@google.com, miguel.ojeda.sandonis@gmail.com,
dakr@kernel.org, daniel.almeida@collabora.com,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v6] rust: Return Option from page_align and ensure no usize overflow
Date: Thu, 4 Dec 2025 21:43:08 +1000 [thread overview]
Message-ID: <aTFzzIjEZ-lMMjtw@fedora> (raw)
In-Reply-To: <DEOIMG7Z0J8B.3OOY2A989T3G6@nvidia.com>
On Wed, Dec 03, 2025 at 07:39:06PM +0900, Alexandre Courbot wrote:
> On Tue Dec 2, 2025 at 6:35 PM JST, Brendan Shephard wrote:
> > Change `page_align()` to return `Option<usize>` to allow validation
> > of the provided `addr` value. This ensures that any value that is
> > within one `PAGE_SIZE` of `usize::MAX` will not panic, and instead
> > returns `None` to indicate overflow.
> >
> > Signed-off-by: Brendan Shephard <bshephar@bne-home.net>
>
> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
>
> A few nits below.
>
> > +/// Returns [`None`] on integer overflow.
> > +///
> > +/// # Examples
> > +///
> > +/// ```rust
>
> I never see the language specified in other doctests. I guess it doesn't
> hurt, but just mentioning it for consistency.
>
Fair, I just took this from the example on the rustdocs page:
https://doc.rust-lang.org/rustdoc/write-documentation/documentation-tests.html
And I didn't give it much additional thought. But I probably should have
confirmed formatting of other examples in the project.
> > +/// use kernel::page::{page_align, PAGE_SIZE};
> > +/// // Case 1: Already aligned
>
> Why number the examples? It doesn't add anything since we don't refer to
> them later.
>
Another valid point. I think a common theme in my reviews is that I'm
being a bit too verbose. Most of it, like in this case comes from my own
internal monologue while I'm figuring it out. I'll take that on-board
and try to be more INFO and less DEBUG moving forward.
prev parent reply other threads:[~2025-12-04 11:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-02 9:35 [PATCH v6] rust: Return Option from page_align and ensure no usize overflow Brendan Shephard
2025-12-02 9:40 ` Alice Ryhl
2025-12-03 10:39 ` Alexandre Courbot
2025-12-04 11:43 ` Brendan Shephard [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=aTFzzIjEZ-lMMjtw@fedora \
--to=bshephar@bne-home.net \
--cc=acourbot@nvidia.com \
--cc=aliceryhl@google.com \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=rust-for-linux@vger.kernel.org \
/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.