Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix new lints related to derives on a packed struct #646

Merged
merged 1 commit into from
Jan 31, 2023
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
50 changes: 47 additions & 3 deletions uefi/src/proto/device_path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub use device_path_gen::{

use crate::proto::{unsafe_protocol, ProtocolPointer};
use core::ffi::c_void;
use core::fmt::{self, Debug, Formatter};
use core::marker::{PhantomData, PhantomPinned};
use core::mem;
use ptr_meta::Pointee;
Expand Down Expand Up @@ -119,7 +120,7 @@ pub struct DevicePathHeader {
/// See the [module-level documentation] for more details.
///
/// [module-level documentation]: crate::proto::device_path
#[derive(Debug, Eq, PartialEq, Pointee)]
#[derive(Eq, Pointee)]
#[repr(C, packed)]
pub struct DevicePathNode {
header: DevicePathHeader,
Expand Down Expand Up @@ -186,6 +187,21 @@ impl DevicePathNode {
}
}

impl Debug for DevicePathNode {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.debug_struct("DevicePathNode")
.field("header", &self.header)
.field("data", &&self.data)
.finish()
}
}

impl PartialEq for DevicePathNode {
fn eq(&self, other: &Self) -> bool {
self.header == other.header && self.data == other.data
}
}

/// A single device path instance that ends with either an [`END_INSTANCE`]
/// or [`END_ENTIRE`] node. Use [`DevicePath::instance_iter`] to get the
/// path instances in a [`DevicePath`].
Expand All @@ -196,7 +212,7 @@ impl DevicePathNode {
/// [`END_INSTANCE`]: DeviceSubType::END_INSTANCE
/// [module-level documentation]: crate::proto::device_path
#[repr(C, packed)]
#[derive(Debug, Eq, PartialEq, Pointee)]
#[derive(Eq, Pointee)]
pub struct DevicePathInstance {
data: [u8],
}
Expand All @@ -216,6 +232,20 @@ impl DevicePathInstance {
}
}

impl Debug for DevicePathInstance {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.debug_struct("DevicePathInstance")
.field("data", &&self.data)
.finish()
}
}

impl PartialEq for DevicePathInstance {
fn eq(&self, other: &Self) -> bool {
self.data == other.data
}
}

/// Device path protocol.
///
/// A device path contains one or more device path instances made of up
Expand All @@ -227,7 +257,7 @@ impl DevicePathInstance {
/// [`END_ENTIRE`]: DeviceSubType::END_ENTIRE
#[repr(C, packed)]
#[unsafe_protocol("09576e91-6d3f-11d2-8e39-00a0c969723b")]
#[derive(Debug, Eq, PartialEq, Pointee)]
#[derive(Eq, Pointee)]
pub struct DevicePath {
data: [u8],
}
Expand Down Expand Up @@ -302,6 +332,20 @@ impl DevicePath {
}
}

impl Debug for DevicePath {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
f.debug_struct("DevicePath")
.field("data", &&self.data)
.finish()
}
}

impl PartialEq for DevicePath {
fn eq(&self, other: &Self) -> bool {
self.data == other.data
}
}

/// Iterator over the [`DevicePathInstance`]s in a [`DevicePath`].
///
/// This struct is returned by [`DevicePath::instance_iter`].
Expand Down