public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg
@ 2020-12-16 17:21 PierreGondois
  2020-12-16 17:21 ` [PATCH v1 01/25] ArmPkg: Format header to fix Ecc crash in ArmMmuLib PierreGondois
                   ` (26 more replies)
  0 siblings, 27 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

The Ecc tools available in the BaseTools package checks for
good practice coding standards. Some errors reported while
running Ecc on the ArmPkg require modifications.

The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

Pierre Gondois (25):
  ArmPkg: Format header to fix Ecc crash in ArmMmuLib
  ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib
  ArmPkg: Fix Ecc error 3002 in OpteeLib
  ArmPkg: Fix Ecc error 3002 in ArmMmuLib
  ArmPkg: Fix Ecc error 3002 in TimerDxe
  ArmPkg: Fix Ecc error 3002 in MmCommunicationDxe
  ArmPkg: Fix Ecc error 3002 in CpuDxe
  ArmPkg: Fix Ecc error 3002 in SemihostFs
  ArmPkg: Fix Ecc error 3002 in ArmDisassemblerLib
  ArmPkg: Fix Ecc error 3001 in SemihostFs
  ArmPkg: Fix Ecc error 5005 in CpuDxe
  ArmPkg: Fix Ecc error 5005 in ArmExceptionLib
  ArmPkg: Fix Ecc error 5007 in CompilerIntrinsicsLib
  ArmPkg: Fix Ecc error 5007 in ArmScmiDxe
  ArmPkg: Fix Ecc error 5007 in CpuDxe
  ArmPkg: Fix Ecc error 5007 in TimerDxe
  ArmPkg: Fix Ecc error 5007 in SemihostFs
  ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib
  ArmPkg: Fix Ecc error 5007 in ArmDisassemblerLib
  ArmPkg: Fix Ecc error 5007 in ArmLib
  ArmPkg: Fix Ecc error 5007 in ArmMmuLib
  ArmPkg: Fix Ecc error 5007 in SemiHostingSerialPortLib
  ArmPkg: Fix Ecc error 5007 in SemihostLib
  ArmPkg: Fix Ecc error 5007 in StandaloneMmMmuLib
  ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib

 ArmPkg/Drivers/ArmScmiDxe/Scmi.c              |  5 ++-
 ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c |  8 ++--
 ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c           |  8 ++--
 ArmPkg/Drivers/CpuDxe/Arm/Mmu.c               | 14 +++----
 ArmPkg/Drivers/CpuDxe/Exception.c             |  8 ++--
 .../MmCommunicationDxe/MmCommunication.c      |  4 +-
 ArmPkg/Drivers/TimerDxe/TimerDxe.c            |  7 ++--
 ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 25 ++++++-----
 .../ArmCacheMaintenanceLib.c                  | 13 +++---
 .../ArmDisassemblerLib/ArmDisassembler.c      | 11 ++++-
 .../Library/ArmExceptionLib/ArmExceptionLib.c |  5 ++-
 ArmPkg/Library/ArmLib/ArmLib.c                | 20 +++------
 .../Library/ArmMmuLib/AArch64/ArmMmuLibCore.c |  2 +-
 .../AArch64/ArmMmuPeiLibConstructor.c         | 14 +++----
 .../Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c   | 34 +++++++--------
 .../Library/CompilerIntrinsicsLib/memcmp_ms.c | 10 +++--
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c | 11 +++--
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c | 11 +++--
 .../CompilerIntrinsicsLib/memmove_ms.c        | 14 +++++--
 ArmPkg/Library/CompilerIntrinsicsLib/memset.c |  8 +++-
 .../Library/CompilerIntrinsicsLib/memset_ms.c |  8 +++-
 .../Arm/DefaultExceptionHandler.c             | 41 ++++++++++---------
 ArmPkg/Library/OpteeLib/Optee.c               |  7 ++--
 .../SemiHostingSerialPortLib/SerialPortLib.c  |  8 +++-
 ArmPkg/Library/SemihostLib/SemihostLib.c      |  6 +--
 .../AArch64/ArmMmuStandaloneMmLib.c           | 13 +++---
 26 files changed, 182 insertions(+), 133 deletions(-)

