]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib
authorPierre Gondois <Pierre.Gondois@arm.com>
Tue, 15 Dec 2020 17:16:02 +0000 (17:16 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 6 Jan 2021 16:22:54 +0000 (16:22 +0000)
This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Fixing this error implies extracting the CpsrChar
array from CpsrString and making it a static variable.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c

index fa9af8c410b9cbe11e7a8dfaabf1442efaa682a2..fddd5c634cc3a129a6664818eaa4fbbddc4c4f45 100644 (file)
@@ -2,7 +2,7 @@
   Default exception handler\r
 \r
   Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
-  Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>\r
+  Copyright (c) 2012 - 2021, Arm Ltd. All rights reserved.<BR>\r
 \r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
@@ -34,6 +34,20 @@ typedef struct {
   CHAR8   Char;\r
 } CPSR_CHAR;\r
 \r
+STATIC CONST CPSR_CHAR mCpsrChar[] = {\r
+  { 31, 'n' },\r
+  { 30, 'z' },\r
+  { 29, 'c' },\r
+  { 28, 'v' },\r
+\r
+  { 9,  'e' },\r
+  { 8,  'a' },\r
+  { 7,  'i' },\r
+  { 6,  'f' },\r
+  { 5,  't' },\r
+  { 0,  '?' }\r
+};\r
+\r
 CHAR8 *\r
 GetImageName (\r
   IN  UINTN  FaultAddress,\r
@@ -45,7 +59,7 @@ GetImageName (
   Convert the Current Program Status Register (CPSR) to a string. The string is\r
   a defacto standard in the ARM world.\r
 \r
-  It is possible to add extra bits by adding them to CpsrChar array.\r
+  It is possible to add extra bits by adding them to mCpsrChar array.\r
 \r
   @param  Cpsr         ARM CPSR register value\r
   @param  ReturnStr    CPSR_STRING_SIZE byte string that contains string\r
@@ -61,25 +75,12 @@ CpsrString (
   UINTN     Index;\r
   CHAR8*    Str;\r
   CHAR8*    ModeStr;\r
-  CPSR_CHAR CpsrChar[] = {\r
-    { 31, 'n' },\r
-    { 30, 'z' },\r
-    { 29, 'c' },\r
-    { 28, 'v' },\r
-\r
-    { 9,  'e' },\r
-    { 8,  'a' },\r
-    { 7,  'i' },\r
-    { 6,  'f' },\r
-    { 5,  't' },\r
-    { 0,  '?' }\r
-  };\r
 \r
   Str = ReturnStr;\r
 \r
-  for (Index = 0; CpsrChar[Index].BIT != 0; Index++, Str++) {\r
-    *Str = CpsrChar[Index].Char;\r
-    if ((Cpsr & (1 << CpsrChar[Index].BIT)) != 0) {\r
+  for (Index = 0; mCpsrChar[Index].BIT != 0; Index++, Str++) {\r
+    *Str = mCpsrChar[Index].Char;\r
+    if ((Cpsr & (1 << mCpsrChar[Index].BIT)) != 0) {\r
       // Concert to upper case if bit is set\r
       *Str &= ~0x20;\r
     }\r
@@ -186,7 +187,9 @@ DefaultExceptionHandler (
   UINT32    DfsrStatus;\r
   UINT32    IfsrStatus;\r
   BOOLEAN   DfsrWrite;\r
-  UINT32    PcAdjust = 0;\r
+  UINT32    PcAdjust;\r
+\r
+  PcAdjust = 0;\r
 \r
   CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x  CPSR 0x%08x ",\r
          gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR);\r