Skip to content

Commit 8eee8cd

Browse files
lauraltdependabot-preview[bot]
authored andcommitted
fix clippy errors
Signed-off-by: Laura Loghin <lauralg@amazon.com>
1 parent 6d84658 commit 8eee8cd

File tree

1 file changed

+16
-34
lines changed

1 file changed

+16
-34
lines changed

src/ioctls/vcpu.rs

Lines changed: 16 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,27 +1466,21 @@ mod tests {
14661466
{
14671467
let entries = cpuid.as_mut_slice();
14681468
for entry in entries.iter_mut() {
1469-
match entry.function {
1470-
0 => {
1471-
// " KVMKVMKVM "
1472-
entry.ebx = 0x4b4d564b;
1473-
entry.ecx = 0x564b4d56;
1474-
entry.edx = 0x4d;
1475-
}
1476-
_ => (),
1469+
if entry.function == 0 {
1470+
// " KVMKVMKVM "
1471+
entry.ebx = 0x4b4d564b;
1472+
entry.ecx = 0x564b4d56;
1473+
entry.edx = 0x4d;
14771474
}
14781475
}
14791476
}
14801477
vcpu.set_cpuid2(&cpuid).unwrap();
14811478
let cpuid_0 = vcpu.get_cpuid2(ncpuids).unwrap();
14821479
for entry in cpuid_0.as_slice() {
1483-
match entry.function {
1484-
0 => {
1485-
assert_eq!(entry.ebx, 0x4b4d564b);
1486-
assert_eq!(entry.ecx, 0x564b4d56);
1487-
assert_eq!(entry.edx, 0x4d);
1488-
}
1489-
_ => (),
1480+
if entry.function == 0 {
1481+
assert_eq!(entry.ebx, 0x4b4d564b);
1482+
assert_eq!(entry.ecx, 0x564b4d56);
1483+
assert_eq!(entry.edx, 0x4d);
14901484
}
14911485
}
14921486

@@ -1496,27 +1490,17 @@ mod tests {
14961490
{
14971491
let entries = cpuid.as_mut_slice();
14981492
for entry in entries.iter_mut() {
1499-
match entry.function {
1500-
7 => {
1501-
if entry.ecx == 0 {
1502-
entry.ebx &= !(1 << EBX_SHA_SHIFT);
1503-
ebx_sha_off = entry.ebx;
1504-
}
1505-
}
1506-
_ => (),
1493+
if entry.function == 7 && entry.ecx == 0 {
1494+
entry.ebx &= !(1 << EBX_SHA_SHIFT);
1495+
ebx_sha_off = entry.ebx;
15071496
}
15081497
}
15091498
}
15101499
vcpu.set_cpuid2(&cpuid).unwrap();
15111500
let cpuid_1 = vcpu.get_cpuid2(ncpuids).unwrap();
15121501
for entry in cpuid_1.as_slice() {
1513-
match entry.function {
1514-
7 => {
1515-
if entry.ecx == 0 {
1516-
assert_eq!(entry.ebx, ebx_sha_off);
1517-
}
1518-
}
1519-
_ => (),
1502+
if entry.function == 7 && entry.ecx == 0 {
1503+
assert_eq!(entry.ebx, ebx_sha_off);
15201504
}
15211505
}
15221506
}
@@ -1898,10 +1882,8 @@ mod tests {
18981882
// Disabling debugging/single-stepping
18991883
debug_struct.control = 0;
19001884
vcpu_fd.set_guest_debug(&debug_struct).unwrap();
1901-
} else {
1902-
if instr_idx >= expected_rips.len() {
1903-
assert!(false);
1904-
}
1885+
} else if instr_idx >= expected_rips.len() {
1886+
unreachable!();
19051887
}
19061888
let vcpu_regs = vcpu_fd.get_regs().unwrap();
19071889
assert_eq!(vcpu_regs.rip, expected_rips[instr_idx]);

0 commit comments

Comments
 (0)