Skip to content

Commit 46693b4

Browse files
fix aarch64 clippy warnings
The warnings are not showing up in the CI because we are not running clippy checks on aarch64. This will be fixed in a future commit in rust-vmm-ci. The PR that enables clippy on aarch64 (among other changes): rust-vmm/rust-vmm-ci#70. Signed-off-by: Andreea Florescu <[email protected]>
1 parent b617581 commit 46693b4

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

src/ioctls/device.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,11 @@ mod tests {
297297
// This value should be saved in the address provided to the ioctl.
298298
let mut data: u32 = 0;
299299

300-
let mut gic_attr = kvm_bindings::kvm_device_attr::default();
301-
gic_attr.group = KVM_DEV_ARM_VGIC_GRP_NR_IRQS;
302-
gic_attr.addr = data as u64;
300+
let mut gic_attr = kvm_bindings::kvm_device_attr {
301+
group: KVM_DEV_ARM_VGIC_GRP_NR_IRQS,
302+
addr: data as u64,
303+
..Default::default()
304+
};
303305

304306
// Without properly providing the address to where the
305307
// value will be stored, the ioctl fails with EFAULT.

src/ioctls/vcpu.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1780,7 +1780,7 @@ mod tests {
17801780
// Get a mutable slice of `mem_size` from `load_addr`.
17811781
// This is safe because we mapped it before.
17821782
let mut slice = std::slice::from_raw_parts_mut(load_addr, mem_size);
1783-
slice.write(&code).unwrap();
1783+
slice.write_all(&code).unwrap();
17841784
}
17851785

17861786
let vcpu_fd = vm.create_vcpu(0).unwrap();
@@ -1825,10 +1825,10 @@ mod tests {
18251825
// The code snippet dirties one page at guest_addr + 0x10000.
18261826
// The code page should not be dirty, as it's not written by the guest.
18271827
let dirty_pages_bitmap = vm.get_dirty_log(slot, mem_size).unwrap();
1828-
let dirty_pages = dirty_pages_bitmap
1828+
let dirty_pages: u32 = dirty_pages_bitmap
18291829
.into_iter()
18301830
.map(|page| page.count_ones())
1831-
.fold(0, |dirty_page_count, i| dirty_page_count + i);
1831+
.sum();
18321832
assert_eq!(dirty_pages, 1);
18331833
}
18341834
VcpuExit::SystemEvent(type_, flags) => {

src/ioctls/vm.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,15 +1291,14 @@ pub(crate) fn create_gic_device(vm: &VmFd, flags: u32) -> DeviceFd {
12911291
fd: 0,
12921292
flags,
12931293
};
1294-
let device_fd = match vm.create_device(&mut gic_device) {
1294+
match vm.create_device(&mut gic_device) {
12951295
Ok(fd) => fd,
12961296
Err(_) => {
12971297
gic_device.type_ = kvm_device_type_KVM_DEV_TYPE_ARM_VGIC_V2;
12981298
vm.create_device(&mut gic_device)
12991299
.expect("Cannot create KVM vGIC device")
13001300
}
1301-
};
1302-
device_fd
1301+
}
13031302
}
13041303

13051304
/// Set supported number of IRQs for vGIC.

0 commit comments

Comments
 (0)