From 4b564bf7f66d5f5d87b49e3b71ba6ec893b0293d Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Sun, 7 Jul 2024 16:43:06 -0400 Subject: [PATCH] uefi: Fix return value lifetime for register_protocol_notify Due to the rules of lifetime elision (https://doc.rust-lang.org/reference/lifetime-elision.html), the lifetime of the `SearchType` returned from `register_protocol_notify` was infered to be the lifetime of `Self`. The correct lifetime is the `protocol` reference. --- uefi/CHANGELOG.md | 2 ++ uefi/src/table/boot.rs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index e746ab9c9..7d57ab742 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -2,6 +2,8 @@ ## Changed - **Breaking:** `uefi::helpers::init` no longer takes an argument. +- The lifetime of the `SearchType` returned from + `BootServices::register_protocol_notify` is now tied to the protocol GUID. # uefi - 0.29.0 (2024-07-02) diff --git a/uefi/src/table/boot.rs b/uefi/src/table/boot.rs index 1a27de37c..f492f495e 100644 --- a/uefi/src/table/boot.rs +++ b/uefi/src/table/boot.rs @@ -683,11 +683,11 @@ impl BootServices { /// /// * [`uefi::Status::OUT_OF_RESOURCES`] /// * [`uefi::Status::INVALID_PARAMETER`] - pub fn register_protocol_notify( + pub fn register_protocol_notify<'guid>( &self, - protocol: &Guid, + protocol: &'guid Guid, event: Event, - ) -> Result<(Event, SearchType)> { + ) -> Result<(Event, SearchType<'guid>)> { let mut key = ptr::null(); // Safety: we clone `event` a couple times, but there will be only one left once we return. unsafe { (self.0.register_protocol_notify)(protocol, event.as_ptr(), &mut key) }