[gnome-control-center] calibrator: Use G_STMT_START/END on SWAP define



commit 4a9bde06792e10c82934b49de316813a6540bcf2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jul 1 16:58:42 2014 +0200

    calibrator: Use G_STMT_START/END on SWAP define
    
    And let it pass the type, so it can be used on other than integers.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732442

 panels/wacom/calibrator/calibrator.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/panels/wacom/calibrator/calibrator.c b/panels/wacom/calibrator/calibrator.c
index d94fedb..baa45b6 100644
--- a/panels/wacom/calibrator/calibrator.c
+++ b/panels/wacom/calibrator/calibrator.c
@@ -25,7 +25,10 @@
 
 #include "calibrator.h"
 
-#define SWAP(x,y)  do { int t; t=(x); x=(y); y=t; } while (0)
+#define SWAP(valtype,x,y)              \
+    G_STMT_START {                     \
+    valtype t; t = (x); x = (y); y = t;        \
+    } G_STMT_END
 
 /* reset clicks */
 void
@@ -142,8 +145,8 @@ finish (struct Calib *c,
     swap_xy = (abs (c->clicked_x [UL] - c->clicked_x [UR]) < abs (c->clicked_y [UL] - c->clicked_y [UR]));
     if (swap_xy)
     {
-        SWAP(c->clicked_x[LL], c->clicked_x[UR]);
-        SWAP(c->clicked_y[LL], c->clicked_y[UR]);
+        SWAP(int, c->clicked_x[LL], c->clicked_x[UR]);
+        SWAP(int, c->clicked_y[LL], c->clicked_y[UR]);
     }
 
     /* Compute min/max coordinates. */
@@ -168,8 +171,8 @@ finish (struct Calib *c,
     /* If x and y has to be swapped we also have to swap the parameters */
     if (swap_xy)
     {
-        SWAP(axis.x_min, axis.y_max);
-        SWAP(axis.y_min, axis.x_max);
+        SWAP(int, axis.x_min, axis.y_max);
+        SWAP(int, axis.y_min, axis.x_max);
     }
 
     *new_axis = axis;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]