From 5e51fb304d2fb9eb813f108c5d25e5f2c48b9798 Mon Sep 17 00:00:00 2001 From: ache Date: Tue, 4 Aug 2026 18:12:14 +0200 Subject: Remove dead code --- src/main.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index e2c179e..5f4f1e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,16 +75,14 @@ async fn main() { states[id as usize] = State::Received { rtt: rtt, ttl }; } } - PingResult::NoPingErr { id: _, ref error } => { - // FEAT: It should fail if states is empty and print a informative characters on the line otherwise - eprintln!("Error: {}", error); - std::process::exit(2); + PingResult::NoPingErr { id } => { + states[id as usize] = State::SendError; } } } Err(TryRecvError::Disconnected) => { - // NOTE: Maybe we should quit, I don't know. - break; + eprintln!("Critical error, pinger thread killed"); + std::process::exit(2); } Err(TryRecvError::Empty) => { // No more ping to read @@ -95,7 +93,7 @@ async fn main() { // Put the cursor back up if !std::process::Command::new("tput").arg("rc").status().map(|s| s.success()).unwrap_or(false) { - println!("Process failed too"); + println!("Process failed too"); std::process::exit(1); } @@ -108,12 +106,12 @@ async fn main() { print_stats(&stats); } // Print stats of the last 30 pings - let firstIndex = if (states.len() as i32) - 30 > 0 { + let first_index = if (states.len() as i32) - 30 > 0 { states.len() - 30 } else { 0 }; - if let Some(stats) = compute_stats(&states[firstIndex..]) { + if let Some(stats) = compute_stats(&states[first_index..]) { print_stats(&stats); } } -- cgit v1.3-2-g11bf