Re: [PATCH] rust: error: clarify that `from_err_ptr` can return `Ok(NULL)`
From: Mirko Adžić
Date: Sun Mar 29 2026 - 05:12:01 EST
Hi, thank you for the review.
On Sat, Mar 28, 2026 at 7:01 PM Miguel Ojeda
<miguel.ojeda.sandonis@xxxxxxxxx> wrote:
> > +/// fn einval_err_ptr() {
> > +/// // SAFETY: ...
> > +/// let result = from_err_ptr(unsafe { bindings::einval_err_ptr() });
> > +/// assert_eq!(result, Err(EINVAL));
> > +/// }
>
> Like you yourself mentioned in the GitHub issue, code inside functions
> is not called, so please move it out -- you can keep the "blocks"
> separated with a newline so that it is easier to see the different
> cases.
Will do, thanks.
> > +/// assert_eq!(result, Ok(0x1234 as *mut kernel::ffi::c_void));
>
> Since you are asserting the value, but the bindings are hidden, it may
> be best to just assert it is not null.
Makes total sense, will be addressed in v2.
Best,
Mirko