rustfmt: update to edition 2024

We can delete rustfmt.toml as the style version defaults to
the crate's rust edition.
This commit is contained in:
Philipp Schuster 2025-03-23 13:29:38 +01:00
parent 907c63c2aa
commit 83412b60a0
101 changed files with 231 additions and 202 deletions

View file

@ -1,2 +0,0 @@
# Temporarily for this commit.
style_edition = "2021"

View file

@ -7,11 +7,11 @@ extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro2::TokenStream as TokenStream2;
use quote::{quote, quote_spanned, TokenStreamExt};
use quote::{TokenStreamExt, quote, quote_spanned};
use syn::spanned::Spanned;
use syn::{
parse_macro_input, parse_quote, parse_quote_spanned, Error, Expr, ExprLit, ExprPath, ItemFn,
ItemStruct, Lit, Visibility,
Error, Expr, ExprLit, ExprPath, ItemFn, ItemStruct, Lit, Visibility, parse_macro_input,
parse_quote, parse_quote_spanned,
};
macro_rules! err {
@ -74,7 +74,7 @@ pub fn unsafe_protocol(args: TokenStream, input: TokenStream) -> TokenStream {
expr,
"macro input must be either a string literal or path to a constant"
)
.into()
.into();
}
};

View file

@ -34,7 +34,7 @@ pub mod time;
mod status;
pub use status::Status;
pub use uguid::{guid, Guid};
pub use uguid::{Guid, guid};
use core::ffi::c_void;
use core::fmt::{self, Debug, Formatter};

View file

@ -3,7 +3,7 @@
use super::device_path::DevicePathProtocol;
use crate::{Event, Status};
use core::ffi::c_void;
use uguid::{guid, Guid};
use uguid::{Guid, guid};
bitflags::bitflags! {
/// ATA Controller attributes.

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Boolean, Guid, Status};
use crate::{Boolean, Guid, Status, guid};
use core::ffi::c_void;
/// Logical block address.

View file

@ -2,7 +2,7 @@
pub mod serial;
use crate::{guid, Boolean, Char16, Event, Guid, PhysicalAddress, Status};
use crate::{Boolean, Char16, Event, Guid, PhysicalAddress, Status, guid};
use bitflags::bitflags;
use core::ptr;

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Guid, Status};
use crate::{Guid, Status, guid};
use bitflags::bitflags;
bitflags! {

View file

@ -2,7 +2,7 @@
mod device_path_gen;
use crate::{guid, Boolean, Char16, Guid};
use crate::{Boolean, Char16, Guid, guid};
pub use device_path_gen::{acpi, bios_boot_spec, end, hardware, media, messaging};

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Event, Guid, Status};
use crate::{Event, Guid, Status, guid};
use core::ffi::c_void;
#[derive(Debug)]

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::protocol::device_path::DevicePathProtocol;
use crate::{guid, Guid, Handle, Status};
use crate::{Guid, Handle, Status, guid};
#[derive(Debug)]
#[repr(C)]

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::time::Time;
use crate::{guid, Boolean, Char16, Event, Guid, Status};
use crate::{Boolean, Char16, Event, Guid, Status, guid};
use bitflags::bitflags;
use core::ffi::c_void;

View file

@ -2,7 +2,7 @@
use crate::firmware_storage::FirmwareVolumeAttributes;
use crate::protocol::block::Lba;
use crate::{guid, Guid, Handle, PhysicalAddress, Status};
use crate::{Guid, Handle, PhysicalAddress, Status, guid};
use core::ffi::c_void;
use core::ops::RangeInclusive;

View file

@ -3,7 +3,7 @@
//! Bindings for HII Database Protocol
use super::{HiiHandle, HiiPackageHeader, HiiPackageListHeader, KeyDescriptor};
use crate::{guid, Guid, Handle, Status};
use crate::{Guid, Handle, Status, guid};
/// EFI_HII_KEYBOARD_LAYOUT
#[derive(Debug)]

View file

@ -3,7 +3,7 @@
use crate::protocol::device_path::DevicePathProtocol;
use crate::table::boot::MemoryType;
use crate::table::system::SystemTable;
use crate::{guid, Guid, Handle, Status};
use crate::{Guid, Handle, Status, guid};
use core::ffi::c_void;
#[derive(Clone, Copy, Debug)]

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::protocol::device_path::DevicePathProtocol;
use crate::{guid, Boolean, Guid, Status};
use crate::{Boolean, Guid, Status, guid};
use core::ffi::c_void;
#[derive(Debug)]

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::table::boot::MemoryAttribute;
use crate::{guid, Guid, PhysicalAddress, Status};
use crate::{Guid, PhysicalAddress, Status, guid};
#[derive(Debug)]
#[repr(C)]

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::table::runtime;
use crate::{guid, Guid, Status};
use crate::{Guid, Status, guid};
#[derive(Debug)]
#[repr(C)]

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Boolean, Char8, Event, Guid, Ipv4Address, MacAddress, Status};
use crate::{Boolean, Char8, Event, Guid, Ipv4Address, MacAddress, Status, guid};
use core::ffi::c_void;
newtype_enum! {

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Boolean, Char16, Char8, Event, Guid, Ipv4Address, Ipv6Address, Status};
use crate::{Boolean, Char8, Char16, Event, Guid, Ipv4Address, Ipv6Address, Status, guid};
use core::ffi::c_void;
use core::fmt::{self, Debug, Formatter};
use core::ptr;

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::protocol::network::ip4::Ip4RouteTable;
use crate::{guid, Char16, Event, Guid, Ipv4Address, MacAddress, Status};
use crate::{Char16, Event, Guid, Ipv4Address, MacAddress, Status, guid};
use core::ffi::c_void;
newtype_enum! {

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Boolean, Char8, Guid, IpAddress, MacAddress, Status};
use crate::{Boolean, Char8, Guid, IpAddress, MacAddress, Status, guid};
use bitflags::bitflags;
use core::ffi::c_void;
use core::fmt::{self, Debug, Formatter};

