[pbs-devel] [PATCH proxmox 11/19] shared-memory: specify generic types for transmute

Shannon Sterz s.sterz at proxmox.com
Thu Mar 6 13:43:41 CET 2025


this annotates a `transmute` call with proper types to avoid possible
undefined behaviour, as suggested by clippy [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations

Signed-off-by: Shannon Sterz <s.sterz at proxmox.com>
---
 proxmox-shared-memory/src/lib.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/proxmox-shared-memory/src/lib.rs b/proxmox-shared-memory/src/lib.rs
index defe678d..cffea598 100644
--- a/proxmox-shared-memory/src/lib.rs
+++ b/proxmox-shared-memory/src/lib.rs
@@ -75,7 +75,7 @@ fn mmap_file<T: Init>(file: &mut File, initialize: bool) -> Result<Mmap<T>, Erro
         Err(err) => bail!("detected wrong types in mmaped files: {}", err),
     }
 
-    Ok(unsafe { std::mem::transmute(mmap) })
+    Ok(unsafe { std::mem::transmute::<Mmap<MaybeUninit<T>>, Mmap<T>>(mmap) })
 }
 
 impl<T: Sized + Init> SharedMemory<T> {
-- 
2.39.5





More information about the pbs-devel mailing list