Latest fmt (#1339)

This commit is contained in:
Dominik Maier 2023-07-02 19:13:46 +02:00 committed by GitHub
parent 07047cb3bb
commit 6f4955619a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 61 additions and 34 deletions

View File

@ -45,7 +45,9 @@ fn adder_loop(port: u16) -> Result<(), Box<dyn std::error::Error>> {
loop {
let mut msg_counter = 0;
loop {
let Some((sender, tag, buf)) = client.recv_buf()? else { break };
let Some((sender, tag, buf)) = client.recv_buf()? else {
break;
};
msg_counter += 1;
match tag {
_TAG_SIMPLE_U32_V1 => {

View File

@ -3045,7 +3045,8 @@ where
let TcpResponse::BrokerConnectHello {
broker_shmem_description,
hostname: _,
} = recv_tcp_msg(&mut stream)?.try_into()? else {
} = recv_tcp_msg(&mut stream)?.try_into()?
else {
return Err(Error::illegal_state(
"Received unexpected Broker Hello".to_string(),
));
@ -3064,7 +3065,9 @@ where
send_tcp_msg(&mut stream, &client_hello_req)?;
let TcpResponse::LocalClientAccepted { client_id } = recv_tcp_msg(&mut stream)?.try_into()? else {
let TcpResponse::LocalClientAccepted { client_id } =
recv_tcp_msg(&mut stream)?.try_into()?
else {
return Err(Error::illegal_state(
"Unexpected Response from Broker".to_string(),
));

View File

@ -353,9 +353,11 @@ impl Drop for ShMemServiceThread {
fn drop(&mut self) {
if self.join_handle.is_some() {
log::info!("Stopping ShMemService");
let Ok(mut stream) = UnixStream::connect_to_unix_addr(
&UnixSocketAddr::new(UNIX_SERVER_NAME).unwrap(),
) else { return };
let Ok(mut stream) =
UnixStream::connect_to_unix_addr(&UnixSocketAddr::new(UNIX_SERVER_NAME).unwrap())
else {
return;
};
let body = postcard::to_allocvec(&ServedShMemRequest::Exit).unwrap();

View File

@ -144,7 +144,9 @@ where
fn load_input_into(&self, testcase: &mut Testcase<Self::Input>) -> Result<(), Error> {
if testcase.input_mut().is_none() {
let Some(file_path) = testcase.file_path().as_ref() else {
return Err(Error::illegal_argument("No file path set for testcase. Could not load inputs."));
return Err(Error::illegal_argument(
"No file path set for testcase. Could not load inputs.",
));
};
let input = I::from_file(file_path)?;
testcase.set_input(input);
@ -155,10 +157,14 @@ where
fn store_input_from(&self, testcase: &Testcase<Self::Input>) -> Result<(), Error> {
// Store the input to disk
let Some(file_path) = testcase.file_path() else {
return Err(Error::illegal_argument("No file path set for testcase. Could not store input to disk."));
return Err(Error::illegal_argument(
"No file path set for testcase. Could not store input to disk.",
));
};
let Some(input) = testcase.input() else {
return Err(Error::illegal_argument("No input available for testcase. Could not store anything."));
return Err(Error::illegal_argument(
"No input available for testcase. Could not store anything.",
));
};
input.to_file(file_path)
}

View File

@ -169,13 +169,17 @@ impl Tokens {
if line.is_empty() || start == Some('#') {
continue;
}
let Some(pos_quote) = line.find('\"') else { return Err(Error::illegal_argument(format!("Illegal line: {line}"))) };
let Some(pos_quote) = line.find('\"') else {
return Err(Error::illegal_argument(format!("Illegal line: {line}")));
};
if line.chars().nth(line.len() - 1) != Some('"') {
return Err(Error::illegal_argument(format!("Illegal line: {line}")));
}
// extract item
let Some(item) = line.get(pos_quote + 1..line.len() - 1) else { return Err(Error::illegal_argument(format!("Illegal line: {line}"))) };
let Some(item) = line.get(pos_quote + 1..line.len() - 1) else {
return Err(Error::illegal_argument(format!("Illegal line: {line}")));
};
if item.is_empty() {
continue;
}

View File

@ -281,7 +281,9 @@ where
/// Cull the `Corpus`
#[allow(clippy::unused_self)]
pub fn accounting_cull(&self, state: &mut CS::State) -> Result<(), Error> {
let Some(top_rated) = state.metadata_map().get::<TopAccountingMetadata>() else { return Ok(()) };
let Some(top_rated) = state.metadata_map().get::<TopAccountingMetadata>() else {
return Ok(());
};
for (_key, idx) in &top_rated.map {
let mut entry = state.corpus().get(*idx)?.borrow_mut();

View File

@ -322,7 +322,9 @@ where
/// Cull the `Corpus` using the `MinimizerScheduler`
#[allow(clippy::unused_self)]
pub fn cull(&self, state: &mut CS::State) -> Result<(), Error> {
let Some(top_rated) = state.metadata_map().get::<TopRatedsMetadata>() else { return Ok(()) };
let Some(top_rated) = state.metadata_map().get::<TopRatedsMetadata>() else {
return Ok(());
};
let mut acc = HashSet::new();

View File

@ -119,7 +119,9 @@ where
start_timer!(state);
let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut();
let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else { return Ok(()); };
let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else {
return Ok(());
};
drop(testcase);
mark_feature_time!(state, PerfFeature::GetInputFromCorpus);

View File

@ -120,7 +120,9 @@ where
start_timer!(state);
let mut testcase = state.corpus().get(corpus_idx)?.borrow_mut();
let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else { return Ok(()); };
let Ok(input) = I::try_transform_from(&mut testcase, state, corpus_idx) else {
return Ok(());
};
drop(testcase);
mark_feature_time!(state, PerfFeature::GetInputFromCorpus);

View File

@ -60,14 +60,16 @@ impl NyxHelper {
parent_cpu_id: Option<u32>,
initial_timeout: Duration,
) -> Result<Self, Error> {
let Some(sharedir) = target_dir.to_str() else { return Err(Error::illegal_argument("can't convert sharedir to str")) };
let Some(sharedir) = target_dir.to_str() else {
return Err(Error::illegal_argument("can't convert sharedir to str"));
};
let work_dir = target_dir.join("workdir");
let work_dir = work_dir.to_str().expect("unable to convert workdir to str");
let nyx_type = if parallel_mode {
let Some(parent_cpu_id) = parent_cpu_id else {
return Err(Error::illegal_argument(
"please set parent_cpu_id in nyx parallel mode",
))
));
};
if cpu_id == parent_cpu_id {
NyxProcessType::PARENT