mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Collapse nested if into match arm guards
Do the necessary replacements to satisfy clippy::collapsible_match. Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
f1c33afc8e
commit
3c62fabfc3
@@ -735,6 +735,7 @@ impl Vmm {
|
||||
|
||||
for signal in signals.forever() {
|
||||
match signal {
|
||||
#[allow(clippy::collapsible_match)]
|
||||
SIGTERM | SIGINT => {
|
||||
if exit_evt.write(1).is_err() {
|
||||
// Resetting the terminal is usually done as the VMM exits
|
||||
|
||||
@@ -132,33 +132,34 @@ impl SerialManager {
|
||||
|
||||
let in_fd = match output {
|
||||
ConsoleOutput::Pty(ref fd) => fd.as_raw_fd(),
|
||||
ConsoleOutput::Tty(_) => {
|
||||
ConsoleOutput::Tty(_)
|
||||
// If running on an interactive TTY then accept input
|
||||
// SAFETY: trivially safe
|
||||
if unsafe { libc::isatty(libc::STDIN_FILENO) == 1 } {
|
||||
// SAFETY: STDIN_FILENO is a valid fd
|
||||
let fd = unsafe { libc::dup(libc::STDIN_FILENO) };
|
||||
if fd == -1 {
|
||||
return Err(Error::DupFd(std::io::Error::last_os_error()));
|
||||
}
|
||||
// SAFETY: fd is valid and owned by us
|
||||
let stdin_clone = unsafe { File::from_raw_fd(fd) };
|
||||
// SAFETY: FFI calls with correct arguments
|
||||
let ret = unsafe {
|
||||
let mut flags = libc::fcntl(stdin_clone.as_raw_fd(), libc::F_GETFL);
|
||||
flags |= libc::O_NONBLOCK;
|
||||
libc::fcntl(stdin_clone.as_raw_fd(), libc::F_SETFL, flags)
|
||||
};
|
||||
|
||||
if ret < 0 {
|
||||
return Err(Error::SetNonBlocking(std::io::Error::last_os_error()));
|
||||
}
|
||||
|
||||
output = ConsoleOutput::Tty(Arc::new(stdin_clone));
|
||||
fd
|
||||
} else {
|
||||
return Ok(None);
|
||||
if unsafe { libc::isatty(libc::STDIN_FILENO) == 1 } =>
|
||||
{
|
||||
// SAFETY: STDIN_FILENO is a valid fd
|
||||
let fd = unsafe { libc::dup(libc::STDIN_FILENO) };
|
||||
if fd == -1 {
|
||||
return Err(Error::DupFd(std::io::Error::last_os_error()));
|
||||
}
|
||||
// SAFETY: fd is valid and owned by us
|
||||
let stdin_clone = unsafe { File::from_raw_fd(fd) };
|
||||
// SAFETY: FFI calls with correct arguments
|
||||
let ret = unsafe {
|
||||
let mut flags = libc::fcntl(stdin_clone.as_raw_fd(), libc::F_GETFL);
|
||||
flags |= libc::O_NONBLOCK;
|
||||
libc::fcntl(stdin_clone.as_raw_fd(), libc::F_SETFL, flags)
|
||||
};
|
||||
|
||||
if ret < 0 {
|
||||
return Err(Error::SetNonBlocking(std::io::Error::last_os_error()));
|
||||
}
|
||||
|
||||
output = ConsoleOutput::Tty(Arc::new(stdin_clone));
|
||||
fd
|
||||
}
|
||||
ConsoleOutput::Tty(_) => {
|
||||
return Ok(None);
|
||||
}
|
||||
ConsoleOutput::Socket(ref fd) => {
|
||||
if let Some(path_in_socket) = socket {
|
||||
|
||||
Reference in New Issue
Block a user