vmm: cpu: Rewrite if chain using match

Address updated clippy error:

error: `if` chain can be rewritten with `match`
   --> vmm/src/cpu.rs:668:9
    |
668 | /         if desired_vcpus > self.present_vcpus() {
669 | |             self.activate_vcpus(desired_vcpus, None)?;
670 | |         } else if desired_vcpus < self.present_vcpus() {
671 | |             self.mark_vcpus_for_removal(desired_vcpus)?;
672 | |         }
    | |_________^
    |
    = 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 <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2019-12-19 17:08:38 +00:00 committed by Samuel Ortiz
parent e25a47b32c
commit 21b88c3ea0

View File

@ -9,6 +9,7 @@
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
//
use std::cmp;
use std::os::unix::thread::JoinHandleExt;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Barrier, Mutex, RwLock, Weak};
@ -665,13 +666,11 @@ impl CpuManager {
}
pub fn resize(&mut self, desired_vcpus: u8) -> Result<()> {
if desired_vcpus > self.present_vcpus() {
self.activate_vcpus(desired_vcpus, None)?;
} else if desired_vcpus < self.present_vcpus() {
self.mark_vcpus_for_removal(desired_vcpus)?;
match desired_vcpus.cmp(&self.present_vcpus()) {
cmp::Ordering::Greater => self.activate_vcpus(desired_vcpus, None),
cmp::Ordering::Less => self.mark_vcpus_for_removal(desired_vcpus),
_ => Ok(()),
}
Ok(())
}
pub fn shutdown(&mut self) -> Result<()> {