Skip to content

Commit

Permalink
Address clippy lints
Browse files Browse the repository at this point in the history
Fix:

- clippy::clone_on_copy
- clippy::implicit_saturating_sub
- clippy::single_match

Signed-off-by: Tim Crawford <[email protected]>
  • Loading branch information
crawfxrd committed May 13, 2024
1 parent 3a78eb1 commit 079ac74
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/coreboot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn init() {
#[allow(clippy::single_match)]
match table {
Table::Serial(serial) => {
*COREBOOT_SERIAL.lock() = Some(serial.clone());
*COREBOOT_SERIAL.lock() = Some(*serial);
},
_ => (),
}
Expand Down
8 changes: 4 additions & 4 deletions src/fde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
},
Key::Down => {
if editing {
if let Some(mut element) = elements.get_mut(selected) {
if let Some(element) = elements.get_mut(selected) {
if element.list {
if element.list_i + 1 < element.options.len() {
element.list_i += 1;
Expand Down Expand Up @@ -950,7 +950,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
},
Key::Up => {
if editing {
if let Some(mut element) = elements.get_mut(selected) {
if let Some(element) = elements.get_mut(selected) {
if element.list {
if element.list_i > 0 {
element.list_i -= 1;
Expand Down Expand Up @@ -1000,7 +1000,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
},
Key::PageDown => {
if editing {
if let Some(mut element) = elements.get_mut(selected) {
if let Some(element) = elements.get_mut(selected) {
if element.list && element.list_i + 1 < element.options.len() {
element.options.swap(element.list_i, element.list_i + 1);
element.list_i += 1;
Expand All @@ -1010,7 +1010,7 @@ fn form_display_inner(form: &Form, user_input: &mut UserInput) -> Result<()> {
},
Key::PageUp => {
if editing {
if let Some(mut element) = elements.get_mut(selected) {
if let Some(element) = elements.get_mut(selected) {
if element.list && element.list_i > 0 {
element.list_i -= 1;
element.options.swap(element.list_i, element.list_i + 1);
Expand Down
14 changes: 5 additions & 9 deletions src/security.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,7 @@ fn confirm(display: &mut Display) -> Result<()> {
}
},
Key::Up => {
if button_i > 0 {
button_i -= 1;
}
button_i = button_i.saturating_sub(1);
},
_ => {},
}
Expand Down Expand Up @@ -275,15 +273,13 @@ extern "win64" fn run() -> bool {
};

debugln!("security state: {:?}", security_state);
match security_state {
if security_state == SecurityState::Lock {
// Already locked, so do not confirm
SecurityState::Lock => {
return false;
},
// Not locked, require confirmation
_ => (),
return false;
}

// Not locked, require confirmation

let res = match Output::one() {
Ok(output) => {
let mut display = Display::new(output);
Expand Down

0 comments on commit 079ac74

Please sign in to comment.