[edk2-devel] [PATCH v2 04/11] ArmPkg: Fix Non-Boolean comparison in ArmGicEnableDistributor

Sami Mujawar posted 11 patches 12 months ago
[edk2-devel] [PATCH v2 04/11] ArmPkg: Fix Non-Boolean comparison in ArmGicEnableDistributor
Posted by Sami Mujawar 12 months ago
According to edk2 coding standard specification, Non-Boolean
comparisons must use a compare operator (==, !=, >, < >=, <=).
See Section 5.7.2.1 at https://edk2-docs.gitbook.io/
edk-ii-c-coding-standards-specification/5_source_files/
57_c_programming

Therefore, fix the comparison in ArmGicEnableDistributor()

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

Notes:
    v2:
     - Improve coding style by using temporary variable      [Ard]
     - Updated based on review feedback                      [Sami]
     - Ref: https://edk2.groups.io/g/devel/message/105189

 ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c b/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c
index 38bbf2e9f81527b2545a0116120ceee56af17808..1a6ad48d1ff6c3eb5c8c375606c1600e42db42d6 100644
--- a/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c
+++ b/ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c
@@ -17,6 +17,7 @@ ArmGicEnableDistributor (
   )
 {
   ARM_GIC_ARCH_REVISION  Revision;
+  UINT32                 GicDistributorCtl;
 
   /*
    * Enable GIC distributor in Non-Secure world.
@@ -26,7 +27,8 @@ ArmGicEnableDistributor (
   if (Revision == ARM_GIC_ARCH_REVISION_2) {
     MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
   } else {
-    if (MmioRead32 (GicDistributorBase + ARM_GIC_ICDDCR) & ARM_GIC_ICDDCR_ARE) {
+    GicDistributorCtl = MmioRead32 (GicDistributorBase + ARM_GIC_ICDDCR);
+    if ((GicDistributorCtl & ARM_GIC_ICDDCR_ARE) != 0) {
       MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x2);
     } else {
       MmioOr32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x1);
-- 
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#105245): https://edk2.groups.io/g/devel/message/105245
Mute This Topic: https://groups.io/mt/99108682/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-