mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
linters: Fix clippy issues
Latest clippy version complains about our existing code for the following reasons: - trait objects without an explicit `dyn` are deprecated - `...` range patterns are deprecated - lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` - unnecessary `unsafe` block - unneeded return statement All these issues have been fixed through this patch, and rustfmt has been run to cleanup potential formatting errors due to those changes. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
@@ -57,7 +57,7 @@ struct ConsoleEpollHandler {
|
||||
mem: GuestMemoryMmap,
|
||||
interrupt_cb: Arc<VirtioInterrupt>,
|
||||
in_buffer: Arc<Mutex<VecDeque<u8>>>,
|
||||
out: Box<io::Write + Send>,
|
||||
out: Box<dyn io::Write + Send>,
|
||||
input_queue_evt: EventFd,
|
||||
output_queue_evt: EventFd,
|
||||
input_evt: EventFd,
|
||||
@@ -321,13 +321,13 @@ pub struct Console {
|
||||
acked_features: u64,
|
||||
config: Arc<Mutex<VirtioConsoleConfig>>,
|
||||
input: Arc<ConsoleInput>,
|
||||
out: Option<Box<io::Write + Send>>,
|
||||
out: Option<Box<dyn io::Write + Send>>,
|
||||
}
|
||||
|
||||
impl Console {
|
||||
/// Create a new virtio console device that gets random data from /dev/urandom.
|
||||
pub fn new(
|
||||
out: Option<Box<io::Write + Send>>,
|
||||
out: Option<Box<dyn io::Write + Send>>,
|
||||
cols: u16,
|
||||
rows: u16,
|
||||
) -> io::Result<(Console, Arc<ConsoleInput>)> {
|
||||
|
||||
@@ -17,7 +17,7 @@ pub enum VirtioInterruptType {
|
||||
}
|
||||
|
||||
pub type VirtioInterrupt = Box<
|
||||
Fn(&VirtioInterruptType, Option<&Queue>) -> std::result::Result<(), std::io::Error>
|
||||
dyn Fn(&VirtioInterruptType, Option<&Queue>) -> std::result::Result<(), std::io::Error>
|
||||
+ Send
|
||||
+ Sync,
|
||||
>;
|
||||
|
||||
@@ -223,7 +223,7 @@ pub struct VirtioPciDevice {
|
||||
msix_num: u16,
|
||||
|
||||
// Virtio device reference and status
|
||||
device: Box<VirtioDevice>,
|
||||
device: Box<dyn VirtioDevice>,
|
||||
device_activated: bool,
|
||||
|
||||
// PCI interrupts.
|
||||
@@ -243,7 +243,11 @@ pub struct VirtioPciDevice {
|
||||
|
||||
impl VirtioPciDevice {
|
||||
/// Constructs a new PCI transport for the given virtio device.
|
||||
pub fn new(memory: GuestMemoryMmap, device: Box<VirtioDevice>, msix_num: u16) -> Result<Self> {
|
||||
pub fn new(
|
||||
memory: GuestMemoryMmap,
|
||||
device: Box<dyn VirtioDevice>,
|
||||
msix_num: u16,
|
||||
) -> Result<Self> {
|
||||
let mut queue_evts = Vec::new();
|
||||
for _ in device.queue_max_sizes().iter() {
|
||||
queue_evts.push(EventFd::new(EFD_NONBLOCK)?)
|
||||
@@ -267,15 +271,15 @@ impl VirtioPciDevice {
|
||||
let (class, subclass) = match VirtioDeviceType::from(device.device_type()) {
|
||||
VirtioDeviceType::TYPE_NET => (
|
||||
PciClassCode::NetworkController,
|
||||
&PciNetworkControllerSubclass::EthernetController as &PciSubclass,
|
||||
&PciNetworkControllerSubclass::EthernetController as &dyn PciSubclass,
|
||||
),
|
||||
VirtioDeviceType::TYPE_BLOCK => (
|
||||
PciClassCode::MassStorage,
|
||||
&PciMassStorageSubclass::MassStorage as &PciSubclass,
|
||||
&PciMassStorageSubclass::MassStorage as &dyn PciSubclass,
|
||||
),
|
||||
_ => (
|
||||
PciClassCode::Other,
|
||||
&PciVirtioSubclass::NonTransitionalBase as &PciSubclass,
|
||||
&PciVirtioSubclass::NonTransitionalBase as &dyn PciSubclass,
|
||||
),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user