From a9e5186075025e7d3b0305669d5a96f96c9c0c19 Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Thu, 10 Dec 2020 10:17:24 +0000 Subject: ArmPkg: Fix Ecc error 3002 in ArmMmuLib This patch fixes the following Ecc reported error: Non-Boolean comparisons should use a compare operator (==, !=, >, < >=, <=) Signed-off-by: Pierre Gondois Reviewed-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 2 +- ArmPkg/Library/ArmMmuLib/Arm/ArmMmuLibUpdate.c | 30 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'ArmPkg') diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c index 513a763e6e..8c736d25bb 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 6f18604f79..34ba691d9d 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-2021, Arm Limited. All rights reserved.
* * 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; } -- cgit v1.2.3