ArmPkg: Fix calculation of offset of chassis SKU Number in SmbiosMiscDxe

The calculation of the chassis SKU number field was being calculated
incorrectly, forgetting that there's one element already present in
the structure.
Fix the calculation and improve code readability by introducing a
SkuNumberField variable.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
This commit is contained in:
Rebecca Cran 2021-03-30 20:16:18 -06:00 committed by mergify[bot]
parent bbeb1bea41
commit 13f32d4a64
1 changed files with 7 additions and 5 deletions

View File

@ -39,6 +39,7 @@ SMBIOS_MISC_TABLE_FUNCTION(MiscChassisManufacturer)
{
CHAR8 *OptionalStrStart;
CHAR8 *StrStart;
UINT8 *SkuNumberField;
UINTN RecordLength;
UINTN ManuStrLen;
UINTN VerStrLen;
@ -117,10 +118,7 @@ SMBIOS_MISC_TABLE_FUNCTION(MiscChassisManufacturer)
ChaNumStrLen = StrLen (ChassisSkuNumber);
ContainedElementCount = InputData->ContainedElementCount;
if (ContainedElementCount > 1) {
ExtendLength = (ContainedElementCount - 1) * sizeof (CONTAINED_ELEMENT);
}
ExtendLength = ContainedElementCount * sizeof (CONTAINED_ELEMENT);
//
// Two zeros following the last string.
@ -149,7 +147,11 @@ SMBIOS_MISC_TABLE_FUNCTION(MiscChassisManufacturer)
(VOID)CopyMem (SmbiosRecord + 1, &ContainedElements, ExtendLength);
//ChassisSkuNumber
*((UINT8 *)SmbiosRecord + sizeof (SMBIOS_TABLE_TYPE3) + ExtendLength) = 5;
SkuNumberField = (UINT8 *)SmbiosRecord +
sizeof (SMBIOS_TABLE_TYPE3) -
sizeof (CONTAINED_ELEMENT) + ExtendLength;
*SkuNumberField = 5;
OptionalStrStart = (CHAR8 *)((UINT8 *)SmbiosRecord + sizeof (SMBIOS_TABLE_TYPE3) +
ExtendLength + 1);