Skip to content

Commit 11b6ec7

Browse files
andreeafloresculauralt
authored andcommitted
fix clippy warnings
- We need to derive Eq when deriving PartialEq - We need to allow a late initialization so we can share code on x86_64 and aarch64. Signed-off-by: Andreea Florescu <fandree@amazon.com>
1 parent 9b5e5bf commit 11b6ec7

File tree

11 files changed

+20
-17
lines changed

11 files changed

+20
-17
lines changed

src/utils/src/resource_download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use std::path::PathBuf;
55
use std::process::Command;
66

7-
#[derive(Debug, PartialEq)]
7+
#[derive(Debug, PartialEq, Eq)]
88
pub enum Error {
99
DownloadError(String),
1010
}

src/vm-vcpu-ref/src/aarch64/interrupts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const AARCH64_GIC_CPUI_BASE: u64 = AARCH64_GIC_DIST_BASE - AARCH64_GIC_CPUI_SIZE
3333
const AARCH64_GIC_REDIST_SIZE: u64 = 0x20000;
3434

3535
/// Specifies the version of the GIC device
36-
#[derive(Debug, PartialEq, Clone, Copy)]
36+
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
3737
pub enum GicVersion {
3838
// The following casts are safe because the device type has small values (i.e. 5 and 7)
3939
/// GICv2 identifier.

src/vm-vcpu-ref/src/aarch64/regs/icc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const ICC_CTLR_EL1_PRIBITS_SHIFT: u64 = 8;
5555
const ICC_CTLR_EL1_PRIBITS_MASK: u64 = 7 << ICC_CTLR_EL1_PRIBITS_SHIFT;
5656

5757
/// Structure for serializing the state of the GIC ICC regs
58-
#[derive(Clone, Debug, PartialEq, Default)]
58+
#[derive(Clone, Debug, PartialEq, Eq, Default)]
5959
pub struct GicSysRegsState {
6060
main_icc_regs: Vec<GicRegState<u64>>,
6161
ap_icc_regs: Vec<Option<GicRegState<u64>>>,

src/vm-vcpu-ref/src/aarch64/regs/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod icc;
1717
mod redist;
1818

1919
/// Generic GIC register state,
20-
#[derive(Clone, Debug, PartialEq)]
20+
#[derive(Clone, Debug, PartialEq, Eq)]
2121
pub struct GicRegState<T> {
2222
pub(crate) chunks: Vec<T>,
2323
}
@@ -167,7 +167,7 @@ fn kvm_device_attr<RegChunk>(
167167
}
168168

169169
/// Structure representing a simple register.
170-
#[derive(PartialEq)]
170+
#[derive(PartialEq, Eq)]
171171
struct SimpleReg {
172172
/// The offset from the component address. The register is memory mapped here.
173173
offset: u64,

src/vm-vcpu-ref/src/x86_64/interrupts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub const APIC_LVT0_REG_OFFSET: usize = 0x350;
3131
pub const APIC_LVT1_REG_OFFSET: usize = 0x360;
3232

3333
/// Specifies the type of interrupt to be sent to the processor.
34-
#[derive(Debug, PartialEq)]
34+
#[derive(Debug, PartialEq, Eq)]
3535
// We user upper case acronyms so that we can stick to the names as they're
3636
// defined in the Intel Manual.
3737
#[allow(clippy::upper_case_acronyms)]
@@ -49,7 +49,7 @@ pub enum DeliveryMode {
4949
}
5050

5151
/// Errors associated with operations related to interrupts.
52-
#[derive(Debug, PartialEq, thiserror::Error)]
52+
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
5353
pub enum Error {
5454
/// The register offset is invalid.
5555
#[error("The register offset is invalid.")]

src/vm-vcpu-ref/src/x86_64/mptable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const MPTABLE_START: u64 = 0x9fc00;
4848
/// Last usable IRQ ID for virtio device interrupts on x86_64.
4949
pub const IRQ_MAX: u8 = 23;
5050

51-
#[derive(Debug, PartialEq)]
51+
#[derive(Debug, PartialEq, Eq)]
5252
/// Errors associated with creating and operating with the MP Table.
5353
pub enum Error {
5454
/// There was too little guest memory to store the entire MP table.

src/vm-vcpu/src/vcpu/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ impl KvmVcpu {
326326
thread_local!(static TLS_VCPU_PTR: RefCell<Option<*const KvmVcpu>> = RefCell::new(None));
327327

328328
/// Create a new vCPU.
329+
// This is needed so we can initialize the vcpu the same way on x86_64 and aarch64, but
330+
// have it as mutable on aarch64.
331+
#[allow(clippy::needless_late_init)]
329332
pub fn new<M: GuestMemory>(
330333
vm_fd: &VmFd,
331334
device_mgr: Arc<Mutex<IoManager>>,

src/vm-vcpu/src/vm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub trait ExitHandler: Clone {
187187
}
188188

189189
/// Represents the current state of the VM.
190-
#[derive(Debug, PartialEq)]
190+
#[derive(Debug, PartialEq, Eq)]
191191
pub enum VmRunState {
192192
Running,
193193
Suspending,
@@ -492,7 +492,7 @@ impl<EH: 'static + ExitHandler + Send> KvmVm<EH> {
492492
.name(format!("vcpu_{}", id))
493493
.spawn(move || {
494494
// TODO: Check the result of both vcpu run & kick.
495-
let _ = vcpu.run(vcpu_run_addr).unwrap();
495+
vcpu.run(vcpu_run_addr).unwrap();
496496
let _ = vcpu_exit_handler.kick();
497497
vcpu.run_state.set_and_notify(VmRunState::Exiting);
498498
})

src/vmm/src/boot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const EBDA_START: u64 = 0x0009_fc00;
2828
// See https://github.com/rust-vmm/linux-loader/issues/51
2929
const E820_RAM: u32 = 1;
3030

31-
#[derive(Debug, PartialEq)]
31+
#[derive(Debug, PartialEq, Eq)]
3232
/// Errors pertaining to boot parameter setup.
3333
pub enum Error {
3434
/// Invalid E820 configuration.

src/vmm/src/config/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod builder;
2020
const KERNEL_CMDLINE_CAPACITY: usize = 4096;
2121

2222
/// Errors encountered converting the `*Config` objects.
23-
#[derive(Clone, Debug, PartialEq)]
23+
#[derive(Clone, Debug, PartialEq, Eq)]
2424
pub enum ConversionError {
2525
/// Failed to parse the string representation for the kernel.
2626
ParseKernel(String),
@@ -73,7 +73,7 @@ impl fmt::Display for ConversionError {
7373
}
7474

7575
/// Guest memory configurations.
76-
#[derive(Clone, Debug, PartialEq)]
76+
#[derive(Clone, Debug, PartialEq, Eq)]
7777
pub struct MemoryConfig {
7878
/// Guest memory size in MiB.
7979
pub size_mib: u32,
@@ -104,7 +104,7 @@ impl TryFrom<&str> for MemoryConfig {
104104
}
105105

106106
/// vCPU configurations.
107-
#[derive(Clone, Debug, PartialEq)]
107+
#[derive(Clone, Debug, PartialEq, Eq)]
108108
pub struct VcpuConfig {
109109
/// Number of vCPUs.
110110
pub num: u8,
@@ -207,7 +207,7 @@ impl TryFrom<&str> for KernelConfig {
207207
}
208208
}
209209
/// Network device configuration.
210-
#[derive(Clone, Debug, PartialEq)]
210+
#[derive(Clone, Debug, PartialEq, Eq)]
211211
pub struct NetConfig {
212212
/// Name of tap device.
213213
pub tap_name: String,
@@ -233,7 +233,7 @@ impl TryFrom<&str> for NetConfig {
233233
}
234234

235235
/// Block device configuration
236-
#[derive(Clone, Debug, PartialEq)]
236+
#[derive(Clone, Debug, PartialEq, Eq)]
237237
pub struct BlockConfig {
238238
/// Path to the block device backend.
239239
pub path: PathBuf,

0 commit comments

Comments
 (0)