From 8a2e8c81272c054398cb72f2cee74d72860da986 Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Mon, 27 Oct 2025 16:16:09 -0400 Subject: [PATCH] fix(sprout): correct rustdoc and clarify safety in some places --- src/actions/chainload.rs | 5 +++-- src/context.rs | 5 ++++- src/extractors/filesystem_device_match.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/actions/chainload.rs b/src/actions/chainload.rs index 96bff81..4b001d4 100644 --- a/src/actions/chainload.rs +++ b/src/actions/chainload.rs @@ -64,7 +64,8 @@ pub fn chainload(context: Rc, configuration: &ChainloadConfigurat // Pass the options to the image, if any are provided. // The holder must drop at the end of this function to ensure the options are not leaked, // and the holder here ensures it outlives the if block here, as a pointer has to be - // passed to the image. This has been hand-validated to be safe. + // passed to the image. + // SAFETY: The options outlive the usage of the image, and the image is not used after this. let mut options_holder: Option> = None; if !options.is_empty() { let options = Box::new( @@ -103,7 +104,7 @@ pub fn chainload(context: Rc, configuration: &ChainloadConfigurat // This call might return, or it may pass full control to another image that will never return. // Capture the result to ensure we can return an error if the image fails to start, but only // after the optional initrd has been unregistered. - let result = uefi::boot::start_image(image).context("unable to start image"); + let result = uefi::boot::start_image(image); // Unregister the initrd if it was registered. if let Some(initrd_handle) = initrd_handle diff --git a/src/context.rs b/src/context.rs index 6afa693..a59c436 100644 --- a/src/context.rs +++ b/src/context.rs @@ -118,7 +118,10 @@ impl SproutContext { pub fn all_values(&self) -> BTreeMap { let mut values = BTreeMap::new(); for key in self.all_keys() { - values.insert(key.clone(), self.get(key).cloned().unwrap_or_default()); + // Acquire the value from the context. Since retrieving all the keys will give us + // a full view of the context, we can be sure that the key exists. + let value = self.get(&key).cloned().unwrap_or_default(); + values.insert(key.clone(), value); } values } diff --git a/src/extractors/filesystem_device_match.rs b/src/extractors/filesystem_device_match.rs index dbe2694..1777537 100644 --- a/src/extractors/filesystem_device_match.rs +++ b/src/extractors/filesystem_device_match.rs @@ -18,7 +18,7 @@ use uefi_raw::Status; /// the device root path that can concatenated with subpaths to access files /// on a particular filesystem. /// -/// This function only requires one of the criteria to match. +/// This function only requires all the criteria to match. /// The fallback value can be used to provide a value if none is found. #[derive(Serialize, Deserialize, Debug, Default, Clone)] pub struct FilesystemDeviceMatchExtractor {