diff options
author | Rebecca Cran <rebecca@nuviainc.com> | 2021-03-30 20:16:18 -0600 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2021-04-27 12:46:26 +0000 |
commit | 13f32d4a642e8af489e75e4446a76de1bb30b011 (patch) | |
tree | fab13108d8b06e0793baeb57d52db392c772875b /ArmPkg/Universal/Smbios/SmbiosMiscDxe | |
parent | bbeb1bea4166c577499a26b5097bab4d69829d94 (diff) | |
download | edk2-13f32d4a642e8af489e75e4446a76de1bb30b011.zip edk2-13f32d4a642e8af489e75e4446a76de1bb30b011.tar.gz edk2-13f32d4a642e8af489e75e4446a76de1bb30b011.tar.bz2 |
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>
Diffstat (limited to 'ArmPkg/Universal/Smbios/SmbiosMiscDxe')
-rw-r--r-- | ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c index 344343e..66e3e53 100644 --- a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c +++ b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c @@ -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);
|