public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io, ard.biesheuvel@arm.com, leif@nuviainc.com
Cc: sami.mujawar@arm.com
Subject: [PATCH v1 04/25] ArmPkg: Fix Ecc error 3002 in ArmMmuLib
Date: Wed, 16 Dec 2020 17:21:39 +0000	[thread overview]
Message-ID: <20201216172200.25846-5-Pierre.Gondois@arm.com> (raw)
In-Reply-To: <20201216172200.25846-1-Pierre.Gondois@arm.com>

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


  parent reply	other threads:[~2020-12-16 17:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` PierreGondois [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201216172200.25846-5-Pierre.Gondois@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox