diff --git a/devices/src/virtio/input/evdev.rs b/devices/src/virtio/input/evdev.rs index 8d63483804..ce553f8a82 100644 --- a/devices/src/virtio/input/evdev.rs +++ b/devices/src/virtio/input/evdev.rs @@ -234,12 +234,12 @@ pub fn supported_events( /// Gets the absolute axes of an event device (see EVIOCGABS ioctl for details). pub fn abs_info(descriptor: &T) -> BTreeMap { - let mut ret: BTreeMap = BTreeMap::new(); + let mut map: BTreeMap = BTreeMap::new(); for abs in 0..ABS_MAX { // Create a new one, zero-ed out every time to avoid carry-overs. let mut abs_info = evdev_abs_info::new(); - let len = unsafe { + let ret = unsafe { // Safe because the kernel won't write more than size of evdev_buffer and we check the // return value ioctl_with_mut_ref( @@ -248,11 +248,11 @@ pub fn abs_info(descriptor: &T) -> BTreeMap 0 { - ret.insert(abs, virtio_input_absinfo::from(abs_info)); + if ret == 0 { + map.insert(abs, virtio_input_absinfo::from(abs_info)); } } - ret + map } /// Grabs an event device (see EVIOCGGRAB ioctl for details). After this function succeeds the given