diff --git a/Cargo.toml b/Cargo.toml index 94329850d..0c7a34dbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -172,6 +172,7 @@ suspicious = "deny" # Individual Lints assertions_on_result_states = "deny" undocumented_unsafe_blocks = "deny" +unnecessary_semicolon = "deny" [workspace.lints.rust] # `level = warn` is irrelevant here but mandatory for rustc/cargo diff --git a/arch/src/aarch64/fdt.rs b/arch/src/aarch64/fdt.rs index 90d687731..ce3551cc7 100644 --- a/arch/src/aarch64/fdt.rs +++ b/arch/src/aarch64/fdt.rs @@ -1150,7 +1150,7 @@ fn print_node(node: fdt_parser::node::FdtNode<'_, '_>, n_spaces: usize) { array, indent = (n_spaces + 2) ); - }; + } } // Print children nodes if there is any diff --git a/arch/src/riscv64/fdt.rs b/arch/src/riscv64/fdt.rs index e78138861..b30d2ce19 100644 --- a/arch/src/riscv64/fdt.rs +++ b/arch/src/riscv64/fdt.rs @@ -472,7 +472,7 @@ fn print_node(node: fdt_parser::node::FdtNode<'_, '_>, n_spaces: usize) { array, indent = (n_spaces + 2) ); - }; + } } // Print children nodes if there is any diff --git a/arch/src/x86_64/mod.rs b/arch/src/x86_64/mod.rs index 91fba56c0..3746730ad 100644 --- a/arch/src/x86_64/mod.rs +++ b/arch/src/x86_64/mod.rs @@ -824,7 +824,7 @@ pub fn configure_vcpu( * APIC_BUS_CYCLE_NS */ ..Default::default() }); - }; + } } for c in &cpuid { diff --git a/arch/src/x86_64/regs.rs b/arch/src/x86_64/regs.rs index 6e7292f3c..f02be41bc 100644 --- a/arch/src/x86_64/regs.rs +++ b/arch/src/x86_64/regs.rs @@ -108,7 +108,7 @@ pub fn setup_regs(vcpu: &dyn hypervisor::Vcpu, entry_point: EntryPoint) -> Resul regs.set_rsp(BOOT_STACK_POINTER.raw_value()); regs.set_rsi(ZERO_PAGE_START.raw_value()); } - }; + } vcpu.set_regs(®s).map_err(Error::SetBaseRegisters) } diff --git a/block/src/lib.rs b/block/src/lib.rs index f7388e505..bdd242f3a 100644 --- a/block/src/lib.rs +++ b/block/src/lib.rs @@ -398,7 +398,7 @@ impl Request { .map_err(ExecuteError::Write)?; } RequestType::Unsupported(t) => return Err(ExecuteError::Unsupported(t)), - }; + } } Ok(len) } @@ -901,7 +901,7 @@ impl DiskTopology { }; if ret != 0 { return Err(std::io::Error::last_os_error()); - }; + } Ok(block_size) } diff --git a/block/src/qcow/raw_file.rs b/block/src/qcow/raw_file.rs index f0eff54df..232871472 100644 --- a/block/src/qcow/raw_file.rs +++ b/block/src/qcow/raw_file.rs @@ -259,7 +259,7 @@ impl Write for RawFile { // SAFETY: tmp_ptr was allocated by alloc_zeroed with layout unsafe { dealloc(tmp_ptr, layout) }; return Err(io::Error::last_os_error()); - }; + } tmp_buf[file_offset..(file_offset + buf_len)].copy_from_slice(buf); diff --git a/block/src/vhdx/vhdx_io.rs b/block/src/vhdx/vhdx_io.rs index 14feac8d9..96ce4ef4c 100644 --- a/block/src/vhdx/vhdx_io.rs +++ b/block/src/vhdx/vhdx_io.rs @@ -128,7 +128,7 @@ pub fn read( _ => { return Err(VhdxIoError::InvalidBatEntryState); } - }; + } sector_count -= sector.free_sectors; sector_index += sector.free_sectors; read_count += sector.free_bytes as usize; @@ -210,7 +210,7 @@ pub fn write( _ => { return Err(VhdxIoError::InvalidBatEntryState); } - }; + } sector_count -= sector.free_sectors; sector_index += sector.free_sectors; write_count += sector.free_bytes as usize; diff --git a/devices/src/ivshmem.rs b/devices/src/ivshmem.rs index 50c056edf..dccad21d7 100644 --- a/devices/src/ivshmem.rs +++ b/devices/src/ivshmem.rs @@ -233,20 +233,18 @@ impl PciDevice for IvshmemDevice { if let Some(resources) = resources { for resource in resources { match resource { - Resource::PciBar { index, base, .. } => { - match index { - IVSHMEM_BAR0_IDX => { - bar0_addr = Some(GuestAddress(base)); - } - IVSHMEM_BAR1_IDX => {} - IVSHMEM_BAR2_IDX => { - bar2_addr = Some(GuestAddress(base)); - } - _ => { - error!("Unexpected pci bar index {index}"); - } - }; - } + Resource::PciBar { index, base, .. } => match index { + IVSHMEM_BAR0_IDX => { + bar0_addr = Some(GuestAddress(base)); + } + IVSHMEM_BAR1_IDX => {} + IVSHMEM_BAR2_IDX => { + bar2_addr = Some(GuestAddress(base)); + } + _ => { + error!("Unexpected pci bar index {index}"); + } + }, _ => { error!("Unexpected resource {resource:?}"); } @@ -348,7 +346,7 @@ impl PciDevice for IvshmemDevice { _ => { warn!("Invalid bar_idx: {bar_idx}"); } - }; + } } fn write_bar(&mut self, base: u64, offset: u64, _data: &[u8]) -> Option> { diff --git a/devices/src/legacy/cmos.rs b/devices/src/legacy/cmos.rs index d5528fb77..ff85d6328 100644 --- a/devices/src/legacy/cmos.rs +++ b/devices/src/legacy/cmos.rs @@ -91,7 +91,7 @@ impl BusDevice for Cmos { } } o => warn!("bad write offset on CMOS device: {o}"), - }; + } None } diff --git a/devices/src/legacy/fw_cfg.rs b/devices/src/legacy/fw_cfg.rs index 1a5c6478c..5013835c8 100644 --- a/devices/src/legacy/fw_cfg.rs +++ b/devices/src/legacy/fw_cfg.rs @@ -710,7 +710,7 @@ impl FwCfg { let bytes = n.to_le_bytes(); data.copy_from_slice(&bytes[start..end]); } - }; + } Some(size as u8) } @@ -756,7 +756,7 @@ impl BusDevice for FwCfg { "fw_cfg: read from unknown port {port:#x}: {size:#x} bytes and offset {offset:#x}." ); } - }; + } } fn write(&mut self, _base: u64, offset: u64, data: &[u8]) -> Option> { @@ -792,7 +792,7 @@ impl BusDevice for FwCfg { _ => debug!( "fw_cfg: write to unknown port {port:#x}: {size:#x} bytes and offset {offset:#x} ." ), - }; + } None } } diff --git a/hypervisor/src/arch/x86/emulator/instructions/mod.rs b/hypervisor/src/arch/x86/emulator/instructions/mod.rs index 945ce16ba..a3ee3f33f 100644 --- a/hypervisor/src/arch/x86/emulator/instructions/mod.rs +++ b/hypervisor/src/arch/x86/emulator/instructions/mod.rs @@ -101,7 +101,7 @@ fn set_op( platform.write_memory(addr, &value.to_le_bytes()[..op_size])?; } k => return Err(PlatformError::InvalidOperand(anyhow!("{:?}", k))), - }; + } Ok(()) } diff --git a/net_util/src/tap.rs b/net_util/src/tap.rs index 413bd7350..36f0e2ba3 100644 --- a/net_util/src/tap.rs +++ b/net_util/src/tap.rs @@ -314,7 +314,7 @@ impl Tap { &ifreq, )?; } - }; + } Ok(()) } diff --git a/option_parser/src/lib.rs b/option_parser/src/lib.rs index 39fb1e51e..ac01831b6 100644 --- a/option_parser/src/lib.rs +++ b/option_parser/src/lib.rs @@ -73,7 +73,7 @@ fn split_commas(s: &str) -> OptionParserResult> { continue; } _ => {} - }; + } current.push(c); } list.push(current); diff --git a/pci/src/configuration.rs b/pci/src/configuration.rs index b3dd5a610..0e45b1c4c 100644 --- a/pci/src/configuration.rs +++ b/pci/src/configuration.rs @@ -593,7 +593,7 @@ impl PciConfiguration { writable_bits[9] = 0xfff0_fff0; // Memory base and limit writable_bits[15] = 0xffff_00ff; // Bridge control (r/w), interrupt line (r/w) } - }; + } registers[11] = (u32::from(subsystem_id) << 16) | u32::from(subsystem_vendor_id); ( diff --git a/pci/src/msix.rs b/pci/src/msix.rs index 7007eb3e5..efd0e7b67 100644 --- a/pci/src/msix.rs +++ b/pci/src/msix.rs @@ -288,7 +288,7 @@ impl MsixConfig { self.table_entries[index].vector_ctl = value; } _ => error!("invalid offset"), - }; + } debug!("MSI_W TABLE offset 0x{offset:x} data 0x{value:x}"); } @@ -304,12 +304,12 @@ impl MsixConfig { self.table_entries[index].vector_ctl = (value >> 32) as u32; } _ => error!("invalid offset"), - }; + } debug!("MSI_W TABLE offset 0x{offset:x} data 0x{value:x}"); } _ => error!("invalid data length"), - }; + } let table_entry = &self.table_entries[index]; diff --git a/pci/src/vfio.rs b/pci/src/vfio.rs index 13a528eba..7c12f116a 100644 --- a/pci/src/vfio.rs +++ b/pci/src/vfio.rs @@ -642,7 +642,7 @@ impl VfioCommon { PCI_CONFIG_BAR_PREFETCHABLE ) { prefetchable = PciBarPrefetchable::Prefetchable - }; + } // To get size write all 1s self.vfio_wrapper @@ -941,7 +941,7 @@ impl VfioCommon { PciCapabilityId::PciExpress => pci_express_cap_found = true, PciCapabilityId::PowerManagement => power_management_cap_found = true, _ => {} - }; + } let cap_next = self.vfio_wrapper.read_config_byte((cap_iter + 1).into()) & PCI_CONFIG_CAPABILITY_PTR_MASK; diff --git a/performance-metrics/src/main.rs b/performance-metrics/src/main.rs index 220532f6c..b3f1ae018 100644 --- a/performance-metrics/src/main.rs +++ b/performance-metrics/src/main.rs @@ -790,7 +790,7 @@ fn main() { eprintln!("Aborting test due to error: '{e:?}'"); std::process::exit(1); } - }; + } } } diff --git a/rate_limiter/src/group.rs b/rate_limiter/src/group.rs index 9ef2a56cd..a4b44dfe3 100644 --- a/rate_limiter/src/group.rs +++ b/rate_limiter/src/group.rs @@ -275,7 +275,7 @@ impl RateLimiterGroup { error!("rate-limit-group worker panicked"); exit_evt.write(1).unwrap(); } - }; + } }) .map(|thread| self.epoll_thread.insert(thread)) .map_err(Error::ThreadSpawn)?; diff --git a/rate_limiter/src/lib.rs b/rate_limiter/src/lib.rs index 6c71036b2..4101c30b3 100644 --- a/rate_limiter/src/lib.rs +++ b/rate_limiter/src/lib.rs @@ -491,12 +491,12 @@ impl RateLimiter { BucketUpdate::Disabled => guard.bandwidth = None, BucketUpdate::Update(tb) => guard.bandwidth = Some(tb), BucketUpdate::None => (), - }; + } match ops { BucketUpdate::Disabled => guard.ops = None, BucketUpdate::Update(tb) => guard.ops = Some(tb), BucketUpdate::None => (), - }; + } } } diff --git a/src/bin/ch-remote.rs b/src/bin/ch-remote.rs index 1393d25f1..13af148bd 100644 --- a/src/bin/ch-remote.rs +++ b/src/bin/ch-remote.rs @@ -1201,7 +1201,7 @@ fn main() { server_api_error_display_modifier, ); process::exit(1) - }; + } } #[cfg(test)] diff --git a/test_infra/src/lib.rs b/test_infra/src/lib.rs index 12d9c5940..99f41f527 100644 --- a/test_infra/src/lib.rs +++ b/test_infra/src/lib.rs @@ -644,7 +644,7 @@ fn scp_to_guest_with_auth( return Err(e); } } - }; + } thread::sleep(std::time::Duration::new((timeout * counter).into(), 0)); } Ok(()) @@ -730,7 +730,7 @@ pub fn ssh_command_ip_with_auth( return Err(e); } } - }; + } thread::sleep(std::time::Duration::new((timeout * counter).into(), 0)); } Ok(s) @@ -1334,7 +1334,7 @@ impl<'a> GuestCommand<'a> { Debug => { self.command.args(["-vv"]); } - }; + } if self.print_cmd { println!( diff --git a/tests/integration.rs b/tests/integration.rs index 72d6aed56..083f1ef31 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -7683,7 +7683,7 @@ mod ivshmem { None, "source VM was not terminated successfully.", ); - }; + } // Post live-migration check to make sure the destination VM is functional let r = std::panic::catch_unwind(|| { @@ -10098,7 +10098,7 @@ mod live_migration { None, "source VM was not terminated successfully.", ); - }; + } // Post live-migration check to make sure the destination VM is functional let r = std::panic::catch_unwind(|| { @@ -10272,7 +10272,7 @@ mod live_migration { None, "source VM was not terminated successfully.", ); - }; + } // Post live-migration check to make sure the destination VM is functional let r = std::panic::catch_unwind(|| { @@ -10490,7 +10490,7 @@ mod live_migration { None, "source VM was not terminated successfully.", ); - }; + } // Post live-migration check to make sure the destination VM is functional let r = std::panic::catch_unwind(|| { @@ -10706,7 +10706,7 @@ mod live_migration { None, "source VM was not terminated successfully.", ); - }; + } // Post live-migration check to make sure the destination VM is functional let r = std::panic::catch_unwind(|| { @@ -10816,7 +10816,7 @@ mod live_migration { Some(ovs_child), "source VM was not terminated successfully.", ); - }; + } // Post live-migration check to make sure the destination VM is functional let r = std::panic::catch_unwind(|| { @@ -10963,7 +10963,7 @@ mod live_migration { None, "source VM was not terminated successfully.", ); - }; + } // Post live-migration check to make sure the destination VM is functioning let r = std::panic::catch_unwind(|| { @@ -11177,7 +11177,7 @@ mod live_migration { None, "Source VM was not terminated successfully.", ); - }; + } // After live migration, ensure the destination VM is running normally let r = std::panic::catch_unwind(|| { diff --git a/virtio-devices/src/block.rs b/virtio-devices/src/block.rs index ff8adf3b4..38eeaf938 100644 --- a/virtio-devices/src/block.rs +++ b/virtio-devices/src/block.rs @@ -223,7 +223,7 @@ impl BlockEpollHandler { queue.go_to_previous_position(); break; } - }; + } } request.set_writeback(self.writeback.load(Ordering::Acquire)); diff --git a/virtio-devices/src/net.rs b/virtio-devices/src/net.rs index fd6a4a3b0..17ca855fc 100644 --- a/virtio-devices/src/net.rs +++ b/virtio-devices/src/net.rs @@ -124,7 +124,7 @@ impl EpollHelperHandler for NetCtrlEpollHandler { "Error getting notification state of control queue: {e}" ))); } - }; + } } _ => { return Err(EpollHelperError::HandleEvent(anyhow!( diff --git a/virtio-devices/src/thread_helper.rs b/virtio-devices/src/thread_helper.rs index df05a60ed..735aebbf5 100644 --- a/virtio-devices/src/thread_helper.rs +++ b/virtio-devices/src/thread_helper.rs @@ -54,7 +54,7 @@ where thread_exit_evt.write(1).ok(); } } - }; + } }) .map(|thread| epoll_threads.push(thread)) .map_err(|e| { diff --git a/virtio-devices/src/transport/pci_device.rs b/virtio-devices/src/transport/pci_device.rs index 4f34ffea6..1a21c7a40 100644 --- a/virtio-devices/src/transport/pci_device.rs +++ b/virtio-devices/src/transport/pci_device.rs @@ -1192,7 +1192,7 @@ impl PciDevice for VirtioPciDevice { } } _ => (), - }; + } // Try and activate the device if the driver status has changed if self.needs_activation() { diff --git a/virtio-devices/src/vsock/csm/connection.rs b/virtio-devices/src/vsock/csm/connection.rs index 69589a45b..3b87194da 100644 --- a/virtio-devices/src/vsock/csm/connection.rs +++ b/virtio-devices/src/vsock/csm/connection.rs @@ -252,7 +252,7 @@ where self.last_fwd_cnt_to_peer = self.fwd_cnt; return Ok(()); } - }; + } } // A credit update is basically a no-op, so we should only waste a perfectly fine RX @@ -380,7 +380,7 @@ where pkt.hdr() ); } - }; + } Ok(()) } @@ -459,7 +459,7 @@ where // it does, so let's absorb it. } _ => self.kill(), - }; + } 0 }); self.fwd_cnt += Wrapping(flushed as u32); diff --git a/virtio-devices/src/vsock/unix/muxer.rs b/virtio-devices/src/vsock/unix/muxer.rs index e02d3429f..e6957efd6 100644 --- a/virtio-devices/src/vsock/unix/muxer.rs +++ b/virtio-devices/src/vsock/unix/muxer.rs @@ -753,7 +753,7 @@ impl VsockMuxer { conn.kill(); warn!("vsock: unable to ack host connection: {err:?}"); } - }; + } } // If the connection wasn't previously scheduled for RX, add it to our RX queue. @@ -975,7 +975,7 @@ mod unit_tests { EpollListener::LocalStream(_) => local_lsn_count += 1, EpollListener::Connection { .. } => conn_lsn_count += 1, _ => (), - }; + } } (local_lsn_count, conn_lsn_count) } diff --git a/virtio-devices/src/vsock/unix/muxer_rxq.rs b/virtio-devices/src/vsock/unix/muxer_rxq.rs index 077cbc889..a319ddbd0 100644 --- a/virtio-devices/src/vsock/unix/muxer_rxq.rs +++ b/virtio-devices/src/vsock/unix/muxer_rxq.rs @@ -102,7 +102,7 @@ impl MuxerRxQ { MuxerRx::ConnRx(_) => { self.synced = false; } - }; + } false } diff --git a/vmm/src/acpi.rs b/vmm/src/acpi.rs index fa107d037..5a4878290 100644 --- a/vmm/src/acpi.rs +++ b/vmm/src/acpi.rs @@ -779,7 +779,7 @@ fn create_acpi_tables_internal( prev_tbl_len = slit.len() as u64; prev_tbl_addr = slit_addr; - }; + } #[cfg(target_arch = "aarch64")] { @@ -957,7 +957,7 @@ pub fn create_acpi_tables_tdx( // SLIT tables.push(create_slit_table(numa_nodes)); - }; + } // VIOT if let Some((iommu_bdf, devices_bdf)) = device_manager.lock().unwrap().iommu_attached_devices() diff --git a/vmm/src/config.rs b/vmm/src/config.rs index 86136c9ec..1ad3cfb30 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -2514,10 +2514,10 @@ impl VmConfig { let mut tty_consoles = Vec::new(); if self.console.mode == ConsoleOutputMode::Tty { tty_consoles.push("virtio-console"); - }; + } if self.serial.mode == ConsoleOutputMode::Tty { tty_consoles.push("serial-console"); - }; + } #[cfg(target_arch = "x86_64")] if self.debug_console.mode == ConsoleOutputMode::Tty { tty_consoles.push("debug-console"); diff --git a/vmm/src/landlock.rs b/vmm/src/landlock.rs index e7efd9cbc..e637119e2 100644 --- a/vmm/src/landlock.rs +++ b/vmm/src/landlock.rs @@ -61,7 +61,7 @@ impl TryFrom<&str> for LandlockAccess { format!("Invalid access: {c}").to_string(), )); } - }; + } } Ok(LandlockAccess { access }) } diff --git a/vmm/src/lib.rs b/vmm/src/lib.rs index a1c3c31aa..df9c94910 100644 --- a/vmm/src/lib.rs +++ b/vmm/src/lib.rs @@ -748,7 +748,7 @@ impl Vmm { error!("Error creating Landlock object: {e:?}"); exit_evt.write(1).ok(); } - }; + } } std::panic::catch_unwind(AssertUnwindSafe(|| { @@ -1513,7 +1513,7 @@ impl RequestHandler for Vmm { // If we don't have a config, we cannot boot a VM. if self.vm_config.is_none() { return Err(VmError::VmMissingConfig); - }; + } // console_info is set to None in vm_shutdown. re-populate here if empty if self.console_info.is_none() { diff --git a/vmm/src/memory_manager.rs b/vmm/src/memory_manager.rs index db00f4d61..5b77afb19 100644 --- a/vmm/src/memory_manager.rs +++ b/vmm/src/memory_manager.rs @@ -507,7 +507,7 @@ impl BusDevice for MemoryManager { _ => { warn!("Unexpected offset for accessing memory manager device: {offset:#}"); } - }; + } None } } diff --git a/vmm/src/vm.rs b/vmm/src/vm.rs index 37a2f73cc..264c4ef80 100644 --- a/vmm/src/vm.rs +++ b/vmm/src/vm.rs @@ -464,7 +464,7 @@ impl VmOps for VmOpsHandler { info!("Barrier released"); } _ => {} - }; + } Ok(()) } @@ -488,7 +488,7 @@ impl VmOps for VmOpsHandler { info!("Barrier released"); } _ => {} - }; + } Ok(()) } }