virtio-queue: add safety comments for impl ByteValued

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2021-11-17 13:43:00 +00:00 committed by Rob Bradford
parent 31b3871eee
commit 94fcfa9f1f

View File

@ -94,6 +94,9 @@ pub struct Descriptor {
next: u16,
}
// SAFETY: Descriptor only contains a series of integers and has no implicit padding
unsafe impl ByteValued for Descriptor {}
#[allow(clippy::len_without_is_empty)]
impl Descriptor {
/// Creates a new descriptor
@ -149,8 +152,6 @@ impl Descriptor {
}
}
unsafe impl ByteValued for Descriptor {}
/// A virtio descriptor chain.
#[derive(Clone, Debug)]
pub struct DescriptorChain<M: GuestAddressSpace> {
@ -421,6 +422,9 @@ pub struct VirtqUsedElem {
len: u32,
}
// SAFETY: VirtqUsedElem only contains a series of integers and has no implicit padding
unsafe impl ByteValued for VirtqUsedElem {}
impl VirtqUsedElem {
/// Create a new `VirtqUsedElem` instance.
pub fn new(id: u16, len: u32) -> Self {
@ -431,8 +435,6 @@ impl VirtqUsedElem {
}
}
unsafe impl ByteValued for VirtqUsedElem {}
/// Struct to hold an exclusive reference to the underlying `QueueState` object.
pub enum QueueStateGuard<'a, M: GuestAddressSpace> {
/// A reference to a `QueueState` object.