From f75c7478280b96d191e86856c0b1c49ff711c284 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Tue, 5 Jun 2018 09:20:05 +0800 Subject: ShellPkg/UefiShellAcpiViewCommandLib: Fix ECC issues 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 Cc: Evan Lloyd Cc: Jaben Carsey Cc: Ruiyu Ni Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi Reviewed-by: Ruiyu Ni --- .../UefiShellAcpiViewCommandLib/AcpiParser.c | 44 ++++++++++++++-------- 1 file changed, 28 insertions(+), 16 deletions(-) (limited to 'ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c') diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c index 088575d014..6d3bc451ac 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.c @@ -21,6 +21,15 @@ 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. **/ @@ -114,10 +123,13 @@ VerifyChecksum ( 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++; @@ -166,11 +178,14 @@ DumpRaw ( 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); @@ -277,7 +292,10 @@ 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; @@ -456,13 +474,16 @@ ParseAcpi ( ) { 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) { @@ -620,11 +641,6 @@ DumpAcpiHeader ( IN UINT8* Ptr ) { - ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; - ACPI_PARSER AcpiHeaderParser[] = { - PARSE_ACPI_HEADER (&AcpiHdrInfo) - }; - return ParseAcpi ( TRUE, 0, @@ -658,10 +674,6 @@ ParseAcpiHeader ( ) { UINT32 BytesParsed; - ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo; - ACPI_PARSER AcpiHeaderParser[] = { - PARSE_ACPI_HEADER (&AcpiHdrInfo) - }; BytesParsed = ParseAcpi ( FALSE, -- cgit v1.2.3