mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: Replace div_round_up operation with div_ceil
As clippy of rust-toolchain version 1.83.0-beta.1 suggests, replace manually implemented `div_round_up!` and the like with `div_ceil` from std. Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
This commit is contained in:
@@ -50,13 +50,6 @@ pub trait GuestDebuggable: vm_migration::Pausable {
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! div_round_up {
|
||||
($n:expr,$d:expr) => {
|
||||
($n + $d - 1) / $d
|
||||
};
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Default, Copy, Clone)]
|
||||
pub struct X86_64UserRegs {
|
||||
@@ -314,7 +307,7 @@ pub trait Elf64Writable {
|
||||
}
|
||||
|
||||
fn elf_note_size(&self, hdr_size: u32, name_size: u32, desc_size: u32) -> u32 {
|
||||
(div_round_up!(hdr_size, 4) + div_round_up!(name_size, 4) + div_round_up!(desc_size, 4)) * 4
|
||||
(hdr_size.div_ceil(4) + name_size.div_ceil(4) + desc_size.div_ceil(4)) * 4
|
||||
}
|
||||
|
||||
fn get_note_size(&self, desc_type: NoteDescType, nr_cpus: u32) -> u32 {
|
||||
|
||||
@@ -1088,9 +1088,9 @@ impl MemoryManager {
|
||||
} else {
|
||||
// Alignment must be "natural" i.e. same as size of block
|
||||
let start_addr = GuestAddress(
|
||||
(start_of_device_area.0 + virtio_devices::VIRTIO_MEM_ALIGN_SIZE
|
||||
- 1)
|
||||
/ virtio_devices::VIRTIO_MEM_ALIGN_SIZE
|
||||
start_of_device_area
|
||||
.0
|
||||
.div_ceil(virtio_devices::VIRTIO_MEM_ALIGN_SIZE)
|
||||
* virtio_devices::VIRTIO_MEM_ALIGN_SIZE,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user