Re: [PATCH 04/79] block: rust: fix generation of bindings to `BLK_STS_.*`
From: Alice Ryhl
Date: Mon Mar 16 2026 - 08:02:56 EST
On Mon, Mar 16, 2026 at 10:27 AM Alice Ryhl <aliceryhl@xxxxxxxxxx> 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@xxxxxxxxxx>
>
> 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@xxxxxxxxxx>
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