dragonball: Fix unnecessary_cast warnings

As we bumped the rust toolchain to 1.66.0, some new warnings have been
raised due to unnecessary_cast.

Let's fix them all here.

For more info about the warnings, please, take a look at:
https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Signed-off-by: Fabiano Fidêncio <fabiano.fidencio@intel.com>
This commit is contained in:
Fabiano Fidêncio 2023-01-02 15:53:35 +01:00
parent a545a65934
commit 0b2f060bf3
5 changed files with 11 additions and 14 deletions

View File

@ -401,9 +401,9 @@ impl AddressSpaceMgr {
let flags = 0u32; let flags = 0u32;
let mem_region = kvm_userspace_memory_region { let mem_region = kvm_userspace_memory_region {
slot: slot as u32, slot,
guest_phys_addr: reg.start_addr().raw_value(), guest_phys_addr: reg.start_addr().raw_value(),
memory_size: reg.len() as u64, memory_size: reg.len(),
userspace_addr: host_addr as u64, userspace_addr: host_addr as u64,
flags, flags,
}; };
@ -421,7 +421,7 @@ impl AddressSpaceMgr {
self.base_to_slot self.base_to_slot
.lock() .lock()
.unwrap() .unwrap()
.insert(reg.start_addr().raw_value(), slot as u32); .insert(reg.start_addr().raw_value(), slot);
Ok(()) Ok(())
} }

View File

@ -435,10 +435,7 @@ impl ResourceManager {
constraint.max = r.1 as u64; constraint.max = r.1 as u64;
} }
match self.allocate_pio_address(&constraint) { match self.allocate_pio_address(&constraint) {
Some(base) => Resource::PioAddressRange { Some(base) => Resource::PioAddressRange { base, size: *size },
base: base as u16,
size: *size,
},
None => { None => {
if let Err(e) = self.free_device_resources(&resources) { if let Err(e) = self.free_device_resources(&resources) {
return Err(e); return Err(e);

View File

@ -41,7 +41,7 @@ extern "C" fn sigsys_handler(num: c_int, info: *mut siginfo_t, _unused: *mut c_v
let si_code = unsafe { (*info).si_code }; let si_code = unsafe { (*info).si_code };
// Sanity check. The condition should never be true. // Sanity check. The condition should never be true.
if num != si_signo || num != SIGSYS || si_code != SYS_SECCOMP_CODE as i32 { if num != si_signo || num != SIGSYS || si_code != SYS_SECCOMP_CODE {
// Safe because we're terminating the process anyway. // Safe because we're terminating the process anyway.
unsafe { _exit(i32::from(super::EXIT_CODE_UNEXPECTED_ERROR)) }; unsafe { _exit(i32::from(super::EXIT_CODE_UNEXPECTED_ERROR)) };
} }

View File

@ -96,14 +96,14 @@ impl Vcpu {
if let Some(start_addr) = kernel_start_addr { if let Some(start_addr) = kernel_start_addr {
dbs_arch::regs::setup_regs( dbs_arch::regs::setup_regs(
&self.fd, &self.fd,
start_addr.raw_value() as u64, start_addr.raw_value(),
dbs_boot::layout::BOOT_STACK_POINTER, dbs_boot::layout::BOOT_STACK_POINTER,
dbs_boot::layout::BOOT_STACK_POINTER, dbs_boot::layout::BOOT_STACK_POINTER,
dbs_boot::layout::ZERO_PAGE_START, dbs_boot::layout::ZERO_PAGE_START,
) )
.map_err(VcpuError::REGSConfiguration)?; .map_err(VcpuError::REGSConfiguration)?;
dbs_arch::regs::setup_fpu(&self.fd).map_err(VcpuError::FPUConfiguration)?; dbs_arch::regs::setup_fpu(&self.fd).map_err(VcpuError::FPUConfiguration)?;
let gdt_table: [u64; dbs_boot::layout::BOOT_GDT_MAX as usize] = [ let gdt_table: [u64; dbs_boot::layout::BOOT_GDT_MAX] = [
gdt_entry(0, 0, 0), // NULL gdt_entry(0, 0, 0), // NULL
gdt_entry(0xa09b, 0, 0xfffff), // CODE gdt_entry(0xa09b, 0, 0xfffff), // CODE
gdt_entry(0xc093, 0, 0xfffff), // DATA gdt_entry(0xc093, 0, 0xfffff), // DATA
@ -129,7 +129,7 @@ impl Vcpu {
fn set_cpuid(&mut self, vcpu_config: &VcpuConfig) -> Result<()> { fn set_cpuid(&mut self, vcpu_config: &VcpuConfig) -> Result<()> {
let cpuid_vm_spec = VmSpec::new( let cpuid_vm_spec = VmSpec::new(
self.id, self.id,
vcpu_config.max_vcpu_count as u8, vcpu_config.max_vcpu_count,
vcpu_config.threads_per_core, vcpu_config.threads_per_core,
vcpu_config.cores_per_die, vcpu_config.cores_per_die,
vcpu_config.dies_per_socket, vcpu_config.dies_per_socket,

View File

@ -81,10 +81,10 @@ fn configure_system<M: GuestMemory>(
if mem_end < mmio_start { if mem_end < mmio_start {
add_e820_entry( add_e820_entry(
&mut params.0, &mut params.0,
himem_start.raw_value() as u64, himem_start.raw_value(),
// it's safe to use unchecked_offset_from because // it's safe to use unchecked_offset_from because
// mem_end > himem_start // mem_end > himem_start
mem_end.unchecked_offset_from(himem_start) as u64 + 1, mem_end.unchecked_offset_from(himem_start) + 1,
bootparam::E820_RAM, bootparam::E820_RAM,
) )
.map_err(Error::BootSystem)?; .map_err(Error::BootSystem)?;
@ -103,7 +103,7 @@ fn configure_system<M: GuestMemory>(
&mut params.0, &mut params.0,
mmio_end.raw_value() + 1, mmio_end.raw_value() + 1,
// it's safe to use unchecked_offset_from because mem_end > mmio_end // it's safe to use unchecked_offset_from because mem_end > mmio_end
mem_end.unchecked_offset_from(mmio_end) as u64, mem_end.unchecked_offset_from(mmio_end),
bootparam::E820_RAM, bootparam::E820_RAM,
) )
.map_err(Error::BootSystem)?; .map_err(Error::BootSystem)?;