From 8ee253cd3f77197e37b84642f2633ae8209ae327 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 17 Nov 2021 13:28:57 +0000 Subject: [PATCH] net_util: add safety comments for `impl ByteValued` Signed-off-by: Wei Liu --- net_util/src/ctrl_queue.rs | 1 + net_util/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/net_util/src/ctrl_queue.rs b/net_util/src/ctrl_queue.rs index 56c86154c..41161c6bf 100644 --- a/net_util/src/ctrl_queue.rs +++ b/net_util/src/ctrl_queue.rs @@ -42,6 +42,7 @@ pub struct ControlHeader { pub cmd: u8, } +// SAFETY: ControlHeader only contains a series of integers unsafe impl ByteValued for ControlHeader {} pub struct CtrlQueue { diff --git a/net_util/src/lib.rs b/net_util/src/lib.rs index 434174727..476c6575c 100644 --- a/net_util/src/lib.rs +++ b/net_util/src/lib.rs @@ -59,7 +59,7 @@ pub struct VirtioNetConfig { pub duplex: u8, } -// Safe because it only has data and has no implicit padding. +// SAFETY: it only has data and has no implicit padding. unsafe impl ByteValued for VirtioNetConfig {} /// Create a sockaddr_in from an IPv4 address, and expose it as