]> git.proxmox.com Git - mirror_edk2.git/commitdiff
DynamicTablesPkg: Fix unaligned pointers usage
authorSami Mujawar <sami.mujawar@arm.com>
Tue, 9 Jul 2019 14:58:37 +0000 (15:58 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sun, 29 Mar 2020 16:53:35 +0000 (16:53 +0000)
The VS2017 compiler reports 'warning C4366: The result of
the unary '&' operator may be unaligned' if an address of
an unaligned structure member is passed as an argument to
a function.

Fix this warning by using local variables in place of
unaligned structure members.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c
DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.h

index 40699ce113caa8530c89ac20562cf5abda26b88e..82070403ac8757f54e839fd00eb4acb3292fc60c 100644 (file)
@@ -1066,6 +1066,9 @@ BuildPpttTable (
   EFI_STATUS                      Status;\r
   UINT32                          TableSize;\r
   UINT32                          ProcTopologyStructCount;\r
+  UINT32                          ProcHierarchyNodeCount;\r
+  UINT32                          CacheStructCount;\r
+  UINT32                          IdStructCount;\r
 \r
   UINT32                          ProcHierarchyNodeOffset;\r
   UINT32                          CacheStructOffset;\r
@@ -1113,7 +1116,7 @@ BuildPpttTable (
              CfgMgrProtocol,\r
              CM_NULL_TOKEN,\r
              &ProcHierarchyNodeList,\r
-             &Generator->ProcHierarchyNodeCount\r
+             &ProcHierarchyNodeCount\r
              );\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((\r
@@ -1124,7 +1127,8 @@ BuildPpttTable (
     goto error_handler;\r
   }\r
 \r
-  ProcTopologyStructCount = Generator->ProcHierarchyNodeCount;\r
+  ProcTopologyStructCount = ProcHierarchyNodeCount;\r
+  Generator->ProcHierarchyNodeCount = ProcHierarchyNodeCount;\r
 \r
   // Get the cache info and update the processor topology structure count with\r
   // Cache Type Structures (Type 1)\r
@@ -1132,7 +1136,7 @@ BuildPpttTable (
              CfgMgrProtocol,\r
              CM_NULL_TOKEN,\r
              &CacheStructList,\r
-             &Generator->CacheStructCount\r
+             &CacheStructCount\r
              );\r
   if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {\r
     DEBUG ((\r
@@ -1143,7 +1147,8 @@ BuildPpttTable (
     goto error_handler;\r
   }\r
 \r
-  ProcTopologyStructCount += Generator->CacheStructCount;\r
+  ProcTopologyStructCount += CacheStructCount;\r
+  Generator->CacheStructCount = CacheStructCount;\r
 \r
   // Get the processor hierarchy node ID info and update the processor topology\r
   // structure count with ID Structures (Type 2)\r
@@ -1151,7 +1156,7 @@ BuildPpttTable (
              CfgMgrProtocol,\r
              CM_NULL_TOKEN,\r
              &IdStructList,\r
-             &Generator->IdStructCount\r
+             &IdStructCount\r
              );\r
   if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {\r
     DEBUG ((\r
@@ -1163,7 +1168,8 @@ BuildPpttTable (
     goto error_handler;\r
   }\r
 \r
-  ProcTopologyStructCount += Generator->IdStructCount;\r
+  ProcTopologyStructCount += IdStructCount;\r
+  Generator->IdStructCount = IdStructCount;\r
 \r
   // Allocate Node Indexer array\r
   NodeIndexer = (PPTT_NODE_INDEXER*)AllocateZeroPool (\r
@@ -1475,6 +1481,12 @@ ACPI_PPTT_GENERATOR PpttGenerator = {
 \r
   // Processor topology node count\r
   0,\r
+  // Count of Processor Hierarchy Nodes\r
+  0,\r
+  // Count of Cache Structures\r
+  0,\r
+  // Count of Id Structures\r
+  0,\r
   // Pointer to PPTT Node Indexer\r
   NULL\r
 };\r
index 6a0fdd08e1533c57285f420555586314c70a5ed5..0a14da502d595e27d87262b1bac681318f1d9ced 100644 (file)
@@ -167,6 +167,12 @@ typedef struct AcpiPpttGenerator {
   ACPI_TABLE_GENERATOR  Header;\r
   /// PPTT structure count\r
   UINT32                ProcTopologyStructCount;\r
+  /// Count of Processor Hierarchy Nodes\r
+  UINT32                ProcHierarchyNodeCount;\r
+  /// Count of Cache Structures\r
+  UINT32                CacheStructCount;\r
+  /// Count of Id Structures\r
+  UINT32                IdStructCount;\r
   /// List of indexed CM objects for PPTT generation\r
   PPTT_NODE_INDEXER   * NodeIndexer;\r
   /// Pointer to the start of Processor Hierarchy nodes in\r
@@ -176,13 +182,6 @@ typedef struct AcpiPpttGenerator {
   PPTT_NODE_INDEXER   * CacheStructIndexedList;\r
   /// Pointer to the start of Id Structures in the Node Indexer array\r
   PPTT_NODE_INDEXER   * IdStructIndexedList;\r
-  /// Count of Processor Hierarchy Nodes\r
-  UINT32                ProcHierarchyNodeCount;\r
-  /// Count of Cache Structures\r
-  UINT32                CacheStructCount;\r
-  /// Count of Id Structures\r
-  UINT32                IdStructCount;\r
-\r
 } ACPI_PPTT_GENERATOR;\r
 \r
 #pragma pack()\r