diff --git a/shims/cros-libva/src/display.rs b/shims/cros-libva/src/display.rs index ef9eef6b..95378bed 100644 --- a/shims/cros-libva/src/display.rs +++ b/shims/cros-libva/src/display.rs @@ -45,18 +45,14 @@ impl Iterator for DrmDeviceIterator { type Item = PathBuf; fn next(&mut self) -> Option { - match self.cur_idx { - idx if idx >= DRM_RENDER_NODE_START + DRM_NUM_NODES => None, - idx => { - let path = PathBuf::from(format!("{}{}", DRM_NODE_DEFAULT_PREFIX, idx)); - if !path.exists() { - None - } else { - self.cur_idx += 1; - Some(path) - } + while self.cur_idx < DRM_RENDER_NODE_START + DRM_NUM_NODES { + let path = PathBuf::from(format!("{}{}", DRM_NODE_DEFAULT_PREFIX, self.cur_idx)); + self.cur_idx += 1; + if path.exists() { + return Some(path); } } + None } }