From faf56c7238a3d04d42cd73ea70819fdd99ebef6d Mon Sep 17 00:00:00 2001 From: andre-braga Date: Tue, 11 Jun 2024 20:24:56 +0000 Subject: [PATCH] uefi: make DevicePathHeader::try_from idiomatic --- uefi/src/proto/device_path/mod.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/uefi/src/proto/device_path/mod.rs b/uefi/src/proto/device_path/mod.rs index 087440bb5..0328fc3db 100644 --- a/uefi/src/proto/device_path/mod.rs +++ b/uefi/src/proto/device_path/mod.rs @@ -124,11 +124,10 @@ impl<'a> TryFrom<&[u8]> for &'a DevicePathHeader { fn try_from(bytes: &[u8]) -> Result { if mem::size_of::() <= bytes.len() { - unsafe { - return Ok(&*bytes.as_ptr().cast::()); - } + unsafe { Ok(&*bytes.as_ptr().cast::()) } + } else { + Err(ByteConversionError::InvalidLength) } - Err(ByteConversionError::InvalidLength) } }