mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 13:45:20 +00:00
build: fix clippy complex closures issue
CI reports clippy errors: error: in a `match` scrutinee, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a `let` --> test_infra/src/lib.rs:93:51 | 93 | match (|| -> Result<(), WaitForBootError> { | ___________________________________________________^ 94 | | let listener = 95 | | TcpListener::bind(listen_addr.as_str()).map_err(WaitForBootError::Listen)?; 96 | | listener ... | 145 | | } 146 | | })() { | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions = note: `-D clippy::blocks-in-conditions` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::blocks_in_conditions)]` Signed-off-by: Yi Wang <foxywang@tencent.com>
This commit is contained in:
parent
5c0b66529a
commit
9c2d650cb8
@ -90,7 +90,7 @@ impl GuestNetworkConfig {
|
|||||||
None => DEFAULT_TCP_LISTENER_TIMEOUT,
|
None => DEFAULT_TCP_LISTENER_TIMEOUT,
|
||||||
};
|
};
|
||||||
|
|
||||||
match (|| -> Result<(), WaitForBootError> {
|
let mut closure = || -> Result<(), WaitForBootError> {
|
||||||
let listener =
|
let listener =
|
||||||
TcpListener::bind(listen_addr.as_str()).map_err(WaitForBootError::Listen)?;
|
TcpListener::bind(listen_addr.as_str()).map_err(WaitForBootError::Listen)?;
|
||||||
listener
|
listener
|
||||||
@ -143,7 +143,9 @@ impl GuestNetworkConfig {
|
|||||||
Err(WaitForBootError::Accept(e))
|
Err(WaitForBootError::Accept(e))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})() {
|
};
|
||||||
|
|
||||||
|
match closure() {
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
let duration = start.elapsed();
|
let duration = start.elapsed();
|
||||||
eprintln!(
|
eprintln!(
|
||||||
@ -559,7 +561,7 @@ fn scp_to_guest_with_auth(
|
|||||||
) -> Result<(), SshCommandError> {
|
) -> Result<(), SshCommandError> {
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
loop {
|
loop {
|
||||||
match (|| -> Result<(), SshCommandError> {
|
let closure = || -> Result<(), SshCommandError> {
|
||||||
let tcp =
|
let tcp =
|
||||||
TcpStream::connect(format!("{ip}:22")).map_err(SshCommandError::Connection)?;
|
TcpStream::connect(format!("{ip}:22")).map_err(SshCommandError::Connection)?;
|
||||||
let mut sess = Session::new().unwrap();
|
let mut sess = Session::new().unwrap();
|
||||||
@ -592,7 +594,9 @@ fn scp_to_guest_with_auth(
|
|||||||
let _ = channel.wait_close();
|
let _ = channel.wait_close();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})() {
|
};
|
||||||
|
|
||||||
|
match closure() {
|
||||||
Ok(_) => break,
|
Ok(_) => break,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
@ -647,7 +651,7 @@ pub fn ssh_command_ip_with_auth(
|
|||||||
|
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
loop {
|
loop {
|
||||||
match (|| -> Result<(), SshCommandError> {
|
let mut closure = || -> Result<(), SshCommandError> {
|
||||||
let tcp =
|
let tcp =
|
||||||
TcpStream::connect(format!("{ip}:22")).map_err(SshCommandError::Connection)?;
|
TcpStream::connect(format!("{ip}:22")).map_err(SshCommandError::Connection)?;
|
||||||
let mut sess = Session::new().unwrap();
|
let mut sess = Session::new().unwrap();
|
||||||
@ -676,7 +680,9 @@ pub fn ssh_command_ip_with_auth(
|
|||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
})() {
|
};
|
||||||
|
|
||||||
|
match closure() {
|
||||||
Ok(_) => break,
|
Ok(_) => break,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
counter += 1;
|
counter += 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user