From: "Rebecca Cran" <rebecca@nuviainc.com>
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@nuviainc.com>,
Leif Lindholm <leif@nuviainc.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>
Subject: [PATCH 4/5] ArmPkg: Fix calculation of offset of chassis SKU Number in SmbiosMiscDxe
Date: Tue, 30 Mar 2021 20:16:18 -0600 [thread overview]
Message-ID: <20210331021619.19761-5-rebecca@nuviainc.com> (raw)
In-Reply-To: <20210331021619.19761-1-rebecca@nuviainc.com>
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>
---
ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c b/ArmPkg/Universal/Smbios/SmbiosMiscDxe/Type03/MiscChassisManufacturerFunction.c
index 344343ed60a5..66e3e5327fc3 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);
--
2.26.2
next prev parent reply other threads:[~2021-03-31 2:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 2:16 [PATCH 0/5] ArmPkg: OemMiscLib and Universal/Smbios improvements and fixes Rebecca Cran
2021-03-31 2:16 ` [PATCH 1/5] ArmPkg: Allow platforms to override PCI supported state in SmbiosMiscDxe Rebecca Cran
2021-04-13 16:51 ` Leif Lindholm
2021-04-13 16:53 ` Ard Biesheuvel
2021-04-14 1:44 ` Rebecca Cran
2021-04-14 1:41 ` Rebecca Cran
2021-03-31 2:16 ` [PATCH 2/5] ArmPkg: Allow platforms to supply more data for SMBIOS Type3 record Rebecca Cran
2021-03-31 2:16 ` [PATCH 3/5] ArmPkg: Allow platforms to report their boot status via OemMiscLib call Rebecca Cran
2021-03-31 2:16 ` Rebecca Cran [this message]
2021-03-31 2:16 ` [PATCH 5/5] ArmPkg: Fix typo of Manufacturer in comment in SmbiosMiscDxe Rebecca Cran
2021-04-13 16:25 ` [PATCH 0/5] ArmPkg: OemMiscLib and Universal/Smbios improvements and fixes Leif Lindholm
2021-04-14 1:42 ` Rebecca Cran
2021-04-27 12:56 ` Leif Lindholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210331021619.19761-5-rebecca@nuviainc.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox