virtio-device: add a safety comment for a dup(2) call

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2021-11-17 17:34:45 +00:00 committed by Rob Bradford
parent 9b3cab8c72
commit 32af6f9723

View File

@ -488,6 +488,7 @@ impl Net {
for fd in fds.iter() { for fd in fds.iter() {
// Duplicate so that it can survive reboots // Duplicate so that it can survive reboots
// SAFETY: FFI call to dup. Trivially safe.
let fd = unsafe { libc::dup(*fd) }; let fd = unsafe { libc::dup(*fd) };
if fd < 0 { if fd < 0 {
return Err(Error::DuplicateTapFd(std::io::Error::last_os_error())); return Err(Error::DuplicateTapFd(std::io::Error::last_os_error()));