From a454b2a2a11d3843768cb66eb4f2102dabe04e4e Mon Sep 17 00:00:00 2001 From: moparisthebest Date: Fri, 24 Sep 2021 00:13:14 -0400 Subject: [PATCH] fix comments and order of operations in input_device --- src/linux/device/input_device.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/linux/device/input_device.rs b/src/linux/device/input_device.rs index d64dd96..e840227 100644 --- a/src/linux/device/input_device.rs +++ b/src/linux/device/input_device.rs @@ -124,9 +124,10 @@ impl InputDevice { pub fn epoll_del(&mut self) -> Result<&mut Self> { if let Some(epoll_fd) = self.epoll_fd { + // set this to None first, if we end up returning an Err early, we can't do anything else anyway... + self.epoll_fd = None; let empty_event = epoll::Event::new(epoll::Events::empty(), 0); epoll::ctl(epoll_fd, EPOLL_CTL_DEL, self.device_file.as_raw_fd(), empty_event)?; - self.epoll_fd = None; } Ok(self) } @@ -134,8 +135,8 @@ impl InputDevice { impl Drop for InputDevice { fn drop(&mut self) { - // todo: only release if grabbed - self.release().ok(); // ignore any errors here, what could we do anyhow? + // ignore any errors here, what could we do anyhow? + self.release().ok(); self.epoll_del().ok(); } }