public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Bi, Dandan" <dandan.bi@intel.com>
To: 'Alexei Fedorov' <Alexei.Fedorov@arm.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Carsey, Jaben" <jaben.carsey@intel.com>,
	"Ni, Ruiyu" <ruiyu.ni@intel.com>
Subject: Re: [patch 2/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues
Date: Wed, 6 Jun 2018 02:42:07 +0000	[thread overview]
Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB3BB28535@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <DB6PR0801MB1766727386D45C823C6B80CF9A660@DB6PR0801MB1766.eurprd08.prod.outlook.com>

Hi Alexei,

Current in the Edk2 implementation, the guard macros in the include header files start with underscore and end with underscore.  And the number of underscore usually used here is one or two.

And the check tool (ECC) also follow above rule to do the check. So it will report error for the ACPIPARSER_H_ 
So do you agree to keep the changes in the patch or update it to_ ACPIPARSER_H_ for alignment consideration firstly?

Then there is another topic, we need to make the Check Tool align with CSS, we may enhance the check tool or update the Spec.

Thanks,
Dandan
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Alexei Fedorov
Sent: Tuesday, June 05, 2018 5:13 PM
To: Bi, Dandan <dandan.bi@intel.com>; edk2-devel@lists.01.org
Cc: Carsey, Jaben <jaben.carsey@intel.com>; Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: Re: [edk2] [patch 2/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues

Hi Dandan Bi,


Your patch contains a number of modifications like the one below:

-#ifndef ACPIPARSER_H_
-#define ACPIPARSER_H_
+#ifndef __ACPIPARSER_H__
+#define __ACPIPARSER_H__


which violate CCS

"3.3.2 Include Files"

"4.3.5.4 The names of guard macros shall end with an underscore character."

and the given examples.


Alexei

________________________________
From: edk2-devel <edk2-devel-bounces@lists.01.org> on behalf of Dandan Bi <dandan.bi@intel.com>
Sent: 05 June 2018 09:33
To: edk2-devel@lists.01.org
Cc: Jaben Carsey; Ruiyu Ni
Subject: [edk2] [patch 2/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues

1. Separate variable definition and initialization.
2. Make the variable naming following Edk2 rule.
Naming convention of local variable:
a.First character should be upper case.
b.Must contain lower case characters.
c.No white space characters.

Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Evan Lloyd <evan.lloyd@arm.com>
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/AcpiParser.h       |  6 +--
 .../UefiShellAcpiViewCommandLib/AcpiTableParser.c  | 50 +++++++++----------  .../UefiShellAcpiViewCommandLib/AcpiTableParser.h  |  6 +--  .../Library/UefiShellAcpiViewCommandLib/AcpiView.c | 58 ++++++++++++++--------  .../Library/UefiShellAcpiViewCommandLib/AcpiView.h | 16 +++---
 .../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.h                  |  6 +--
 .../UefiShellAcpiViewCommandLib.inf                |  3 ++
 17 files changed, 190 insertions(+), 129 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/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index ecf7dae9038..cea8857bc08 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -9,12 +9,12 @@

   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/

-#ifndef ACPIPARSER_H_
-#define ACPIPARSER_H_
+#ifndef __ACPIPARSER_H__
+#define __ACPIPARSER_H__

 #define OUTPUT_FIELD_COLUMN_WIDTH  36

 /// The RSDP table signature is "RSD PTR " (8 bytes)  /// However The signature for ACPI tables is 4 bytes.
@@ -789,6 +789,6 @@ ParseAcpiXsdt (
   IN UINT8*  Ptr,
   IN UINT32  AcpiTableLength,
   IN UINT8   AcpiTableRevision
   );

-#endif // ACPIPARSER_H_
+#endif // __ACPIPARSER_H__
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/AcpiTableParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
index ca33b935760..5a6c4df12f3 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
@@ -9,12 +9,12 @@

   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/

-#ifndef ACPITABLEPARSER_H_
-#define ACPITABLEPARSER_H_
+#ifndef __ACPITABLEPARSER_H__
+#define __ACPITABLEPARSER_H__

 /**
   The maximum number of ACPI table parsers.
 */
 #define MAX_ACPI_TABLE_PARSERS          16
@@ -128,6 +128,6 @@ EFIAPI
 GetParser (
   IN  UINT32                   Signature,
   OUT PARSE_ACPI_TABLE_PROC *  ParserProc
   );

-#endif // ACPITABLEPARSER_H_
+#endif // __ACPITABLEPARSER_H__
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..4e7ac93ca03 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -9,12 +9,12 @@

   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/

-#ifndef ACPIVIEW_H_
-#define ACPIVIEW_H_
+#ifndef __ACPIVIEW_H__
+#define __ACPIVIEW_H__

 /**
   A macro to define the max file name length  **/
 #define MAX_FILE_NAME_LEN    128
@@ -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.
 **/
@@ -111,6 +111,6 @@ ProcessTableReportOptions (
   IN CONST UINT32  Signature,
   IN CONST UINT8*  TablePtr,
   IN CONST UINT32  Length
   );

-#endif // ACPIVIEW_H_
+#endif // __ACPIVIEW_H__
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/Dbg2Pars
+++ er.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/GtdtPars
+++ er.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/IortPars
+++ er.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/MadtPars
+++ er.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/RsdpPars
+++ er.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/SlitPars
+++ er.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/SpcrPars
+++ er.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/SratPars
+++ er.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/UefiShellAcpiViewComm
+++ andLib.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.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
index f547569cf37..4ea958b80e7 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComm
+++ andLib.h
@@ -9,12 +9,12 @@

   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/

-#ifndef UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H_
-#define UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H_
+#ifndef __UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H__
+#define __UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H__

 extern EFI_HII_HANDLE gShellAcpiViewHiiHandle;

 /**
   Function for 'acpiview' command.
@@ -27,6 +27,6 @@ EFIAPI
 ShellCommandRunAcpiView (
   IN EFI_HANDLE        ImageHandle,
   IN EFI_SYSTEM_TABLE  *SystemTable
   );

-#endif // UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H_
+#endif // __UEFI_SHELL_ACPIVIEW_COMMAND_LIB_H__
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/UefiShellAcpiViewComm
+++ andLib.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

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2018-06-06  2:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-05  8:33 [patch 0/2] ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues Dandan Bi
2018-06-05  8:33 ` [patch 1/2] " Dandan Bi
2018-06-05  8:33 ` [patch 2/2] " Dandan Bi
2018-06-05  9:13   ` Alexei Fedorov
2018-06-06  2:42     ` Bi, Dandan [this message]
2018-06-06  9:36       ` Alexei Fedorov

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=3C0D5C461C9E904E8F62152F6274C0BB3BB28535@shsmsx102.ccr.corp.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