]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add Coccinelle patch for replacing tt_assert() usage on integer types.
authorAlexander Færøy <ahf@torproject.org>
Mon, 5 Jun 2017 15:22:11 +0000 (15:22 +0000)
committerNick Mathewson <nickm@torproject.org>
Thu, 24 Aug 2017 19:21:43 +0000 (15:21 -0400)
This patch replaces tt_assert() comparison of integers and unsigned
integers with their respective tt_int_op or tt_uint_op counterpart.

scripts/coccinelle/test_assert_int.cocci [new file with mode: 0644]

diff --git a/scripts/coccinelle/test_assert_int.cocci b/scripts/coccinelle/test_assert_int.cocci
new file mode 100644 (file)
index 0000000..80e86b4
--- /dev/null
@@ -0,0 +1,49 @@
+@@
+int e;
+constant c;
+@@
+
+(
+- tt_assert(e == c)
++ tt_int_op(e, OP_EQ, c)
+|
+- tt_assert(e != c)
++ tt_int_op(e, OP_NE, c)
+|
+- tt_assert(e < c)
++ tt_int_op(e, OP_LT, c)
+|
+- tt_assert(e <= c)
++ tt_int_op(e, OP_LE, c)
+|
+- tt_assert(e > c)
++ tt_int_op(e, OP_GT, c)
+|
+- tt_assert(e >= c)
++ tt_int_op(e, OP_GE, c)
+)
+
+@@
+unsigned int e;
+constant c;
+@@
+
+(
+- tt_assert(e == c)
++ tt_uint_op(e, OP_EQ, c)
+|
+- tt_assert(e != c)
++ tt_uint_op(e, OP_NE, c)
+|
+- tt_assert(e < c)
++ tt_uint_op(e, OP_LT, c)
+|
+- tt_assert(e <= c)
++ tt_uint_op(e, OP_LE, c)
+|
+- tt_assert(e > c)
++ tt_uint_op(e, OP_GT, c)
+|
+- tt_assert(e >= c)
++ tt_uint_op(e, OP_GE, c)
+)