[tor-commits] [tor/master] Define macros meaning <,>,==,!=,<=,>=

nickm at torproject.org nickm at torproject.org
Wed Nov 12 18:42:22 UTC 2014


commit 00f59098767766cc594c89837781c28a1ec67682
Author: Nick Mathewson <nickm at torproject.org>
Date:   Thu Nov 6 11:19:31 2014 -0500

    Define macros meaning <,>,==,!=,<=,>=
    
    This lets us avoid putting operators directly in macro arguments,
    and thus will help us unconfuse coccinelle.
    
    For ticket 13172.
---
 changes/ticket13172 |    4 ++++
 src/common/compat.h |    9 +++++++++
 2 files changed, 13 insertions(+)

diff --git a/changes/ticket13172 b/changes/ticket13172
new file mode 100644
index 0000000..a1d47fd
--- /dev/null
+++ b/changes/ticket13172
@@ -0,0 +1,4 @@
+  o Code simplification and refactoring:
+    - Avoid using operators directly as macro arguments: this lets us
+      apply coccinelle transformations to our codebase more
+      directly. Closes ticket 13172.
\ No newline at end of file
diff --git a/src/common/compat.h b/src/common/compat.h
index f2eef5b..7001361 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -203,6 +203,15 @@ extern INLINE double U64_TO_DBL(uint64_t x) {
 #define STMT_END } while (0)
 #endif
 
+/* Some tools (like coccinelle) don't like to see operators as macro
+ * arguments. */
+#define OP_LT <
+#define OP_GT >
+#define OP_GE >=
+#define OP_LE <=
+#define OP_EQ ==
+#define OP_NE !=
+
 /* ===== String compatibility */
 #ifdef _WIN32
 /* Windows names string functions differently from most other platforms. */





More information about the tor-commits mailing list