Re: [RFC v3 22/27] lib: rspdm: Support SPDM certificate validation

From: Miguel Ojeda

Date: Wed Apr 01 2026 - 06:53:57 EST


On Wed, Apr 1, 2026 at 3:48 AM Alistair Francis <alistair23@xxxxxxxxx> wrote:
>
> I think it's Rust-ier as it uses the fact that
> * if statements can be used as expressions, which is a cool feature of Rust

Sure, but a feature being nice doesn't mean it is idiomatic to apply
it in every context.

More generally, regarding cool features (whether in C or C++ or Rust
etc.), I would say one should strive to keep code as simple as
possible, i.e. we use fancy features when they buy us something, not
just because we can. The kernel applies this principle too.

> * Rust is explicit about comparisons being bools (no `if (value)` for example)

Yes, but I am not sure how this is related.

> So I find the if statement expression returning explicit bools very
> Rust-y and easier to read

If you mean that that seeing `true` and `false` may be clearer because
it is more explicit, then that sounds OK (whether someone agrees or
not), but it is a different argument than being idiomatic.

In any case, I replied initially because the code should be
Clippy-clean, and currently we have that lint enabled -- does it not
trigger in your particular case? i.e. even if you have removed the
code, it would be nice to know why it didn't trigger, or if you were
not testing with `CLIPPY=1`.

Anyway, if you think it is idiomatic Rust, then I would suggest
discussing it with the Clippy folks, because they have it as a warning
by default.

Thanks!

Cheers,
Miguel