From 4817953949e939687e428249cea1607cd66a134a Mon Sep 17 00:00:00 2001 From: Sami Mujawar Date: Mon, 5 Aug 2019 16:30:38 +0100 Subject: [PATCH] DynamicTablesPkg: IORT: Fix uninitialized memory usage On enabling the /analyse option the VS2017 compiler reports: warning C6001: Using uninitialized memory. This warning is reported as some variables that were being logged were uninitialised. To fix this, moved the logging code after the variables being logged are initialised. Signed-off-by: Sami Mujawar Reviewed-by: Alexei Fedorov --- .../Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 96 +++++++++---------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c index bd71220ca1..65d006c89e 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c @@ -1738,6 +1738,14 @@ BuildIortTable ( goto error_handler; } TableSize += NodeSize; + + DEBUG (( + DEBUG_INFO, + " ItsGroupNodeCount = %d\n" \ + " ItsGroupOffset = %d\n", + ItsGroupNodeCount, + ItsGroupOffset + )); } // Named Component Nodes @@ -1760,6 +1768,14 @@ BuildIortTable ( goto error_handler; } TableSize += NodeSize; + + DEBUG (( + DEBUG_INFO, + " NamedComponentNodeCount = %d\n" \ + " NamedComponentOffset = %d\n", + NamedComponentNodeCount, + NamedComponentOffset + )); } // Root Complex Nodes @@ -1782,6 +1798,14 @@ BuildIortTable ( goto error_handler; } TableSize += NodeSize; + + DEBUG (( + DEBUG_INFO, + " RootComplexNodeCount = %d\n" \ + " RootComplexOffset = %d\n", + RootComplexNodeCount, + RootComplexOffset + )); } // SMMUv1/SMMUv2 Nodes @@ -1804,6 +1828,14 @@ BuildIortTable ( goto error_handler; } TableSize += NodeSize; + + DEBUG (( + DEBUG_INFO, + " SmmuV1V2NodeCount = %d\n" \ + " SmmuV1V2Offset = %d\n", + SmmuV1V2NodeCount, + SmmuV1V2Offset + )); } // SMMUv3 Nodes @@ -1826,6 +1858,14 @@ BuildIortTable ( goto error_handler; } TableSize += NodeSize; + + DEBUG (( + DEBUG_INFO, + " SmmuV3NodeCount = %d\n" \ + " SmmuV3Offset = %d\n", + SmmuV3NodeCount, + SmmuV3Offset + )); } // PMCG Nodes @@ -1848,6 +1888,14 @@ BuildIortTable ( goto error_handler; } TableSize += NodeSize; + + DEBUG (( + DEBUG_INFO, + " PmcgNodeCount = %d\n" \ + " PmcgOffset = %d\n", + PmcgNodeCount, + PmcgOffset + )); } DEBUG (( @@ -1859,54 +1907,6 @@ BuildIortTable ( TableSize )); - DEBUG (( - DEBUG_INFO, - " ItsGroupNodeCount = %d\n" \ - " ItsGroupOffset = %d\n", - ItsGroupNodeCount, - ItsGroupOffset - )); - - DEBUG (( - DEBUG_INFO, - " NamedComponentNodeCount = %d\n" \ - " NamedComponentOffset = %d\n", - NamedComponentNodeCount, - NamedComponentOffset - )); - - DEBUG (( - DEBUG_INFO, - " RootComplexNodeCount = %d\n" \ - " RootComplexOffset = %d\n", - RootComplexNodeCount, - RootComplexOffset - )); - - DEBUG (( - DEBUG_INFO, - " SmmuV1V2NodeCount = %d\n" \ - " SmmuV1V2Offset = %d\n", - SmmuV1V2NodeCount, - SmmuV1V2Offset - )); - - DEBUG (( - DEBUG_INFO, - " SmmuV3NodeCount = %d\n" \ - " SmmuV3Offset = %d\n", - SmmuV3NodeCount, - SmmuV3Offset - )); - - DEBUG (( - DEBUG_INFO, - " PmcgNodeCount = %d\n" \ - " PmcgOffset = %d\n", - PmcgNodeCount, - PmcgOffset - )); - if (TableSize > MAX_UINT32) { Status = EFI_INVALID_PARAMETER; DEBUG ((