From 3a15e54bdc3a471c87f26c696fb0512d5f0f2700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Mon, 20 Nov 2023 09:52:27 +0100 Subject: [PATCH 1/2] Add missing Debug derives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add free Debug derives plus a lint to prevent future issues. Signed-off-by: Carlos López --- CHANGELOG.md | 5 +++++ src/atomic.rs | 1 + src/lib.rs | 1 + src/mmap.rs | 1 + src/mmap_unix.rs | 1 + src/volatile_memory.rs | 2 ++ 6 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0efec250..1fcdbd0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## Upcoming version + +- [[#266](https://github.com/rust-vmm/vm-memory/pull/266)] Derive `Debug` for several + types that were missing it. + ## [v0.13.1] ### Added diff --git a/src/atomic.rs b/src/atomic.rs index ae102245..4b20b2c4 100644 --- a/src/atomic.rs +++ b/src/atomic.rs @@ -124,6 +124,7 @@ impl Deref for GuestMemoryLoadGuard { /// this structure is dropped (falls out of scope) the lock will be unlocked, /// possibly after updating the memory map represented by the /// `GuestMemoryAtomic` that created the guard. +#[derive(Debug)] pub struct GuestMemoryExclusiveGuard<'a, M: GuestMemory> { parent: &'a GuestMemoryAtomic, _guard: MutexGuard<'a, ()>, diff --git a/src/lib.rs b/src/lib.rs index ca1870f8..6688b1d6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,6 +18,7 @@ #![deny(clippy::doc_markdown)] #![deny(missing_docs)] +#![deny(missing_debug_implementations)] #[macro_use] pub mod address; diff --git a/src/mmap.rs b/src/mmap.rs index f0bc5d9c..ebd84a05 100644 --- a/src/mmap.rs +++ b/src/mmap.rs @@ -616,6 +616,7 @@ impl GuestMemoryMmap { /// An iterator over the elements of `GuestMemoryMmap`. /// /// This struct is created by `GuestMemory::iter()`. See its documentation for more. +#[derive(Debug)] pub struct Iter<'a, B>(std::slice::Iter<'a, Arc>>); impl<'a, B> Iterator for Iter<'a, B> { diff --git a/src/mmap_unix.rs b/src/mmap_unix.rs index c1d1adb2..b0001821 100644 --- a/src/mmap_unix.rs +++ b/src/mmap_unix.rs @@ -52,6 +52,7 @@ pub enum Error { pub type Result = result::Result; /// A factory struct to build `MmapRegion` objects. +#[derive(Debug)] pub struct MmapRegionBuilder { size: usize, prot: i32, diff --git a/src/volatile_memory.rs b/src/volatile_memory.rs index 5ad0ab27..9e394f84 100644 --- a/src/volatile_memory.rs +++ b/src/volatile_memory.rs @@ -302,6 +302,7 @@ impl<'a> From<&'a mut [u8]> for VolatileSlice<'a, ()> { struct Packed(T); /// A guard to perform mapping and protect unmapping of the memory. +#[derive(Debug)] pub struct PtrGuard { addr: *mut u8, len: usize, @@ -347,6 +348,7 @@ impl PtrGuard { } /// A mutable guard to perform mapping and protect unmapping of the memory. +#[derive(Debug)] pub struct PtrGuardMut(PtrGuard); #[allow(clippy::len_without_is_empty)] From 7754e4954358409b26b3f21832d68c950e8771b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20L=C3=B3pez?= Date: Mon, 20 Nov 2023 10:03:03 +0100 Subject: [PATCH 2/2] Update coverage_config_x86_64.json MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos López --- coverage_config_x86_64.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coverage_config_x86_64.json b/coverage_config_x86_64.json index 33cef401..58b5f3e9 100644 --- a/coverage_config_x86_64.json +++ b/coverage_config_x86_64.json @@ -1,5 +1,5 @@ { - "coverage_score": 86.72, + "coverage_score": 86.07, "exclude_path": "mmap_windows.rs", "crate_features": "backend-mmap,backend-atomic,backend-bitmap" }