Skip to content

kqueue: use from_bits_retain to avoid panics on unknown flags#2784

Merged
SteveLauC merged 1 commit into
nix-rust:masterfrom
kamalmarhubi:push-yyzzrmrswyuu
May 11, 2026
Merged

kqueue: use from_bits_retain to avoid panics on unknown flags#2784
SteveLauC merged 1 commit into
nix-rust:masterfrom
kamalmarhubi:push-yyzzrmrswyuu

Conversation

@kamalmarhubi
Copy link
Copy Markdown
Member

What does this PR do

KEvent::flags() and KEvent::fflags() used from_bits().unwrap(), which panics if the kernel returns flags unknown to the current bitflags definition. Use from_bits_retain to preserve all bits without panicking.

Checklist:

  • I have read CONTRIBUTING.md
  • I have written necessary tests and rustdoc comments
  • A change log has been added if this PR modifies nix's API

KEvent::flags() and KEvent::fflags() used from_bits().unwrap(), which
panics if the kernel returns flags unknown to the current bitflags
definition. Use from_bits_retain to preserve all bits without panicking.
@xtqqczze
Copy link
Copy Markdown
Contributor

from_bits_retain only became available with #2027, so it's less likely the original intent was to panic.

@kamalmarhubi
Copy link
Copy Markdown
Member Author

from_bits_retain only became available with #2027, so it's less likely the original intent was to panic.

Ah thanks for that context! I just assumed it was originally done in error since the in theory a newer kernel could return bits we don't know about.

@SteveLauC SteveLauC added this pull request to the merge queue May 11, 2026
Merged via the queue into nix-rust:master with commit 6c15701 May 11, 2026
58 of 59 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants