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:
Ruoqing He
2024-10-18 17:22:20 +08:00
committed by Rob Bradford
parent 67fb786c54
commit 6164aa0885
13 changed files with 16 additions and 31 deletions

View File

@@ -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 {

View File

@@ -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,
);