manager: Make match indent towers more idiomatic

This commit is contained in:
Vicki Pfau 2024-03-19 16:54:07 -07:00
parent 2e55bc2330
commit dce3ad8437

View file

@ -356,12 +356,18 @@ impl SMManager {
// write value // write value
let data = format!("s 0 {clocks}\n"); let data = format!("s 0 {clocks}\n");
let result = myfile.write(data.as_bytes()).await; let result = myfile.write(data.as_bytes()).await;
match result { if let Err(message) = result {
Ok(_worked) => { println!("Error writing to sysfs file {message}");
return false;
}
let data = format!("s 1 {clocks}\n"); let data = format!("s 1 {clocks}\n");
let result = myfile.write(data.as_bytes()).await; let result = myfile.write(data.as_bytes()).await;
match result { if let Err(message) = result {
Ok(_worked) => { println!("Error writing to sysfs file {message}");
return false;
}
let result = myfile.write("c\n".as_bytes()).await; let result = myfile.write("c\n".as_bytes()).await;
match result { match result {
Ok(_worked) => true, Ok(_worked) => true,
@ -371,18 +377,6 @@ impl SMManager {
} }
} }
} }
Err(message) => {
println!("Error writing to sysfs file {message}");
false
}
}
}
Err(message) => {
println!("Error writing to sysfs file {message}");
false
}
}
}
async fn set_tdp_limit(&self, limit: i32) -> bool { async fn set_tdp_limit(&self, limit: i32) -> bool {
// Set TDP limit given if within range (3-15) // Set TDP limit given if within range (3-15)
@ -460,65 +454,69 @@ impl SMManager {
Ok(WifiDebugMode::Off) => { Ok(WifiDebugMode::Off) => {
// If mode is 0 disable wifi debug mode // If mode is 0 disable wifi debug mode
// Stop any existing trace and flush to disk. // Stop any existing trace and flush to disk.
match stop_tracing(self.should_trace).await { let result = match stop_tracing(self.should_trace).await {
Ok(result) => { Ok(result) => result,
if result { Err(message) => {
println!("stop_tracing command had an error {message}");
return false;
}
};
if !result {
println!("stop_tracing command failed somehow, bailing");
return false;
}
// Stop_tracing was successful // Stop_tracing was successful
match setup_iwd_config(false).await { if let Err(message) = setup_iwd_config(false).await {
Ok(_) => { println!("setup_iwd_config false got an error somehow {message}");
return false;
}
// setup_iwd_config false worked // setup_iwd_config false worked
match restart_iwd().await { let value = match restart_iwd().await {
Ok(value) => { Ok(value) => value,
Err(message) => {
println!("restart_iwd got an error {message}");
return false;
}
};
if value { if value {
// restart iwd worked // restart iwd worked
self.wifi_debug_mode = WifiDebugMode::Off; self.wifi_debug_mode = WifiDebugMode::Off;
} else { } else {
// restart_iwd failed // restart_iwd failed
println!( println!("restart_iwd failed somehow, check log above");
"restart_iwd failed somehow, check log above"
);
return false; return false;
} }
} }
Err(message) => {
println!("restart_iwd got an error {message}");
return false;
}
}
}
Err(message) => {
println!(
"setup_iwd_config false got an error somehow {message}"
);
return false;
}
}
} else {
println!("stop_tracing command failed somehow, bailing");
return false;
}
}
Err(message) => {
println!("stop_tracing command had an error {message}");
return false;
}
}
}
Ok(WifiDebugMode::On) => { Ok(WifiDebugMode::On) => {
// If mode is 1 enable wifi debug mode // If mode is 1 enable wifi debug mode
if buffer_size < MIN_BUFFER_SIZE { if buffer_size < MIN_BUFFER_SIZE {
return false; return false;
} }
match setup_iwd_config(true).await { if let Err(message) = setup_iwd_config(true).await {
Ok(_) => { println!("setup_iwd_config true got an error somehow {message}");
return false;
}
// setup_iwd_config worked // setup_iwd_config worked
match restart_iwd().await { let value = match restart_iwd().await {
Ok(value) => { Ok(value) => value,
if value { Err(message) => {
println!("restart_iwd got an error {message}");
return false;
}
};
if !value {
println!("restart_iwd failed somehow");
return false;
}
// restart_iwd worked // restart_iwd worked
match start_tracing(buffer_size, self.should_trace).await { let value = match start_tracing(buffer_size, self.should_trace).await {
Ok(value) => { Ok(value) => value,
Err(message) => {
println!("start_tracing got an error {message}");
return false;
}
};
if value { if value {
// start_tracing worked // start_tracing worked
self.wifi_debug_mode = WifiDebugMode::On; self.wifi_debug_mode = WifiDebugMode::On;
@ -528,28 +526,6 @@ impl SMManager {
return false; return false;
} }
} }
Err(message) => {
println!("start_tracing got an error {message}");
return false;
}
}
} else {
println!("restart_iwd failed somehow");
return false;
}
}
Err(message) => {
println!("restart_iwd got an error {message}");
return false;
}
}
}
Err(message) => {
println!("setup_iwd_config true got an error somehow {message}");
return false;
}
}
}
Err(_) => { Err(_) => {
// Invalid mode requested, more coming later, but add this catch-all for now // Invalid mode requested, more coming later, but add this catch-all for now
println!("Invalid wifi debug mode {mode} requested"); println!("Invalid wifi debug mode {mode} requested");