From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.69.1608139377746662088 for ; Wed, 16 Dec 2020 09:22:57 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pierre.gondois@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 795791FB; Wed, 16 Dec 2020 09:22:57 -0800 (PST) Received: from e120189.arm.com (unknown [10.57.25.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3E2383F66E; Wed, 16 Dec 2020 09:22:56 -0800 (PST) From: "PierreGondois" To: devel@edk2.groups.io, ard.biesheuvel@arm.com, leif@nuviainc.com Cc: sami.mujawar@arm.com Subject: [PATCH v1 25/25] ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib Date: Wed, 16 Dec 2020 17:22:00 +0000 Message-Id: <20201216172200.25846-26-Pierre.Gondois@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201216172200.25846-1-Pierre.Gondois@arm.com> References: <20201216172200.25846-1-Pierre.Gondois@arm.com> From: Pierre Gondois 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 --- The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1 .../Arm/DefaultExceptionHandler.c | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c index fa9af8c410b9..ad205a5a1ebf 100644 --- a/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c +++ b/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c @@ -2,7 +2,7 @@ Default exception handler Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
- Copyright (c) 2012, ARM Ltd. All rights reserved.
+ Copyright (c) 2012 - 2020, Arm Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -34,6 +34,20 @@ typedef struct { CHAR8 Char; } CPSR_CHAR; +STATIC CONST CPSR_CHAR mCpsrChar[] = { + { 31, 'n' }, + { 30, 'z' }, + { 29, 'c' }, + { 28, 'v' }, + + { 9, 'e' }, + { 8, 'a' }, + { 7, 'i' }, + { 6, 'f' }, + { 5, 't' }, + { 0, '?' } +}; + CHAR8 * GetImageName ( IN UINTN FaultAddress, @@ -45,7 +59,7 @@ GetImageName ( Convert the Current Program Status Register (CPSR) to a string. The string is a defacto standard in the ARM world. - It is possible to add extra bits by adding them to CpsrChar array. + It is possible to add extra bits by adding them to mCpsrChar array. @param Cpsr ARM CPSR register value @param ReturnStr CPSR_STRING_SIZE byte string that contains string @@ -61,25 +75,12 @@ CpsrString ( UINTN Index; CHAR8* Str; CHAR8* ModeStr; - CPSR_CHAR CpsrChar[] = { - { 31, 'n' }, - { 30, 'z' }, - { 29, 'c' }, - { 28, 'v' }, - - { 9, 'e' }, - { 8, 'a' }, - { 7, 'i' }, - { 6, 'f' }, - { 5, 't' }, - { 0, '?' } - }; Str = ReturnStr; - for (Index = 0; CpsrChar[Index].BIT != 0; Index++, Str++) { - *Str = CpsrChar[Index].Char; - if ((Cpsr & (1 << CpsrChar[Index].BIT)) != 0) { + for (Index = 0; mCpsrChar[Index].BIT != 0; Index++, Str++) { + *Str = mCpsrChar[Index].Char; + if ((Cpsr & (1 << mCpsrChar[Index].BIT)) != 0) { // Concert to upper case if bit is set *Str &= ~0x20; } @@ -186,7 +187,9 @@ DefaultExceptionHandler ( UINT32 DfsrStatus; UINT32 IfsrStatus; BOOLEAN DfsrWrite; - UINT32 PcAdjust = 0; + UINT32 PcAdjust; + + PcAdjust = 0; CharCount = AsciiSPrint (Buffer,sizeof (Buffer),"\n%a Exception PC at 0x%08x CPSR 0x%08x ", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR); -- 2.17.1