mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-queue: add safety comments for impl ByteValued
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user