diff --git a/rust/src/main.rs b/rust/src/main.rs index 7eae48a..4bb6f2b 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -242,23 +242,15 @@ fn safe_main() -> anyhow::Result<()> { log(log::LogMessage::FilesystemMount, free_space.free_size as u32, free_space.total_size as u32, &free_space.used_size.to_string(), ""); + let mut cur = board.get_rtc_time().or_else(|err| { + println!("rtc module error: {:?}", err); + board.general_fault(true); + board.time() + }).map_err(|err| -> Result<(), _>{ + bail!("time error {}", err); + }).unwrap(); - let mut cur = match board.get_rtc_time() { - Ok(time) => time, - Err(err) => { - println!("rtc module error: {}", err); - board.general_fault(true); - let time = board.time(); - match time { - Ok(cur) => cur, - Err(err) => { - bail!("time error {}", err); - } - } - } - }; - - //check if we know the time current > 2020 + //check if we know the time current > 2020 (plausibility check, this code is newer than 2020) if cur.year() < 2020 { to_config = true; log(log::LogMessage::YearInplausibleForceConfig, 0,0,"",""); @@ -988,7 +980,7 @@ fn main() { // if safe_main exists with error, rollback to known good ota version Err(err) => { println!("Failed main {}", err); - let rollback_successful = rollback_and_reboot(); + let _rollback_successful = rollback_and_reboot(); panic!("Failed to rollback :("); } }