Skip to content

Commit d556095

Browse files
Serban Iorgabonzini
authored andcommitted
fix clippy warnings
1 parent eb2fc0b commit d556095

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

src/bytes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ mod tests {
359359
fn read_slice(&self, buf: &mut [u8], addr: usize) -> Result<(), Self::E> {
360360
self.validate_slice_op(buf, addr)?;
361361

362-
buf.copy_from_slice(&self.container[addr..=buf.len() - 1]);
362+
buf.copy_from_slice(&self.container[addr..buf.len()]);
363363

364364
Ok(())
365365
}

src/mmap.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,15 @@ impl GuestMemoryRegion for GuestRegionMmap {
372372
/// Represents the entire physical memory of the guest by tracking all its memory regions.
373373
/// Each region is an instance of `GuestRegionMmap`, being backed by a mapping in the
374374
/// virtual address space of the calling process.
375-
#[derive(Clone, Debug)]
375+
#[derive(Clone, Debug, Default)]
376376
pub struct GuestMemoryMmap {
377377
regions: Vec<Arc<GuestRegionMmap>>,
378378
}
379379

380380
impl GuestMemoryMmap {
381381
/// Creates an empty `GuestMemoryMmap` instance.
382382
pub fn new() -> Self {
383-
GuestMemoryMmap {
384-
regions: Vec::new(),
385-
}
383+
Self::default()
386384
}
387385

388386
/// Creates a container and allocates anonymous memory for guest memory regions.

src/mmap_unix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,10 @@ mod tests {
271271
// distinctive value when the error is represented by another variant.
272272
impl Error {
273273
pub fn raw_os_error(&self) -> i32 {
274-
return match self {
274+
match self {
275275
Error::Mmap(e) => e.raw_os_error().unwrap(),
276276
_ => std::i32::MIN,
277-
};
277+
}
278278
}
279279
}
280280

src/volatile_memory.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,8 +1084,8 @@ mod tests {
10841084
format!(
10851085
"{}",
10861086
Error::TooBig {
1087-
nelements: 100000,
1088-
size: 1000000000
1087+
nelements: 100_000,
1088+
size: 1_000_000_000
10891089
}
10901090
),
10911091
"100000 elements of size 1000000000 would overflow a usize"
@@ -1498,8 +1498,8 @@ mod tests {
14981498
let a_ref = &mut a[..];
14991499
let a_slice = a_ref.get_slice(0, a_ref.len()).unwrap();
15001500
let a_array_ref: VolatileArrayRef<u8> = a_slice.into();
1501-
for i in 0..a_vec.len() {
1502-
assert_eq!(a_array_ref.load(i), a_vec[i]);
1501+
for (i, entry) in a_vec.iter().enumerate() {
1502+
assert_eq!(&a_array_ref.load(i), entry);
15031503
}
15041504
}
15051505

0 commit comments

Comments
 (0)