Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion library/std/src/sys/env/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,20 @@ mod uefi_env {
pub(crate) fn unset(key: &OsStr) -> io::Result<()> {
let mut key_ptr = helpers::os_string_to_raw(key)
.ok_or(io::const_error!(io::ErrorKind::InvalidInput, "invalid key"))?;
unsafe { set_raw(key_ptr.as_mut_ptr(), crate::ptr::null_mut()) }
let r = unsafe { set_raw(key_ptr.as_mut_ptr(), crate::ptr::null_mut()) };

// The UEFI Shell spec only lists `EFI_SUCCESS` as a possible return value for
// `SetEnv`, but the edk2 implementation can return errors. Allow most of these
// errors to bubble up to the caller, but ignore `NotFound` errors; deleting a
// nonexistent variable is not listed as an error condition of
// `std::env::remove_var`.
if let Err(err) = &r
&& err.kind() == io::ErrorKind::NotFound
{
Ok(())
} else {
r
}
}

pub(crate) fn get_all() -> io::Result<Vec<(OsString, OsString)>> {
Expand Down
Loading