[Intel-gfx] [PATCH i-g-t 2/3] lib/igt.cocci: Deal with min/max/swap
ville.syrjala at linux.intel.com
ville.syrjala at linux.intel.com
Fri Dec 5 07:04:13 PST 2014
From: Ville Syrjälä <ville.syrjala at linux.intel.com>
Replace open coded min/max/swap with the macro invocation.
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
lib/igt.cocci | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/lib/igt.cocci b/lib/igt.cocci
index adebb31..0d337bf 100644
--- a/lib/igt.cocci
+++ b/lib/igt.cocci
@@ -91,3 +91,39 @@ expression E;
@@
- assert(E);
+ igt_assert(E);
+
+// Replace open-coded swap()
+@@
+type T;
+T a, b, tmp;
+@@
+- tmp = a;
+- a = b;
+- b = tmp;
++ swap(a, b);
+
+// Replace open-coded min()
+@@
+expression a;
+expression b;
+@@
+(
+- ((a) < (b) ? (a) : (b))
++ min(a, b)
+|
+- ((a) <= (b) ? (a) : (b))
++ min(a, b)
+)
+
+// Replace open-coded max()
+@@
+expression a;
+expression b;
+@@
+(
+- ((a) > (b) ? (a) : (b))
++ max(a, b)
+|
+- ((a) >= (b) ? (a) : (b))
++ max(a, b)
+)
--
2.0.4
More information about the Intel-gfx
mailing list