From d5f294b3262e10c14c5276d75b458def2b678e74 Mon Sep 17 00:00:00 2001 From: Wei Liu Date: Wed, 16 Nov 2022 23:23:07 +0000 Subject: [PATCH] main: add safety comments Signed-off-by: Wei Liu --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.rs b/src/main.rs index 4065fb594..cc6998777 100644 --- a/src/main.rs +++ b/src/main.rs @@ -453,6 +453,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result, Error> { .convert("fd") .map_err(Error::ParsingEventMonitor)? .unwrap(); + // SAFETY: fd is valid unsafe { File::from_raw_fd(fd) } } else if parser.is_set("path") { std::fs::OpenOptions::new() @@ -592,6 +593,7 @@ fn start_vmm(cmd_arguments: ArgMatches) -> Result, Error> { fn main() { // Ensure all created files (.e.g sockets) are only accessible by this user + // SAFETY: trivially safe let _ = unsafe { libc::umask(0o077) }; let (default_vcpus, default_memory, default_rng) = prepare_default_values(); @@ -607,6 +609,7 @@ fn main() { } }; + // SAFETY: trivially safe let on_tty = unsafe { libc::isatty(libc::STDIN_FILENO) } != 0; if on_tty { // Don't forget to set the terminal in canonical mode