View file

@ -4,7 +4,7 @@ use core::ffi;
use bitflags::bitflags;
use crate::{guid, Boolean, Event, Guid, IpAddress, MacAddress, Status};
use crate::{Boolean, Event, Guid, IpAddress, MacAddress, Status, guid};
#[derive(Debug)]
#[repr(C)]

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Guid, Status};
use crate::{Guid, Status, guid};
use core::ffi::c_void;
newtype_enum! {

View file

@ -3,7 +3,7 @@
use super::device_path::DevicePathProtocol;
use crate::Status;
use core::ffi::c_void;
use uguid::{guid, Guid};
use uguid::{Guid, guid};
bitflags::bitflags! {
/// In an NVMe command, the `flags` field specifies which cdw (command specific word)

View file

@ -2,7 +2,7 @@
//! `Rng` protocol.
use crate::{guid, Guid, Status};
use crate::{Guid, Status, guid};
newtype_enum! {
/// The algorithms listed are optional, not meant to be exhaustive

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use super::device_path::DevicePathProtocol;
use crate::{guid, Event, Guid, Status};
use crate::{Event, Guid, Status, guid};
use core::ffi::c_void;
pub const SCSI_TARGET_MAX_BYTES: usize = 0x10;

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Char16, Guid};
use crate::{Char16, Guid, guid};
use core::ffi::c_void;
pub type ShellFileHandle = *const c_void;

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{guid, Char16, Char8, Guid};
use crate::{Char8, Char16, Guid, guid};
#[derive(Debug)]
#[repr(C)]

View file

@ -10,7 +10,7 @@
//! [TCG]: https://trustedcomputinggroup.org/
//! [TPM]: https://en.wikipedia.org/wiki/Trusted_Platform_Module
use crate::{guid, Guid, PhysicalAddress, Status};
use crate::{Guid, PhysicalAddress, Status, guid};
use core::ffi::c_void;
/// Information about the protocol and the TPM device.

View file

@ -13,7 +13,7 @@
//! [TPM]: https://en.wikipedia.org/wiki/Trusted_Platform_Module
use super::EventType;
use crate::{guid, Guid, PhysicalAddress, Status};
use crate::{Guid, PhysicalAddress, Status, guid};
use bitflags::bitflags;
use core::ffi::c_void;

View file

@ -4,7 +4,7 @@ use core::ffi;
use bitflags::bitflags;
use crate::{guid, Boolean, Guid, Status};
use crate::{Boolean, Guid, Status, guid};
use super::{AsyncUsbTransferCallback, DataDirection, DeviceRequest, UsbTransferStatus};

View file

@ -2,7 +2,7 @@
use core::ffi;
use crate::{guid, Boolean, Char16, Guid, Status};
use crate::{Boolean, Char16, Guid, Status, guid};
use super::{
AsyncUsbTransferCallback, ConfigDescriptor, DataDirection, DeviceDescriptor, DeviceRequest,

View file

@ -3,10 +3,10 @@
//! UEFI services available at runtime, even after the OS boots.
use crate::capsule::CapsuleHeader;
use crate::table::boot::MemoryDescriptor;
use crate::table::Header;
use crate::table::boot::MemoryDescriptor;
use crate::time::Time;
use crate::{guid, Boolean, Char16, Guid, PhysicalAddress, Status};
use crate::{Boolean, Char16, Guid, PhysicalAddress, Status, guid};
use bitflags::bitflags;
use core::ffi::c_void;

View file

@ -1,10 +1,10 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::protocol::console::{SimpleTextInputProtocol, SimpleTextOutputProtocol};
use crate::table::Header;
use crate::table::boot::BootServices;
use crate::table::configuration::ConfigurationTable;
use crate::table::runtime::RuntimeServices;
use crate::table::Header;
use crate::{Char16, Handle};
use core::mem::size_of;
use core::ptr;

View file

@ -17,10 +17,10 @@ use alloc::vec::Vec;
use log::info;
use uefi::boot::{self, LoadImageSource};
use uefi::prelude::*;
use uefi::proto::BootPolicy;
use uefi::proto::device_path::build::{self, DevicePathBuilder};
use uefi::proto::device_path::{DevicePath, DeviceSubType, DeviceType, LoadedImageDevicePath};
use uefi::proto::loaded_image::LoadedImage;
use uefi::proto::BootPolicy;
/// Get the device path of the shell app. This is the same as the
/// currently-loaded image's device path, but with the file path part changed.

View file

@ -8,7 +8,7 @@ use uefi::boot::{
};
use uefi::mem::memory_map::MemoryType;
use uefi::proto::unsafe_protocol;
use uefi::{boot, guid, system, Event, Guid, Identify};
use uefi::{Event, Guid, Identify, boot, guid, system};
pub fn test() {
test_tpl();

View file

@ -3,11 +3,11 @@
use alloc::string::ToString;
use uefi::boot::{LoadImageSource, SearchType};
use uefi::fs::FileSystem;
use uefi::proto::BootPolicy;
use uefi::proto::console::text::Output;
use uefi::proto::device_path::media::FilePath;
use uefi::proto::device_path::{DevicePath, LoadedImageDevicePath};
use uefi::proto::BootPolicy;
use uefi::{boot, CString16, Identify};
use uefi::{CString16, Identify, boot};
mod memory;
mod misc;

View file

@ -7,7 +7,7 @@ use alloc::vec::Vec;
use uefi::boot::ScopedProtocol;
use uefi::fs::{FileSystem, IoError, IoErrorContext, PathBuf};
use uefi::proto::media::fs::SimpleFileSystem;
use uefi::{cstr16, fs, Status};
use uefi::{Status, cstr16, fs};
/// Tests functionality from the `uefi::fs` module. This test relies on a
/// working File System Protocol, which is tested at a dedicated place.

View file

@ -15,7 +15,7 @@ use uefi::prelude::*;
use uefi::proto::console::serial::Serial;
use uefi::proto::device_path::build::{self, DevicePathBuilder};
use uefi::proto::device_path::messaging::Vendor;
use uefi::{print, println, system, Result};
use uefi::{Result, print, println, system};
mod boot;
mod fs;

View file

@ -2,8 +2,8 @@
use uefi::boot;
use uefi::boot::{OpenProtocolAttributes, OpenProtocolParams};
use uefi::proto::ata::pass_thru::AtaPassThru;
use uefi::proto::ata::AtaRequestBuilder;
use uefi::proto::ata::pass_thru::AtaPassThru;
pub fn test() {
info!("Running ATA PassThru tests");

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::{send_request_to_host, HostRequest};
use crate::{HostRequest, send_request_to_host};
use uefi::boot::{self, OpenProtocolAttributes, OpenProtocolParams};
use uefi::proto::console::gop::{BltOp, BltPixel, FrameBuffer, GraphicsOutput, PixelFormat};

View file

@ -2,7 +2,7 @@
use crate::reconnect_serial_to_console;
use uefi::proto::console::serial::{ControlBits, Serial};
use uefi::{boot, Result, ResultExt, Status};
use uefi::{Result, ResultExt, Status, boot};
// For the duration of this function, the serial device is opened in
// exclusive mode. That means logs will not work, which means we should

View file

@ -80,10 +80,10 @@ fn test_debug_support() {
// make sure that the max processor index is a sane value, i.e. it works
let maximum_processor_index = debug_support.get_maximum_processor_index();
assert_ne!(
maximum_processor_index,
usize::MAX,
"get_maximum_processor_index() returning garbage, unless you really have 18,446,744,073,709,551,615 processors"
);
maximum_processor_index,
usize::MAX,
"get_maximum_processor_index() returning garbage, unless you really have 18,446,744,073,709,551,615 processors"
);
info!("- Architecture: {:?}", debug_support.arch());
info!("- Maximum Processor Index: {:?}", maximum_processor_index);

View file

@ -6,7 +6,7 @@ use uefi::proto::device_path::build::{self, DevicePathBuilder};
use uefi::proto::device_path::text::{
AllowShortcuts, DevicePathFromText, DevicePathToText, DisplayOnly,
};
use uefi::proto::device_path::{messaging, DevicePath, DevicePathNode, LoadedImageDevicePath};
use uefi::proto::device_path::{DevicePath, DevicePathNode, LoadedImageDevicePath, messaging};
use uefi::proto::loaded_image::LoadedImage;
use uefi::proto::media::disk::DiskIo;
use uefi::{boot, cstr16};
@ -240,11 +240,21 @@ fn test_device_path_append() {
);
assert_eq!(
path.append_path(&path2).unwrap().to_string(DisplayOnly(false), AllowShortcuts(false)).unwrap(),
cstr16!("Ata(Primary,Master,0x1)/VenMsg(E0C14753-F9BE-11D2-9A0C-0090273FC14D)/Ata(Primary,Master,0x1)/VenMsg(E0C14753-F9BE-11D2-9A0C-0090273FC14D)")
path.append_path(&path2)
.unwrap()
.to_string(DisplayOnly(false), AllowShortcuts(false))
.unwrap(),
cstr16!(
"Ata(Primary,Master,0x1)/VenMsg(E0C14753-F9BE-11D2-9A0C-0090273FC14D)/Ata(Primary,Master,0x1)/VenMsg(E0C14753-F9BE-11D2-9A0C-0090273FC14D)"
)
);
assert_eq!(
path.append_node(node).unwrap().to_string(DisplayOnly(false), AllowShortcuts(false)).unwrap(),
cstr16!("Ata(Primary,Master,0x1)/VenMsg(E0C14753-F9BE-11D2-9A0C-0090273FC14D)/Ata(Primary,Master,0x1)")
path.append_node(node)
.unwrap()
.to_string(DisplayOnly(false), AllowShortcuts(false))
.unwrap(),
cstr16!(
"Ata(Primary,Master,0x1)/VenMsg(E0C14753-F9BE-11D2-9A0C-0090273FC14D)/Ata(Primary,Master,0x1)"
)
);
}

View file

@ -104,10 +104,12 @@ fn test_component_name<C: ComponentNameInterface>(english: &str) {
.find_map(|handle| {
let component_name = C::open(*handle).ok()?;
assert!(component_name
.supported_languages()
.ok()?
.any(|lang| lang == english));
assert!(
component_name
.supported_languages()
.ok()?
.any(|lang| lang == english)
);
let driver_name = component_name.driver_name(english).ok()?;
if driver_name == fat_driver_name {

View file

@ -7,10 +7,10 @@ use core::ffi::c_void;
use core::pin::Pin;
use core::ptr;
use core::ptr::addr_of;
use uefi::proto::BootPolicy;
use uefi::proto::device_path::build::DevicePathBuilder;
use uefi::proto::media::load_file::{LoadFile, LoadFile2};
use uefi::proto::BootPolicy;
use uefi::{boot, Guid, Handle};
use uefi::{Guid, Handle, boot};
use uefi_raw::protocol::device_path::DevicePathProtocol;
use uefi_raw::protocol::media::{LoadFile2Protocol, LoadFileProtocol};
use uefi_raw::{Boolean, Status};

View file

@ -175,9 +175,11 @@ fn test_existing_file(directory: &mut Directory) {
file.delete().unwrap();
// Verify the file is gone.
assert!(directory
.open(input_file_path, FileMode::Read, FileAttribute::empty())
.is_err());
assert!(
directory
.open(input_file_path, FileMode::Read, FileAttribute::empty())
.is_err()
);
}
/// Test file creation.

View file

@ -2,7 +2,7 @@
use uefi::boot::{self, OpenProtocolParams};
use uefi::proto::loaded_image::LoadedImage;
use uefi::{proto, Identify};
use uefi::{Identify, proto};
pub fn test() {
info!("Testing various protocols");
@ -61,12 +61,14 @@ fn test_protocols_per_handle() {
}
fn test_test_protocol() {
assert!(boot::test_protocol::<LoadedImage>(OpenProtocolParams {
handle: boot::image_handle(),
agent: boot::image_handle(),
controller: None,
})
.unwrap());
assert!(
boot::test_protocol::<LoadedImage>(OpenProtocolParams {
handle: boot::image_handle(),
agent: boot::image_handle(),
controller: None,
})
.unwrap()
);
}
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]

View file

@ -2,11 +2,11 @@
use alloc::vec::Vec;
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
use uefi::proto::device_path::DevicePath;
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
use uefi::proto::network::http::{HttpBinding, HttpHelper};
use uefi::proto::network::ip4config2::Ip4Config2;
use uefi::{boot, Handle};
use uefi::{Handle, boot};
use uefi_raw::protocol::network::http::HttpStatusCode;

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use uefi::proto::network::pxe::{BaseCode, DhcpV4Packet, IpFilter, IpFilters, UdpOpFlags};
use uefi::proto::network::IpAddress;
use uefi::{boot, CStr8};
use uefi::proto::network::pxe::{BaseCode, DhcpV4Packet, IpFilter, IpFilters, UdpOpFlags};
use uefi::{CStr8, boot};
pub fn test() {
// Skip the test if the `pxe` feature is not enabled.

View file

@ -2,9 +2,9 @@
use core::time::Duration;
use uefi::proto::network::snp::{InterruptStatus, ReceiveFlags, SimpleNetwork};
use uefi::proto::network::MacAddress;
use uefi::{boot, Status};
use uefi::proto::network::snp::{InterruptStatus, ReceiveFlags, SimpleNetwork};
use uefi::{Status, boot};
pub fn test() {
info!("Testing the simple network protocol");
@ -78,10 +78,12 @@ pub fn test() {
\x04\x01\x02\x03\x04";
let dest_addr = MacAddress([0xffu8; 32]);
assert!(!simple_network
.get_interrupt_status()
.unwrap()
.contains(InterruptStatus::TRANSMIT));
assert!(
!simple_network
.get_interrupt_status()
.unwrap()
.contains(InterruptStatus::TRANSMIT)
);
// Send the frame
simple_network

View file

@ -2,8 +2,8 @@
use core::time::Duration;
use uefi::boot;
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
use uefi::proto::device_path::DevicePath;
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
use uefi::proto::media::block::BlockIO;
use uefi::proto::nvme::pass_thru::NvmePassThru;
use uefi::proto::nvme::{NvmeQueueType, NvmeRequestBuilder};

View file

@ -5,7 +5,7 @@ use core::ptr;
use core::sync::atomic::{AtomicUsize, Ordering};
use core::time::Duration;
use uefi::proto::pi::mp::MpServices;
use uefi::{boot, Status};
use uefi::{Status, boot};
/// Number of cores qemu is configured to have
const NUM_CPUS: usize = 4;

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use uefi::proto::scsi::pass_thru::ExtScsiPassThru;
use uefi::proto::scsi::ScsiRequestBuilder;
use uefi::proto::scsi::pass_thru::ExtScsiPassThru;
pub fn test() {
info!("Running extended SCSI Pass Thru tests");

View file

@ -2,7 +2,7 @@
use core::cmp::Ordering;
use uefi::proto::string::unicode_collation::{StrConversionError, UnicodeCollation};
use uefi::{boot, CStr16, CStr8};
use uefi::{CStr8, CStr16, boot};
pub fn test() {
info!("Testing the Unicode Collation protocol");

View file

@ -2,7 +2,7 @@
use alloc::vec::Vec;
use uefi::boot;
use uefi::proto::tcg::{v1, v2, AlgorithmId, EventType, HashAlgorithm, PcrIndex};
use uefi::proto::tcg::{AlgorithmId, EventType, HashAlgorithm, PcrIndex, v1, v2};
// Environmental note:
//
@ -264,10 +264,11 @@ pub fn test_tcg_v2() {
// Check that there was no attempt to change the active banks in the
// previous boot.
assert!(tcg
.get_result_of_set_active_pcr_banks()
.expect("get_result_of_set_active_pcr_banks failed")
.is_none());
assert!(
tcg.get_result_of_set_active_pcr_banks()
.expect("get_result_of_set_active_pcr_banks failed")
.is_none()
);
// PCR 8 is initially zero.
assert_eq!(tcg_v2_read_pcr_8(&mut tcg), [0; 20]);

View file

@ -3,7 +3,7 @@
use log::info;
use uefi::prelude::*;
use uefi::runtime::{VariableAttributes, VariableVendor};
use uefi::{guid, runtime, CStr16, Error};
use uefi::{CStr16, Error, guid, runtime};
/// Test variable name.
const NAME: &CStr16 = cstr16!("UefiRsTestVar");

View file

@ -22,7 +22,7 @@
//! [`proto`]: crate::proto
pub use uefi_raw::table::boot::{
EventType, MemoryAttribute, MemoryDescriptor, MemoryType, Tpl, PAGE_SIZE,
EventType, MemoryAttribute, MemoryDescriptor, MemoryType, PAGE_SIZE, Tpl,
};
use crate::data_types::PhysicalAddress;
@ -37,7 +37,7 @@ use crate::proto::{BootPolicy, Protocol, ProtocolPointer};
use crate::runtime::{self, ResetType};
use crate::table::Revision;
use crate::util::opt_nonnull_to_ptr;
use crate::{table, Char16, Error, Event, Guid, Handle, Result, Status, StatusExt};
use crate::{Char16, Error, Event, Guid, Handle, Result, Status, StatusExt, table};
use core::ffi::c_void;
use core::mem::MaybeUninit;
use core::ops::{Deref, DerefMut};

View file

@ -119,11 +119,7 @@ pub trait Align {
fn offset_up_to_alignment(val: usize) -> usize {
assert!(Self::alignment() != 0);
let r = val % Self::alignment();
if r == 0 {
0
} else {
Self::alignment() - r
}
if r == 0 { 0 } else { Self::alignment() - r }
}
/// Round `val` up so that it is aligned.
@ -162,14 +158,14 @@ mod guid;
pub use guid::{Guid, Identify};
pub mod chars;
pub use chars::{Char16, Char8};
pub use chars::{Char8, Char16};
#[macro_use]
mod opaque;
mod strs;
pub use strs::{
CStr16, CStr8, EqStrUntilNul, FromSliceWithNulError, FromStrWithBufError, PoolString,
CStr8, CStr16, EqStrUntilNul, FromSliceWithNulError, FromStrWithBufError, PoolString,
UnalignedCStr16Error,
};

View file

@ -2,8 +2,8 @@
use super::chars::{Char16, NUL_16};
use super::strs::{CStr16, FromSliceWithNulError};
use crate::data_types::strs::EqStrUntilNul;
use crate::data_types::UnalignedSlice;
use crate::data_types::strs::EqStrUntilNul;
use crate::polyfill::vec_into_raw_parts;
use alloc::borrow::{Borrow, ToOwned};
use alloc::string::String;

View file

@ -2,8 +2,8 @@
use uefi_raw::Status;
use super::chars::{Char16, Char8, NUL_16, NUL_8};
use super::UnalignedSlice;
use super::chars::{Char8, Char16, NUL_8, NUL_16};
use crate::mem::PoolAllocation;
use crate::polyfill::maybe_uninit_slice_assume_init_ref;
use core::borrow::Borrow;
@ -801,7 +801,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::{cstr16, cstr8};
use crate::{cstr8, cstr16};
use alloc::format;
use alloc::string::String;

View file

@ -3,7 +3,7 @@
//! Module for directory iteration. See [`UefiDirectoryIter`].
use super::*;
use crate::{cstr16, CStr16, Result};
use crate::{CStr16, Result, cstr16};
use alloc::boxed::Box;
/// Common skip dirs in UEFI/FAT-style file systems.

View file

@ -2,8 +2,8 @@
//! Module for [`FileSystem`].
use crate::fs::*;
use crate::Status;
use crate::fs::*;
use alloc::boxed::Box;
use alloc::string::String;
use alloc::vec;

View file

@ -23,9 +23,9 @@ pub use path::{Components, Path};
pub use pathbuf::PathBuf;
use crate::data_types::chars::NUL_16;
use crate::{cstr16, CStr16, Char16};
pub(super) use validation::validate_path;
use crate::{CStr16, Char16, cstr16};
pub use validation::PathError;
pub(super) use validation::validate_path;
/// The default separator for paths.
pub const SEPARATOR: Char16 = unsafe { Char16::from_u16_unchecked('\\' as u16) };

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::fs::path::Path;
use crate::fs::SEPARATOR;
use crate::fs::path::Path;
use crate::{CStr16, CString16, Char16};
use core::fmt::{Display, Formatter};

View file

@ -8,8 +8,8 @@
//! [`fs`]: crate::fs
use super::Path;
use crate::fs::CHARACTER_DENY_LIST;
use crate::Char16;
use crate::fs::CHARACTER_DENY_LIST;
use core::fmt::{self, Display, Formatter};
/// Errors related to file paths.
@ -68,7 +68,7 @@ pub fn validate_path<P: AsRef<Path>>(path: P) -> Result<(), PathError> {
mod tests {
use super::*;
use crate::fs::PathBuf;
use crate::{cstr16, CString16};
use crate::{CString16, cstr16};
#[test]
fn test_validate_path() {

View file

@ -258,7 +258,7 @@ mod util;
#[cfg(feature = "alloc")]
pub use data_types::CString16;
pub use data_types::{CStr16, CStr8, Char16, Char8, Event, Guid, Handle, Identify};
pub use data_types::{CStr8, CStr16, Char8, Char16, Event, Guid, Handle, Identify};
pub use result::{Error, Result, ResultExt, Status, StatusExt};
/// Re-export ucs2_cstr so that it can be used in the implementation of the
/// cstr16 macro. It is hidden since it's not intended to be used directly.

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use alloc::alloc::{alloc, dealloc, Layout, LayoutError};
use alloc::alloc::{Layout, LayoutError, alloc, dealloc};
use core::error::Error;
use core::fmt;
use core::ptr::NonNull;

View file

@ -349,7 +349,9 @@ impl Drop for MemoryMapBackingMemory {
log::error!("Failed to deallocate memory map: {e:?}");
}
} else {
log::debug!("Boot services are exited. Memory map won't be freed using the UEFI boot services allocator.");
log::debug!(
"Boot services are exited. Memory map won't be freed using the UEFI boot services allocator."
);
}
}
}

View file

@ -210,7 +210,7 @@ mod tests {
let mut buf: Align16<[u8; 16]> = Align16([0; 16]);
let data: &mut SomeDataAlign16 = uefi_function_stub_read(&mut buf.0).unwrap();
assert_eq!(&data.0 .0, &[1, 2, 3, 4]);
assert_eq!(&data.0.0, &[1, 2, 3, 4]);
}
/// This unit tests checks the [`make_boxed`] utility. The test has different code and behavior
@ -234,6 +234,6 @@ mod tests {
#[cfg(feature = "unstable")]
let data: Box<SomeDataAlign16> = make_boxed(fetch_data_fn, Global).unwrap();
assert_eq!(&data.0 .0, &[1, 2, 3, 4]);
assert_eq!(&data.0.0, &[1, 2, 3, 4]);
}
}

View file

@ -5,5 +5,5 @@
//! This includes the system table modules, `Status` codes, etc.
pub use crate::{
boot, cstr16, cstr8, entry, runtime, system, Handle, ResultExt, Status, StatusExt,
Handle, ResultExt, Status, StatusExt, boot, cstr8, cstr16, entry, runtime, system,
};

View file

@ -3,15 +3,15 @@
//! ATA Pass Thru Protocol.
use super::{AtaRequest, AtaResponse};
use crate::StatusExt;
use crate::mem::{AlignedBuffer, PoolAllocation};
use crate::proto::device_path::PoolDevicePathNode;
use crate::StatusExt;
use core::alloc::LayoutError;
use core::ptr::{self, NonNull};
use uefi_macros::unsafe_protocol;
use uefi_raw::Status;
use uefi_raw::protocol::ata::AtaPassThruProtocol;
use uefi_raw::protocol::device_path::DevicePathProtocol;
use uefi_raw::Status;
/// Mode structure with controller-specific information.
pub type AtaPassThruMode = uefi_raw::protocol::ata::AtaPassThruMode;

View file

@ -54,7 +54,7 @@
use crate::proto::unsafe_protocol;
use crate::util::usize_from_u32;
use crate::{boot, Result, StatusExt};
use crate::{Result, StatusExt, boot};
use core::fmt::{Debug, Formatter};
use core::marker::PhantomData;
use core::ptr::{self, NonNull};

View file

@ -82,12 +82,12 @@ pub mod util;
mod device_path_gen;
pub use device_path_gen::{
acpi, bios_boot_spec, end, hardware, media, messaging, DevicePathNodeEnum,
DevicePathNodeEnum, acpi, bios_boot_spec, end, hardware, media, messaging,
};
pub use uefi_raw::protocol::device_path::{DeviceSubType, DeviceType};
use crate::mem::PoolAllocation;
use crate::proto::{unsafe_protocol, ProtocolPointer};
use crate::proto::{ProtocolPointer, unsafe_protocol};
use core::ffi::c_void;
use core::fmt::{self, Debug, Display, Formatter};
use core::ops::Deref;

View file

@ -6,8 +6,8 @@ use super::{DevicePath, DevicePathNode, PoolDevicePath};
use crate::mem::PoolAllocation;
use core::ptr::NonNull;
use uefi_macros::unsafe_protocol;
use uefi_raw::protocol::device_path::DevicePathUtilitiesProtocol;
use uefi_raw::Status;
use uefi_raw::protocol::device_path::DevicePathUtilitiesProtocol;
/// Protocol with utility functions for working with device paths.
#[derive(Debug)]

View file

@ -347,17 +347,19 @@ fn language_to_cstr(language: &str) -> Result<LanguageCStr> {
#[cfg(test)]
mod tests {
use super::*;
use alloc::vec::Vec;
use LanguageIterKind::{V1, V2};
use alloc::vec::Vec;
#[test]
fn test_language_iter_v1() {
// Empty string.
let data = "\0";
assert!(LanguageIter::new(data.as_ptr(), V1)
.unwrap()
.next()
.is_none());
assert!(
LanguageIter::new(data.as_ptr(), V1)
.unwrap()
.next()
.is_none()
);
// Two languages.
let data = "engfra\0";
@ -389,10 +391,12 @@ mod tests {
fn test_language_iter_v2() {
// Empty string.
let data = "\0";
assert!(LanguageIter::new(data.as_ptr(), V2)
.unwrap()
.next()
.is_none());
assert!(
LanguageIter::new(data.as_ptr(), V2)
.unwrap()
.next()
.is_none()
);
// Two languages.
let data = "en;fr\0";

View file

@ -1,8 +1,8 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use super::{File, FileHandle, FileInfo, FromUefi, RegularFile};
use crate::data_types::Align;
use crate::Result;
use crate::data_types::Align;
use core::ffi::c_void;
#[cfg(feature = "alloc")]
use {crate::mem::make_boxed, alloc::boxed::Box};

View file

@ -427,8 +427,8 @@ impl FileProtocolInfo for FileSystemVolumeLabel {}
#[cfg(test)]
mod tests {
use super::*;
use crate::runtime::{Daylight, Time, TimeParams};
use crate::CString16;
use crate::runtime::{Daylight, Time, TimeParams};
use alloc::vec;
fn validate_layout<T: InfoInternal + ?Sized>(info: &T, name: &[Char16]) {

View file

@ -2,15 +2,15 @@
//! LoadFile and LoadFile2 protocols.
use crate::proto::unsafe_protocol;
#[cfg(doc)]
use crate::Status;
use crate::proto::unsafe_protocol;
#[cfg(all(feature = "alloc", feature = "unstable"))]
use alloc::alloc::Global;
use uefi_raw::protocol::media::{LoadFile2Protocol, LoadFileProtocol};
#[cfg(feature = "alloc")]
use {
crate::{mem::make_boxed, proto::device_path::DevicePath, Result, StatusExt},
crate::{Result, StatusExt, mem::make_boxed, proto::device_path::DevicePath},
alloc::boxed::Box,
uefi::proto::BootPolicy,
uefi_raw::Boolean,

View file

@ -3,7 +3,7 @@
//! Partition information protocol.
use crate::proto::unsafe_protocol;
use crate::{guid, Char16, Guid};
use crate::{Char16, Guid, guid};
newtype_enum! {
/// MBR OS type.

View file

@ -9,7 +9,7 @@
use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;
use core::ffi::{c_char, c_void, CStr};
use core::ffi::{CStr, c_char, c_void};
use core::ptr;
use log::debug;

View file

@ -13,10 +13,10 @@ use uefi::boot::ScopedProtocol;
use uefi::prelude::*;
use uefi::proto::unsafe_protocol;
use uefi::{print, println};
use uefi_raw::Ipv4Address;
use uefi_raw::protocol::network::ip4_config2::{
Ip4Config2DataType, Ip4Config2InterfaceInfo, Ip4Config2Policy, Ip4Config2Protocol,
};
use uefi_raw::Ipv4Address;
/// IP4 Config2 [`Protocol`]. Configure IPv4 networking.
///

View file

@ -16,8 +16,8 @@ use crate::{Result, StatusExt};
use core::ffi::c_void;
use core::ptr;
use core::ptr::NonNull;
use uefi_raw::protocol::network::snp::SimpleNetworkProtocol;
use uefi_raw::Boolean;
use uefi_raw::protocol::network::snp::SimpleNetworkProtocol;
pub use uefi_raw::protocol::network::snp::{
InterruptStatus, NetworkMode, NetworkState, NetworkStatistics, ReceiveFlags,

View file

@ -3,15 +3,15 @@
//! NVM Express Pass Thru Protocol.
use super::{NvmeRequest, NvmeResponse};
use crate::StatusExt;
use crate::mem::{AlignedBuffer, PoolAllocation};
use crate::proto::device_path::PoolDevicePathNode;
use crate::StatusExt;
use core::alloc::LayoutError;
use core::ptr::{self, NonNull};
use uefi_macros::unsafe_protocol;
use uefi_raw::Status;
use uefi_raw::protocol::device_path::DevicePathProtocol;
use uefi_raw::protocol::nvme::{NvmExpressCompletion, NvmExpressPassThruProtocol};
use uefi_raw::Status;
/// Nvme Pass Thru Protocol Mode structure.
///

View file

@ -3,17 +3,17 @@
//! Extended SCSI Pass Thru protocols.
use super::{ScsiRequest, ScsiResponse};
use crate::StatusExt;
use crate::mem::{AlignedBuffer, PoolAllocation};
use crate::proto::device_path::PoolDevicePathNode;
use crate::proto::unsafe_protocol;
use crate::StatusExt;
use core::alloc::LayoutError;
use core::ptr::{self, NonNull};
use uefi_raw::Status;
use uefi_raw::protocol::device_path::DevicePathProtocol;
use uefi_raw::protocol::scsi::{
ExtScsiPassThruMode, ExtScsiPassThruProtocol, SCSI_TARGET_MAX_BYTES,
};
use uefi_raw::Status;
/// Structure representing a SCSI target address.
pub type ScsiTarget = [u8; SCSI_TARGET_MAX_BYTES];

View file

@ -3,7 +3,7 @@
//! `ShellParams` protocol
use crate::proto::unsafe_protocol;
use crate::{data_types, Char16};
use crate::{Char16, data_types};
use core::slice::from_raw_parts;
use uefi_raw::protocol::shell_params::ShellParametersProtocol;

View file

@ -5,7 +5,7 @@
//! This protocol is used in the boot services environment to perform
//! lexical comparison functions on Unicode strings for given languages.
use crate::data_types::{CStr16, CStr8};
use crate::data_types::{CStr8, CStr16};
use crate::proto::unsafe_protocol;
use core::cmp::Ordering;
use core::fmt::{self, Display, Formatter};

View file

@ -12,7 +12,7 @@
//! [TCG]: https://trustedcomputinggroup.org/
//! [TPM]: https://en.wikipedia.org/wiki/Trusted_Platform_Module
use super::{v1, AlgorithmId, EventType, HashAlgorithm, PcrIndex};
use super::{AlgorithmId, EventType, HashAlgorithm, PcrIndex, v1};
use crate::data_types::{Align, PhysicalAddress, UnalignedSlice};
use crate::proto::unsafe_protocol;
use crate::util::{ptr_write_unaligned_and_add, usize_from_u32};

View file

@ -95,9 +95,11 @@ mod tests {
assert!(Status::BUFFER_TOO_SMALL.to_result().is_err());
assert_eq!(Status::SUCCESS.to_result_with_val(|| 123).unwrap(), 123);
assert!(Status::WARN_DELETE_FAILURE
.to_result_with_val(|| 123)
.is_err());
assert!(
Status::WARN_DELETE_FAILURE
.to_result_with_val(|| 123)
.is_err()
);
assert!(Status::BUFFER_TOO_SMALL.to_result_with_val(|| 123).is_err());
assert!(Status::SUCCESS.to_result_with_err(|_| 123).is_ok());

View file

@ -16,9 +16,9 @@ use uefi_raw::table::boot::MemoryDescriptor;
#[cfg(feature = "alloc")]
use {
crate::mem::make_boxed,
crate::CString16,
crate::Guid,
crate::mem::make_boxed,
alloc::borrow::ToOwned,
alloc::boxed::Box,
alloc::{vec, vec::Vec},

View file

@ -11,7 +11,7 @@
//!
//! See <https://uefi.org/specs/UEFI/2.10/04_EFI_System_Table.html#efi-configuration-table-properties-table>.
use crate::{guid, Guid};
use crate::{Guid, guid};
use bitflags::bitflags;
use core::ffi::c_void;

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use crate::arch::UefiArch;
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use std::env;
use std::ffi::OsString;
use std::process::Command;

View file

@ -17,9 +17,9 @@ use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::token::Comma;
use syn::{
parenthesized, Abi, Attribute, Field, Fields, FieldsNamed, FieldsUnnamed, File, Item,
ItemConst, ItemMacro, ItemStruct, ItemType, ItemUnion, LitInt, ReturnType, Type, TypeArray,
TypeBareFn, TypePtr, Visibility,
Abi, Attribute, Field, Fields, FieldsNamed, FieldsUnnamed, File, Item, ItemConst, ItemMacro,
ItemStruct, ItemType, ItemUnion, LitInt, ReturnType, Type, TypeArray, TypeBareFn, TypePtr,
Visibility, parenthesized,
};
use walkdir::WalkDir;
@ -492,22 +492,26 @@ mod tests {
};
// Valid fn ptr.
assert!(check_fn_ptr(
&parse_quote! {
unsafe extern "efiapi" fn()
},
src(),
)
.is_ok());
assert!(
check_fn_ptr(
&parse_quote! {
unsafe extern "efiapi" fn()
},
src(),
)
.is_ok()
);
// Valid fn ptr with c-variadics.
assert!(check_fn_ptr(
&parse_quote! {
unsafe extern "C" fn(usize, ...)
},
src(),
)
.is_ok());
assert!(
check_fn_ptr(
&parse_quote! {
unsafe extern "C" fn(usize, ...)
},
src(),
)
.is_ok()
);
// Not `extern efiapi`.
check_fn_err(
@ -545,16 +549,18 @@ mod tests {
#[test]
fn test_struct() {
// Valid struct.
assert!(check_struct(
&parse_quote! {
#[repr(C)]
pub struct S {
pub f: u32,
}
},
src(),
)
.is_ok());
assert!(
check_struct(
&parse_quote! {
#[repr(C)]
pub struct S {
pub f: u32,
}
},
src(),
)
.is_ok()
);
// Missing `pub` on struct.
check_item_err(
@ -637,17 +643,19 @@ mod tests {
#[test]
fn test_union() {
// Valid union.
assert!(check_union(
&parse_quote! {
#[repr(C)]
pub union U {
pub a: u32,
pub b: u64,
}
},
src(),
)
.is_ok());
assert!(
check_union(
&parse_quote! {
#[repr(C)]
pub union U {
pub a: u32,
pub b: u64,
}
},
src(),
)
.is_ok()
);
// Missing `pub` on union.
check_item_err(

View file

@ -2,7 +2,7 @@
use crate::device_path::util::is_doc_attr;
use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens, TokenStreamExt};
use quote::{ToTokens, TokenStreamExt, quote};
use syn::{Attribute, Expr, ExprLit, Field, Ident, Lit, Path, Type, TypeArray};
/// A fixed-size non-array type.

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use super::node::{is_node_attr, Node};
use super::node::{Node, is_node_attr};
use heck::ToUpperCamelCase;
use proc_macro2::{Span, TokenStream};
use quote::quote;

View file

@ -6,7 +6,7 @@ mod node;
mod util;
use crate::opt::GenCodeOpt;
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use fs_err as fs;
use group::NodeGroup;
use proc_macro2::TokenStream;
@ -54,7 +54,7 @@ fn gen_uefi_raw_code_as_string(groups: &[NodeGroup]) -> Result<String> {
use bitflags::bitflags;
use crate::protocol::device_path;
use crate::table::boot::MemoryType;
use crate::{guid, Guid, IpAddress};
use crate::{Guid, IpAddress, guid};
use device_path::DevicePathProtocol as DevicePathHeader;
#[cfg(doc)]
use device_path::DeviceType;

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use std::io::Write;
use std::process::{Command, Stdio};
use std::thread;

View file

@ -2,7 +2,7 @@
use anyhow::Result;
use fatfs::{Date, DateTime, FileSystem, FormatVolumeOptions, FsOptions, Time};
use mbrman::{MBRPartitionEntry, BOOT_INACTIVE, CHS, MBR};
use mbrman::{BOOT_INACTIVE, CHS, MBR, MBRPartitionEntry};
use std::io::{Cursor, Read, Write};
use std::ops::Range;
use std::path::Path;

View file

@ -14,7 +14,7 @@ mod tpm;
mod util;
use crate::opt::{FmtOpt, TestOpt};
use anyhow::{bail, Result};
use anyhow::{Result, bail};
use arch::UefiArch;
use cargo::{Cargo, CargoAction, Feature, Package, TargetTypes};
use clap::Parser;

View file

@ -7,10 +7,10 @@ use crate::pipe::Pipe;
use crate::tpm::Swtpm;
use crate::util::command_to_string;
use crate::{net, platform};
use anyhow::{bail, Context, Result};
use anyhow::{Context, Result, bail};
use ovmf_prebuilt::{FileType, Prebuilt, Source};
use regex::bytes::Regex;
use serde_json::{json, Value};
use serde_json::{Value, json};
use std::env;
use std::ffi::OsString;
use std::io::{BufRead, BufReader, Read, Write};

Some files were not shown because too many files have changed in this diff Show more