]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg: Fix Ecc error 3002 in ArmMmuLib
authorPierre Gondois <Pierre.Gondois@arm.com>
Thu, 10 Dec 2020 10:17:24 +0000 (10:17 +0000)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 6 Jan 2021 16:22:54 +0000 (16:22 +0000)
This patch fixes the following Ecc reported error:
Non-Boolean comparisons should use a compare operator
(==, !=, >, < >=, <=)

Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c

index 513a763e6e87418caa7f86da9f0b1937b8546a23..8c736d25bb80f726fa534770e0b8d4f6637fc8aa 100644 (file)
@@ -294,7 +294,7 @@ UpdateRegionMapping (
 {\r
   UINTN     T0SZ;\r
 \r
-  if (((RegionStart | RegionLength) & EFI_PAGE_MASK)) {\r
+  if (((RegionStart | RegionLength) & EFI_PAGE_MASK) != 0) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
index 6f18604f799f21a9a581ba033b4b69f353cda7a0..34ba691d9da8e9a8c87f228a11b4b515a02c5bdc 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
 *  File managing the MMU for ARMv7 architecture\r
 *\r
-*  Copyright (c) 2011-2016, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2021, Arm Limited. All rights reserved.<BR>\r
 *\r
 *  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 *\r
@@ -105,7 +105,7 @@ UpdatePageEntries (
   // EntryMask: bitmask of values to change (1 = change this value, 0 = leave alone)\r
   // EntryValue: values at bit positions specified by EntryMask\r
   EntryMask = TT_DESCRIPTOR_PAGE_TYPE_MASK | TT_DESCRIPTOR_PAGE_AP_MASK;\r
-  if (Attributes & EFI_MEMORY_XP) {\r
+  if ((Attributes & EFI_MEMORY_XP) != 0) {\r
     EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE_XN;\r
   } else {\r
     EntryValue = TT_DESCRIPTOR_PAGE_TYPE_PAGE;\r
@@ -116,33 +116,33 @@ UpdatePageEntries (
   // is irrelevant. If no memory attribute is specified, we preserve whatever\r
   // memory type is set in the page tables, and update the permission attributes\r
   // only.\r
-  if (Attributes & EFI_MEMORY_UC) {\r
+  if ((Attributes & EFI_MEMORY_UC) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
     // map to strongly ordered\r
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0, B=0\r
-  } else if (Attributes & EFI_MEMORY_WC) {\r
+  } else if ((Attributes & EFI_MEMORY_WC) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
     // map to normal non-cachable\r
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2, B=0, C=0\r
-  } else if (Attributes & EFI_MEMORY_WT) {\r
+  } else if ((Attributes & EFI_MEMORY_WT) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
     // write through with no-allocate\r
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] = 0, C=1, B=0\r
-  } else if (Attributes & EFI_MEMORY_WB) {\r
+  } else if ((Attributes & EFI_MEMORY_WB) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK;\r
     // write back (with allocate)\r
     EntryValue |= TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001, C=1, B=1\r
-  } else if (Attributes & CACHE_ATTRIBUTE_MASK) {\r
+  } else if ((Attributes & CACHE_ATTRIBUTE_MASK) != 0) {\r
     // catch unsupported memory type attributes\r
     ASSERT (FALSE);\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  if (Attributes & EFI_MEMORY_RO) {\r
+  if ((Attributes & EFI_MEMORY_RO) != 0) {\r
     EntryValue |= TT_DESCRIPTOR_PAGE_AP_RO_RO;\r
   } else {\r
     EntryValue |= TT_DESCRIPTOR_PAGE_AP_RW_RW;\r
@@ -244,39 +244,39 @@ UpdateSectionEntries (
   // is irrelevant. If no memory attribute is specified, we preserve whatever\r
   // memory type is set in the page tables, and update the permission attributes\r
   // only.\r
-  if (Attributes & EFI_MEMORY_UC) {\r
+  if ((Attributes & EFI_MEMORY_UC) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
     // map to strongly ordered\r
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0, B=0\r
-  } else if (Attributes & EFI_MEMORY_WC) {\r
+  } else if ((Attributes & EFI_MEMORY_WC) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
     // map to normal non-cachable\r
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2, B=0, C=0\r
-  } else if (Attributes & EFI_MEMORY_WT) {\r
+  } else if ((Attributes & EFI_MEMORY_WT) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
     // write through with no-allocate\r
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] = 0, C=1, B=0\r
-  } else if (Attributes & EFI_MEMORY_WB) {\r
+  } else if ((Attributes & EFI_MEMORY_WB) != 0) {\r
     // modify cacheability attributes\r
     EntryMask |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK;\r
     // write back (with allocate)\r
     EntryValue |= TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001, C=1, B=1\r
-  } else if (Attributes & CACHE_ATTRIBUTE_MASK) {\r
+  } else if ((Attributes & CACHE_ATTRIBUTE_MASK) != 0) {\r
     // catch unsupported memory type attributes\r
     ASSERT (FALSE);\r
     return EFI_UNSUPPORTED;\r
   }\r
 \r
-  if (Attributes & EFI_MEMORY_RO) {\r
+  if ((Attributes & EFI_MEMORY_RO) != 0) {\r
     EntryValue |= TT_DESCRIPTOR_SECTION_AP_RO_RO;\r
   } else {\r
     EntryValue |= TT_DESCRIPTOR_SECTION_AP_RW_RW;\r
   }\r
 \r
-  if (Attributes & EFI_MEMORY_XP) {\r
+  if ((Attributes & EFI_MEMORY_XP) != 0) {\r
     EntryValue |= TT_DESCRIPTOR_SECTION_XN_MASK;\r
   }\r
 \r