mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
misc: Address clippy beta issues
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
064c1e2c8b
commit
3a63143f33
@ -66,7 +66,7 @@ impl QcowRawFile {
|
|||||||
non_zero_flags: u64,
|
non_zero_flags: u64,
|
||||||
) -> io::Result<()> {
|
) -> io::Result<()> {
|
||||||
self.file.seek(SeekFrom::Start(offset))?;
|
self.file.seek(SeekFrom::Start(offset))?;
|
||||||
let mut buffer = BufWriter::with_capacity(table.len() * size_of::<u64>(), &mut self.file);
|
let mut buffer = BufWriter::with_capacity(std::mem::size_of_val(table), &mut self.file);
|
||||||
for addr in table {
|
for addr in table {
|
||||||
let val = if *addr == 0 {
|
let val = if *addr == 0 {
|
||||||
0
|
0
|
||||||
@ -91,7 +91,7 @@ impl QcowRawFile {
|
|||||||
/// Writes a refcount block to the file.
|
/// Writes a refcount block to the file.
|
||||||
pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> io::Result<()> {
|
pub fn write_refcount_block(&mut self, offset: u64, table: &[u16]) -> io::Result<()> {
|
||||||
self.file.seek(SeekFrom::Start(offset))?;
|
self.file.seek(SeekFrom::Start(offset))?;
|
||||||
let mut buffer = BufWriter::with_capacity(table.len() * size_of::<u16>(), &mut self.file);
|
let mut buffer = BufWriter::with_capacity(std::mem::size_of_val(table), &mut self.file);
|
||||||
for count in table {
|
for count in table {
|
||||||
buffer.write_u16::<BigEndian>(*count)?;
|
buffer.write_u16::<BigEndian>(*count)?;
|
||||||
}
|
}
|
||||||
|
@ -309,11 +309,7 @@ impl Emulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.established_flag_cached = true;
|
self.established_flag_cached = true;
|
||||||
if est.resp.bit != 0 {
|
self.established_flag = est.resp.bit == 0;
|
||||||
self.established_flag = false;
|
|
||||||
} else {
|
|
||||||
self.established_flag = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.established_flag
|
self.established_flag
|
||||||
}
|
}
|
||||||
|
@ -145,11 +145,7 @@ impl DiskSpec {
|
|||||||
let bits = f
|
let bits = f
|
||||||
.read_u32::<LittleEndian>()
|
.read_u32::<LittleEndian>()
|
||||||
.map_err(VhdxMetadataError::ReadMetadata)?;
|
.map_err(VhdxMetadataError::ReadMetadata)?;
|
||||||
if bits & BLOCK_HAS_PARENT != 0 {
|
disk_spec.has_parent = bits & BLOCK_HAS_PARENT != 0;
|
||||||
disk_spec.has_parent = true;
|
|
||||||
} else {
|
|
||||||
disk_spec.has_parent = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
metadata_presence |= METADATA_FILE_PARAMETER_PRESENT;
|
metadata_presence |= METADATA_FILE_PARAMETER_PRESENT;
|
||||||
} else if metadata_entry.item_id
|
} else if metadata_entry.item_id
|
||||||
|
@ -605,7 +605,7 @@ impl VirtioDevice for Fs {
|
|||||||
&mut self,
|
&mut self,
|
||||||
shm_regions: VirtioSharedMemoryList,
|
shm_regions: VirtioSharedMemoryList,
|
||||||
) -> std::result::Result<(), crate::Error> {
|
) -> std::result::Result<(), crate::Error> {
|
||||||
if let Some(mut cache) = self.cache.as_mut() {
|
if let Some(cache) = self.cache.as_mut() {
|
||||||
cache.0 = shm_regions;
|
cache.0 = shm_regions;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,8 +110,7 @@ impl Bus {
|
|||||||
let devices = self.devices.read().unwrap();
|
let devices = self.devices.read().unwrap();
|
||||||
let (range, dev) = devices
|
let (range, dev) = devices
|
||||||
.range(..=BusRange { base: addr, len: 1 })
|
.range(..=BusRange { base: addr, len: 1 })
|
||||||
.rev()
|
.next_back()?;
|
||||||
.next()?;
|
|
||||||
dev.upgrade().map(|d| (*range, d.clone()))
|
dev.upgrade().map(|d| (*range, d.clone()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1124,7 +1124,7 @@ impl CpuManager {
|
|||||||
|
|
||||||
fn remove_vcpu(&mut self, cpu_id: u8) -> Result<()> {
|
fn remove_vcpu(&mut self, cpu_id: u8) -> Result<()> {
|
||||||
info!("Removing vCPU: cpu_id = {}", cpu_id);
|
info!("Removing vCPU: cpu_id = {}", cpu_id);
|
||||||
let mut state = &mut self.vcpu_states[usize::from(cpu_id)];
|
let state = &mut self.vcpu_states[usize::from(cpu_id)];
|
||||||
state.kill.store(true, Ordering::SeqCst);
|
state.kill.store(true, Ordering::SeqCst);
|
||||||
state.signal_thread();
|
state.signal_thread();
|
||||||
state.join_thread()?;
|
state.join_thread()?;
|
||||||
|
@ -1591,7 +1591,7 @@ impl MemoryManager {
|
|||||||
.ok_or(Error::MemoryRangeAllocation)?;
|
.ok_or(Error::MemoryRangeAllocation)?;
|
||||||
|
|
||||||
// Update the slot so that it can be queried via the I/O port
|
// Update the slot so that it can be queried via the I/O port
|
||||||
let mut slot = &mut self.hotplug_slots[self.next_hotplug_slot];
|
let slot = &mut self.hotplug_slots[self.next_hotplug_slot];
|
||||||
slot.active = true;
|
slot.active = true;
|
||||||
slot.inserting = true;
|
slot.inserting = true;
|
||||||
slot.base = region.start_addr().0;
|
slot.base = region.start_addr().0;
|
||||||
|
@ -1258,7 +1258,7 @@ impl Vm {
|
|||||||
.resize(desired_memory)
|
.resize(desired_memory)
|
||||||
.map_err(Error::MemoryManager)?;
|
.map_err(Error::MemoryManager)?;
|
||||||
|
|
||||||
let mut memory_config = &mut self.config.lock().unwrap().memory;
|
let memory_config = &mut self.config.lock().unwrap().memory;
|
||||||
|
|
||||||
if let Some(new_region) = &new_region {
|
if let Some(new_region) = &new_region {
|
||||||
self.device_manager
|
self.device_manager
|
||||||
|
Loading…
Reference in New Issue
Block a user