--
2.17.1


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v1 01/25] ArmPkg: Format header to fix Ecc crash in ArmMmuLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 02/25] ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib PierreGondois
                   ` (25 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

The header of the file is not formatted properly, making
the Ecc tool crash when running on the ArmPkg.

The following command was run:
  ./BaseTools/BinWrappers/PosixLike/Ecc
    -c BaseTools/Source/Python/Ecc/config.ini
    -e BaseTools/Source/Python/Ecc/exception.xml
    -t ArmPkg -r ArmPkgEcc.xls

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 .../ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c    | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
index 4fc3c92fdbf5..56edaade779b 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
@@ -1,10 +1,10 @@
-#/* @file
-#
-#  Copyright (c) 2016, Linaro Limited. All rights reserved.
-#
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#*/
+/** @file
+
+  Copyright (c) 2016, Linaro Limited. All rights reserved.
+  Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+*/

 #include <Base.h>

--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 02/25] ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
  2020-12-16 17:21 ` [PATCH v1 01/25] ArmPkg: Format header to fix Ecc crash in ArmMmuLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 03/25] ArmPkg: Fix Ecc error 3002 in OpteeLib PierreGondois
                   ` (24 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Brackets are also added to comply to with the coding
standard.

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c  | 3 ++-
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c     | 4 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c  | 4 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c | 7 +++++--
 ArmPkg/Library/CompilerIntrinsicsLib/memset.c     | 4 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c  | 4 +++-
 6 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
index 551f8e77c12f..8491e2401f1e 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------
 //
 // Copyright (c) 2019, Pete Batard. All rights reserved.
+// Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
@@ -20,7 +21,7 @@ int memcmp(const void *s1, const void *s2, size_t n)
   unsigned char const *t1 = s1;
   unsigned char const *t2 = s2;

-  while (n--) {
+  while (n-- != 0) {
     if (*t1 != *t2)
       return (int)*t1 - (int)*t2;
     t1++;
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
index 6e9c85f4bafd..d4827531dd04 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------
 //
 // Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
+// Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
@@ -13,8 +14,9 @@ static void __memcpy(void *dest, const void *src, size_t n)
   unsigned char *d = dest;
   unsigned char const *s = src;

-  while (n--)
+  while (n-- != 0) {
     *d++ = *s++;
+  }
 }

 void *memcpy(void *dest, const void *src, size_t n)
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
index 34feef5a4bb9..a9590df68054 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------
 //
 // Copyright (c) 2017, Pete Batard. All rights reserved.<BR>
+// Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
@@ -20,8 +21,9 @@ void* memcpy(void *dest, const void *src, size_t n)
   unsigned char *d = dest;
   unsigned char const *s = src;

-  while (n--)
+  while (n-- != 0) {
     *d++ = *s++;
+  }

   return dest;
 }
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
index 5b261ef8b948..a2e1ef9c8883 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------
 //
 // Copyright (c) 2019, Pete Batard. All rights reserved.
+// Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
@@ -21,13 +22,15 @@ void* memmove(void *dest, const void *src, size_t n)
   unsigned char const *s = src;

   if (d < s) {
-    while (n--)
+    while (n-- != 0) {
       *d++ = *s++;
+    }
   } else {
     d += n;
     s += n;
-    while (n--)
+    while (n-- != 0) {
       *--d = *--s;
+    }
   }

   return dest;
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset.c
index 24398d591f79..57fc776333b0 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset.c
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------
 //
 // Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
+// Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
@@ -13,8 +14,9 @@ void *__memset(void *s, int c, size_t n)
 {
   unsigned char *d = s;

-  while (n--)
+  while (n-- != 0) {
     *d++ = c;
+  }

   return s;
 }
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
index 4de55d845718..463fc21d3184 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
@@ -1,6 +1,7 @@
 //------------------------------------------------------------------------------
 //
 // Copyright (c) 2017, Pete Batard. All rights reserved.<BR>
+// Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
 //
@@ -19,8 +20,9 @@ void *memset(void *s, int c, size_t n)
 {
   unsigned char *d = s;

-  while (n--)
+  while (n-- != 0) {
     *d++ = (unsigned char)c;
+  }

   return s;
 }
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 03/25] ArmPkg: Fix Ecc error 3002 in OpteeLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
  2020-12-16 17:21 ` [PATCH v1 01/25] ArmPkg: Format header to fix Ecc crash in ArmMmuLib PierreGondois
  2020-12-16 17:21 ` [PATCH v1 02/25] ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 04/25] ArmPkg: Fix Ecc error 3002 in ArmMmuLib PierreGondois
                   ` (23 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/OpteeLib/Optee.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/ArmPkg/Library/OpteeLib/Optee.c b/ArmPkg/Library/OpteeLib/Optee.c
index 2562bc093b61..e763228e9cd3 100644
--- a/ArmPkg/Library/OpteeLib/Optee.c
+++ b/ArmPkg/Library/OpteeLib/Optee.c
@@ -3,6 +3,7 @@
   secure monitor calls.

   Copyright (c) 2018, Linaro Ltd. All rights reserved.<BR>
+  Copyright (c) 2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -227,7 +228,7 @@ OpteeOpenSession (

   MessageArg->NumParams = 2;

-  if (OpteeCallWithArg ((UINTN)MessageArg)) {
+  if (OpteeCallWithArg ((UINTN)MessageArg) != 0) {
     MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
     MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
   }
@@ -431,7 +432,7 @@ OpteeInvokeFunction (

   MessageArg->NumParams = OPTEE_MAX_CALL_PARAMS;

-  if (OpteeCallWithArg ((UINTN)MessageArg)) {
+  if (OpteeCallWithArg ((UINTN)MessageArg) != 0) {
     MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
     MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
   }
@@ -440,7 +441,7 @@ OpteeInvokeFunction (
         InvokeFunctionArg->Params,
         OPTEE_MAX_CALL_PARAMS,
         MessageArg->Params
-        )) {
+        ) != 0) {
     MessageArg->Return = OPTEE_ERROR_COMMUNICATION;
     MessageArg->ReturnOrigin = OPTEE_ORIGIN_COMMUNICATION;
   }
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 04/25] ArmPkg: Fix Ecc error 3002 in ArmMmuLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (2 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 03/25] ArmPkg: Fix Ecc error 3002 in OpteeLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 05/25] ArmPkg: Fix Ecc error 3002 in TimerDxe PierreGondois
                   ` (22 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 .../Library/ArmMmuLib/AArch64/ArmMmuLibCore.c |  2 +-
 .../Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c   | 30 +++++++++----------
 2 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
index 513a763e6e87..8c736d25bb80 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
@@ -294,7 +294,7 @@ UpdateRegionMapping (
 {
   UINTN     T0SZ;

-  if (((RegionStart | RegionLength) & EFI_PAGE_MASK)) {
+  if (((RegionStart | RegionLength) & EFI_PAGE_MASK) != 0) {
     return EFI_INVALID_PARAMETER;
   }

diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c
index 6f18604f799f..c7f2744c4fac 100644
--- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c
+++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c
@@ -1,7 +1,7 @@
 /** @file
 *  File managing the MMU for ARMv7 architecture
 *
-*  Copyright (c) 2011-2016, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2020, Arm Limited. All rights reserved.<BR>
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
 *
@@ -105,7 +105,7 @@ UpdatePageEntries (
   // EntryMask: bitmask of values to change (1 = change this value, 0 = leave alone)
   // EntryValue: values at bit positions specified by EntryMask
   EntryMask = TT_DESCRIPTOR_PAGE_TYPE_MASK | TT_DESCRIPTOR_PAGE_AP_MASK;
-  if (Attributes & EFI_MEMORY_XP) {
+  if ((Attributes & EFI_MEMORY_XP) != 0) {
     EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE_XN;
   } else {
     EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE;
@@ -116,33 +116,33 @@ UpdatePageEntries (
   // is irrelevant. If no memory attribute is specified, we preserve whatever
   // memory type is set in the page tables, and update the permission attributes
   // only.
-  if (Attributes & EFI_MEMORY_UC) {
+  if ((Attributes & EFI_MEMORY_UC) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;
     // map to strongly ordered
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0, B=0
-  } else if (Attributes & EFI_MEMORY_WC) {
+  } else if ((Attributes & EFI_MEMORY_WC) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;
     // map to normal non-cachable
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2, B=0, C=0
-  } else if (Attributes & EFI_MEMORY_WT) {
+  } else if ((Attributes & EFI_MEMORY_WT) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;
     // write through with no-allocate
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] = 0, C=1, B=0
-  } else if (Attributes & EFI_MEMORY_WB) {
+  } else if ((Attributes & EFI_MEMORY_WB) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;
     // write back (with allocate)
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001, C=1, B=1
-  } else if (Attributes & CACHE_ATTRIBUTE_MASK) {
+  } else if ((Attributes & CACHE_ATTRIBUTE_MASK) != 0) {
     // catch unsupported memory type attributes
     ASSERT (FALSE);
     return EFI_UNSUPPORTED;
   }

-  if (Attributes & EFI_MEMORY_RO) {
+  if ((Attributes & EFI_MEMORY_RO) != 0) {
     EntryValue |= TT_DESCRIPTOR_PAGE_AP_RO_RO;
   } else {
     EntryValue |= TT_DESCRIPTOR_PAGE_AP_RW_RW;
@@ -244,39 +244,39 @@ UpdateSectionEntries (
   // is irrelevant. If no memory attribute is specified, we preserve whatever
   // memory type is set in the page tables, and update the permission attributes
   // only.
-  if (Attributes & EFI_MEMORY_UC) {
+  if ((Attributes & EFI_MEMORY_UC) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;
     // map to strongly ordered
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0, B=0
-  } else if (Attributes & EFI_MEMORY_WC) {
+  } else if ((Attributes & EFI_MEMORY_WC) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;
     // map to normal non-cachable
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2, B=0, C=0
-  } else if (Attributes & EFI_MEMORY_WT) {
+  } else if ((Attributes & EFI_MEMORY_WT) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;
     // write through with no-allocate
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] = 0, C=1, B=0
-  } else if (Attributes & EFI_MEMORY_WB) {
+  } else if ((Attributes & EFI_MEMORY_WB) != 0) {
     // modify cacheability attributes
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;
     // write back (with allocate)
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001, C=1, B=1
-  } else if (Attributes & CACHE_ATTRIBUTE_MASK) {
+  } else if ((Attributes & CACHE_ATTRIBUTE_MASK) != 0) {
     // catch unsupported memory type attributes
     ASSERT (FALSE);
     return EFI_UNSUPPORTED;
   }

-  if (Attributes & EFI_MEMORY_RO) {
+  if ((Attributes & EFI_MEMORY_RO) != 0) {
     EntryValue |= TT_DESCRIPTOR_SECTION_AP_RO_RO;
   } else {
     EntryValue |= TT_DESCRIPTOR_SECTION_AP_RW_RW;
   }

-  if (Attributes & EFI_MEMORY_XP) {
+  if ((Attributes & EFI_MEMORY_XP) != 0) {
     EntryValue |= TT_DESCRIPTOR_SECTION_XN_MASK;
   }

--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 05/25] ArmPkg: Fix Ecc error 3002 in TimerDxe
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (3 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 04/25] ArmPkg: Fix Ecc error 3002 in ArmMmuLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 06/25] ArmPkg: Fix Ecc error 3002 in MmCommunicationDxe PierreGondois
                   ` (21 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Drivers/TimerDxe/TimerDxe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
index dccaeae23c29..69f31e880a68 100644
--- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c
+++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
@@ -1,7 +1,7 @@
 /** @file
   Timer Architecture Protocol driver of the ARM flavor

-  Copyright (c) 2011-2013 ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2011-2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -307,7 +307,7 @@ TimerInterruptHandler (
   // Check if the timer interrupt is active
   if ((ArmGenericTimerGetTimerCtrlReg () ) & ARM_ARCH_TIMER_ISTATUS) {

-    if (mTimerNotifyFunction) {
+    if (mTimerNotifyFunction != 0) {
       mTimerNotifyFunction (mTimerPeriod * mElapsedPeriod);
     }

--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 06/25] ArmPkg: Fix Ecc error 3002 in MmCommunicationDxe
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (4 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 05/25] ArmPkg: Fix Ecc error 3002 in TimerDxe PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 07/25] ArmPkg: Fix Ecc error 3002 in CpuDxe PierreGondois
                   ` (20 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index 9457eaf1d809..fc3f9ffb4338 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -1,6 +1,6 @@
 /** @file

-  Copyright (c) 2016-2019, ARM Limited. All rights reserved.
+  Copyright (c) 2016-2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -96,7 +96,7 @@ MmCommunication2Communicate (
                sizeof (CommunicateHeader->MessageLength);

   // If the length of the CommBuffer is 0 then return the expected length.
-  if (CommSize) {
+  if (CommSize != 0) {
     // This case can be used by the consumer of this driver to find out the
     // max size that can be used for allocating CommBuffer.
     if ((*CommSize == 0) ||
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 07/25] ArmPkg: Fix Ecc error 3002 in CpuDxe
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (5 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 06/25] ArmPkg: Fix Ecc error 3002 in MmCommunicationDxe PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 08/25] ArmPkg: Fix Ecc error 3002 in SemihostFs PierreGondois
                   ` (19 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 6 +++---
 ArmPkg/Drivers/CpuDxe/Arm/Mmu.c     | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
index fca2d4f7638a..9f894a743ae7 100644
--- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
+++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
@@ -2,7 +2,7 @@

 Copyright (c) 2009, Hewlett-Packard Company. All rights reserved.<BR>
 Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>
-Portions copyright (c) 2011-2013, ARM Ltd. All rights reserved.<BR>
+Portions copyright (c) 2011-2020, Arm Limited. All rights reserved.<BR>
 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>

 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -282,12 +282,12 @@ EfiAttributeToArmAttribute (
   ArmAttributes |= TT_AF;

   // Determine protection attributes
-  if (EfiAttributes & EFI_MEMORY_RO) {
+  if ((EfiAttributes & EFI_MEMORY_RO) != 0) {
     ArmAttributes |= TT_AP_RO_RO;
   }

   // Process eXecute Never attribute
-  if (EfiAttributes & EFI_MEMORY_XP) {
+  if ((EfiAttributes & EFI_MEMORY_XP) != 0) {
     ArmAttributes |= TT_PXN_MASK;
   }

diff --git a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c
index 6fb5112a1a8e..40bb8760f40d 100644
--- a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c
+++ b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c
@@ -2,7 +2,7 @@

 Copyright (c) 2009, Hewlett-Packard Company. All rights reserved.<BR>
 Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR>
-Portions copyright (c) 2013, ARM Ltd. All rights reserved.<BR>
+Portions copyright (c) 2013-2020, Arm Limited. All rights reserved.<BR>
 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>

 SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -366,14 +366,14 @@ EfiAttributeToArmAttribute (
   }

   // Determine protection attributes
-  if (EfiAttributes & EFI_MEMORY_RO) {
+  if ((EfiAttributes & EFI_MEMORY_RO) != 0) {
     ArmAttributes |= TT_DESCRIPTOR_SECTION_AP_RO_RO;
   } else {
     ArmAttributes |= TT_DESCRIPTOR_SECTION_AP_RW_RW;
   }

   // Determine eXecute Never attribute
-  if (EfiAttributes & EFI_MEMORY_XP) {
+  if ((EfiAttributes & EFI_MEMORY_XP) != 0) {
     ArmAttributes |= TT_DESCRIPTOR_SECTION_XN_MASK;
   }

--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 08/25] ArmPkg: Fix Ecc error 3002 in SemihostFs
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (6 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 07/25] ArmPkg: Fix Ecc error 3002 in CpuDxe PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 09/25] ArmPkg: Fix Ecc error 3002 in ArmDisassemblerLib PierreGondois
                   ` (18 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
index a66bcb136918..3b07d979182f 100644
--- a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
+++ b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
@@ -2,7 +2,7 @@
   Support a Semi Host file system over a debuggers JTAG

   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Portions copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
+  Portions copyright (c) 2011 - 2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -196,8 +196,8 @@ FileOpen (
     return EFI_INVALID_PARAMETER;
   }

-  if ((OpenMode & EFI_FILE_MODE_CREATE) &&
-      (Attributes & EFI_FILE_DIRECTORY)    ) {
+  if (((OpenMode & EFI_FILE_MODE_CREATE) != 0) &&
+      ((Attributes & EFI_FILE_DIRECTORY) != 0)) {
     return EFI_WRITE_PROTECTED;
   }

@@ -234,7 +234,7 @@ FileOpen (
   Return = SemihostFileOpen (AsciiFileName, SemihostMode, &SemihostHandle);

   if (RETURN_ERROR (Return)) {
-    if (OpenMode & EFI_FILE_MODE_CREATE) {
+    if ((OpenMode & EFI_FILE_MODE_CREATE) != 0) {
       //
       // In the create if does not exist case, if the opening in update
       // mode failed, create it and open it in update mode. The update
@@ -277,7 +277,8 @@ FileOpen (

   FileFcb->Info.FileSize     = Length;
   FileFcb->Info.PhysicalSize = Length;
-  FileFcb->Info.Attribute    = (OpenMode & EFI_FILE_MODE_CREATE) ? Attributes : 0;
+  FileFcb->Info.Attribute    = ((OpenMode & EFI_FILE_MODE_CREATE) != 0) ?
+                                 Attributes : 0;

   InsertTailList (&gFileList, &FileFcb->Link);

--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 09/25] ArmPkg: Fix Ecc error 3002 in ArmDisassemblerLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (7 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 08/25] ArmPkg: Fix Ecc error 3002 in SemihostFs PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 10/25] ArmPkg: Fix Ecc error 3001 in SemihostFs PierreGondois
                   ` (17 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
index d206cf4ea908..04b6c2cd21e0 100644
--- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
+++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
@@ -2,6 +2,7 @@
   Default exception handler

   Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>
+  Copyright (c) 2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -367,7 +368,11 @@ DisassembleArmInstruction (
       AsciiSPrint (Buf, Size, "CPS #0x%x", (OpCode & 0x2f));
     } else {
       imode = (OpCode >> 18) & 0x3;
-      Index = AsciiSPrint (Buf, Size, "CPS%a %a%a%a", (imode == 3) ? "ID":"IE", (OpCode & BIT8) ? "A":"", (OpCode & BIT7) ? "I":"", (OpCode & BIT6) ? "F":"");
+      Index = AsciiSPrint (Buf, Size, "CPS%a %a%a%a",
+                      (imode == 3) ? "ID":"IE",
+                      ((OpCode & BIT8) != 0) ? "A":"",
+                      ((OpCode & BIT7) != 0) ? "I":"",
+                      ((OpCode & BIT6) != 0) ? "F":"");
       if ((OpCode & BIT17) != 0) {
         AsciiSPrint (&Buf[Index], Size - Index, ", #0x%x", OpCode & 0x1f);
       }
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 10/25] ArmPkg: Fix Ecc error 3001 in SemihostFs
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (8 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 09/25] ArmPkg: Fix Ecc error 3002 in ArmDisassemblerLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 11/25] ArmPkg: Fix Ecc error 5005 in CpuDxe PierreGondois
                   ` (16 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
Boolean values and variable type BOOLEAN should not use
explicit comparisons to TRUE or FALSE

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
index 3b07d979182f..c03c1a462285 100644
--- a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
+++ b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
@@ -764,7 +764,7 @@ GetFileInfo (
   UINTN           ResultSize;
   UINTN           Index;

-  if (Fcb->IsRoot == TRUE) {
+  if (Fcb->IsRoot) {
     ResultSize = SIZE_OF_EFI_FILE_INFO + sizeof(CHAR16);
   } else {
     NameSize   = AsciiStrLen (Fcb->FileName) + 1;
@@ -784,7 +784,7 @@ GetFileInfo (
   // Fill in the structure
   Info->Size = ResultSize;

-  if (Fcb->IsRoot == TRUE) {
+  if (Fcb->IsRoot) {
     Info->FileName[0]  = L'\0';
   } else {
     for (Index = 0; Index < NameSize; Index++) {
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 11/25] ArmPkg: Fix Ecc error 5005 in CpuDxe
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (9 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 10/25] ArmPkg: Fix Ecc error 3001 in SemihostFs PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 12/25] ArmPkg: Fix Ecc error 5005 in ArmExceptionLib PierreGondois
                   ` (15 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
The body of a function should be contained by open
and close braces that must be in the first column

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Drivers/CpuDxe/Exception.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/ArmPkg/Drivers/CpuDxe/Exception.c b/ArmPkg/Drivers/CpuDxe/Exception.c
index 50ed50ebb046..3050ba60e7c4 100644
--- a/ArmPkg/Drivers/CpuDxe/Exception.c
+++ b/ArmPkg/Drivers/CpuDxe/Exception.c
@@ -1,7 +1,7 @@
 /** @file

   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Portions Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
+  Portions Copyright (c) 2011 - 2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -14,7 +14,8 @@
 EFI_STATUS
 InitializeExceptions (
   IN EFI_CPU_ARCH_PROTOCOL    *Cpu
-  ) {
+  )
+{
   EFI_STATUS                      Status;
   EFI_VECTOR_HANDOFF_INFO         *VectorInfoList;
   EFI_VECTOR_HANDOFF_INFO         *VectorInfo;
@@ -92,7 +93,8 @@ EFI_STATUS
 RegisterInterruptHandler(
   IN EFI_EXCEPTION_TYPE             InterruptType,
   IN EFI_CPU_INTERRUPT_HANDLER      InterruptHandler
-  ) {
+  )
+{
   // pass down to CpuExceptionHandlerLib
   return (EFI_STATUS)RegisterCpuInterruptHandler(InterruptType, InterruptHandler);
 }
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 12/25] ArmPkg: Fix Ecc error 5005 in ArmExceptionLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (10 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 11/25] ArmPkg: Fix Ecc error 5005 in CpuDxe PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 13/25] ArmPkg: Fix Ecc error 5007 in CompilerIntrinsicsLib PierreGondois
                   ` (14 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
The body of a function should be contained by open
and close braces that must be in the first column

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
index 1ff90dede57f..0fba64a17507 100644
--- a/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
+++ b/ArmPkg/Library/ArmExceptionLib/ArmExceptionLib.c
@@ -2,7 +2,7 @@
 *  Main file supporting the SEC Phase for Versatile Express
 *
 *  Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2020, Arm Limited. All rights reserved.<BR>
 *  Copyright (c) 2016 HP Development Company, L.P.
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -253,7 +253,8 @@ RETURN_STATUS
 RegisterCpuInterruptHandler(
   IN EFI_EXCEPTION_TYPE             ExceptionType,
   IN EFI_CPU_INTERRUPT_HANDLER      ExceptionHandler
-  ) {
+  )
+{
   if (ExceptionType > gMaxExceptionNumber) {
     return RETURN_UNSUPPORTED;
   }
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 13/25] ArmPkg: Fix Ecc error 5007 in CompilerIntrinsicsLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (11 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 12/25] ArmPkg: Fix Ecc error 5005 in ArmExceptionLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 14/25] ArmPkg: Fix Ecc error 5007 in ArmScmiDxe PierreGondois
                   ` (13 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c  | 7 +++++--
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c     | 7 +++++--
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c  | 7 +++++--
 ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c | 7 +++++--
 ArmPkg/Library/CompilerIntrinsicsLib/memset.c     | 4 +++-
 ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c  | 4 +++-
 6 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
index 8491e2401f1e..5e46a7345d84 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
@@ -18,8 +18,11 @@ int memcmp(void *, void *, size_t);
 #pragma function(memcmp)
 int memcmp(const void *s1, const void *s2, size_t n)
 {
-  unsigned char const *t1 = s1;
-  unsigned char const *t2 = s2;
+  unsigned char const *t1;
+  unsigned char const *t2;
+
+  t1 = s1;
+  t2 = s2;

   while (n-- != 0) {
     if (*t1 != *t2)
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
index d4827531dd04..6d40c423c608 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
@@ -11,8 +11,11 @@ typedef __SIZE_TYPE__ size_t;

 static void __memcpy(void *dest, const void *src, size_t n)
 {
-  unsigned char *d = dest;
-  unsigned char const *s = src;
+  unsigned char *d;
+  unsigned char const *s;
+
+  d = dest;
+  s = src;

   while (n-- != 0) {
     *d++ = *s++;
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
index a9590df68054..616a08a05f4d 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
@@ -18,8 +18,11 @@ void* memcpy(void *, const void *, size_t);
 #pragma function(memcpy)
 void* memcpy(void *dest, const void *src, size_t n)
 {
-  unsigned char *d = dest;
-  unsigned char const *s = src;
+  unsigned char *d;
+  unsigned char const *s;
+
+  d = dest;
+  s = src;

   while (n-- != 0) {
     *d++ = *s++;
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
index a2e1ef9c8883..36b0a1101515 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
@@ -18,8 +18,11 @@ void* memmove(void *, const void *, size_t);
 #pragma function(memmove)
 void* memmove(void *dest, const void *src, size_t n)
 {
-  unsigned char *d = dest;
-  unsigned char const *s = src;
+  unsigned char *d;
+  unsigned char const *s;
+
+  d = dest;
+  s = src;

   if (d < s) {
     while (n-- != 0) {
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset.c
index 57fc776333b0..1d53c2644566 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset.c
@@ -12,7 +12,9 @@ typedef __SIZE_TYPE__ size_t;
 static __attribute__((__used__))
 void *__memset(void *s, int c, size_t n)
 {
-  unsigned char *d = s;
+  unsigned char *d;
+
+  d = s;

   while (n-- != 0) {
     *d++ = c;
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
index 463fc21d3184..86dcf3b08c07 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
@@ -18,7 +18,9 @@ void* memset(void *, int, size_t);
 #pragma function(memset)
 void *memset(void *s, int c, size_t n)
 {
-  unsigned char *d = s;
+  unsigned char *d;
+
+  d = s;

   while (n-- != 0) {
     *d++ = (unsigned char)c;
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 14/25] ArmPkg: Fix Ecc error 5007 in ArmScmiDxe
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (12 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 13/25] ArmPkg: Fix Ecc error 5007 in CompilerIntrinsicsLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 15/25] ArmPkg: Fix Ecc error 5007 in CpuDxe PierreGondois
                   ` (12 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Drivers/ArmScmiDxe/Scmi.c              | 5 +++--
 ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c | 8 +++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
index c4af3ec4ecc1..3e62f2b1a48c 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/Scmi.c
@@ -1,6 +1,6 @@
 /** @file

-  Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+  Copyright (c) 2017-2020, Arm Limited. All rights reserved.

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -161,8 +161,9 @@ ScmiProtocolDiscoveryCommon (
   )
 {
   SCMI_COMMAND  Command;
-  UINT32        PayloadLength = 0;
+  UINT32        PayloadLength;

+  PayloadLength = 0;
   Command.ProtocolId = ProtocolId;
   Command.MessageId  = MessageId;

diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
index ac0d21d862b3..8002e039c98a 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c
@@ -1,6 +1,6 @@
 /** @file

-  Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+  Copyright (c) 2017-2020, Arm Limited. All rights reserved.

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -189,12 +189,14 @@ ClockDescribeRates (
   CLOCK_DESCRIBE_RATES   *DescribeRates;
   CLOCK_RATE_DWORD       *Rate;

-  UINT32                 RequiredArraySize = 0;
-  UINT32                 RateIndex = 0;
+  UINT32                 RequiredArraySize;
+  UINT32                 RateIndex;
   UINT32                 RateNo;
   UINT32                 RateOffset;

   *TotalRates = 0;
+  RequiredArraySize = 0;
+  RateIndex = 0;

   Status = ScmiCommandGetPayload (&MessageParams);
   if (EFI_ERROR (Status)) {
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 15/25] ArmPkg: Fix Ecc error 5007 in CpuDxe
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (13 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 14/25] ArmPkg: Fix Ecc error 5007 in ArmScmiDxe PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 16/25] ArmPkg: Fix Ecc error 5007 in TimerDxe PierreGondois
                   ` (11 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 2 +-
 ArmPkg/Drivers/CpuDxe/Arm/Mmu.c     | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
index 9f894a743ae7..529aeaefa17e 100644
--- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
+++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c
@@ -189,7 +189,7 @@ SyncCacheConfig (
   )
 {
   EFI_STATUS                          Status;
-  UINT32                              PageAttribute = 0;
+  UINT32                              PageAttribute;
   UINT64                             *FirstLevelTableAddress;
   UINTN                               TableLevel;
   UINTN                               TableCount;
diff --git a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c
index 40bb8760f40d..cd8073418dba 100644
--- a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c
+++ b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c
@@ -155,8 +155,8 @@ SyncCacheConfigPage (
   EFI_STATUS                          Status;
   UINT32                              i;
   volatile ARM_PAGE_TABLE_ENTRY       *SecondLevelTable;
-  UINT32                              NextPageAttributes = 0;
-  UINT32                              PageAttributes = 0;
+  UINT32                              NextPageAttributes;
+  UINT32                              PageAttributes;
   UINT32                              BaseAddress;
   UINT64                              GcdAttributes;

@@ -226,8 +226,8 @@ SyncCacheConfig (
   UINT32                              i;
   EFI_PHYSICAL_ADDRESS                NextRegionBase;
   UINT64                              NextRegionLength;
-  UINT32                              NextSectionAttributes = 0;
-  UINT32                              SectionAttributes = 0;
+  UINT32                              NextSectionAttributes;
+  UINT32                              SectionAttributes;
   UINT64                              GcdAttributes;
   volatile ARM_FIRST_LEVEL_DESCRIPTOR   *FirstLevelTable;
   UINTN                               NumberOfDescriptors;
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 16/25] ArmPkg: Fix Ecc error 5007 in TimerDxe
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (14 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 15/25] ArmPkg: Fix Ecc error 5007 in CpuDxe PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 17/25] ArmPkg: Fix Ecc error 5007 in SemihostFs PierreGondois
                   ` (10 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Drivers/TimerDxe/TimerDxe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Drivers/TimerDxe/TimerDxe.c b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
index 69f31e880a68..7a69f3882696 100644
--- a/ArmPkg/Drivers/TimerDxe/TimerDxe.c
+++ b/ArmPkg/Drivers/TimerDxe/TimerDxe.c
@@ -359,7 +359,7 @@ TimerInitialize (
   IN EFI_SYSTEM_TABLE   *SystemTable
   )
 {
-  EFI_HANDLE  Handle = NULL;
+  EFI_HANDLE  Handle;
   EFI_STATUS  Status;
   UINTN       TimerCtrlReg;
   UINT32      TimerHypIntrNum;
@@ -408,6 +408,7 @@ TimerInitialize (
   Status = TimerDriverSetTimerPeriod (&gTimer, FixedPcdGet32(PcdTimerPeriod)); // TIMER_DEFAULT_PERIOD
   ASSERT_EFI_ERROR (Status);

+  Handle = NULL;
   // Install the Timer Architectural Protocol onto a new handle
   Status = gBS->InstallMultipleProtocolInterfaces(
                   &Handle,
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 17/25] ArmPkg: Fix Ecc error 5007 in SemihostFs
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (15 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 16/25] ArmPkg: Fix Ecc error 5007 in TimerDxe PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 18/25] ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib PierreGondois
                   ` (9 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
index c03c1a462285..0468d242f7e4 100644
--- a/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
+++ b/ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c
@@ -90,8 +90,9 @@ AllocateFCB (
   VOID
   )
 {
-  SEMIHOST_FCB *Fcb = AllocateZeroPool (sizeof (SEMIHOST_FCB));
+  SEMIHOST_FCB *Fcb;

+  Fcb = AllocateZeroPool (sizeof (SEMIHOST_FCB));
   if (Fcb != NULL) {
     CopyMem (&Fcb->File, &gSemihostFsFile, sizeof (gSemihostFsFile));
     Fcb->Signature = SEMIHOST_FCB_SIGNATURE;
@@ -122,7 +123,7 @@ VolumeOpen (
   OUT EFI_FILE                        **Root
   )
 {
-  SEMIHOST_FCB *RootFcb = NULL;
+  SEMIHOST_FCB *RootFcb;

   if (Root == NULL) {
     return EFI_INVALID_PARAMETER;
@@ -759,12 +760,13 @@ GetFileInfo (
   OUT    VOID          *Buffer
   )
 {
-  EFI_FILE_INFO   *Info = NULL;
-  UINTN           NameSize = 0;
+  EFI_FILE_INFO   *Info;
+  UINTN           NameSize;
   UINTN           ResultSize;
   UINTN           Index;

   if (Fcb->IsRoot) {
+    NameSize = 0;
     ResultSize = SIZE_OF_EFI_FILE_INFO + sizeof(CHAR16);
   } else {
     NameSize   = AsciiStrLen (Fcb->FileName) + 1;
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 18/25] ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (16 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 17/25] ArmPkg: Fix Ecc error 5007 in SemihostFs PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 19/25] ArmPkg: Fix Ecc error 5007 in ArmDisassemblerLib PierreGondois
                   ` (8 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 .../ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c
index 440a5c372566..e14c40b3beb4 100644
--- a/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c
+++ b/ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.c
@@ -1,7 +1,7 @@
 /** @file

   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.
+  Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -20,11 +20,14 @@ CacheRangeOperation (
   IN  UINTN           LineLength
   )
 {
-  UINTN ArmCacheLineAlignmentMask  = LineLength - 1;
-
+  UINTN ArmCacheLineAlignmentMask;
   // Align address (rounding down)
-  UINTN AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask);
-  UINTN EndAddress     = (UINTN)Start + Length;
+  UINTN AlignedAddress;
+  UINTN EndAddress;
+
+  ArmCacheLineAlignmentMask = LineLength - 1;
+  AlignedAddress = (UINTN)Start - ((UINTN)Start & ArmCacheLineAlignmentMask);
+  EndAddress     = (UINTN)Start + Length;

   // Perform the line operation on an address in each cache line
   while (AlignedAddress < EndAddress) {
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 19/25] ArmPkg: Fix Ecc error 5007 in ArmDisassemblerLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (17 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 18/25] ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 20/25] ArmPkg: Fix Ecc error 5007 in ArmLib PierreGondois
                   ` (7 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
index 04b6c2cd21e0..1882163522d9 100644
--- a/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
+++ b/ArmPkg/Library/ArmDisassemblerLib/ArmDisassembler.c
@@ -158,7 +158,7 @@ DisassembleArmInstruction (
   IN  BOOLEAN   Extended
   )
 {
-  UINT32    OpCode = **OpCodePtr;
+  UINT32    OpCode;
   CHAR8     *Type, *Root;
   BOOLEAN   I, P, U, B, W, L, S, H;
   UINT32    Rn, Rd, Rm;
@@ -166,6 +166,8 @@ DisassembleArmInstruction (
   UINT32    Index;
   UINT32    shift_imm, shift;

+  OpCode =  = **OpCodePtr;
+
   I = (OpCode & BIT25) == BIT25;
   P = (OpCode & BIT24) == BIT24;
   U = (OpCode & BIT23) == BIT23;
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 20/25] ArmPkg: Fix Ecc error 5007 in ArmLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (18 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 19/25] ArmPkg: Fix Ecc error 5007 in ArmDisassemblerLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 21/25] ArmPkg: Fix Ecc error 5007 in ArmMmuLib PierreGondois
                   ` (6 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/ArmLib/ArmLib.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/ArmPkg/Library/ArmLib/ArmLib.c b/ArmPkg/Library/ArmLib/ArmLib.c
index 3905d02c5e7e..c454ce5b99ad 100644
--- a/ArmPkg/Library/ArmLib/ArmLib.c
+++ b/ArmPkg/Library/ArmLib/ArmLib.c
@@ -1,7 +1,7 @@
 /** @file

   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2011 - 2020, ARM Ltd. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -19,9 +19,7 @@ ArmSetAuxCrBit (
   IN  UINT32    Bits
   )
 {
-  UINT32 val = ArmReadAuxCr();
-  val |= Bits;
-  ArmWriteAuxCr(val);
+  ArmWriteAuxCr(ArmReadAuxCr() | Bits);
 }

 VOID
@@ -30,9 +28,7 @@ ArmUnsetAuxCrBit (
   IN  UINT32    Bits
   )
 {
-  UINT32 val = ArmReadAuxCr();
-  val &= ~Bits;
-  ArmWriteAuxCr(val);
+  ArmWriteAuxCr(ArmReadAuxCr() & ~Bits);
 }

 //
@@ -45,10 +41,7 @@ ArmSetCpuActlrBit (
   IN  UINTN    Bits
   )
 {
-  UINTN Value;
-  Value =  ArmReadCpuActlr ();
-  Value |= Bits;
-  ArmWriteCpuActlr (Value);
+  ArmWriteCpuActlr (ArmReadCpuActlr () | Bits);
 }

 VOID
@@ -57,10 +50,7 @@ ArmUnsetCpuActlrBit (
   IN  UINTN    Bits
   )
 {
-  UINTN Value;
-  Value = ArmReadCpuActlr ();
-  Value &= ~Bits;
-  ArmWriteCpuActlr (Value);
+  ArmWriteCpuActlr (ArmReadCpuActlr () & ~Bits);
 }

 UINTN
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 21/25] ArmPkg: Fix Ecc error 5007 in ArmMmuLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (19 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 20/25] ArmPkg: Fix Ecc error 5007 in ArmLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 22/25] ArmPkg: Fix Ecc error 5007 in SemiHostingSerialPortLib PierreGondois
                   ` (5 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c
index c7f2744c4fac..6d8249510bbf 100644
--- a/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c
+++ b/ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c
@@ -220,7 +220,7 @@ UpdateSectionEntries (
   IN UINT64                    Attributes
   )
 {
-  EFI_STATUS    Status = EFI_SUCCESS;
+  EFI_STATUS    Status;
   UINT32        EntryMask;
   UINT32        EntryValue;
   UINT32        FirstLevelIdx;
@@ -231,6 +231,8 @@ UpdateSectionEntries (
   VOID          *Mva;
   volatile ARM_FIRST_LEVEL_DESCRIPTOR   *FirstLevelTable;

+  Status = EFI_SUCCESS;
+
   // EntryMask: bitmask of values to change (1 = change this value, 0 = leave alone)
   // EntryValue: values at bit positions specified by EntryMask

--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 22/25] ArmPkg: Fix Ecc error 5007 in SemiHostingSerialPortLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (20 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 21/25] ArmPkg: Fix Ecc error 5007 in ArmMmuLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 23/25] ArmPkg: Fix Ecc error 5007 in SemihostLib PierreGondois
                   ` (4 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/SemiHostingSerialPortLib/SerialPortLib.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/Library/SemiHostingSerialPortLib/SerialPortLib.c b/ArmPkg/Library/SemiHostingSerialPortLib/SerialPortLib.c
index 7e5c61fad4bd..2973d107a323 100644
--- a/ArmPkg/Library/SemiHostingSerialPortLib/SerialPortLib.c
+++ b/ArmPkg/Library/SemiHostingSerialPortLib/SerialPortLib.c
@@ -2,6 +2,7 @@
   Serial I/O Port library functions with no library constructor/destructor

   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
+  Copyright (c) 2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -55,10 +56,13 @@ SerialPortWrite (
 )
 {
   UINT8 PrintBuffer[PRINT_BUFFER_SIZE];
-  UINTN SourceIndex      = 0;
-  UINTN DestinationIndex = 0;
+  UINTN SourceIndex;
+  UINTN DestinationIndex;
   UINT8 CurrentCharacter;

+  SourceIndex      = 0;
+  DestinationIndex = 0;
+
   while (SourceIndex < NumberOfBytes)
   {
       CurrentCharacter = Buffer[SourceIndex++];
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 23/25] ArmPkg: Fix Ecc error 5007 in SemihostLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (21 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 22/25] ArmPkg: Fix Ecc error 5007 in SemiHostingSerialPortLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:21 ` [PATCH v1 24/25] ArmPkg: Fix Ecc error 5007 in StandaloneMmMmuLib PierreGondois
                   ` (3 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 ArmPkg/Library/SemihostLib/SemihostLib.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/ArmPkg/Library/SemihostLib/SemihostLib.c b/ArmPkg/Library/SemihostLib/SemihostLib.c
index 78b862468b10..481c46fc24f7 100644
--- a/ArmPkg/Library/SemihostLib/SemihostLib.c
+++ b/ArmPkg/Library/SemihostLib/SemihostLib.c
@@ -1,7 +1,7 @@
 /** @file

   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
-  Copyright (c) 2013 - 2014, ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2013 - 2020, Arm Limited. All rights reserved.<BR>

   SPDX-License-Identifier: BSD-2-Clause-Patent

@@ -135,9 +135,7 @@ SemihostFileClose (
   IN UINTN  FileHandle
   )
 {
-  INT32 Result = Semihost_SYS_CLOSE(&FileHandle);
-
-  if (Result == -1) {
+  if (Semihost_SYS_CLOSE (&FileHandle) == -1) {
     return RETURN_INVALID_PARAMETER;
   } else {
     return RETURN_SUCCESS;
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 24/25] ArmPkg: Fix Ecc error 5007 in StandaloneMmMmuLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (22 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 23/25] ArmPkg: Fix Ecc error 5007 in SemihostLib PierreGondois
@ 2020-12-16 17:21 ` PierreGondois
  2020-12-16 17:22 ` [PATCH v1 25/25] ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib PierreGondois
                   ` (2 subsequent siblings)
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:21 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

This patch fixes the following Ecc reported error:
There should be no initialization of a variable as
part of its declaration

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
---
The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

 .../AArch64/ArmMmuStandaloneMmLib.c                 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c
index 3806490f7006..0b64e3384e6d 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c
+++ b/ArmPkg/Library/StandaloneMmMmuLib/AArch64/ArmMmuStandaloneMmLib.c
@@ -1,7 +1,7 @@
 /** @file
 *  File managing the MMU for ARMv8 architecture in S-EL0
 *
-*  Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+*  Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.<BR>
 *
 *  SPDX-License-Identifier: BSD-2-Clause-Patent
 *
@@ -14,6 +14,7 @@
 #include <Library/ArmMmuLib.h>
 #include <Library/ArmSvcLib.h>
 #include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>

 STATIC
@@ -23,12 +24,12 @@ GetMemoryPermissions (
   OUT UINT32                    *MemoryAttributes
   )
 {
-  ARM_SVC_ARGS  GetMemoryPermissionsSvcArgs = {0};
+  ARM_SVC_ARGS  GetMemoryPermissionsSvcArgs;
+
+  ZeroMem (&GetMemoryPermissionsSvcArgs, sizeof (ARM_SVC_ARGS));

   GetMemoryPermissionsSvcArgs.Arg0 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64;
   GetMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
-  GetMemoryPermissionsSvcArgs.Arg2 = 0;
-  GetMemoryPermissionsSvcArgs.Arg3 = 0;

   ArmCallSvc (&GetMemoryPermissionsSvcArgs);
   if (GetMemoryPermissionsSvcArgs.Arg0 == ARM_SVC_SPM_RET_INVALID_PARAMS) {
@@ -49,7 +50,9 @@ RequestMemoryPermissionChange (
   )
 {
   EFI_STATUS    Status;
-  ARM_SVC_ARGS  ChangeMemoryPermissionsSvcArgs = {0};
+  ARM_SVC_ARGS  ChangeMemoryPermissionsSvcArgs;
+
+  ZeroMem (&ChangeMemoryPermissionsSvcArgs, sizeof (ARM_SVC_ARGS));

   ChangeMemoryPermissionsSvcArgs.Arg0 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64;
   ChangeMemoryPermissionsSvcArgs.Arg1 = BaseAddress;
--
2.17.1


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v1 25/25] ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (23 preceding siblings ...)
  2020-12-16 17:21 ` [PATCH v1 24/25] ArmPkg: Fix Ecc error 5007 in StandaloneMmMmuLib PierreGondois
@ 2020-12-16 17:22 ` PierreGondois
  2020-12-18 18:31 ` [edk2-devel] [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg Sami Mujawar
  2021-01-06 16:23 ` Ard Biesheuvel
  26 siblings, 0 replies; 28+ messages in thread
From: PierreGondois @ 2020-12-16 17:22 UTC (permalink / raw)
  To: devel, ard.biesheuvel, leif; +Cc: sami.mujawar

From: Pierre Gondois <Pierre.Gondois@arm.com>

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>
---
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.<BR>
-  Copyright (c) 2012, ARM Ltd. All rights reserved.<BR>
+  Copyright (c) 2012 - 2020, Arm Ltd. All rights reserved.<BR>

   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


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [edk2-devel] [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (24 preceding siblings ...)
  2020-12-16 17:22 ` [PATCH v1 25/25] ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib PierreGondois
@ 2020-12-18 18:31 ` Sami Mujawar
  2021-01-06 16:23 ` Ard Biesheuvel
  26 siblings, 0 replies; 28+ messages in thread
From: Sami Mujawar @ 2020-12-18 18:31 UTC (permalink / raw)
  To: devel@edk2.groups.io, Pierre Gondois, Ard Biesheuvel,
	leif@nuviainc.com, nd

For this patch series:

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of PierreGondois via groups.io
Sent: 16 December 2020 05:22 PM
To: devel@edk2.groups.io; Ard Biesheuvel <Ard.Biesheuvel@arm.com>; leif@nuviainc.com
Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Subject: [edk2-devel] [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg

From: Pierre Gondois <Pierre.Gondois@arm.com>

The Ecc tools available in the BaseTools package checks for
good practice coding standards. Some errors reported while
running Ecc on the ArmPkg require modifications.

The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1

Pierre Gondois (25):
  ArmPkg: Format header to fix Ecc crash in ArmMmuLib
  ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib
  ArmPkg: Fix Ecc error 3002 in OpteeLib
  ArmPkg: Fix Ecc error 3002 in ArmMmuLib
  ArmPkg: Fix Ecc error 3002 in TimerDxe
  ArmPkg: Fix Ecc error 3002 in MmCommunicationDxe
  ArmPkg: Fix Ecc error 3002 in CpuDxe
  ArmPkg: Fix Ecc error 3002 in SemihostFs
  ArmPkg: Fix Ecc error 3002 in ArmDisassemblerLib
  ArmPkg: Fix Ecc error 3001 in SemihostFs
  ArmPkg: Fix Ecc error 5005 in CpuDxe
  ArmPkg: Fix Ecc error 5005 in ArmExceptionLib
  ArmPkg: Fix Ecc error 5007 in CompilerIntrinsicsLib
  ArmPkg: Fix Ecc error 5007 in ArmScmiDxe
  ArmPkg: Fix Ecc error 5007 in CpuDxe
  ArmPkg: Fix Ecc error 5007 in TimerDxe
  ArmPkg: Fix Ecc error 5007 in SemihostFs
  ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib
  ArmPkg: Fix Ecc error 5007 in ArmDisassemblerLib
  ArmPkg: Fix Ecc error 5007 in ArmLib
  ArmPkg: Fix Ecc error 5007 in ArmMmuLib
  ArmPkg: Fix Ecc error 5007 in SemiHostingSerialPortLib
  ArmPkg: Fix Ecc error 5007 in SemihostLib
  ArmPkg: Fix Ecc error 5007 in StandaloneMmMmuLib
  ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib

 ArmPkg/Drivers/ArmScmiDxe/Scmi.c              |  5 ++-
 ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c |  8 ++--
 ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c           |  8 ++--
 ArmPkg/Drivers/CpuDxe/Arm/Mmu.c               | 14 +++----
 ArmPkg/Drivers/CpuDxe/Exception.c             |  8 ++--
 .../MmCommunicationDxe/MmCommunication.c      |  4 +-
 ArmPkg/Drivers/TimerDxe/TimerDxe.c            |  7 ++--
 ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 25 ++++++-----
 .../ArmCacheMaintenanceLib.c                  | 13 +++---
 .../ArmDisassemblerLib/ArmDisassembler.c      | 11 ++++-
 .../Library/ArmExceptionLib/ArmExceptionLib.c |  5 ++-
 ArmPkg/Library/ArmLib/ArmLib.c                | 20 +++------
 .../Library/ArmMmuLib/AArch64/ArmMmuLibCore.c |  2 +-
 .../AArch64/ArmMmuPeiLibConstructor.c         | 14 +++----
 .../Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c   | 34 +++++++--------
 .../Library/CompilerIntrinsicsLib/memcmp_ms.c | 10 +++--
 ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c | 11 +++--
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c | 11 +++--
 .../CompilerIntrinsicsLib/memmove_ms.c        | 14 +++++--
 ArmPkg/Library/CompilerIntrinsicsLib/memset.c |  8 +++-
 .../Library/CompilerIntrinsicsLib/memset_ms.c |  8 +++-
 .../Arm/DefaultExceptionHandler.c             | 41 ++++++++++---------
 ArmPkg/Library/OpteeLib/Optee.c               |  7 ++--
 .../SemiHostingSerialPortLib/SerialPortLib.c  |  8 +++-
 ArmPkg/Library/SemihostLib/SemihostLib.c      |  6 +--
 .../AArch64/ArmMmuStandaloneMmLib.c           | 13 +++---
 26 files changed, 182 insertions(+), 133 deletions(-)

--
2.17.1






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.

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg
  2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
                   ` (25 preceding siblings ...)
  2020-12-18 18:31 ` [edk2-devel] [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg Sami Mujawar
@ 2021-01-06 16:23 ` Ard Biesheuvel
  26 siblings, 0 replies; 28+ messages in thread
From: Ard Biesheuvel @ 2021-01-06 16:23 UTC (permalink / raw)
  To: Pierre.Gondois, devel, leif; +Cc: sami.mujawar

On 12/16/20 6:21 PM, Pierre.Gondois@arm.com wrote:
> From: Pierre Gondois <Pierre.Gondois@arm.com>
> 
> The Ecc tools available in the BaseTools package checks for
> good practice coding standards. Some errors reported while
> running Ecc on the ArmPkg require modifications.
> 
> The changes can be seen at: https://github.com/PierreARM/edk2/commits/1552_Ecc_ArmPkg_v1
> 
> Pierre Gondois (25):
>   ArmPkg: Format header to fix Ecc crash in ArmMmuLib
>   ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib
>   ArmPkg: Fix Ecc error 3002 in OpteeLib
>   ArmPkg: Fix Ecc error 3002 in ArmMmuLib
>   ArmPkg: Fix Ecc error 3002 in TimerDxe
>   ArmPkg: Fix Ecc error 3002 in MmCommunicationDxe
>   ArmPkg: Fix Ecc error 3002 in CpuDxe
>   ArmPkg: Fix Ecc error 3002 in SemihostFs
>   ArmPkg: Fix Ecc error 3002 in ArmDisassemblerLib
>   ArmPkg: Fix Ecc error 3001 in SemihostFs
>   ArmPkg: Fix Ecc error 5005 in CpuDxe
>   ArmPkg: Fix Ecc error 5005 in ArmExceptionLib
>   ArmPkg: Fix Ecc error 5007 in CompilerIntrinsicsLib
>   ArmPkg: Fix Ecc error 5007 in ArmScmiDxe
>   ArmPkg: Fix Ecc error 5007 in CpuDxe
>   ArmPkg: Fix Ecc error 5007 in TimerDxe
>   ArmPkg: Fix Ecc error 5007 in SemihostFs
>   ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib
>   ArmPkg: Fix Ecc error 5007 in ArmDisassemblerLib
>   ArmPkg: Fix Ecc error 5007 in ArmLib
>   ArmPkg: Fix Ecc error 5007 in ArmMmuLib
>   ArmPkg: Fix Ecc error 5007 in SemiHostingSerialPortLib
>   ArmPkg: Fix Ecc error 5007 in SemihostLib
>   ArmPkg: Fix Ecc error 5007 in StandaloneMmMmuLib
>   ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib
> 

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>

Merged as #1305 (with a few tweaks)

Thanks Pierre!


>  ArmPkg/Drivers/ArmScmiDxe/Scmi.c              |  5 ++-
>  ArmPkg/Drivers/ArmScmiDxe/ScmiClockProtocol.c |  8 ++--
>  ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c           |  8 ++--
>  ArmPkg/Drivers/CpuDxe/Arm/Mmu.c               | 14 +++----
>  ArmPkg/Drivers/CpuDxe/Exception.c             |  8 ++--
>  .../MmCommunicationDxe/MmCommunication.c      |  4 +-
>  ArmPkg/Drivers/TimerDxe/TimerDxe.c            |  7 ++--
>  ArmPkg/Filesystem/SemihostFs/Arm/SemihostFs.c | 25 ++++++-----
>  .../ArmCacheMaintenanceLib.c                  | 13 +++---
>  .../ArmDisassemblerLib/ArmDisassembler.c      | 11 ++++-
>  .../Library/ArmExceptionLib/ArmExceptionLib.c |  5 ++-
>  ArmPkg/Library/ArmLib/ArmLib.c                | 20 +++------
>  .../Library/ArmMmuLib/AArch64/ArmMmuLibCore.c |  2 +-
>  .../AArch64/ArmMmuPeiLibConstructor.c         | 14 +++----
>  .../Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c   | 34 +++++++--------
>  .../Library/CompilerIntrinsicsLib/memcmp_ms.c | 10 +++--
>  ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c | 11 +++--
>  .../Library/CompilerIntrinsicsLib/memcpy_ms.c | 11 +++--
>  .../CompilerIntrinsicsLib/memmove_ms.c        | 14 +++++--
>  ArmPkg/Library/CompilerIntrinsicsLib/memset.c |  8 +++-
>  .../Library/CompilerIntrinsicsLib/memset_ms.c |  8 +++-
>  .../Arm/DefaultExceptionHandler.c             | 41 ++++++++++---------
>  ArmPkg/Library/OpteeLib/Optee.c               |  7 ++--
>  .../SemiHostingSerialPortLib/SerialPortLib.c  |  8 +++-
>  ArmPkg/Library/SemihostLib/SemihostLib.c      |  6 +--
>  .../AArch64/ArmMmuStandaloneMmLib.c           | 13 +++---
>  26 files changed, 182 insertions(+), 133 deletions(-)
> 
> --
> 2.17.1
> 


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2021-01-06 16:23 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-16 17:21 [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg PierreGondois
2020-12-16 17:21 ` [PATCH v1 01/25] ArmPkg: Format header to fix Ecc crash in ArmMmuLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 02/25] ArmPkg: Fix Ecc error 3002 in CompilerIntrinsicsLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 03/25] ArmPkg: Fix Ecc error 3002 in OpteeLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 04/25] ArmPkg: Fix Ecc error 3002 in ArmMmuLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 05/25] ArmPkg: Fix Ecc error 3002 in TimerDxe PierreGondois
2020-12-16 17:21 ` [PATCH v1 06/25] ArmPkg: Fix Ecc error 3002 in MmCommunicationDxe PierreGondois
2020-12-16 17:21 ` [PATCH v1 07/25] ArmPkg: Fix Ecc error 3002 in CpuDxe PierreGondois
2020-12-16 17:21 ` [PATCH v1 08/25] ArmPkg: Fix Ecc error 3002 in SemihostFs PierreGondois
2020-12-16 17:21 ` [PATCH v1 09/25] ArmPkg: Fix Ecc error 3002 in ArmDisassemblerLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 10/25] ArmPkg: Fix Ecc error 3001 in SemihostFs PierreGondois
2020-12-16 17:21 ` [PATCH v1 11/25] ArmPkg: Fix Ecc error 5005 in CpuDxe PierreGondois
2020-12-16 17:21 ` [PATCH v1 12/25] ArmPkg: Fix Ecc error 5005 in ArmExceptionLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 13/25] ArmPkg: Fix Ecc error 5007 in CompilerIntrinsicsLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 14/25] ArmPkg: Fix Ecc error 5007 in ArmScmiDxe PierreGondois
2020-12-16 17:21 ` [PATCH v1 15/25] ArmPkg: Fix Ecc error 5007 in CpuDxe PierreGondois
2020-12-16 17:21 ` [PATCH v1 16/25] ArmPkg: Fix Ecc error 5007 in TimerDxe PierreGondois
2020-12-16 17:21 ` [PATCH v1 17/25] ArmPkg: Fix Ecc error 5007 in SemihostFs PierreGondois
2020-12-16 17:21 ` [PATCH v1 18/25] ArmPkg: Fix Ecc error 5007 in ArmCacheMaintenanceLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 19/25] ArmPkg: Fix Ecc error 5007 in ArmDisassemblerLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 20/25] ArmPkg: Fix Ecc error 5007 in ArmLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 21/25] ArmPkg: Fix Ecc error 5007 in ArmMmuLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 22/25] ArmPkg: Fix Ecc error 5007 in SemiHostingSerialPortLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 23/25] ArmPkg: Fix Ecc error 5007 in SemihostLib PierreGondois
2020-12-16 17:21 ` [PATCH v1 24/25] ArmPkg: Fix Ecc error 5007 in StandaloneMmMmuLib PierreGondois
2020-12-16 17:22 ` [PATCH v1 25/25] ArmPkg: Fix Ecc error 5007 in DefaultExceptionHandlerLib PierreGondois
2020-12-18 18:31 ` [edk2-devel] [PATCH v1 00/25] Fix Ecc reported errors in ArmPkg Sami Mujawar
2021-01-06 16:23 ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox