Re: [PATCH 04/79] block: rust: fix generation of bindings to `BLK_STS_.*`

Alice Ryhl
2026-03-16T11:58:41Z

On Mon, Mar 16, 2026 at 10:27 AM Alice Ryhl <aliceryhl@google.com> wrote:
>
> On Mon, Feb 16, 2026 at 12:34:51AM +0100, Andreas Hindborg wrote:
> > Bindgen generates constants for CPP integer literals as u32. The
> > `blk_status_t` type is defined as `u8` but the variants of the type are
> > defined as integer literals via CPP macros. Thus the defined variants of
> > the type are not of the same type as the type itself.
> >
> > Prevent bindgen from emitting generated bindings for the `BLK_STS_.*`
> > defines and instead define constants manually in `bindings_helper.h`
> >
> > Also remove casts that are no longer necessary.
> >
> > Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
>
> It'd be ideal to change the C header to use an enum, but that may not
> work as I'm not sure you can specify the integer width you want for an
> enum.
>
> Reviewed-by: Alice Ryhl <aliceryhl@google.com>

Honestly, it might be better just to declare a Rust module somewhere
with each constant redeclared:

const BLK_STS_FOO: blk_status_t = bindings::BLK_STS_FOO as blk_status_t;

Alice