summaryrefslogtreecommitdiff
path: root/coccinelle
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-04-20 15:36:20 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-06-04 11:50:44 +0200
commitd94a24ca2ea769755beaed0659b966b1ec75c8d4 (patch)
treee809995a39930fbc317fecc96e403c13f76737f0 /coccinelle
parent00bfe67f6b178056bffcfa9fbfb04ca3fa809989 (diff)
Add macro for checking if some flags are set
This way we don't need to repeat the argument twice. I didn't replace all instances. I think it's better to leave out: - asserts - comparisons like x & y == x, which are mathematically equivalent, but here we aren't checking if flags are set, but if the argument fits in the flags.
Diffstat (limited to 'coccinelle')
-rw-r--r--coccinelle/flags-set.cocci15
1 files changed, 15 insertions, 0 deletions
diff --git a/coccinelle/flags-set.cocci b/coccinelle/flags-set.cocci
new file mode 100644
index 0000000000..1a70717e76
--- /dev/null
+++ b/coccinelle/flags-set.cocci
@@ -0,0 +1,15 @@
+@@
+expression x, y;
+@@
+- ((x) & (y)) == (y)
++ FLAGS_SET(x, y)
+@@
+expression x, y;
+@@
+- (x & (y)) == (y)
++ FLAGS_SET(x, y)
+@@
+expression x, y;
+@@
+- ((x) & y) == y
++ FLAGS_SET(x, y)