[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <DB1LRERP8RYU.1FA5867DN8BCZ@nvidia.com>
Date: Wed, 02 Jul 2025 22:27:24 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Alexandre Courbot" <acourbot@...dia.com>, "Daniel Almeida"
<daniel.almeida@...labora.com>, "Miguel Ojeda" <ojeda@...nel.org>, "Alex
Gaynor" <alex.gaynor@...il.com>, "Boqun Feng" <boqun.feng@...il.com>, "Gary
Guo" <gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>, "Andreas Hindborg" <a.hindborg@...nel.org>,
"Alice Ryhl" <aliceryhl@...gle.com>, "Trevor Gross" <tmgross@...ch.edu>,
"Danilo Krummrich" <dakr@...nel.org>, "Benno Lossin" <lossin@...nel.org>
Cc: <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH v7] rust: kernel: add support for bits/genmask macros
On Wed Jul 2, 2025 at 10:25 PM JST, Alexandre Courbot wrote:
>> +impl_genmask_fn!(
>> + u64,
>> + /// # Examples
>> + ///
>> + /// ```
>> + /// # use kernel::bits::genmask_u64;
>> + /// let mask = genmask_u64(21..=39);
>> + /// assert_eq!(mask, 0x000000ffffe00000);
>
> I think we should also have 2 examples that show the behavior at the
> limits (i.e. `0..=0` and `0..=63` here ; possibly others if you can see
> interesting cases.). They are useful to understand how the function
> actually works, and would also have caught the errors I pointed out
> above.
Also one last nit: users will count the bits on these examples, so to
make that task easier, please write long hexadecimal values as
`0x0000_00ff_ffe0_0000`. :)
Powered by blists - more mailing lists