Page MenuHomeFreeBSD

bhyve: Address an unused parameter warning in the smbios code
ClosedPublic

Authored by markj on Nov 6 2022, 7:37 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 23 2024, 12:30 AM
Unknown Object (File)
Feb 15 2024, 8:44 AM
Unknown Object (File)
Feb 15 2024, 8:43 AM
Unknown Object (File)
Feb 15 2024, 8:43 AM
Unknown Object (File)
Feb 15 2024, 8:43 AM
Unknown Object (File)
Feb 15 2024, 8:11 AM
Unknown Object (File)
Feb 13 2024, 11:34 AM
Unknown Object (File)
Jan 23 2024, 6:40 PM
Subscribers

Details

Summary

The compiler was warning that the "size" parameter to
smbios_generic_initializer() was unused. This parameter is apparently
used to populate the "maximum structure size" field in the SMBIOS entry
point, but we are always setting it to zero, apparently without ill
effect. The SMBIOS specification doesn't really describe how it is to
be used, and FreeBSD and Linux appear to ignore it. So just remove all
of the code used to initialize this field.

No functional change intended.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Nov 6 2022, 7:37 PM

The SMBIOS specification describes the field as:

Size of the largest SMBIOS structure, in bytes, and encompasses
the structure’s formatted area and text strings

It's also part of the conformance guidelines:

The following conformance requirements apply for SMBIOS 2.5 or later implementations.
...
3. The structure-table is traversable and conforms to the entry-point specifications:
   ...
   3.7 The maximum structure size (formatted area plus its string-pool) is less than or equal to the Maximum
       Structure Size specified by the entry-point.

I think it's intended to be used for buffer allocations. An OS can allocate a buffer of that size and it's guaranteed that every smbios structure fits into the buffer.
It shouldn't be hard to correctly implement the maxssize field. So, I'd prefer to make use of the size parameter instead of dropping it.

I agree with Corvin that I'd rather us fix it to be the right value. I suspect it's just missing code to initialize *size in the various callbacks?

Implement the maximum structure size.

Rather than making each table handler fill it out, just change smbios_build()
to compare the beginning and end pointers of each table and keep track of
the maximum.

This revision is now accepted and ready to land.Nov 15 2022, 6:27 AM
jhb added inline comments.
usr.sbin/bhyve/smbiostbl.c
929

Nice, this is a much better fix, yes.