public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Alexei.Fedorov@arm.com, Sami Mujawar <sami.mujawar@arm.com>,
	Evan Lloyd <evan.lloyd@arm.com>,
	Jaben Carsey <jaben.carsey@intel.com>,
	Ruiyu Ni <ruiyu.ni@intel.com>
Subject: [patch V2 2/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
Date: Wed,  6 Jun 2018 20:49:52 +0800	[thread overview]
Message-ID: <20180606124952.77236-3-dandan.bi@intel.com> (raw)
In-Reply-To: <20180606124952.77236-1-dandan.bi@intel.com>

1. Separate variable definition and initialization.
2. Make the variable naming following Edk2 rule.

V2: Remove the updates of guard macros in header files.

Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Evan Lloyd <evan.lloyd@arm.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../UefiShellAcpiViewCommandLib/AcpiParser.c       | 44 ++++++++++------
 .../UefiShellAcpiViewCommandLib/AcpiTableParser.c  | 50 +++++++++----------
 .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 58 ++++++++++++++--------
 .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 10 ++--
 .../Parsers/Dbg2/Dbg2Parser.c                      |  5 +-
 .../Parsers/Gtdt/GtdtParser.c                      |  5 +-
 .../Parsers/Iort/IortParser.c                      | 26 +++++-----
 .../Parsers/Madt/MadtParser.c                      |  4 +-
 .../Parsers/Rsdp/RsdpParser.c                      | 10 +++-
 .../Parsers/Slit/SlitParser.c                      | 44 ++++++++--------
 .../Parsers/Spcr/SpcrParser.c                      | 10 +++-
 .../Parsers/Srat/SratParser.c                      | 21 +++++---
 .../UefiShellAcpiViewCommandLib.c                  |  5 +-
 .../UefiShellAcpiViewCommandLib.inf                |  3 ++
 14 files changed, 178 insertions(+), 117 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
index 088575d0144..6d3bc451acd 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c
@@ -19,10 +19,19 @@
 
 STATIC UINT32   gIndent;
 STATIC UINT32   mTableErrorCount;
 STATIC UINT32   mTableWarningCount;
 
+STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
+
+/**
+  An ACPI_PARSER array describing the ACPI header.
+**/
+STATIC CONST ACPI_PARSER AcpiHeaderParser[] = {
+  PARSE_ACPI_HEADER (&AcpiHdrInfo)
+};
+
 /**
   This function resets the ACPI table error counter to Zero.
 **/
 VOID
 ResetErrorCount (
@@ -112,14 +121,17 @@ VerifyChecksum (
   IN BOOLEAN Log,
   IN UINT8*  Ptr,
   IN UINT32  Length
   )
 {
-  UINTN ByteCount = 0;
-  UINT8 Checksum = 0;
+  UINTN ByteCount;
+  UINT8 Checksum;
   UINTN OriginalAttribute;
 
+  ByteCount = 0;
+  Checksum = 0;
+
   while (ByteCount < Length) {
     Checksum += *(Ptr++);
     ByteCount++;
   }
 
@@ -164,15 +176,18 @@ EFIAPI
 DumpRaw (
   IN UINT8* Ptr,
   IN UINT32 Length
   )
 {
-  UINTN ByteCount = 0;
+  UINTN ByteCount;
   UINTN PartLineChars;
-  UINTN AsciiBufferIndex = 0;
+  UINTN AsciiBufferIndex;
   CHAR8 AsciiBuffer[17];
 
+  ByteCount = 0;
+  AsciiBufferIndex = 0;
+
   Print (L"Address  : 0x%p\n", Ptr);
   Print (L"Length   : %d\n", Length);
 
   while (ByteCount < Length) {
     if ((ByteCount & 0x0F) == 0) {
@@ -275,11 +290,14 @@ DumpUint64 (
   )
 {
   // Some fields are not aligned and this causes alignment faults
   // on ARM platforms if the compiler generates LDRD instructions.
   // Perform word access so that LDRD instructions are not generated.
-  UINT64 Val = *(UINT32*)(Ptr + sizeof (UINT32));
+  UINT64 Val;
+
+  Val = *(UINT32*)(Ptr + sizeof (UINT32));
+
   Val <<= 32;
   Val |= *(UINT32*)Ptr;
 
   Print (Format, Val);
 }
@@ -454,17 +472,20 @@ ParseAcpi (
   IN CONST ACPI_PARSER* Parser,
   IN UINT32             ParserItems
 )
 {
   UINT32  Index;
-  UINT32  Offset = 0;
+  UINT32  Offset;
+  BOOLEAN HighLight;
+
+  Offset = 0;
 
   // Increment the Indent
   gIndent += Indent;
 
   if (Trace && (AsciiName != NULL)){
-    BOOLEAN HighLight = GetColourHighlighting ();
+    HighLight = GetColourHighlighting ();
     UINTN   OriginalAttribute;
 
     if (HighLight) {
       OriginalAttribute = gST->ConOut->Mode->Attribute;
       gST->ConOut->SetAttribute (
@@ -618,15 +639,10 @@ UINT32
 EFIAPI
 DumpAcpiHeader (
   IN UINT8* Ptr
   )
 {
-  ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
-  ACPI_PARSER AcpiHeaderParser[] = {
-    PARSE_ACPI_HEADER (&AcpiHdrInfo)
-  };
-
   return ParseAcpi (
            TRUE,
            0,
            "ACPI Table Header",
            Ptr,
@@ -656,14 +672,10 @@ ParseAcpiHeader (
   OUT CONST UINT32** Length,
   OUT CONST UINT8**  Revision
   )
 {
   UINT32                        BytesParsed;
-  ACPI_DESCRIPTION_HEADER_INFO  AcpiHdrInfo;
-  ACPI_PARSER AcpiHeaderParser[] = {
-    PARSE_ACPI_HEADER (&AcpiHdrInfo)
-  };
 
   BytesParsed = ParseAcpi (
                   FALSE,
                   0,
                   NULL,
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
index 7b1a02cad3e..fff5757bf58 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
@@ -43,36 +43,36 @@ EFIAPI
 RegisterParser (
   IN  UINT32                  Signature,
   IN  PARSE_ACPI_TABLE_PROC   ParserProc
   )
 {
-  UINT32 index;
+  UINT32 Index;
 
   if ((ParserProc == NULL) || (Signature == ACPI_PARSER_SIGNATURE_NULL)) {
     return EFI_INVALID_PARAMETER;
   }
 
   // Search if a parser is already installed
-  for (index = 0;
-       index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
-       index++)
+  for (Index = 0;
+       Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
+       Index++)
   {
-    if (Signature == mTableParserList[index].Signature) {
-      if (mTableParserList[index].Parser != NULL) {
+    if (Signature == mTableParserList[Index].Signature) {
+      if (mTableParserList[Index].Parser != NULL) {
         return EFI_ALREADY_STARTED;
       }
     }
   }
 
   // Find the first free slot and register the parser
-  for (index = 0;
-      index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
-      index++)
+  for (Index = 0;
+      Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
+      Index++)
   {
-    if (mTableParserList[index].Signature == ACPI_PARSER_SIGNATURE_NULL) {
-      mTableParserList[index].Signature = Signature;
-      mTableParserList[index].Parser = ParserProc;
+    if (mTableParserList[Index].Signature == ACPI_PARSER_SIGNATURE_NULL) {
+      mTableParserList[Index].Signature = Signature;
+      mTableParserList[Index].Parser = ParserProc;
       return EFI_SUCCESS;
     }
   }
 
   // No free slot found
@@ -94,23 +94,23 @@ EFI_STATUS
 EFIAPI
 DeregisterParser (
   IN  UINT32                  Signature
   )
 {
-  UINT32 index;
+  UINT32 Index;
 
   if (Signature == ACPI_PARSER_SIGNATURE_NULL) {
     return EFI_INVALID_PARAMETER;
   }
 
-  for (index = 0;
-       index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
-       index++)
+  for (Index = 0;
+       Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
+       Index++)
   {
-    if (Signature == mTableParserList[index].Signature) {
-      mTableParserList[index].Signature = ACPI_PARSER_SIGNATURE_NULL;
-      mTableParserList[index].Parser = NULL;
+    if (Signature == mTableParserList[Index].Signature) {
+      mTableParserList[Index].Signature = ACPI_PARSER_SIGNATURE_NULL;
+      mTableParserList[Index].Parser = NULL;
       return EFI_SUCCESS;
     }
   }
 
   // No matching registered parser found.
@@ -135,22 +135,22 @@ EFIAPI
 GetParser (
   IN  UINT32                   Signature,
   OUT PARSE_ACPI_TABLE_PROC *  ParserProc
   )
 {
-  UINT32 index;
+  UINT32 Index;
 
   if ((ParserProc == NULL) || (Signature == ACPI_PARSER_SIGNATURE_NULL)) {
     return EFI_INVALID_PARAMETER;
   }
 
-  for (index = 0;
-       index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
-       index++)
+  for (Index = 0;
+       Index < (sizeof (mTableParserList) / sizeof (mTableParserList[0]));
+       Index++)
   {
-    if (Signature == mTableParserList[index].Signature) {
-      *ParserProc = mTableParserList[index].Parser;
+    if (Signature == mTableParserList[Index].Signature) {
+      *ParserProc = mTableParserList[Index].Parser;
       return EFI_SUCCESS;
     }
   }
 
   // No matching registered parser found.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index f5602e94291..47ce93f104b 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -120,12 +120,15 @@ DumpAcpiTableToFile (
   IN CONST UINTN   Length
   )
 {
   EFI_STATUS         Status;
   CHAR16             FileNameBuffer[MAX_FILE_NAME_LEN];
-  SHELL_FILE_HANDLE  DumpFileHandle = NULL;
-  UINTN              TransferBytes = Length;
+  SHELL_FILE_HANDLE  DumpFileHandle;
+  UINTN              TransferBytes;
+
+  DumpFileHandle = NULL;
+  TransferBytes = Length;
 
   UnicodeSPrint (
     FileNameBuffer,
     sizeof (FileNameBuffer),
     L".\\%s%04d.bin",
@@ -184,24 +187,29 @@ ProcessTableReportOptions (
   IN CONST UINT8*  TablePtr,
   IN CONST UINT32  Length
   )
 {
   UINTN   OriginalAttribute;
-  UINT8*  SignaturePtr = (UINT8*)(UINTN)&Signature;
-  BOOLEAN Log = FALSE;
-  BOOLEAN HighLight = GetColourHighlighting ();
+  UINT8*  SignaturePtr;
+  BOOLEAN Log;
+  BOOLEAN HighLight;
+
+  SignaturePtr = (UINT8*)(UINTN)&Signature;
+  Log = FALSE;
+  HighLight = GetColourHighlighting ();
+
   switch (GetReportOption ()) {
-    case EREPORT_ALL:
+    case ReportAll:
       Log = TRUE;
       break;
-    case EREPORT_SELECTED:
+    case ReportSelected:
       if (Signature == GetSelectedAcpiTable ()) {
         Log = TRUE;
         mSelectedAcpiTableFound = TRUE;
       }
       break;
-    case EREPORT_TABLE_LIST:
+    case ReportTableList:
       if (mTableCount == 0) {
         if (HighLight) {
           OriginalAttribute = gST->ConOut->Mode->Attribute;
           gST->ConOut->SetAttribute (
                          gST->ConOut,
@@ -221,17 +229,17 @@ ProcessTableReportOptions (
         SignaturePtr[1],
         SignaturePtr[2],
         SignaturePtr[3]
         );
       break;
-    case EREPORT_DUMP_BIN_FILE:
+    case ReportDumpBinFile:
       if (Signature == GetSelectedAcpiTable ()) {
         mSelectedAcpiTableFound = TRUE;
         DumpAcpiTableToFile (TablePtr, Length);
       }
       break;
-    case EREPORT_MAX:
+    case ReportMax:
       // We should never be here.
       // This case is only present to prevent compiler warning.
       break;
   } // switch
 
@@ -271,13 +279,15 @@ STATIC
 UINT32
 ConvertStrToAcpiSignature (
   IN  CONST CHAR16* Str
   )
 {
-  UINT8 Index = 0;
+  UINT8 Index;
   CHAR8 Ptr[4];
 
+  Index = 0;
+
   // Convert to Upper case and convert to ASCII
   while ((Index < 4) && (Str[Index] != 0)) {
     if (Str[Index] >= L'a' && Str[Index] <= L'z') {
       Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
     } else {
@@ -369,16 +379,16 @@ AcpiView (
       );
     return EFI_NOT_FOUND;
   }
 
   ReportOption = GetReportOption ();
-  if (EREPORT_TABLE_LIST != ReportOption) {
-    if (((EREPORT_SELECTED == ReportOption)  ||
-         (EREPORT_DUMP_BIN_FILE == ReportOption)) &&
+  if (ReportTableList != ReportOption) {
+    if (((ReportSelected == ReportOption)  ||
+         (ReportDumpBinFile == ReportOption)) &&
         (!mSelectedAcpiTableFound)) {
       Print (L"\nRequested ACPI Table not found.\n");
-    } else if (EREPORT_DUMP_BIN_FILE != ReportOption) {
+    } else if (ReportDumpBinFile != ReportOption) {
       OriginalAttribute = gST->ConOut->Mode->Attribute;
 
       Print (L"\nTable Statistics:\n");
 
       if (GetColourHighlighting ()) {
@@ -424,27 +434,31 @@ ShellCommandRunAcpiView (
   IN EFI_HANDLE        ImageHandle,
   IN EFI_SYSTEM_TABLE* SystemTable
   )
 {
   EFI_STATUS         Status;
-  SHELL_STATUS       ShellStatus = SHELL_SUCCESS;
-  LIST_ENTRY*        Package = NULL;
+  SHELL_STATUS       ShellStatus;
+  LIST_ENTRY*        Package;
   CHAR16*            ProblemParam;
   CONST CHAR16*      Temp;
   CHAR8              ColourOption[8];
-  SHELL_FILE_HANDLE  TmpDumpFileHandle = NULL;
+  SHELL_FILE_HANDLE  TmpDumpFileHandle;
 
   // Set Defaults
-  mReportType = EREPORT_ALL;
+  mReportType = ReportAll;
   mTableCount = 0;
   mBinTableCount = 0;
   mSelectedAcpiTable = 0;
   mSelectedAcpiTableName = NULL;
   mSelectedAcpiTableFound = FALSE;
   mVerbose = TRUE;
   mConsistencyCheck = TRUE;
 
+  ShellStatus = SHELL_SUCCESS;
+  Package = NULL;
+  TmpDumpFileHandle = NULL;
+
   // Reset The error/warning counters
   ResetErrorCount ();
   ResetWarningCount ();
 
   Status = ShellCommandLineParse (ParamList, &Package, &ProblemParam, TRUE);
@@ -545,23 +559,23 @@ ShellCommandRunAcpiView (
           SetColourHighlighting (FALSE);
         }
       }
 
       if (ShellCommandLineGetFlag (Package, L"-l")) {
-        mReportType = EREPORT_TABLE_LIST;
+        mReportType = ReportTableList;
       } else {
         mSelectedAcpiTableName = ShellCommandLineGetValue (Package, L"-s");
         if (mSelectedAcpiTableName != NULL) {
           mSelectedAcpiTable = (UINT32)ConvertStrToAcpiSignature (
                                          mSelectedAcpiTableName
                                          );
-          mReportType = EREPORT_SELECTED;
+          mReportType = ReportSelected;
 
           if (ShellCommandLineGetFlag (Package, L"-d"))  {
             // Create a temporary file to check if the media is writable.
             CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
-            mReportType = EREPORT_DUMP_BIN_FILE;
+            mReportType = ReportDumpBinFile;
 
             UnicodeSPrint (
               FileNameBuffer,
               sizeof (FileNameBuffer),
               L".\\%s%04d.tmp",
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
index b035395a721..615686dde83 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -31,15 +31,15 @@
 
 /**
   The EREPORT_OPTION enum describes ACPI table Reporting options.
 **/
 typedef enum ReportOption {
-  EREPORT_ALL,            ///< Report All tables.
-  EREPORT_SELECTED,       ///< Report Selected table.
-  EREPORT_TABLE_LIST,     ///< Report List of tables.
-  EREPORT_DUMP_BIN_FILE,  ///< Dump selected table to a file.
-  EREPORT_MAX
+  ReportAll,            ///< Report All tables.
+  ReportSelected,       ///< Report Selected table.
+  ReportTableList,      ///< Report List of tables.
+  ReportDumpBinFile,    ///< Dump selected table to a file.
+  ReportMax,
 } EREPORT_OPTION;
 
 /**
   This function resets the ACPI table error counter to Zero.
 **/
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
index 7f66bce074e..bc8b7b00e38 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
@@ -110,11 +110,14 @@ EFIAPI
 ValidateNameSpaceStrLen (
   IN UINT8* Ptr,
   IN VOID*  Context
   )
 {
-  UINT16 NameSpaceStrLen = *(UINT16*)Ptr;
+  UINT16 NameSpaceStrLen;
+
+  NameSpaceStrLen = *(UINT16*)Ptr;
+
   if (NameSpaceStrLen < 2) {
     IncrementErrorCount ();
     Print (
       L"\nERROR: NamespaceString Length = %d. If no Namespace device exists,\n"
        "    then NamespaceString[] must contain a period '.'",
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
index 30cf3e14f7e..3a3cee948ad 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
@@ -136,11 +136,14 @@ EFIAPI
 ValidateGtBlockTimerCount (
   IN UINT8* Ptr,
   IN VOID*  Context
   )
 {
-  UINT32 BlockTimerCount = *(UINT32*)Ptr;
+  UINT32 BlockTimerCount;
+
+  BlockTimerCount = *(UINT32*)Ptr;
+
   if (BlockTimerCount > 8) {
     IncrementErrorCount ();
     Print (
       L"\nERROR: Timer Count = %d. Max Timer Count is 8.",
       BlockTimerCount
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
index 704dfc407cc..fb0abe3c43b 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
@@ -25,17 +25,17 @@ STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
 
 /**
   The EIORT_NODE enum describes the IORT Node types.
 **/
 typedef enum IortNode {
-  EIORT_NODE_ITS_GROUP,        ///< ITS Group node
-  EIORT_NODE_NAMED_COMPONENT,  ///< Named Component node
-  EIORT_NODE_ROOT_COMPLEX,     ///< Root Complex node
-  EIORT_NODE_SMMUV1_V2,        ///< SMMU v1/v2 node
-  EIORT_NODE_SMMUV3,           ///< SMMU v3 node
-  EIORT_NODE_PMCG,             ///< PMC group node
-  EIORT_NODE_MAX
+  Iort_Node_ITS_Group,        ///< ITS Group node
+  Iort_Node_Named_Component,  ///< Named Component node
+  Iort_Node_Root_Complex,     ///< Root Complex node
+  Iort_Node_SMMUV1_V2,        ///< SMMU v1/v2 node
+  Iort_Node_SMMUV3,           ///< SMMU v3 node
+  Iort_Node_PMCG,             ///< PMC group node
+  Iort_Node_Max
 } EIORT_NODE;
 
 // Local Variables
 STATIC CONST UINT32* IortNodeCount;
 STATIC CONST UINT32* IortNodeOffset;
@@ -663,49 +663,49 @@ ParseAcpiIort (
 
     PrintFieldName (2, L"* Node Offset *");
     Print (L"0x%x\n", Offset);
 
     switch (*IortNodeType) {
-      case EIORT_NODE_ITS_GROUP:
+      case Iort_Node_ITS_Group:
         DumpIortNodeIts (
           NodePtr,
           *IortNodeLength
           );
         break;
-      case EIORT_NODE_NAMED_COMPONENT:
+      case Iort_Node_Named_Component:
         DumpIortNodeNamedComponent (
           NodePtr,
           *IortNodeLength,
           *IortIdMappingCount,
           *IortIdMappingOffset
           );
         break;
-      case EIORT_NODE_ROOT_COMPLEX:
+      case Iort_Node_Root_Complex:
         DumpIortNodeRootComplex (
           NodePtr,
           *IortNodeLength,
           *IortIdMappingCount,
           *IortIdMappingOffset
           );
         break;
-      case EIORT_NODE_SMMUV1_V2:
+      case Iort_Node_SMMUV1_V2:
         DumpIortNodeSmmuV1V2 (
           NodePtr,
           *IortNodeLength,
           *IortIdMappingCount,
           *IortIdMappingOffset
           );
         break;
-      case EIORT_NODE_SMMUV3:
+      case Iort_Node_SMMUV3:
         DumpIortNodeSmmuV3 (
           NodePtr,
           *IortNodeLength,
           *IortIdMappingCount,
           *IortIdMappingOffset
           );
         break;
-      case EIORT_NODE_PMCG:
+      case Iort_Node_PMCG:
         DumpIortNodePmcg (
           NodePtr,
           *IortNodeLength,
           *IortIdMappingCount,
           *IortIdMappingOffset
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
index 3ac27086a6b..a704b0c6314 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
@@ -195,11 +195,13 @@ ParseAcpiMadt (
   IN UINT8   AcpiTableRevision
   )
 {
   UINT32 Offset;
   UINT8* InterruptContollerPtr;
-  UINT32 GICDCount = 0;
+  UINT32 GICDCount;
+
+  GICDCount = 0;
 
   if (!Trace) {
     return;
   }
 
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
index c33bb1e9234..164cd462022 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
@@ -86,11 +86,14 @@ ValidateRsdtAddress (
   // Reference: Server Base Boot Requirements System Software on ARM Platforms
   // Section: 4.2.1.1 RSDP
   // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
   //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
   //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
-  UINT32 RsdtAddr = *(UINT32*)Ptr;
+  UINT32 RsdtAddr;
+
+  RsdtAddr = *(UINT32*)Ptr;
+
   if (RsdtAddr != 0) {
     IncrementErrorCount ();
     Print (
       L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.",
       RsdtAddr
@@ -118,11 +121,14 @@ ValidateXsdtAddress (
   // Reference: Server Base Boot Requirements System Software on ARM Platforms
   // Section: 4.2.1.1 RSDP
   // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
   //   - Within the RSDP, the RsdtAddress field must be null (zero) and the
   //     XsdtAddresss MUST be a valid, non-null, 64-bit value.
-  UINT64 XsdtAddr = *(UINT64*)Ptr;
+  UINT64 XsdtAddr;
+
+  XsdtAddr = *(UINT64*)Ptr;
+
   if (XsdtAddr == 0) {
     IncrementErrorCount ();
     Print (
       L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.",
       XsdtAddr
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
index a028ae541ca..c38666d2b7f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
@@ -61,12 +61,12 @@ ParseAcpiSlit (
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
   )
 {
   UINT32 Offset;
-  UINT64 i;
-  UINT64 j;
+  UINT64 Count;
+  UINT64 Index;
   UINT64 LocalityCount;
   UINT8* LocalityPtr;
   CHAR16 Buffer[80];  // Used for AsciiName param of ParseAcpi
 
   if (!Trace) {
@@ -96,50 +96,50 @@ ParseAcpiSlit (
       LocalityCount
       );
     PrintFieldName (0, Buffer);
     Print (L"\n");
     Print (L"       ");
-    for (j = 0; j < LocalityCount; j++) {
-      Print (L" (%3d) ", j);
+    for (Index = 0; Index < LocalityCount; Index++) {
+      Print (L" (%3d) ", Index);
     }
     Print (L"\n");
-    for (i = 0; i < LocalityCount; i++) {
-      Print (L" (%3d) ", i);
-      for (j = 0; j < LocalityCount; j++) {
-        Print (L"  %3d  ", SLIT_ELEMENT (LocalityPtr, i, j));
+    for (Count = 0; Count< LocalityCount; Count++) {
+      Print (L" (%3d) ", Count);
+      for (Index = 0; Index < LocalityCount; Index++) {
+        Print (L"  %3d  ", SLIT_ELEMENT (LocalityPtr, Count, Index));
       }
       Print (L"\n");
     }
   }
 
   // Validate
-  for (i = 0; i < LocalityCount; i++) {
-    for (j = 0; j < LocalityCount; j++) {
+  for (Count = 0; Count < LocalityCount; Count++) {
+    for (Index = 0; Index < LocalityCount; Index++) {
       // Element[x][x] must be equal to 10
-      if ((i == j) && (SLIT_ELEMENT (LocalityPtr, i, j) != 10)) {
+      if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count,Index) != 10)) {
         IncrementErrorCount ();
         Print (
           L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."
             " Normalized Value is not 10\n",
-          i,
-          j,
-          SLIT_ELEMENT (LocalityPtr, i, j)
+          Count,
+          Index,
+          SLIT_ELEMENT (LocalityPtr, Count, Index)
           );
       }
       // Element[i][j] must be equal to Element[j][i]
-      if (SLIT_ELEMENT (LocalityPtr, i, j) !=
-          SLIT_ELEMENT (LocalityPtr, j, i)) {
+      if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=
+          SLIT_ELEMENT (LocalityPtr, Index, Count)) {
         IncrementErrorCount ();
         Print (
           L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"
            "Element[0x%lx][0x%lx] (%3d) do not match.\n",
-          i,
-          j,
-          SLIT_ELEMENT (LocalityPtr, i, j),
-          j,
-          i,
-          SLIT_ELEMENT (LocalityPtr, j, i)
+          Count,
+          Index,
+          SLIT_ELEMENT (LocalityPtr, Count, Index),
+          Index,
+          Count,
+          SLIT_ELEMENT (LocalityPtr, Index, Count)
           );
       }
     }
   }
 }
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c
index 64340886fe5..815ba9a9db0 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c
@@ -96,11 +96,14 @@ ValidateInterruptType (
   IN UINT8* Ptr,
   IN VOID*  Context
   )
 {
 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
-  UINT8 InterruptType = *Ptr;
+  UINT8 InterruptType;
+
+  InterruptType = *Ptr;
+
   if (InterruptType !=
         EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {
     IncrementErrorCount ();
     Print (
       L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",
@@ -124,11 +127,14 @@ ValidateIrq (
   IN UINT8* Ptr,
   IN VOID*  Context
   )
 {
 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
-  UINT8 Irq = *Ptr;
+  UINT8 Irq;
+
+  Irq = *Ptr;
+
   if (Irq != 0) {
     IncrementErrorCount ();
     Print (
       L"\nERROR: Irq = %d. This must be zero on ARM Platforms\n",
       Irq
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
index fbe943d898a..043277aabf8 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
@@ -175,11 +175,14 @@ VOID
 DumpSratApicProximity (
  IN CONST CHAR16* Format,
  IN UINT8*        Ptr
  )
 {
-  UINT32 ProximityDomain = Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16);
+  UINT32 ProximityDomain;
+
+  ProximityDomain = Ptr[0] | (Ptr[1] << 8) | (Ptr[2] << 16);
+
   Print (Format, ProximityDomain);
 }
 
 /**
   This function parses the ACPI SRAT table.
@@ -208,17 +211,23 @@ ParseAcpiSrat (
   IN UINT8   AcpiTableRevision
   )
 {
   UINT32 Offset;
   UINT8* ResourcePtr;
-  UINT32 GicCAffinityIndex = 0;
-  UINT32 GicITSAffinityIndex = 0;
-  UINT32 MemoryAffinityIndex = 0;
-  UINT32 ApicSapicAffinityIndex = 0;
-  UINT32 X2ApicAffinityIndex = 0;
+  UINT32 GicCAffinityIndex;
+  UINT32 GicITSAffinityIndex;
+  UINT32 MemoryAffinityIndex;
+  UINT32 ApicSapicAffinityIndex;
+  UINT32 X2ApicAffinityIndex;
   CHAR8  Buffer[80];  // Used for AsciiName param of ParseAcpi
 
+  GicCAffinityIndex = 0;
+  GicITSAffinityIndex = 0;
+  MemoryAffinityIndex = 0;
+  ApicSapicAffinityIndex = 0;
+  X2ApicAffinityIndex = 0;
+
   if (!Trace) {
     return;
   }
 
   Offset = ParseAcpi (
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index 8479bfbc9be..c2f40009eeb 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -62,11 +62,14 @@ ACPI_TABLE_PARSER ParserList[] = {
 EFI_STATUS
 RegisterAllParsers (
   )
 {
   EFI_STATUS Status;
-  UINTN Count = sizeof (ParserList) / sizeof (ParserList[0]);
+  UINTN Count;
+
+  Count = sizeof (ParserList) / sizeof (ParserList[0]);
+
   while (Count-- != 0) {
     Status = RegisterParser (
                ParserList[Count].Signature,
                ParserList[Count].Parser
                );
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index dbdb7e301b4..6df8c08b855 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -25,10 +25,13 @@
 
 [Sources.common]
   UefiShellAcpiViewCommandLib.uni
   UefiShellAcpiViewCommandLib.c
   UefiShellAcpiViewCommandLib.h
+  AcpiParser.h
+  AcpiTableParser.h
+  AcpiView.h
   AcpiParser.c
   AcpiTableParser.c
   AcpiView.c
   Parsers/Bgrt/BgrtParser.c
   Parsers/Dbg2/Dbg2Parser.c
-- 
2.14.3.windows.1



  parent reply	other threads:[~2018-06-06 12:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06 12:49 [patch V2 0/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues Dandan Bi
2018-06-06 12:49 ` [patch V2 1/2] " Dandan Bi
2018-06-06 12:49 ` Dandan Bi [this message]
2018-06-11  2:03 ` [patch V2 0/2] " Ni, Ruiyu

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=20180606124952.77236-3-dandan.bi@intel.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