Skip to content

Commit

Permalink
Formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus-it committed Jul 5, 2022
1 parent c7fe98c commit ec2dd9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
29 changes: 14 additions & 15 deletions src/efi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,14 +258,18 @@ impl Default for AuthVariable {
}

impl Volume {

pub fn boot_entries(&self) -> BootEntryIter {
// XXX - just store the iterator in the struct?
let mut vars: Vec<&AuthVariable> = self.vars.iter().filter(|&v|
v.name.starts_with("Boot0") &&
v.state == VAR_ADDED &&
v.guid.to_string() == EFI_GLOBAL_VARIABLE_GUID.to_string())
.collect();
let mut vars: Vec<&AuthVariable> = self
.vars
.iter()
.filter(|&v| {
v.name.starts_with("Boot0")
&& v.state == VAR_ADDED
&& v.guid.to_string()
== EFI_GLOBAL_VARIABLE_GUID.to_string()
})
.collect();
vars.reverse();
BootEntryIter { vars }
}
Expand All @@ -289,9 +293,7 @@ impl Volume {
self.vars.retain(|v| {
v.state == VAR_ADDED
|| (v.state == (VAR_ADDED & VAR_IN_DELETED_TRANSITION)
&& !known.contains(
&format!("{}/{}", v.guid, v.name),
))
&& !known.contains(&format!("{}/{}", v.guid, v.name)))
});

// Now promote any remaining ADDED/IN_DELETED_TRANSITION entries
Expand Down Expand Up @@ -551,12 +553,9 @@ impl fmt::Debug for BootEntryType {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}",
match self {
BootEntryType::PCI(f, d) =>
format!("PCI {}.{}", d, f),
BootEntryType::App(ref guid) =>
format!("App {}", guid),
BootEntryType::Path(ref path) =>
format!("Path {}", path),
BootEntryType::PCI(f, d) => format!("PCI {}.{}", d, f),
BootEntryType::App(ref guid) => format!("App {}", guid),
BootEntryType::Path(ref path) => format!("Path {}", path),
BootEntryType::Unknown => "unknown".to_string(),
}
)
Expand Down
13 changes: 4 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ extern crate serde_json;
#[macro_use]
extern crate lazy_static;



mod efi;

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -134,7 +132,7 @@ fn main() {
}

if let Some(ref var) = args.remove {
fv.remove_var(&var, &efi::EFI_GLOBAL_VARIABLE_GUID.to_string());
fv.remove_var(var, &efi::EFI_GLOBAL_VARIABLE_GUID.to_string());
changed = true;
}

Expand Down Expand Up @@ -175,12 +173,9 @@ struct BootOptions {
}

fn list_boot_options(args: &Args, fv: &efi::Volume) {

let beiter = fv.boot_entries().filter(|v| {
match args.filter {
Some(ref filter) => v.name.contains(filter),
_ => true
}
let beiter = fv.boot_entries().filter(|v| match args.filter {
Some(ref filter) => v.name.contains(filter),
_ => true,
});

let opts = BootOptions {
Expand Down

0 comments on commit ec2dd9b

Please sign in to comment.