From 6f49cb2860daa0aef28f1d6ff2ef7ae3ba88f990 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 17 Nov 2021 13:26:24 +0000 Subject: [PATCH] block_util: add safety comments for `impl ByteValued` Signed-off-by: Wei Liu --- block_util/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block_util/src/lib.rs b/block_util/src/lib.rs index 7f2831462..8cd7079e5 100644 --- a/block_util/src/lib.rs +++ b/block_util/src/lib.rs @@ -409,8 +409,6 @@ pub struct VirtioBlockConfig { pub write_zeroes_may_unmap: u8, pub unused1: [u8; 3], } -unsafe impl ByteValued for VirtioBlockConfig {} - #[derive(Copy, Clone, Debug, Default, Versionize)] #[repr(C, packed)] pub struct VirtioBlockGeometry { @@ -418,6 +416,9 @@ pub struct VirtioBlockGeometry { pub heads: u8, pub sectors: u8, } + +// SAFETY: these data structures only contain a series of integers +unsafe impl ByteValued for VirtioBlockConfig {} unsafe impl ByteValued for VirtioBlockGeometry {} /// Check if io_uring for block device can be used on the current system, as