Skip to content

Commit

Permalink
fix: remove more unwrap() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
iTrooz committed Dec 25, 2023
1 parent 048b724 commit f4efb56
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions efivar/src/boot/parse/boot_entry.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//! This module contains parsing code for a boot entry

use std::{convert::TryInto, fmt::Display, io::Read};
use std::{fmt::Display, io::Read};

use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};

use crate::{efi::Variable, utils::read_nt_utf16_string, Error, VarReader};
use byteorder::{LittleEndian, ReadBytesExt};

use super::FilePathList;
use crate::{efi::Variable, utils::read_nt_utf16_string, Error, VarReader};
use std::convert::TryFrom;

bitflags! {
/// Possible attributes of a boot entry as a bitfield
Expand Down Expand Up @@ -80,9 +80,12 @@ impl BootEntry {
} else {
vec![]
};
bytes
.write_u16::<LittleEndian>(fpl_bytes.len().try_into().unwrap())
.unwrap();
bytes.append(
&mut u16::try_from(fpl_bytes.len())
.unwrap()
.to_le_bytes()
.to_vec(),
);

// append description bytes
let mut desc_bytes = self
Expand All @@ -92,7 +95,7 @@ impl BootEntry {
.collect();
bytes.append(&mut desc_bytes);
// write description null termination
bytes.write_u16::<LittleEndian>(0x0000).unwrap();
bytes.append(&mut vec![0x00, 0x00]);

// append file path list bytes
bytes.append(&mut fpl_bytes);
Expand Down

0 comments on commit f4efb56

Please sign in to comment.