Skip to content

Commit e3ab917

Browse files
authored
epoll: use from_bits_retain to avoid panics on unknown flags (#2783)
EpollEvent::events() 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.
1 parent 6c15701 commit e3ab917

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

changelog/2783.fixed.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fixed `EpollEvent::events()` to use `from_bits_retain` instead of
2+
`from_bits().unwrap()`, preventing panics when the kernel returns
3+
unknown epoll flags.

src/sys/epoll.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl EpollEvent {
6363
}
6464

6565
pub fn events(&self) -> EpollFlags {
66-
EpollFlags::from_bits(self.event.events as c_int).unwrap()
66+
EpollFlags::from_bits_retain(self.event.events as c_int)
6767
}
6868

6969
pub const fn data(&self) -> u64 {

0 commit comments

Comments
 (0)