Skip to content

Commit aaf0c58

Browse files
likebreathrbradford
authored andcommitted
vfio-user: Fix beta clippy issues
Fixed the following issue with `$cargo clippy --fix`: error: manual implementation of `.is_multiple_of()` --> vfio-user/examples/gpio/pci.rs:406:12 | 406 | if offset % 4 != 0 { | ^^^^^^^^^^^^^^^ help: replace with: `!offset.is_multiple_of(4)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_multiple_of = note: `-D clippy::manual-is-multiple-of` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::manual_is_multiple_of)]` Signed-off-by: Bo Chen <[email protected]>
1 parent c52ddc9 commit aaf0c58

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

vfio-user/examples/gpio/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ impl ServerBackend for TestBackend {
8989
if region == VFIO_PCI_CONFIG_REGION_INDEX {
9090
if len > 4 {
9191
// For larger accesses require multiple of 4 and natural
92-
assert!(len % 4 == 0);
93-
assert!(offset % 4 == 0);
92+
assert!(len.is_multiple_of(4));
93+
assert!(offset.is_multiple_of(4));
9494
let mut reg_idx = offset as usize / 4;
9595
let mut data_offset = 0;
9696
while data_offset < len {
@@ -115,7 +115,7 @@ impl ServerBackend for TestBackend {
115115
} else if region == VFIO_PCI_BAR2_REGION_INDEX && offset == 0 {
116116
info!("gpio value read: count = {}", self.count);
117117
self.count += 1;
118-
if self.count.0 % 3 == 0 {
118+
if self.count.0.is_multiple_of(3) {
119119
data[0] = 1;
120120
if let Some(irq) = &mut self.irq {
121121
info!("Triggering interrupt for count = {}", self.count);

vfio-user/examples/gpio/pci.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ impl PciConfiguration {
403403

404404
/// Writes a 32bit dword to `offset`. `offset` must be 32bit aligned.
405405
fn write_dword(&mut self, offset: usize, value: u32) {
406-
if offset % 4 != 0 {
406+
if !offset.is_multiple_of(4) {
407407
warn!("bad PCI config dword write offset {offset}");
408408
return;
409409
}
@@ -494,7 +494,7 @@ impl PciConfiguration {
494494
return Err(Error::BarSizeInvalid(config.size));
495495
}
496496

497-
if config.addr % config.size != 0 {
497+
if !config.addr.is_multiple_of(config.size) {
498498
return Err(Error::BarAlignmentInvalid(config.addr, config.size));
499499
}
500500

0 commit comments

Comments
 (0)