[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72kaUXSTMmQCFKKF-OJNXuhi13xJcbAoq5iFbSZ0wwz61A@mail.gmail.com>
Date: Thu, 27 Feb 2025 18:35:33 +0100
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Burak Emir <bqe@...gle.com>
Cc: Yury Norov <yury.norov@...il.com>, Rasmus Villemoes <linux@...musvillemoes.dk>,
Viresh Kumar <viresh.kumar@...aro.org>, 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>,
Benno Lossin <benno.lossin@...ton.me>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rust: add bindings and API for bitmap.h and bitops.h.
On Thu, Feb 27, 2025 at 11:17 AM Burak Emir <bqe@...gle.com> wrote:
>
> +use crate::bindings::{
> + bitmap_copy, bitmap_free, bitmap_zalloc, clear_bit, find_last_bit, find_next_zero_bit, set_bit,
> +};
I think it may be best to avoid importing `bindings::*` things, so
that it is clear when they happen and so that they are easier to grep
for.
I guess some of these may benefit from being inline when small
constants are involved, similar to what the C docs mention -- do we
want to have equivalents to the C "generic" ones that could be inlined
well?
> +/// * `ptr` is obtained from a successful call to bitmap_zalloc and
Please use Markdown wherever possible, e.g. `bitmap_zalloc`.
> +#[cold]
> +fn not_in_bounds_lt(arg: &'static str, len: usize, val: usize) -> ! {
> + panic!("{arg} must be less than length {len}, was {val}");
> +}
Should these be more explicit? e.g. `panic_if_not_in_bounds_lt`?
Do we want to only have infallible versions?
> +impl Bitmap {
> + /// Constructs a new Bitmap.
Please use intra-doc links where possible (and Markdown), e.g. [`Bitmap`].
> + /// Fails with AllocError if `nbits` is greater than or equal to 2^32,
> + /// or when the bitmap could not be allocated.
Some examples would be nice to add, which double as KUnit tests.
Thanks!
Cheers,
Miguel
Powered by blists - more mailing lists