libbpf / libbpf-rs

Minimal and opinionated eBPF tooling for the Rust ecosystem
Other
788 stars 138 forks source link

libbpf-cargo: Stop treating C enums as "unsafe" #1006

Closed danielocfb closed 2 weeks ago

danielocfb commented 2 weeks ago

In the past C enums were mapped to Rust enums in the generated skeletons. Because Rust enums enums have stricter requirements than C ones, we have to wrap them in MaybeUninit (see 87929fff0d9d ("libbpf-cargo: Wrap generated "unsafe" types in MaybeUninit")).

With the switch to using regular constants for representing these C enums in Rust as done in commit e24198391c0a ("libbpf-cargo: Generate C enums as custom types with const fields"), we no longer have to treat them as "unsafe" and can remove the MaybeUninit wrapper.