mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 23:41:15 +00:00
arch: smbios: Use struct initialiser where possible
Checking arch v0.1.0 (/home/rob/src/cloud-hypervisor/arch) error: field assignment outside of initializer for an instance created with Default::default() --> arch/src/x86_64/smbios.rs:174:9 | 174 | smbios_biosinfo.typ = BIOS_INFORMATION; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::field-reassign-with-default` implied by `-D warnings` note: consider initializing the variable with `x86_64::smbios::SmbiosBiosInfo { typ: BIOS_INFORMATION, length: mem::size_of::<SmbiosBiosInfo>() as u8, handle: handle, vendor: 1, version: 2, characteristics: PCI_SUPPORTED, characteristics_ext2: IS_VIRTUAL_MACHINE, ..Default::default() }` and removing relevant reassignments --> arch/src/x86_64/smbios.rs:173:9 | 173 | let mut smbios_biosinfo = SmbiosBiosInfo::default(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
f452fe7497
commit
44ac11efc7
@ -170,14 +170,16 @@ pub fn setup_smbios(mem: &GuestMemoryMmap) -> Result<u64> {
|
|||||||
|
|
||||||
{
|
{
|
||||||
handle += 1;
|
handle += 1;
|
||||||
let mut smbios_biosinfo = SmbiosBiosInfo::default();
|
let smbios_biosinfo = SmbiosBiosInfo {
|
||||||
smbios_biosinfo.typ = BIOS_INFORMATION;
|
typ: BIOS_INFORMATION,
|
||||||
smbios_biosinfo.length = mem::size_of::<SmbiosBiosInfo>() as u8;
|
length: mem::size_of::<SmbiosBiosInfo>() as u8,
|
||||||
smbios_biosinfo.handle = handle;
|
handle,
|
||||||
smbios_biosinfo.vendor = 1; // First string written in this section
|
vendor: 1, // First string written in this section
|
||||||
smbios_biosinfo.version = 2; // Second string written in this section
|
version: 2, // Second string written in this section
|
||||||
smbios_biosinfo.characteristics = PCI_SUPPORTED;
|
characteristics: PCI_SUPPORTED,
|
||||||
smbios_biosinfo.characteristics_ext2 = IS_VIRTUAL_MACHINE;
|
characteristics_ext2: IS_VIRTUAL_MACHINE,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
curptr = write_and_incr(mem, smbios_biosinfo, curptr)?;
|
curptr = write_and_incr(mem, smbios_biosinfo, curptr)?;
|
||||||
curptr = write_string(mem, "cloud-hypervisor", curptr)?;
|
curptr = write_string(mem, "cloud-hypervisor", curptr)?;
|
||||||
curptr = write_string(mem, "0", curptr)?;
|
curptr = write_string(mem, "0", curptr)?;
|
||||||
@ -186,12 +188,14 @@ pub fn setup_smbios(mem: &GuestMemoryMmap) -> Result<u64> {
|
|||||||
|
|
||||||
{
|
{
|
||||||
handle += 1;
|
handle += 1;
|
||||||
let mut smbios_sysinfo = SmbiosSysInfo::default();
|
let smbios_sysinfo = SmbiosSysInfo {
|
||||||
smbios_sysinfo.typ = SYSTEM_INFORMATION;
|
typ: SYSTEM_INFORMATION,
|
||||||
smbios_sysinfo.length = mem::size_of::<SmbiosSysInfo>() as u8;
|
length: mem::size_of::<SmbiosSysInfo>() as u8,
|
||||||
smbios_sysinfo.handle = handle;
|
handle,
|
||||||
smbios_sysinfo.manufacturer = 1; // First string written in this section
|
manufacturer: 1, // First string written in this section
|
||||||
smbios_sysinfo.product_name = 2; // Second string written in this section
|
product_name: 2, // Second string written in this section
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
curptr = write_and_incr(mem, smbios_sysinfo, curptr)?;
|
curptr = write_and_incr(mem, smbios_sysinfo, curptr)?;
|
||||||
curptr = write_string(mem, "Cloud Hypervisor", curptr)?;
|
curptr = write_string(mem, "Cloud Hypervisor", curptr)?;
|
||||||
curptr = write_string(mem, "cloud-hypervisor", curptr)?;
|
curptr = write_string(mem, "cloud-hypervisor", curptr)?;
|
||||||
@ -200,25 +204,29 @@ pub fn setup_smbios(mem: &GuestMemoryMmap) -> Result<u64> {
|
|||||||
|
|
||||||
{
|
{
|
||||||
handle += 1;
|
handle += 1;
|
||||||
let mut smbios_sysinfo = SmbiosSysInfo::default();
|
let smbios_sysinfo = SmbiosSysInfo {
|
||||||
smbios_sysinfo.typ = END_OF_TABLE;
|
typ: END_OF_TABLE,
|
||||||
smbios_sysinfo.length = mem::size_of::<SmbiosSysInfo>() as u8;
|
length: mem::size_of::<SmbiosSysInfo>() as u8,
|
||||||
smbios_sysinfo.handle = handle;
|
handle,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
curptr = write_and_incr(mem, smbios_sysinfo, curptr)?;
|
curptr = write_and_incr(mem, smbios_sysinfo, curptr)?;
|
||||||
curptr = write_and_incr(mem, 0 as u8, curptr)?;
|
curptr = write_and_incr(mem, 0 as u8, curptr)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut smbios_ep = Smbios30Entrypoint::default();
|
let mut smbios_ep = Smbios30Entrypoint {
|
||||||
smbios_ep.signature = *SM3_MAGIC_IDENT;
|
signature: *SM3_MAGIC_IDENT,
|
||||||
smbios_ep.length = mem::size_of::<Smbios30Entrypoint>() as u8;
|
length: mem::size_of::<Smbios30Entrypoint>() as u8,
|
||||||
// SMBIOS rev 3.2.0
|
// SMBIOS rev 3.2.0
|
||||||
smbios_ep.majorver = 0x03;
|
majorver: 0x03,
|
||||||
smbios_ep.minorver = 0x02;
|
minorver: 0x02,
|
||||||
smbios_ep.docrev = 0x00;
|
docrev: 0x00,
|
||||||
smbios_ep.revision = 0x01; // SMBIOS 3.0
|
revision: 0x01, // SMBIOS 3.0
|
||||||
smbios_ep.max_size = curptr.unchecked_offset_from(physptr) as u32;
|
max_size: curptr.unchecked_offset_from(physptr) as u32,
|
||||||
smbios_ep.physptr = physptr.0;
|
physptr: physptr.0,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
smbios_ep.checksum = compute_checksum(&smbios_ep);
|
smbios_ep.checksum = compute_checksum(&smbios_ep);
|
||||||
mem.write_obj(smbios_ep, GuestAddress(SMBIOS_START))
|
mem.write_obj(smbios_ep, GuestAddress(SMBIOS_START))
|
||||||
.map_err(|_| Error::WriteSmbiosEp)?;
|
.map_err(|_| Error::WriteSmbiosEp)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user