summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@chromium.org>2019-04-12 18:23:43 -0700
committerchrome-bot <chrome-bot@chromium.org>2019-04-17 17:22:49 -0700
commit2da9b8181f357d05b839cfb31d6288e1266c70f6 (patch)
treed4f576bbe1711e7514b7716e8f8a5aeb26333c9a
parent526d0dad9220fad4cb1fe0e9e89a16dd4f65b8de (diff)
downloadcrosvm-2da9b8181f357d05b839cfb31d6288e1266c70f6.tar
crosvm-2da9b8181f357d05b839cfb31d6288e1266c70f6.tar.gz
crosvm-2da9b8181f357d05b839cfb31d6288e1266c70f6.tar.bz2
crosvm-2da9b8181f357d05b839cfb31d6288e1266c70f6.tar.lz
crosvm-2da9b8181f357d05b839cfb31d6288e1266c70f6.tar.xz
crosvm-2da9b8181f357d05b839cfb31d6288e1266c70f6.tar.zst
crosvm-2da9b8181f357d05b839cfb31d6288e1266c70f6.zip
clippy: Resolve block_in_if_condition_stmt
TEST=bin/clippy

Change-Id: I36153632fbe21e8e23a36f0522b7afa1a72b5192
Reviewed-on: https://chromium-review.googlesource.com/1566658
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
-rwxr-xr-xbin/clippy1
-rw-r--r--devices/src/usb/xhci/usb_hub.rs25
2 files changed, 13 insertions, 13 deletions
diff --git a/bin/clippy b/bin/clippy
index c370bd2..6bc59aa 100755
--- a/bin/clippy
+++ b/bin/clippy
@@ -13,7 +13,6 @@ cd ..
 
 SUPPRESS=(
     # To be resolved.
-    block_in_if_condition_stmt
     clone_on_copy
     collapsible_if
     const_static_lifetime
diff --git a/devices/src/usb/xhci/usb_hub.rs b/devices/src/usb/xhci/usb_hub.rs
index d5c532e..ae4f2f8 100644
--- a/devices/src/usb/xhci/usb_hub.rs
+++ b/devices/src/usb/xhci/usb_hub.rs
@@ -208,21 +208,22 @@ impl UsbHub {
     /// Try to detach device of bus, addr, vid, pid
     pub fn try_detach(&self, bus: u8, addr: u8, vid: u16, pid: u16) -> Result<()> {
         for port in &self.ports {
-            if !port
-                .get_backend_device()
-                .as_ref()
-                .map(|d| {
-                    d.host_bus() == bus
-                        && d.host_address() == addr
-                        && d.get_vid() == vid
-                        && d.get_pid() == pid
-                })
-                .unwrap_or(false)
+            let backend_device = port.get_backend_device();
+
+            let d = match backend_device.as_ref() {
+                None => continue,
+                Some(d) => d,
+            };
+
+            if d.host_bus() == bus
+                && d.host_address() == addr
+                && d.get_vid() == vid
+                && d.get_pid() == pid
             {
-                continue;
+                return port.detach();
             }
-            return port.detach();
         }
+
         Err(Error::NoSuchDevice {
             bus,
             addr,