diff --git a/uefi/src/helpers/logger.rs b/uefi/src/helpers/logger.rs index c7fdba50a..f9aee2ff0 100644 --- a/uefi/src/helpers/logger.rs +++ b/uefi/src/helpers/logger.rs @@ -248,7 +248,7 @@ impl fmt::Write for DecoratedLog<'_, '_, W> { // If the string ends with a newline character, we must 1/propagate it // to the output (it was swallowed by the iteration) and 2/prepare to // write the log level of the beginning of the next line (if any). - if let Some('\n') = s.chars().next_back() { + if s.ends_with('\n') { writeln!(self.writer)?; self.at_line_start = true; } diff --git a/uefi/src/proto/media/file/dir.rs b/uefi/src/proto/media/file/dir.rs index c87628d39..f3ba174eb 100644 --- a/uefi/src/proto/media/file/dir.rs +++ b/uefi/src/proto/media/file/dir.rs @@ -69,7 +69,7 @@ impl Directory { let read_entry_res = self.read_entry(&mut []); // If no more entries are available, return early. - if let Ok(None) = read_entry_res { + if read_entry_res == Ok(None) { return Ok(None); } @@ -102,7 +102,7 @@ impl Directory { let read_entry_res = self.read_entry(&mut []); // If no more entries are available, return early. - if let Ok(None) = read_entry_res { + if read_entry_res == Ok(None) { return Ok(None); } diff --git a/uefi/src/proto/tcg/v1.rs b/uefi/src/proto/tcg/v1.rs index 5f73b7caa..07a497a58 100644 --- a/uefi/src/proto/tcg/v1.rs +++ b/uefi/src/proto/tcg/v1.rs @@ -429,14 +429,13 @@ impl Tcg { data_to_hash: Option<&[u8]>, ) -> Result { let hash_data; - let hash_data_len; - if let Some(data_to_hash) = data_to_hash { + let hash_data_len = if let Some(data_to_hash) = data_to_hash { hash_data = data_to_hash.as_ptr() as PhysicalAddress; - hash_data_len = u64::try_from(data_to_hash.len()).unwrap(); + u64::try_from(data_to_hash.len()).unwrap() } else { hash_data = 0; - hash_data_len = 0; - } + 0 + }; // Don't bother returning these, it's not very useful info. let mut event_number = 0; diff --git a/uefi/src/runtime.rs b/uefi/src/runtime.rs index 624897399..a45f04192 100644 --- a/uefi/src/runtime.rs +++ b/uefi/src/runtime.rs @@ -321,14 +321,13 @@ impl Iterator for VariableKeys { })) } Err(err) => { + self.is_done = true; if err.status() == Status::NOT_FOUND { // This status indicates the end of the list. The final variable // has already been yielded at this point, so return `None`. - self.is_done = true; None } else { // Return the error and end iteration. - self.is_done = true; Some(Err(err.to_err_without_payload())) } }