summaryrefslogtreecommitdiff
path: root/scripts/coccinelle
diff options
context:
space:
mode:
authorAlexander Færøy <ahf@torproject.org>2017-06-05 15:22:11 +0000
committerNick Mathewson <nickm@torproject.org>2017-08-24 15:21:43 -0400
commit7666cd88817422da17f6ef725122ce0b230c1d24 (patch)
tree52600736722b7999e4d568daa594224838539f50 /scripts/coccinelle
parent3fd68b249b1472097c3d1466d28b926dbd380657 (diff)
downloadtor-7666cd88817422da17f6ef725122ce0b230c1d24.tar.gz
tor-7666cd88817422da17f6ef725122ce0b230c1d24.zip
Add Coccinelle patch for replacing tt_assert() usage on integer types.
This patch replaces tt_assert() comparison of integers and unsigned integers with their respective tt_int_op or tt_uint_op counterpart.
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/test_assert_int.cocci49
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/coccinelle/test_assert_int.cocci b/scripts/coccinelle/test_assert_int.cocci
new file mode 100644
index 0000000000..80e86b4f3c
--- /dev/null
+++ b/scripts/coccinelle/test_assert_int.cocci
@@ -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)
+)