[Openmp-commits] [openmp] 7b0ca32 - [OpenMP] avoid warning: equality comparison with extraneous parentheses

Joachim Protze via Openmp-commits openmp-commits at lists.llvm.org
Thu Nov 5 03:21:53 PST 2020


Author: Joachim Protze
Date: 2020-11-05T12:13:08+01:00
New Revision: 7b0ca32b6228f6268bdd5952577ebd5ebcb2f6f7

URL: https://github.com/llvm/llvm-project/commit/7b0ca32b6228f6268bdd5952577ebd5ebcb2f6f7
DIFF: https://github.com/llvm/llvm-project/commit/7b0ca32b6228f6268bdd5952577ebd5ebcb2f6f7.diff

LOG: [OpenMP] avoid warning: equality comparison with extraneous parentheses

The macros are used in several places with an if(macro) pattern. This results
in several warnings about extraneous parenteses in equality comparison.

Having the constant at the lhs of the comparison, avoids this warning.

Differential Revision: https://reviews.llvm.org/D90756

Added: 
    

Modified: 
    openmp/runtime/src/kmp.h

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp.h b/openmp/runtime/src/kmp.h
index e78e3b9c7df3..594c5ad88468 100644
--- a/openmp/runtime/src/kmp.h
+++ b/openmp/runtime/src/kmp.h
@@ -1099,12 +1099,12 @@ extern kmp_uint64 __kmp_now_nsec();
 #define KMP_TLS_GTID_MIN INT_MAX
 #endif
 
-#define KMP_MASTER_TID(tid) ((tid) == 0)
-#define KMP_WORKER_TID(tid) ((tid) != 0)
+#define KMP_MASTER_TID(tid) (0 == (tid))
+#define KMP_WORKER_TID(tid) (0 != (tid))
 
-#define KMP_MASTER_GTID(gtid) (__kmp_tid_from_gtid((gtid)) == 0)
-#define KMP_WORKER_GTID(gtid) (__kmp_tid_from_gtid((gtid)) != 0)
-#define KMP_INITIAL_GTID(gtid) ((gtid) == 0)
+#define KMP_MASTER_GTID(gtid) (0 == __kmp_tid_from_gtid((gtid)))
+#define KMP_WORKER_GTID(gtid) (0 != __kmp_tid_from_gtid((gtid)))
+#define KMP_INITIAL_GTID(gtid) (0 == (gtid))
 
 #ifndef TRUE
 #define FALSE 0
@@ -2074,7 +2074,7 @@ extern kmp_uint64 __kmp_taskloop_min_tasks;
 // The tt_found_tasks flag is a signal to all threads in the team that tasks
 // were spawned and queued since the previous barrier release.
 #define KMP_TASKING_ENABLED(task_team)                                         \
-  (TCR_SYNC_4((task_team)->tt.tt_found_tasks) == TRUE)
+  (TRUE == TCR_SYNC_4((task_team)->tt.tt_found_tasks))
 /*!
 @ingroup BASIC_TYPES
 @{


        


More information about the Openmp-commits mailing list