Fixes warnings about the "width", "height", "x_org", and "y_org"
variables in "set_output_next" potentially being undefined. Although
careful consideration of the code shows that they must be defined,
GCC's static analyzer apparently isn't quite up to the task. This
commit rewrites the loop/switch construct to be more straightforward
and analyzable.

Signed-off-by: Jason Gerecke <killert...@gmail.com>
---
 tools/xsetwacom.c | 29 +++++++++--------------------
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 22b47de..1fd70c8 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -2189,7 +2189,6 @@ static Bool get_mapped_area(Display *dpy, XDevice *dev, 
int *width, int *height,
        unsigned long nitems, bytes_after;
        float *data;
        Bool matrix_is_valid = True;
-       int i;
 
        int display_width = DisplayWidth(dpy, DefaultScreen(dpy));
        int display_height = DisplayHeight(dpy, DefaultScreen(dpy));
@@ -2218,27 +2217,17 @@ static Bool get_mapped_area(Display *dpy, XDevice *dev, 
int *width, int *height,
        TRACE(" [ %f %f %f ]\n", data[3], data[4], data[5]);
        TRACE(" [ %f %f %f ]\n", data[6], data[7], data[8]);
 
-       for (i = 0; i < nitems && matrix_is_valid; i++)
-       {
-               switch (i) {
-                       case 0: *width  = rint(display_width  * data[i]); break;
-                       case 2: *x_org  = rint(display_width  * data[i]); break;
-                       case 4: *height = rint(display_height * data[i]); break;
-                       case 5: *y_org  = rint(display_height * data[i]); break;
-                       case 8:
-                               if (data[i] != 1)
-                                       matrix_is_valid = False;
-                               break;
-                       default:
-                               if (data[i] != 0)
-                                       matrix_is_valid = False;
-                               break;
-               }
+       *width  = rint(display_width  * data[0]);
+       *x_org  = rint(display_width  * data[2]);
+       *height = rint(display_height * data[4]);
+       *y_org  = rint(display_height * data[5]);
+       if ((data[1] != 0 || data[3] != 0 || data[6] != 0 || data[7] != 0) ||
+           (data[8] != 1)) {
+               fprintf(stderr, "Non-rectangular transformation matrix 
detected.\n");
+               matrix_is_valid = False;
        }
-       XFree(data);
 
-       if (!matrix_is_valid)
-               fprintf(stderr, "Non-rectangular transformation matrix 
detected.\n");
+       XFree(data);
 
        return matrix_is_valid;
 }
-- 
2.2.2


------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel

Reply via email to