Re: [PATCH v2] rust/list: replace unwrap() with ? in doctest examples
From: Miguel Ojeda
Date: Mon Jun 23 2025 - 19:12:51 EST
On Tue, May 27, 2025 at 10:52 PM Albin Babu Varghese
<albinbabuvarghese20@xxxxxxxxx> wrote:
>
> Using `unwrap()` in kernel doctests can cause panics on error and may
> give newcomers the mistaken impression that panicking is acceptable
> in kernel code.
>
> Replace all `.unwrap()` calls in `kernel::list`
> examples with `.ok_or(EINVAL)?` so that errors are properly propagated.
>
> Closes: https://github.com/Rust-for-Linux/linux/issues/1164
> Suggested-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
> Reviewed-by: Benno Lossin <lossin@xxxxxxxxxx>
> Link: https://github.com/Rust-for-Linux/linux/issues/1164
> Signed-off-by: Albin Babu Varghese <albinbabuvarghese20@xxxxxxxxx>
Applied to `rust-next` -- thanks everyone!
[ Reworded slightly. - Miguel ]
Cheers,
Miguel