Skip to content

Commit eb56701

Browse files
authored
Merge pull request #182 from immunant/kkysen/safety-comments-fn-VirtIONetRaw-receive_wait
Add `// SAFETY` comments to `fn VirtIONetRaw::receive_wait`
2 parents 1630ca6 + af0f6df commit eb56701

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/device/net/dev_raw.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,13 @@ impl<H: Hal, T: Transport, const QUEUE_SIZE: usize> VirtIONetRaw<H, T, QUEUE_SIZ
257257
/// received packet. It returns the length of the header and the length of
258258
/// the packet.
259259
pub fn receive_wait(&mut self, rx_buf: &mut [u8]) -> Result<(usize, usize)> {
260+
// SAFETY: After calling `receive_begin`, `rx_buf` is not accessed
261+
// until calling `receive_complete` when the request is complete.
260262
let token = unsafe { self.receive_begin(rx_buf)? };
261263
while self.poll_receive().is_none() {
262264
core::hint::spin_loop();
263265
}
266+
// SAFETY: This `rx_buf` is the same one passed to `receive_begin`.
264267
unsafe { self.receive_complete(token, rx_buf) }
265268
}
266269
}

0 commit comments

Comments
 (0)