Skip to content

Commit 9296de5

Browse files
JBYoshiJonathanWoollett-Light
authored andcommitted
Update types for (in)equality checks
For equalities and inequalities, we can change the types on each side to always convert to the larger type, which ensures all conversions are safe. Signed-off-by: Jonathan Browne <[email protected]>
1 parent 207f382 commit 9296de5

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/vmm/src/arch/x86_64/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn add_e820_entry(
191191
size: u64,
192192
mem_type: u32,
193193
) -> Result<(), ConfigurationError> {
194-
if params.e820_entries >= params.e820_table.len() as u8 {
194+
if params.e820_entries as usize >= params.e820_table.len() {
195195
return Err(ConfigurationError::E820Configuration);
196196
}
197197

src/vmm/src/arch/x86_64/msr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ pub fn set_msrs(vcpu: &VcpuFd, msr_entries: &[kvm_msr_entry]) -> Result<(), MsrE
490490
vcpu.set_msrs(&msrs)
491491
.map_err(MsrError::SetMsrs)
492492
.and_then(|msrs_written| {
493-
if msrs_written as u32 == msrs.as_fam_struct_ref().nmsrs {
493+
if msrs_written == msrs.as_fam_struct_ref().nmsrs as usize {
494494
Ok(())
495495
} else {
496496
Err(MsrError::SetMsrsIncomplete)

src/vmm/src/vstate/vcpu/x86_64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ impl KvmVcpu {
439439
// per million beacuse it is common for TSC frequency
440440
// to differ due to calibration at boot time.
441441
let diff = (i64::from(self.get_tsc_khz()?) - i64::from(state_tsc_freq)).abs();
442-
Ok(diff > (f64::from(state_tsc_freq) * TSC_KHZ_TOL).round() as i64)
442+
Ok(diff as f64 > (f64::from(state_tsc_freq) * TSC_KHZ_TOL).round())
443443
}
444444

445445
/// Scale the TSC frequency of this vCPU to the one provided as a parameter.

0 commit comments

Comments
 (0)