clippy: Fix codebase to compile with beta toolchain

Fixes the current codebase so that every cargo clippy can be run with
the beta toolchain without any error.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2021-03-29 10:23:58 +02:00 committed by Rob Bradford
parent 943377e6a3
commit 73e8fd4d72
7 changed files with 8 additions and 29 deletions

View File

@ -3,7 +3,6 @@
pub mod kvm { pub mod kvm {
use std::any::Any; use std::any::Any;
use std::convert::TryInto;
use std::sync::Arc; use std::sync::Arc;
use std::{boxed::Box, result}; use std::{boxed::Box, result};
type Result<T> = result::Result<T, Error>; type Result<T> = result::Result<T, Error>;
@ -16,9 +15,6 @@ pub mod kvm {
/// The hypervisor agnostic device /// The hypervisor agnostic device
device: Arc<dyn hypervisor::Device>, device: Arc<dyn hypervisor::Device>,
/// Vector holding values of GICR_TYPER for each vCPU
gicr_typers: Vec<u64>,
/// GIC device properties, to be used for setting up the fdt entry /// GIC device properties, to be used for setting up the fdt entry
gic_properties: [u64; 4], gic_properties: [u64; 4],
@ -74,9 +70,7 @@ pub mod kvm {
self.vcpu_count self.vcpu_count
} }
fn set_gicr_typers(&mut self, gicr_typers: Vec<u64>) { fn set_gicr_typers(&mut self, _gicr_typers: Vec<u64>) {}
self.gicr_typers = gicr_typers;
}
fn as_any_concrete_mut(&mut self) -> &mut dyn Any { fn as_any_concrete_mut(&mut self) -> &mut dyn Any {
self self
@ -94,7 +88,6 @@ pub mod kvm {
) -> Box<dyn GicDevice> { ) -> Box<dyn GicDevice> {
Box::new(KvmGicV3Its { Box::new(KvmGicV3Its {
device, device,
gicr_typers: vec![0; vcpu_count.try_into().unwrap()],
gic_properties: [ gic_properties: [
KvmGicV3::get_dist_addr(), KvmGicV3::get_dist_addr(),
KvmGicV3::get_dist_size(), KvmGicV3::get_dist_size(),

View File

@ -111,10 +111,10 @@ pub mod kvm {
flags: u32, flags: u32,
) -> Result<()> { ) -> Result<()> {
let attr = kvm_bindings::kvm_device_attr { let attr = kvm_bindings::kvm_device_attr {
flags,
group, group,
attr, attr,
addr, addr,
flags,
}; };
device device
.set_device_attr(&attr) .set_device_attr(&attr)
@ -132,10 +132,10 @@ pub mod kvm {
flags: u32, flags: u32,
) -> Result<()> { ) -> Result<()> {
let mut attr = kvm_bindings::kvm_device_attr { let mut attr = kvm_bindings::kvm_device_attr {
flags,
group, group,
attr, attr,
addr, addr,
flags,
}; };
device device
.get_device_attr(&mut attr) .get_device_attr(&mut attr)

View File

@ -1814,8 +1814,8 @@ mod tests {
tx_bytes, tx_bytes,
tx_frames, tx_frames,
read_bytes, read_bytes,
read_ops,
write_bytes, write_bytes,
read_ops,
write_ops, write_ops,
} }
} }

View File

@ -437,9 +437,7 @@ struct VhostUserHandler<S: VhostUserBackend> {
backend: Arc<RwLock<S>>, backend: Arc<RwLock<S>>,
workers: Vec<Arc<VringWorker>>, workers: Vec<Arc<VringWorker>>,
owned: bool, owned: bool,
features_acked: bool,
acked_features: u64, acked_features: u64,
acked_protocol_features: u64,
num_queues: usize, num_queues: usize,
max_queue_size: usize, max_queue_size: usize,
queues_per_thread: Vec<u64>, queues_per_thread: Vec<u64>,
@ -515,9 +513,7 @@ impl<S: VhostUserBackend> VhostUserHandler<S> {
backend, backend,
workers, workers,
owned: false, owned: false,
features_acked: false,
acked_features: 0, acked_features: 0,
acked_protocol_features: 0,
num_queues, num_queues,
max_queue_size, max_queue_size,
queues_per_thread, queues_per_thread,
@ -554,9 +550,7 @@ impl<S: VhostUserBackend> VhostUserSlaveReqHandlerMut for VhostUserHandler<S> {
fn reset_owner(&mut self) -> VhostUserResult<()> { fn reset_owner(&mut self) -> VhostUserResult<()> {
self.owned = false; self.owned = false;
self.features_acked = false;
self.acked_features = 0; self.acked_features = 0;
self.acked_protocol_features = 0;
Ok(()) Ok(())
} }
@ -570,7 +564,6 @@ impl<S: VhostUserBackend> VhostUserSlaveReqHandlerMut for VhostUserHandler<S> {
} }
self.acked_features = features; self.acked_features = features;
self.features_acked = true;
// If VHOST_USER_F_PROTOCOL_FEATURES has not been negotiated, // If VHOST_USER_F_PROTOCOL_FEATURES has not been negotiated,
// the ring is initialized in an enabled state. // the ring is initialized in an enabled state.
@ -597,11 +590,10 @@ impl<S: VhostUserBackend> VhostUserSlaveReqHandlerMut for VhostUserHandler<S> {
Ok(self.backend.read().unwrap().protocol_features()) Ok(self.backend.read().unwrap().protocol_features())
} }
fn set_protocol_features(&mut self, features: u64) -> VhostUserResult<()> { fn set_protocol_features(&mut self, _features: u64) -> VhostUserResult<()> {
// Note: slave that reported VHOST_USER_F_PROTOCOL_FEATURES must // Note: slave that reported VHOST_USER_F_PROTOCOL_FEATURES must
// support this message even before VHOST_USER_SET_FEATURES was // support this message even before VHOST_USER_SET_FEATURES was
// called. // called.
self.acked_protocol_features = features;
Ok(()) Ok(())
} }

View File

@ -469,10 +469,10 @@ impl VhostUserBlkBackendConfig {
path, path,
socket, socket,
num_queues, num_queues,
queue_size,
readonly, readonly,
direct, direct,
poll_queue, poll_queue,
queue_size,
}) })
} }
} }

View File

@ -94,7 +94,6 @@ impl std::convert::From<Error> for std::io::Error {
struct VhostUserNetThread { struct VhostUserNetThread {
net: NetQueuePair, net: NetQueuePair,
vring_worker: Option<Arc<VringWorker>>,
kill_evt: EventFd, kill_evt: EventFd,
} }
@ -102,7 +101,6 @@ impl VhostUserNetThread {
/// Create a new virtio network device with the given TAP interface. /// Create a new virtio network device with the given TAP interface.
fn new(tap: Tap) -> Result<Self> { fn new(tap: Tap) -> Result<Self> {
Ok(VhostUserNetThread { Ok(VhostUserNetThread {
vring_worker: None,
kill_evt: EventFd::new(EFD_NONBLOCK).map_err(Error::CreateKillEventFd)?, kill_evt: EventFd::new(EFD_NONBLOCK).map_err(Error::CreateKillEventFd)?,
net: NetQueuePair { net: NetQueuePair {
mem: None, mem: None,
@ -119,7 +117,6 @@ impl VhostUserNetThread {
pub fn set_vring_worker(&mut self, vring_worker: Option<Arc<VringWorker>>) { pub fn set_vring_worker(&mut self, vring_worker: Option<Arc<VringWorker>>) {
self.net.epoll_fd = Some(vring_worker.as_ref().unwrap().as_raw_fd()); self.net.epoll_fd = Some(vring_worker.as_ref().unwrap().as_raw_fd());
self.vring_worker = vring_worker;
} }
} }
@ -345,11 +342,7 @@ pub fn start_net_backend(backend_command: &str) {
} }
}; };
let tap = if let Some(tap) = backend_config.tap.as_ref() { let tap = backend_config.tap.as_deref();
Some(tap.as_str())
} else {
None
};
let net_backend = Arc::new(RwLock::new( let net_backend = Arc::new(RwLock::new(
VhostUserNetBackend::new( VhostUserNetBackend::new(

View File

@ -862,6 +862,7 @@ pub struct DeviceManager {
// MSI Interrupt Manager // MSI Interrupt Manager
msi_interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>, msi_interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
#[cfg_attr(feature = "mshv", allow(dead_code))]
// Legacy Interrupt Manager // Legacy Interrupt Manager
legacy_interrupt_manager: Option<Arc<dyn InterruptManager<GroupConfig = LegacyIrqGroupConfig>>>, legacy_interrupt_manager: Option<Arc<dyn InterruptManager<GroupConfig = LegacyIrqGroupConfig>>>,