Re: [PATCH v7 06/10] rust: id_pool: take a NonZero capacity in with_capacity

[email protected]
Newsgroups org.freedesktop.lists.dri-devel
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The modified imports in the doc test do not fully adhere to the kernel vertical import style.
--

--- Patch [6]: [PATCH v7 06/10] rust: id_pool: take a NonZero capacity in with_capacity ---
commit f4b7961ebb7650ae12d08eb8b7b640d56c620f68
Author: Eliot Courtney <[email protected]>

rust: id_pool: take a NonZero capacity in with_capacity

This commit modifies IdPool::with_capacity to accept a NonZero capacity
type instead of a standard integer. It updates the implementation to extract
the non-zero value and adjusts the corresponding documentation tests to use
the nz macro.

> diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
> index 384753fe0e44a..9494fde701eea 100644
> --- a/rust/kernel/id_pool.rs
> +++ b/rust/kernel/id_pool.rs
> @@ -23,10 +23,13 @@
>  /// Basic usage
>  ///
>  /// ```
> -/// use kernel::alloc::AllocError;
> -/// use kernel::id_pool::{IdPool, UnusedId};
> +/// use kernel::{
> +///     alloc::AllocError,
> +///     id_pool::{IdPool, UnusedId},

[Severity: Low]
This isn't a bug, but the modified imports in this doc test do not fully adhere
to the kernel vertical import style.

Should IdPool and UnusedId be split onto their own lines?

> +///     nz, //
> +/// };
>  ///
> -/// let mut pool = IdPool::with_capacity(64, GFP_KERNEL)?;
> +/// let mut pool = IdPool::with_capacity(nz!(64), GFP_KERNEL)?;
>  /// for i in 0..64 {
>  ///     assert_eq!(i, pool.find_unused_id(i).ok_or(ENOSPC)?.acquire());
>  /// }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.