Skip to content

Commit 0460744

Browse files
Jonathan Woollett-Lightroypat
authored andcommitted
Update clippy
Signed-off-by: Jonathan Woollett-Light <jcawl@amazon.co.uk>
1 parent 5a99554 commit 0460744

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/ioctls/system.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use crate::cap::Cap;
1414
use crate::ioctls::vm::{new_vmfd, VmFd};
1515
use crate::ioctls::Result;
1616
use crate::kvm_ioctls::*;
17-
#[cfg(any(target_arch = "aarch64"))]
17+
#[cfg(target_arch = "aarch64")]
1818
use kvm_bindings::KVM_VM_TYPE_ARM_IPA_SIZE_MASK;
1919
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2020
use kvm_bindings::{CpuId, MsrList, Msrs, KVM_MAX_CPUID_ENTRIES, KVM_MAX_MSR_ENTRIES};
@@ -576,7 +576,7 @@ impl Kvm {
576576
/// // Check that the VM mmap size is the same reported by `KVM_GET_VCPU_MMAP_SIZE`.
577577
/// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap());
578578
/// ```
579-
#[cfg(any(target_arch = "aarch64"))]
579+
#[cfg(target_arch = "aarch64")]
580580
pub fn create_vm(&self) -> Result<VmFd> {
581581
let mut ipa_size = 0; // Create using default VM type
582582
if self.check_extension(Cap::ArmVmIPASize) {
@@ -615,7 +615,7 @@ impl Kvm {
615615
/// assert!(vm.run_size() == kvm.get_vcpu_mmap_size().unwrap());
616616
/// }
617617
/// ```
618-
#[cfg(any(target_arch = "aarch64"))]
618+
#[cfg(target_arch = "aarch64")]
619619
pub fn create_vm_with_ipa_size(&self, ipa_size: u32) -> Result<VmFd> {
620620
self.create_vm_with_type((ipa_size & KVM_VM_TYPE_ARM_IPA_SIZE_MASK).into())
621621
}
@@ -848,7 +848,7 @@ mod tests {
848848
}
849849

850850
#[test]
851-
#[cfg(any(target_arch = "aarch64"))]
851+
#[cfg(target_arch = "aarch64")]
852852
fn test_create_vm_with_ipa_size() {
853853
let kvm = Kvm::new().unwrap();
854854
if kvm.check_extension(Cap::ArmVmIPASize) {

src/ioctls/vcpu.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,11 +1391,10 @@ impl VcpuFd {
13911391
// SAFETY: The data_offset is defined by the kernel to be some number of bytes
13921392
// into the kvm_run stucture, which we have fully mmap'd.
13931393
let data_ptr = unsafe { run_start.offset(io.data_offset as isize) };
1394-
// SAFETY: The slice's lifetime is limited to the lifetime of this vCPU, which is equal
1395-
// to the mmap of the `kvm_run` struct that this is slicing from.
1396-
let data_slice = unsafe {
1397-
std::slice::from_raw_parts_mut::<u8>(data_ptr as *mut u8, data_size)
1398-
};
1394+
let data_slice =
1395+
// SAFETY: The slice's lifetime is limited to the lifetime of this vCPU, which is equal
1396+
// to the mmap of the `kvm_run` struct that this is slicing from.
1397+
unsafe { std::slice::from_raw_parts_mut::<u8>(data_ptr, data_size) };
13991398
match u32::from(io.direction) {
14001399
KVM_EXIT_IO_IN => Ok(VcpuExit::IoIn(port, data_slice)),
14011400
KVM_EXIT_IO_OUT => Ok(VcpuExit::IoOut(port, data_slice)),
@@ -1597,7 +1596,7 @@ impl VcpuFd {
15971596
/// ```
15981597
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
15991598
pub fn set_sync_valid_reg(&mut self, reg: SyncReg) {
1600-
let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
1599+
let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
16011600
kvm_run.kvm_valid_regs |= reg as u64;
16021601
}
16031602

@@ -1619,7 +1618,7 @@ impl VcpuFd {
16191618
/// ```
16201619
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
16211620
pub fn set_sync_dirty_reg(&mut self, reg: SyncReg) {
1622-
let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
1621+
let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
16231622
kvm_run.kvm_dirty_regs |= reg as u64;
16241623
}
16251624

@@ -1641,7 +1640,7 @@ impl VcpuFd {
16411640
/// ```
16421641
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
16431642
pub fn clear_sync_valid_reg(&mut self, reg: SyncReg) {
1644-
let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
1643+
let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
16451644
kvm_run.kvm_valid_regs &= !(reg as u64);
16461645
}
16471646

@@ -1663,7 +1662,7 @@ impl VcpuFd {
16631662
/// ```
16641663
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
16651664
pub fn clear_sync_dirty_reg(&mut self, reg: SyncReg) {
1666-
let mut kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
1665+
let kvm_run: &mut kvm_run = self.kvm_run_ptr.as_mut_ref();
16671666
kvm_run.kvm_dirty_regs &= !(reg as u64);
16681667
}
16691668

@@ -2714,7 +2713,7 @@ mod tests {
27142713

27152714
let orig_sregs = vcpu.get_sregs().unwrap();
27162715

2717-
let mut sync_regs = vcpu.sync_regs_mut();
2716+
let sync_regs = vcpu.sync_regs_mut();
27182717

27192718
// Initialize the sregs in sync_regs to be the original sregs
27202719
sync_regs.sregs = orig_sregs;

0 commit comments

Comments
 (0)