summaryrefslogtreecommitdiff
path: root/scripts/coccinelle
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/coccinelle')
-rw-r--r--scripts/coccinelle/bool_assignment.cocci13
-rw-r--r--scripts/coccinelle/bool_expression.cocci29
-rw-r--r--scripts/coccinelle/bool_function.cocci21
-rw-r--r--scripts/coccinelle/bool_function_type.cocci19
-rw-r--r--scripts/coccinelle/test_after_assert.cocci7
5 files changed, 89 insertions, 0 deletions
diff --git a/scripts/coccinelle/bool_assignment.cocci b/scripts/coccinelle/bool_assignment.cocci
new file mode 100644
index 0000000000..e6146ea310
--- /dev/null
+++ b/scripts/coccinelle/bool_assignment.cocci
@@ -0,0 +1,13 @@
+@@
+bool b;
+@@
+
+(
+ b =
+- 0
++ false
+|
+ b =
+- 1
++ true
+)
diff --git a/scripts/coccinelle/bool_expression.cocci b/scripts/coccinelle/bool_expression.cocci
new file mode 100644
index 0000000000..c0c329cb59
--- /dev/null
+++ b/scripts/coccinelle/bool_expression.cocci
@@ -0,0 +1,29 @@
+@@
+bool t;
+@@
+
+(
+- t == true
++ t
+|
+- true == t
++ t
+|
+- t != true
++ !t
+|
+- true != t
++ !t
+|
+- t == false
++ !t
+|
+- false == t
++ !t
+|
+- t != false
++ t
+|
+- false != t
++ t
+)
diff --git a/scripts/coccinelle/bool_function.cocci b/scripts/coccinelle/bool_function.cocci
new file mode 100644
index 0000000000..0328ecfbbe
--- /dev/null
+++ b/scripts/coccinelle/bool_function.cocci
@@ -0,0 +1,21 @@
+@@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+bool fn ( ... )
+{
+<...
+return
+(
+- 0
++ false
+|
+- 1
++ true
+)
+ ;
+...>
+}
diff --git a/scripts/coccinelle/bool_function_type.cocci b/scripts/coccinelle/bool_function_type.cocci
new file mode 100644
index 0000000000..71bf4f53b8
--- /dev/null
+++ b/scripts/coccinelle/bool_function_type.cocci
@@ -0,0 +1,19 @@
+@@
+identifier fn;
+typedef bool;
+symbol false;
+symbol true;
+@@
+
+- int
++ bool
+fn (...)
+{
+?...
+return
+(
+ true
+|
+ false
+);
+}
diff --git a/scripts/coccinelle/test_after_assert.cocci b/scripts/coccinelle/test_after_assert.cocci
new file mode 100644
index 0000000000..30596a89c2
--- /dev/null
+++ b/scripts/coccinelle/test_after_assert.cocci
@@ -0,0 +1,7 @@
+@@
+identifier i;
+@@
+
+assert(i);
+- if (!i)
+- return ...;