Skip to content

Remove uses of enum #4419

@tgross35

Description

@tgross35

Rust enums become UB if they hold an unexpected value, while C enums are effectively a grouped list of named constants. This causes easy UB if e.g. C adds a value or returns a value not represented by the enum (as is allowed in C), and this value gets passed to Rust.

The easiest thing to do is map enums to constants, which we already do in most cases. We could also consider an enum! macro that figures out the values.

Some more context is at https://mdaverde.com/posts/rust-bindgen-enum/ and rust-lang/rust-bindgen#2646.

Metadata

Metadata

Assignees

No one assigned

    Labels

    I-unsound 💥A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions