Skip to content

Commit

Permalink
Merge pull request #646 from nicholasbishop/bishop-fix-packed-slice
Browse files Browse the repository at this point in the history
Fix new lints related to derives on a packed struct
  • Loading branch information
phip1611 authored Jan 31, 2023
2 parents aa9e485 + c44bf3e commit c685730
Showing 1 changed file with 47 additions and 3 deletions.
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

0 comments on commit c685730

Please sign in to comment.