Remove uses of `enum`
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- operating-systems
Research direction
Start by reviewing the existing cases where C enums are mapped to constants, then read the linked bindgen context and the discussion in rust-bindgen issue #2646. Determine the scope of enum uses to remove and whether an enum! macro is needed. Done means the affected bindings avoid unsafe Rust enums while preserving the C values across platforms.
Written by the indexing model from the issue text.
Description
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 https://github.com/rust-lang/rust-bindgen/issues/2646.
- Dominant language
- Rust
- Stars
- 2.6k
- Forks
- 1.3k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 27
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-lang/libc
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
riscv32gc-unknown-linux-gnu: `timex` uses the 32-bit `c_long` layout (144 bytes), glibc's riscv32 `struct timex` is 208 bytesPossibly taken @compiler-segfault claimed this 3 days ago. OpenC-bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rust-lang/libc#5697 · 3 comments ·
Maintainers usually reply within 1 day
-
Expose `open_how` on AndroidPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-lang/libc#5673 · 1 comment ·
Maintainers usually reply within 1 day
-
RTEMS: `dirfd` is not declaredPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
rust-lang/libc#5655 · 1 comment ·
Maintainers usually reply within 1 day
-
C-bug O-macos
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rust-lang/libc#5650 · 16 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CakeRepository/agentshangout#995 ·
-
area:frontend kind:bug priority:p3 ready
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day