arch: improve some structures in smbios code

There is no need to manually implement Clone for some structures.

It is better to explicitly spell out repr(C) to avoid the compiler
reordering the fields.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2022-08-04 10:36:52 +00:00 committed by Rob Bradford
parent dc75519372
commit a62b611659

View File

@ -75,8 +75,9 @@ fn compute_checksum<T: Copy>(v: &T) -> u8 {
(!checksum).wrapping_add(1)
}
#[repr(C)]
#[repr(packed)]
#[derive(Default, Copy)]
#[derive(Default, Copy, Clone)]
pub struct Smbios30Entrypoint {
pub signature: [u8; 5usize],
pub checksum: u8,
@ -90,14 +91,9 @@ pub struct Smbios30Entrypoint {
pub physptr: u64,
}
impl Clone for Smbios30Entrypoint {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[repr(packed)]
#[derive(Default, Copy)]
#[derive(Default, Copy, Clone)]
pub struct SmbiosBiosInfo {
pub typ: u8,
pub length: u8,
@ -112,14 +108,9 @@ pub struct SmbiosBiosInfo {
pub characteristics_ext2: u8,
}
impl Clone for SmbiosBiosInfo {
fn clone(&self) -> Self {
*self
}
}
#[repr(C)]
#[repr(packed)]
#[derive(Default, Copy)]
#[derive(Default, Copy, Clone)]
pub struct SmbiosSysInfo {
pub typ: u8,
pub length: u8,
@ -134,12 +125,6 @@ pub struct SmbiosSysInfo {
pub family: u8,
}
impl Clone for SmbiosSysInfo {
fn clone(&self) -> Self {
*self
}
}
// SAFETY: These data structures only contain a series of integers
unsafe impl ByteValued for Smbios30Entrypoint {}
unsafe impl ByteValued for SmbiosBiosInfo {}