@@ -1466,27 +1466,21 @@ mod tests {
1466
1466
{
1467
1467
let entries = cpuid. as_mut_slice ( ) ;
1468
1468
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 ;
1477
1474
}
1478
1475
}
1479
1476
}
1480
1477
vcpu. set_cpuid2 ( & cpuid) . unwrap ( ) ;
1481
1478
let cpuid_0 = vcpu. get_cpuid2 ( ncpuids) . unwrap ( ) ;
1482
1479
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 ) ;
1490
1484
}
1491
1485
}
1492
1486
@@ -1496,27 +1490,17 @@ mod tests {
1496
1490
{
1497
1491
let entries = cpuid. as_mut_slice ( ) ;
1498
1492
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 ;
1507
1496
}
1508
1497
}
1509
1498
}
1510
1499
vcpu. set_cpuid2 ( & cpuid) . unwrap ( ) ;
1511
1500
let cpuid_1 = vcpu. get_cpuid2 ( ncpuids) . unwrap ( ) ;
1512
1501
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) ;
1520
1504
}
1521
1505
}
1522
1506
}
@@ -1898,10 +1882,8 @@ mod tests {
1898
1882
// Disabling debugging/single-stepping
1899
1883
debug_struct. control = 0 ;
1900
1884
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 ! ( ) ;
1905
1887
}
1906
1888
let vcpu_regs = vcpu_fd. get_regs ( ) . unwrap ( ) ;
1907
1889
assert_eq ! ( vcpu_regs. rip, expected_rips[ instr_idx] ) ;
0 commit comments