Skip to content

Commit 34e52a1

Browse files
Merge pull request #1202 from andre-braga/idiom
uefi: make DevicePathHeader::try_from idiomatic
2 parents ed28e51 + faf56c7 commit 34e52a1

File tree

1 file changed

+3
-4
lines changed
  • uefi/src/proto/device_path

1 file changed

+3
-4
lines changed

uefi/src/proto/device_path/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ impl<'a> TryFrom<&[u8]> for &'a DevicePathHeader {
124124

125125
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
126126
if mem::size_of::<DevicePathHeader>() <= bytes.len() {
127-
unsafe {
128-
return Ok(&*bytes.as_ptr().cast::<DevicePathHeader>());
129-
}
127+
unsafe { Ok(&*bytes.as_ptr().cast::<DevicePathHeader>()) }
128+
} else {
129+
Err(ByteConversionError::InvalidLength)
130130
}
131-
Err(ByteConversionError::InvalidLength)
132131
}
133132
}
134133

0 commit comments

Comments
 (0)