From d5682cd306a9f1cbd1894f3aab423b7925053812 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 19 Dec 2019 17:12:34 +0000 Subject: [PATCH] vmm: device_manager: Rewrite if chain using match To reflect updated clippy rules: error: `if` chain can be rewritten with `match` --> vmm/src/device_manager.rs:1508:25 | 1508 | / if ret > 0 { 1509 | | debug!("MSI message successfully delivered"); 1510 | | } else if ret == 0 { 1511 | | warn!("failed to deliver MSI message, blocked by guest"); 1512 | | } | |_________________________^ | = note: `-D clippy::comparison-chain` implied by `-D warnings` = help: Consider rewriting the `if` chain to use `cmp` and `match`. = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#comparison_chain Signed-off-by: Rob Bradford --- vmm/src/device_manager.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 68fb409e0..f4b0d413c 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -34,6 +34,7 @@ use std::fs::{File, OpenOptions}; use std::io::{self, sink, stdout}; use arch::layout::{APIC_START, IOAPIC_SIZE, IOAPIC_START}; +use std::cmp; use std::collections::HashMap; use std::os::unix::fs::OpenOptionsExt; use std::os::unix::io::AsRawFd; @@ -1504,12 +1505,14 @@ impl DeviceManager { return vm_fd_clone .signal_msi(msi_queue) .map_err(|e| io::Error::from_raw_os_error(e.errno())) - .map(|ret| { - if ret > 0 { + .map(|ret| match ret.cmp(&0) { + cmp::Ordering::Greater => { debug!("MSI message successfully delivered"); - } else if ret == 0 { + } + cmp::Ordering::Equal => { warn!("failed to deliver MSI message, blocked by guest"); } + _ => {} }); }