Skip to content

Commit 99c7ded

Browse files
Merge pull request #1760 from rust-osdev/clippy-misc-fixes
style: misc clippy fixes
2 parents b02a37d + 6c8020f commit 99c7ded

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

uefi/src/helpers/logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ impl<W: fmt::Write> fmt::Write for DecoratedLog<'_, '_, W> {
248248
// If the string ends with a newline character, we must 1/propagate it
249249
// to the output (it was swallowed by the iteration) and 2/prepare to
250250
// write the log level of the beginning of the next line (if any).
251-
if let Some('\n') = s.chars().next_back() {
251+
if s.ends_with('\n') {
252252
writeln!(self.writer)?;
253253
self.at_line_start = true;
254254
}

uefi/src/proto/media/file/dir.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl Directory {
6969
let read_entry_res = self.read_entry(&mut []);
7070

7171
// If no more entries are available, return early.
72-
if let Ok(None) = read_entry_res {
72+
if read_entry_res == Ok(None) {
7373
return Ok(None);
7474
}
7575

@@ -102,7 +102,7 @@ impl Directory {
102102
let read_entry_res = self.read_entry(&mut []);
103103

104104
// If no more entries are available, return early.
105-
if let Ok(None) = read_entry_res {
105+
if read_entry_res == Ok(None) {
106106
return Ok(None);
107107
}
108108

uefi/src/proto/tcg/v1.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -429,14 +429,13 @@ impl Tcg {
429429
data_to_hash: Option<&[u8]>,
430430
) -> Result {
431431
let hash_data;
432-
let hash_data_len;
433-
if let Some(data_to_hash) = data_to_hash {
432+
let hash_data_len = if let Some(data_to_hash) = data_to_hash {
434433
hash_data = data_to_hash.as_ptr() as PhysicalAddress;
435-
hash_data_len = u64::try_from(data_to_hash.len()).unwrap();
434+
u64::try_from(data_to_hash.len()).unwrap()
436435
} else {
437436
hash_data = 0;
438-
hash_data_len = 0;
439-
}
437+
0
438+
};
440439

441440
// Don't bother returning these, it's not very useful info.
442441
let mut event_number = 0;

uefi/src/runtime.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,13 @@ impl Iterator for VariableKeys {
321321
}))
322322
}
323323
Err(err) => {
324+
self.is_done = true;
324325
if err.status() == Status::NOT_FOUND {
325326
// This status indicates the end of the list. The final variable
326327
// has already been yielded at this point, so return `None`.
327-
self.is_done = true;
328328
None
329329
} else {
330330
// Return the error and end iteration.
331-
self.is_done = true;
332331
Some(Err(err.to_err_without_payload()))
333332
}
334333
}

0 commit comments

Comments
 (0)