mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
misc: Fix beta clippy errors
Fix clippy error: "error: manual implementation of `.is_multiple_of() `" from rustc 1.90.0-beta.1 (788da80fc 2025-08-04). Signed-off-by: Songqian Li <sionli@tencent.com>
This commit is contained in:
@@ -265,7 +265,7 @@ impl BalloonEpollHandler {
|
||||
error!("The head contains the request type is not right");
|
||||
return Err(Error::UnexpectedWriteOnlyDescriptor);
|
||||
}
|
||||
if desc.len() as usize % data_chunk_size != 0 {
|
||||
if !(desc.len() as usize).is_multiple_of(data_chunk_size) {
|
||||
error!("the request size {} is not right", desc.len());
|
||||
return Err(Error::InvalidRequest);
|
||||
}
|
||||
|
||||
@@ -193,35 +193,35 @@ unsafe impl ByteValued for VirtioMemConfig {}
|
||||
|
||||
impl VirtioMemConfig {
|
||||
fn validate(&self) -> result::Result<(), Error> {
|
||||
if self.addr % self.block_size != 0 {
|
||||
if !self.addr.is_multiple_of(self.block_size) {
|
||||
return Err(Error::ValidateError(anyhow!(
|
||||
"addr 0x{:x} is not aligned on block_size 0x{:x}",
|
||||
self.addr,
|
||||
self.block_size
|
||||
)));
|
||||
}
|
||||
if self.region_size % self.block_size != 0 {
|
||||
if !self.region_size.is_multiple_of(self.block_size) {
|
||||
return Err(Error::ValidateError(anyhow!(
|
||||
"region_size 0x{:x} is not aligned on block_size 0x{:x}",
|
||||
self.region_size,
|
||||
self.block_size
|
||||
)));
|
||||
}
|
||||
if self.usable_region_size % self.block_size != 0 {
|
||||
if !self.usable_region_size.is_multiple_of(self.block_size) {
|
||||
return Err(Error::ValidateError(anyhow!(
|
||||
"usable_region_size 0x{:x} is not aligned on block_size 0x{:x}",
|
||||
self.usable_region_size,
|
||||
self.block_size
|
||||
)));
|
||||
}
|
||||
if self.plugged_size % self.block_size != 0 {
|
||||
if !self.plugged_size.is_multiple_of(self.block_size) {
|
||||
return Err(Error::ValidateError(anyhow!(
|
||||
"plugged_size 0x{:x} is not aligned on block_size 0x{:x}",
|
||||
self.plugged_size,
|
||||
self.block_size
|
||||
)));
|
||||
}
|
||||
if self.requested_size % self.block_size != 0 {
|
||||
if !self.requested_size.is_multiple_of(self.block_size) {
|
||||
return Err(Error::ValidateError(anyhow!(
|
||||
"requested_size 0x{:x} is not aligned on block_size 0x{:x}",
|
||||
self.requested_size,
|
||||
@@ -244,7 +244,7 @@ impl VirtioMemConfig {
|
||||
size,
|
||||
self.region_size
|
||||
)));
|
||||
} else if size % self.block_size != 0 {
|
||||
} else if !size.is_multiple_of(self.block_size) {
|
||||
return Err(Error::ResizeError(anyhow!(
|
||||
"new size 0x{:x} is not aligned on block_size 0x{:x}",
|
||||
size,
|
||||
@@ -267,7 +267,7 @@ impl VirtioMemConfig {
|
||||
// Start address must be aligned on block_size, the size must be
|
||||
// greater than 0, and all blocks covered by the request must be
|
||||
// in the usable region.
|
||||
if addr % self.block_size != 0
|
||||
if !addr.is_multiple_of(self.block_size)
|
||||
|| size == 0
|
||||
|| (addr < self.addr || addr + size > self.addr + self.usable_region_size)
|
||||
{
|
||||
|
||||
@@ -706,7 +706,7 @@ impl VirtioDevice for Net {
|
||||
|
||||
let num_queues = queues.len();
|
||||
let event_idx = self.common.feature_acked(VIRTIO_RING_F_EVENT_IDX.into());
|
||||
if self.common.feature_acked(VIRTIO_NET_F_CTRL_VQ.into()) && num_queues % 2 != 0 {
|
||||
if self.common.feature_acked(VIRTIO_NET_F_CTRL_VQ.into()) && !num_queues.is_multiple_of(2) {
|
||||
let ctrl_queue_index = num_queues - 1;
|
||||
let (_, mut ctrl_queue, ctrl_queue_evt) = queues.remove(ctrl_queue_index);
|
||||
|
||||
|
||||
@@ -298,7 +298,7 @@ impl VirtioDevice for Net {
|
||||
|
||||
let num_queues = queues.len();
|
||||
let event_idx = self.common.feature_acked(VIRTIO_RING_F_EVENT_IDX.into());
|
||||
if self.common.feature_acked(VIRTIO_NET_F_CTRL_VQ.into()) && num_queues % 2 != 0 {
|
||||
if self.common.feature_acked(VIRTIO_NET_F_CTRL_VQ.into()) && !num_queues.is_multiple_of(2) {
|
||||
let ctrl_queue_index = num_queues - 1;
|
||||
let (_, mut ctrl_queue, ctrl_queue_evt) = queues.remove(ctrl_queue_index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user