From d339387e2adbedeeb89221bd0f7643c61498b0d5 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sat, 7 Jun 2025 15:43:53 -0400 Subject: [PATCH 1/3] xtask: Fix mismatched_lifetime_syntaxes lint in device_path_gen --- uefi/src/proto/device_path/device_path_gen.rs | 8 ++++---- xtask/src/device_path/field.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/uefi/src/proto/device_path/device_path_gen.rs b/uefi/src/proto/device_path/device_path_gen.rs index 9b0c35f3e..c588cba8b 100644 --- a/uefi/src/proto/device_path/device_path_gen.rs +++ b/uefi/src/proto/device_path/device_path_gen.rs @@ -570,7 +570,7 @@ pub mod acpi { /// comes from Table B-2 ACPI 3.0 specification. At least one /// ADR value is required. #[must_use] - pub fn adr(&self) -> UnalignedSlice { + pub fn adr(&self) -> UnalignedSlice<'_, u32> { let ptr: *const [u32] = addr_of!(self.adr); let (ptr, len): (*const (), usize) = ptr_meta::to_raw_parts(ptr); unsafe { UnalignedSlice::new(ptr.cast::(), len) } @@ -1174,7 +1174,7 @@ pub mod messaging { /// Last 64 (or fewer) characters of the USB Serial number. #[must_use] - pub fn serial_number(&self) -> UnalignedSlice { + pub fn serial_number(&self) -> UnalignedSlice<'_, u16> { let ptr: *const [u16] = addr_of!(self.serial_number); let (ptr, len): (*const (), usize) = ptr_meta::to_raw_parts(ptr); unsafe { UnalignedSlice::new(ptr.cast::(), len) } @@ -2424,7 +2424,7 @@ pub mod messaging { /// One or more instances of the DNS server address. #[must_use] - pub fn addresses(&self) -> UnalignedSlice { + pub fn addresses(&self) -> UnalignedSlice<'_, IpAddress> { let ptr: *const [IpAddress] = addr_of!(self.addresses); let (ptr, len): (*const (), usize) = ptr_meta::to_raw_parts(ptr); unsafe { UnalignedSlice::new(ptr.cast::(), len) } @@ -2933,7 +2933,7 @@ pub mod media { impl FilePath { /// Null-terminated path. #[must_use] - pub fn path_name(&self) -> UnalignedSlice { + pub fn path_name(&self) -> UnalignedSlice<'_, u16> { let ptr: *const [u16] = addr_of!(self.path_name); let (ptr, len): (*const (), usize) = ptr_meta::to_raw_parts(ptr); unsafe { UnalignedSlice::new(ptr.cast::(), len) } diff --git a/xtask/src/device_path/field.rs b/xtask/src/device_path/field.rs index fdb54c420..19a6b0a4a 100644 --- a/xtask/src/device_path/field.rs +++ b/xtask/src/device_path/field.rs @@ -264,7 +264,7 @@ impl NodeField { // In the general case we can't safely return a // reference to the slice since it might be // unaligned, so use `UnalignedSlice`. - ret_type = quote!(UnalignedSlice<#slice_elem>); + ret_type = quote!(UnalignedSlice<'_, #slice_elem>); ret_val = quote!( let ptr: *const [#slice_elem] = addr_of!(self.#field_name); let (ptr, len): (*const (), usize) = ptr_meta::to_raw_parts(ptr); From 43aee0840e5934c3fff61e40a34bcab6a50d6f5e Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 8 Jun 2025 14:22:57 -0400 Subject: [PATCH 2/3] test-runner: Fix mismatched_lifetime_syntaxes lint --- uefi-test-runner/src/proto/driver.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/uefi-test-runner/src/proto/driver.rs b/uefi-test-runner/src/proto/driver.rs index c35bf3e75..f6bacff21 100644 --- a/uefi-test-runner/src/proto/driver.rs +++ b/uefi-test-runner/src/proto/driver.rs @@ -28,7 +28,7 @@ impl ComponentNameInterface for ScopedProtocol { boot::open_protocol_exclusive::(handle) } - fn supported_languages(&self) -> core::result::Result { + fn supported_languages(&self) -> core::result::Result, LanguageError> { (**self).supported_languages() } @@ -51,7 +51,7 @@ impl ComponentNameInterface for ScopedProtocol { boot::open_protocol_exclusive::(handle) } - fn supported_languages(&self) -> core::result::Result { + fn supported_languages(&self) -> core::result::Result, LanguageError> { (**self).supported_languages() } @@ -74,7 +74,7 @@ impl ComponentNameInterface for ComponentName { Self::open(handle) } - fn supported_languages(&self) -> core::result::Result { + fn supported_languages(&self) -> core::result::Result, LanguageError> { self.supported_languages() } From 7355810e70223571ce62d8d6c9586bb9081c2d2c Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 8 Jun 2025 14:23:10 -0400 Subject: [PATCH 3/3] uefi: Fix mismatched_lifetime_syntaxes lint --- uefi/src/data_types/strs.rs | 2 +- uefi/src/fs/path/path.rs | 2 +- uefi/src/proto/console/gop.rs | 4 ++-- uefi/src/proto/device_path/mod.rs | 8 ++++---- uefi/src/proto/driver/component_name.rs | 10 +++++++--- uefi/src/proto/tcg/v1.rs | 4 ++-- uefi/src/proto/tcg/v2.rs | 10 +++++----- 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/uefi/src/data_types/strs.rs b/uefi/src/data_types/strs.rs index 4bee5fe3e..0673e4589 100644 --- a/uefi/src/data_types/strs.rs +++ b/uefi/src/data_types/strs.rs @@ -569,7 +569,7 @@ impl CStr16 { /// Returns an iterator over this C string #[must_use] - pub const fn iter(&self) -> CStr16Iter { + pub const fn iter(&self) -> CStr16Iter<'_> { CStr16Iter { inner: self, pos: 0, diff --git a/uefi/src/fs/path/path.rs b/uefi/src/fs/path/path.rs index 4caa71a2f..47e2a9fe3 100644 --- a/uefi/src/fs/path/path.rs +++ b/uefi/src/fs/path/path.rs @@ -37,7 +37,7 @@ impl Path { /// Iterator over the components of a path. #[must_use] - pub fn components(&self) -> Components { + pub fn components(&self) -> Components<'_> { Components { path: self.as_ref(), i: 0, diff --git a/uefi/src/proto/console/gop.rs b/uefi/src/proto/console/gop.rs index 81ad17afa..adf087fdc 100644 --- a/uefi/src/proto/console/gop.rs +++ b/uefi/src/proto/console/gop.rs @@ -104,7 +104,7 @@ impl GraphicsOutput { /// Returns a [`ModeIter`]. #[must_use] - pub const fn modes(&self) -> ModeIter { + pub const fn modes(&self) -> ModeIter<'_> { ModeIter { gop: self, current: 0, @@ -295,7 +295,7 @@ impl GraphicsOutput { } /// Access the frame buffer directly - pub fn frame_buffer(&mut self) -> FrameBuffer { + pub fn frame_buffer(&mut self) -> FrameBuffer<'_> { assert!( self.current_mode_info().pixel_format() != PixelFormat::BltOnly, "Cannot access the framebuffer in a Blt-only mode" diff --git a/uefi/src/proto/device_path/mod.rs b/uefi/src/proto/device_path/mod.rs index c9d779b1b..c1b56a855 100644 --- a/uefi/src/proto/device_path/mod.rs +++ b/uefi/src/proto/device_path/mod.rs @@ -289,7 +289,7 @@ impl DevicePathNode { /// Convert from a generic [`DevicePathNode`] reference to an enum /// of more specific node types. - pub fn as_enum(&self) -> Result { + pub fn as_enum(&self) -> Result, NodeConversionError> { DevicePathNodeEnum::try_from(self) } @@ -365,7 +365,7 @@ impl DevicePathInstance { /// /// [`DevicePathNodes`]: DevicePathNode #[must_use] - pub const fn node_iter(&self) -> DevicePathNodeIterator { + pub const fn node_iter(&self) -> DevicePathNodeIterator<'_> { DevicePathNodeIterator { nodes: &self.data, stop_condition: StopCondition::AnyEndNode, @@ -539,7 +539,7 @@ impl DevicePath { /// Get an iterator over the [`DevicePathInstance`]s in this path. #[must_use] - pub const fn instance_iter(&self) -> DevicePathInstanceIterator { + pub const fn instance_iter(&self) -> DevicePathInstanceIterator<'_> { DevicePathInstanceIterator { remaining_path: Some(self), } @@ -550,7 +550,7 @@ impl DevicePath { /// [`is_end_entire`][DevicePathNode::is_end_entire] is true. That ending /// path is not returned by the iterator. #[must_use] - pub const fn node_iter(&self) -> DevicePathNodeIterator { + pub const fn node_iter(&self) -> DevicePathNodeIterator<'_> { DevicePathNodeIterator { nodes: &self.data, stop_condition: StopCondition::EndEntireNode, diff --git a/uefi/src/proto/driver/component_name.rs b/uefi/src/proto/driver/component_name.rs index 2ae35b199..7f5f18c23 100644 --- a/uefi/src/proto/driver/component_name.rs +++ b/uefi/src/proto/driver/component_name.rs @@ -43,7 +43,9 @@ impl ComponentName1 { /// English is encoded as "eng". /// /// [ISO 639-2]: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes - pub const fn supported_languages(&self) -> core::result::Result { + pub const fn supported_languages( + &self, + ) -> core::result::Result, LanguageError> { LanguageIter::new(self.0.supported_languages, LanguageIterKind::V1) } @@ -110,7 +112,9 @@ impl ComponentName2 { /// as "en". /// /// [RFC 4646]: https://www.rfc-editor.org/rfc/rfc4646 - pub const fn supported_languages(&self) -> core::result::Result { + pub const fn supported_languages( + &self, + ) -> core::result::Result, LanguageError> { LanguageIter::new(self.0.supported_languages, LanguageIterKind::V2) } @@ -185,7 +189,7 @@ impl ComponentName { /// [ISO 639-2]: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes /// [RFC 4646]: https://www.rfc-editor.org/rfc/rfc4646 #[allow(clippy::missing_const_for_fn)] // false-positive since Rust 1.86 - pub fn supported_languages(&self) -> core::result::Result { + pub fn supported_languages(&self) -> core::result::Result, LanguageError> { match self { Self::V1(cn1) => cn1.supported_languages(), Self::V2(cn2) => cn2.supported_languages(), diff --git a/uefi/src/proto/tcg/v1.rs b/uefi/src/proto/tcg/v1.rs index 8ab30f939..e974e8a35 100644 --- a/uefi/src/proto/tcg/v1.rs +++ b/uefi/src/proto/tcg/v1.rs @@ -276,7 +276,7 @@ impl EventLog<'_> { /// Iterator of events in the log. #[must_use] - pub const fn iter(&self) -> EventLogIter { + pub const fn iter(&self) -> EventLogIter<'_> { EventLogIter { log: self, location: self.location, @@ -356,7 +356,7 @@ pub struct StatusCheck<'a> { impl Tcg { /// Get information about the protocol and TPM device, as well as /// the TPM event log. - pub fn status_check(&mut self) -> Result { + pub fn status_check(&mut self) -> Result> { let mut protocol_capability = TcgBootServiceCapability::default(); let mut feature_flags = 0; let mut event_log_location = 0; diff --git a/uefi/src/proto/tcg/v2.rs b/uefi/src/proto/tcg/v2.rs index 39c425bba..c46d3e800 100644 --- a/uefi/src/proto/tcg/v2.rs +++ b/uefi/src/proto/tcg/v2.rs @@ -336,7 +336,7 @@ pub struct EventLog<'a> { impl EventLog<'_> { /// Iterator of events in the log. #[must_use] - pub fn iter(&self) -> EventLogIter { + pub fn iter(&self) -> EventLogIter<'_> { if let Some(header) = self.header() { // Advance past the header let location = unsafe { self.location.add(header.size_in_bytes) }; @@ -356,7 +356,7 @@ impl EventLog<'_> { } /// Header at the beginning of the event log. - fn header(&self) -> Option { + fn header(&self) -> Option> { // The spec is unclear if the header is present when there are // no entries, so lets assume that `self.location` will be null // if there's no header, and otherwise valid. @@ -513,7 +513,7 @@ impl<'a> PcrEvent<'a> { /// Digests of the data hashed for this event. #[must_use] - pub fn digests(&self) -> PcrEventDigests { + pub fn digests(&self) -> PcrEventDigests<'_> { PcrEventDigests { data: self.digests, algorithm_digest_sizes: self.algorithm_digest_sizes.clone(), @@ -579,7 +579,7 @@ impl Tcg { /// Get the V1 event log. This provides events in the same format as a V1 /// TPM, so all events use SHA-1 hashes. - pub fn get_event_log_v1(&mut self) -> Result { + pub fn get_event_log_v1(&mut self) -> Result> { let mut location = 0; let mut last_entry = 0; let mut truncated = 0; @@ -608,7 +608,7 @@ impl Tcg { } /// Get the V2 event log. This format allows for a flexible list of hash types. - pub fn get_event_log_v2(&mut self) -> Result { + pub fn get_event_log_v2(&mut self) -> Result> { let mut location = 0; let mut last_entry = 0; let mut truncated = 0;