Skip to content

Commit f6ef1b6

Browse files
Sergii Glushchenkoandreeaflorescu
Sergii Glushchenko
authored andcommitted
Fix clippy warnings and adjust test coverage
Signed-off-by: Sergii Glushchenko <gsserge@amazon.com>
1 parent 0ea6e6f commit f6ef1b6

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

coverage_config_x86_64.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"coverage_score": 87.6,
2+
"coverage_score": 87.8,
33
"exclude_path": "mmap_windows.rs",
44
"crate_features": "backend-mmap,backend-atomic,backend-bitmap"
55
}

src/atomic_integer.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
use std::sync::atomic::Ordering;
55

6+
/// # Safety
7+
///
68
/// Objects that implement this trait must consist exclusively of atomic types
79
/// from [`std::sync::atomic`](https://doc.rust-lang.org/std/sync/atomic/), except for
810
/// [`AtomicPtr<T>`](https://doc.rust-lang.org/std/sync/atomic/struct.AtomicPtr.html) and

src/bytes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ use crate::volatile_memory::VolatileSlice;
2222

2323
/// Types for which it is safe to initialize from raw data.
2424
///
25+
/// # Safety
26+
///
2527
/// A type `T` is `ByteValued` if and only if it can be initialized by reading its contents from a
2628
/// byte array. This is generally true for all plain-old-data structs. It is notably not true for
2729
/// any type that includes a reference.
@@ -55,7 +57,7 @@ pub unsafe trait ByteValued: Copy + Default + Send + Sync {
5557

5658
/// Converts a mutable slice of raw data into a mutable reference of `Self`.
5759
///
58-
/// Because `Self` is made from a reference to the mutable slice`, mutations to the returned
60+
/// Because `Self` is made from a reference to the mutable slice, mutations to the returned
5961
/// reference are immediately reflected in `data`. The value of the returned `Self` will depend
6062
/// on the representation of the type in memory, and may change in an unstable fashion.
6163
///

src/mmap.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,15 +1529,15 @@ mod tests {
15291529
])
15301530
.unwrap();
15311531

1532-
assert_eq!(guest_mem.check_range(start_addr1, 0x0), true);
1533-
assert_eq!(guest_mem.check_range(start_addr1, 0x200), true);
1534-
assert_eq!(guest_mem.check_range(start_addr1, 0x400), true);
1535-
assert_eq!(guest_mem.check_range(start_addr1, 0xa00), false);
1536-
assert_eq!(guest_mem.check_range(start_addr2, 0x7ff), true);
1537-
assert_eq!(guest_mem.check_range(start_addr2, 0x800), true);
1538-
assert_eq!(guest_mem.check_range(start_addr2, 0x801), false);
1539-
assert_eq!(guest_mem.check_range(start_addr2, 0xc00), false);
1540-
assert_eq!(guest_mem.check_range(start_addr1, std::usize::MAX), false);
1532+
assert!(guest_mem.check_range(start_addr1, 0x0));
1533+
assert!(guest_mem.check_range(start_addr1, 0x200));
1534+
assert!(guest_mem.check_range(start_addr1, 0x400));
1535+
assert!(!guest_mem.check_range(start_addr1, 0xa00));
1536+
assert!(guest_mem.check_range(start_addr2, 0x7ff));
1537+
assert!(guest_mem.check_range(start_addr2, 0x800));
1538+
assert!(!guest_mem.check_range(start_addr2, 0x801));
1539+
assert!(!guest_mem.check_range(start_addr2, 0xc00));
1540+
assert!(!guest_mem.check_range(start_addr1, std::usize::MAX));
15411541
}
15421542

15431543
#[test]

src/mmap_unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<B: Bitmap> MmapRegionBuilder<B> {
191191
fn build_raw(self) -> Result<MmapRegion<B>> {
192192
// Safe because this call just returns the page size and doesn't have any side effects.
193193
let page_size = unsafe { libc::sysconf(libc::_SC_PAGESIZE) } as usize;
194-
let addr = self.raw_ptr.clone().unwrap();
194+
let addr = self.raw_ptr.unwrap();
195195

196196
// Check that the pointer to the mapping is page-aligned.
197197
if (addr as usize) & (page_size - 1) != 0 {

0 commit comments

Comments
 (0)