diff --git a/uefi/src/proto/network/pxe.rs b/uefi/src/proto/network/pxe.rs index fdb844d72..754acb977 100644 --- a/uefi/src/proto/network/pxe.rs +++ b/uefi/src/proto/network/pxe.rs @@ -160,9 +160,7 @@ impl BaseCode { false, ) }; - Result::from(status)?; - - Ok(buffer_size) + status.into_with_val(|| buffer_size) } /// Reads a file located on a TFTP server. @@ -193,9 +191,7 @@ impl BaseCode { dont_use_buffer, ) }; - Result::from(status)?; - - Ok(buffer_size) + status.into_with_val(|| buffer_size) } /// Writes to a file located on a TFTP server. @@ -324,9 +320,7 @@ impl BaseCode { false, ) }; - Result::from(status)?; - - Ok(buffer_size) + status.into_with_val(|| buffer_size) } /// Reads a file located on a MTFTP server. @@ -358,9 +352,7 @@ impl BaseCode { dont_use_buffer, ) }; - Result::from(status)?; - - Ok(buffer_size) + status.into_with_val(|| buffer_size) } /// Reads a directory listing of a directory on a MTFTP server. @@ -530,9 +522,7 @@ impl BaseCode { (&mut buffer[0] as *mut u8).cast(), ) }; - Result::from(status)?; - - Ok(buffer_size) + status.into_with_val(|| buffer_size) } /// Updates the IP receive filters of a network device and enables software diff --git a/uefi/src/proto/network/snp.rs b/uefi/src/proto/network/snp.rs index 5a403551c..b0adb4269 100644 --- a/uefi/src/proto/network/snp.rs +++ b/uefi/src/proto/network/snp.rs @@ -152,16 +152,14 @@ impl SimpleNetwork { let mut stats_table: NetworkStats = Default::default(); let mut stats_size = core::mem::size_of::(); let status = (self.statistics)(self, false, Some(&mut stats_size), Some(&mut stats_table)); - Result::from(status)?; - Ok(stats_table) + status.into_with_val(|| stats_table) } /// Convert a multicast IP address to a multicast HW MAC Address. pub fn mcast_ip_to_mac(&self, ipv6: bool, ip: IpAddress) -> Result { let mut mac_address = MacAddress([0; 32]); let status = (self.mcast_ip_to_mac)(self, ipv6, &ip, &mut mac_address); - Result::from(status)?; - Ok(mac_address) + status.into_with_val(|| mac_address) } /// Perform read operations on the NVRAM device attached to @@ -194,8 +192,7 @@ impl SimpleNetwork { pub fn get_interrupt_status(&self) -> Result { let mut interrupt_status = InterruptStatus::empty(); let status = (self.get_status)(self, Some(&mut interrupt_status), None); - Result::from(status)?; - Ok(interrupt_status) + status.into_with_val(|| interrupt_status) } /// Read the current recycled transmit buffer status from a @@ -203,8 +200,7 @@ impl SimpleNetwork { pub fn get_recycled_transmit_buffer_status(&self) -> Result>> { let mut tx_buf: *mut c_void = ptr::null_mut(); let status = (self.get_status)(self, None, Some(&mut tx_buf)); - Result::from(status)?; - Ok(NonNull::new(tx_buf.cast())) + status.into_with_val(|| NonNull::new(tx_buf.cast())) } /// Place a packet in the transmit queue of a network interface. @@ -249,8 +245,7 @@ impl SimpleNetwork { dest_addr, protocol, ); - Result::from(status)?; - Ok(buffer_size) + status.into_with_val(|| buffer_size) } /// Event that fires once a packet is available to be received.