OSDN Git Service

Patch from Chris Larson to clean up comparisons between mismatched types
authorDouglas Lowder <douglowder@mac.com>
Wed, 20 Oct 2004 05:01:27 +0000 (22:01 -0700)
committerDouglas Lowder <douglowder@mac.com>
Wed, 20 Oct 2004 05:01:27 +0000 (22:01 -0700)
(signed and unsigned), some of which can break Xfbdev.
-DML

19 files changed:
ChangeLog
plugins/arctic2-raw.c
plugins/collie-raw.c
plugins/corgi-raw.c
plugins/dejitter.c
plugins/h3600-raw.c
plugins/input-raw.c
plugins/mk712-raw.c
plugins/pthres.c
plugins/ucb1x00-raw.c
plugins/variance.c
src/ts_attach.c
src/ts_config.c
src/ts_load_module.c
tests/fbutils.c
tests/testutils.c
tests/ts_calibrate.c
tests/ts_harvest.c
tests/ts_test.c

index 4fd537a..1b4aecd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-19 Chris Larson <kergoth@handhelds.org>
+
+       * Files all over the tree: Fixed up a bunch of compile warnings,
+         at least some of which actually did cause breakage for the user.
+
 2004-07-08 Chris Larson <kergoth@handhelds.org>
 
        * plugins/input-raw.c: As EV_SYN can be checked for at runtime rather
index 98f6f37..b55218c 100644 (file)
@@ -23,7 +23,7 @@ static int arctic2_read(struct tslib_module_info *inf, struct ts_sample *samp, i
        ret = read(ts->fd, arctic2_evt, sizeof(*arctic2_evt) * nr);
        if(ret > 0) {
                int nr = ret / sizeof(*arctic2_evt);
-               while(ret >= sizeof(*arctic2_evt)) {
+               while(ret >= (int)sizeof(*arctic2_evt)) {
                        samp->x = (short)arctic2_evt->x;
                        samp->y = (short)arctic2_evt->y;
                        samp->pressure = arctic2_evt->pressure;
index 33faffd..b5398f1 100644 (file)
@@ -22,7 +22,7 @@ static int collie_read(struct tslib_module_info *inf, struct ts_sample *samp, in
        ret = read(ts->fd, collie_evt, sizeof(*collie_evt) * nr);
        if(ret > 0) {
                int nr = ret / sizeof(*collie_evt);
-               while(ret >= sizeof(*collie_evt)) {
+               while(ret >= (int)sizeof(*collie_evt)) {
                        samp->x = collie_evt->x;
                        samp->y = collie_evt->y;
                        samp->pressure = collie_evt->pressure;
index f758719..9c7abd9 100644 (file)
@@ -22,7 +22,7 @@ static int corgi_read(struct tslib_module_info *inf, struct ts_sample *samp, int
        ret = read(ts->fd, corgi_evt, sizeof(*corgi_evt) * nr);
        if(ret > 0) {
                int nr = ret / sizeof(*corgi_evt);
-               while(ret >= sizeof(*corgi_evt)) {
+               while(ret >= (int)sizeof(*corgi_evt)) {
                        samp->x = corgi_evt->x;
                        samp->y = corgi_evt->y;
                        samp->pressure = corgi_evt->pressure;
index cea8f5c..c99a28c 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the LGPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: dejitter.c,v 1.7 2004/07/21 19:12:58 dlowder Exp $
+ * $Id: dejitter.c,v 1.8 2004/10/19 22:01:27 dlowder Exp $
  *
  * Problem: some touchscreens read the X/Y values from ADC with a
  * great level of noise in their lowest bits. This produces "jitter"
@@ -58,17 +58,17 @@ static const unsigned char weight [NR_SAMPHISTLEN - 1][NR_SAMPHISTLEN + 1] =
 struct ts_hist {
        int x;
        int y;
-       int p;
+       unsigned int p;
 };
 
 struct tslib_dejitter {
        struct tslib_module_info module;
-       unsigned int delta;
-       unsigned int x;
-       unsigned int y;
-       unsigned int down;
-       unsigned int nr;
-       unsigned int head;
+       int delta;
+       int x;
+       int y;
+       int down;
+       int nr;
+       int head;
        struct ts_hist hist[NR_SAMPHISTLEN];
 };
 
@@ -81,7 +81,8 @@ static void average (struct tslib_dejitter *djt, struct ts_sample *samp)
 {
        const unsigned char *w;
        int sn = djt->head;
-       int i, x = 0, y = 0, p = 0;
+       int i, x = 0, y = 0;
+       unsigned int p = 0;
 
         w = weight [djt->nr - 2];
 
index 33031ec..ad29f32 100644 (file)
@@ -22,7 +22,7 @@ static int h3600_read(struct tslib_module_info *inf, struct ts_sample *samp, int
        ret = read(ts->fd, h3600_evt, sizeof(*h3600_evt) * nr);
        if(ret > 0) {
                int nr = ret / sizeof(*h3600_evt);
-               while(ret >= sizeof(*h3600_evt)) {
+               while(ret >= (int)sizeof(*h3600_evt)) {
                        samp->x = h3600_evt->x;
                        samp->y = h3600_evt->y;
                        samp->pressure = h3600_evt->pressure;
index cc9de62..ccc644c 100644 (file)
@@ -10,7 +10,7 @@
  * This file is placed under the LGPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: input-raw.c,v 1.3 2004/10/18 22:10:30 dlowder Exp $
+ * $Id: input-raw.c,v 1.4 2004/10/19 22:01:27 dlowder Exp $
  *
  * Read raw pressure, x, y, and timestamp from a touchscreen device.
  */
@@ -86,7 +86,7 @@ static int ts_input_read(struct tslib_module_info *inf,
        if (i->using_syn) {
                while (total < nr) {
                        ret = read(ts->fd, &ev, sizeof(struct input_event));
-                       if (ret < sizeof(struct input_event)) {
+                       if (ret < (int)sizeof(struct input_event)) {
                                total = -1;
                                break;
                        }
@@ -150,7 +150,7 @@ static int ts_input_read(struct tslib_module_info *inf,
                                break;
                        }
        
-                       if (ret < sizeof(struct input_event)) {
+                       if (ret < (int)sizeof(struct input_event)) {
                                /* short read
                                 * restart read to get the rest of the event
                                 */
index f589c24..ed802cf 100644 (file)
@@ -22,7 +22,7 @@ static int mk712_read(struct tslib_module_info *inf, struct ts_sample *samp, int
        ret = read(ts->fd, mk712_evt, sizeof(*mk712_evt) * nr);
        if(ret > 0) {
                int nr = ret / sizeof(*mk712_evt);
-               while(ret >= sizeof(*mk712_evt)) {
+               while(ret >= (int)sizeof(*mk712_evt)) {
                        samp->x = (short)mk712_evt->x;
                        samp->y = (short)mk712_evt->y;
                        if(mk712_evt->header==0)
index df81410..e9eae68 100644 (file)
@@ -25,8 +25,8 @@
 
 struct tslib_pthres {
        struct tslib_module_info module;
-       int     pmin;
-       int     pmax;
+       unsigned int    pmin;
+       unsigned int    pmax;
 };
 
 static int
index 864c7e3..69e2454 100644 (file)
@@ -23,7 +23,7 @@ static int ucb1x00_read(struct tslib_module_info *inf, struct ts_sample *samp, i
        ret = read(ts->fd, ucb1x00_evt, sizeof(*ucb1x00_evt) * nr);
        if(ret > 0) {
                int nr = ret / sizeof(*ucb1x00_evt);
-               while(ret >= sizeof(*ucb1x00_evt)) {
+               while(ret >= (int)sizeof(*ucb1x00_evt)) {
                        samp->x = ucb1x00_evt->x;
                        samp->y = ucb1x00_evt->y;
                        samp->pressure = ucb1x00_evt->pressure;
index 93b4413..471914b 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the LGPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: variance.c,v 1.4 2004/07/21 19:12:59 dlowder Exp $
+ * $Id: variance.c,v 1.5 2004/10/19 22:01:27 dlowder Exp $
  *
  * Variance filter for touchscreen values.
  *
@@ -33,7 +33,7 @@
 
 struct tslib_variance {
        struct tslib_module_info module;
-       unsigned int delta;
+       int delta;
         struct ts_sample last;
         struct ts_sample noise;
        unsigned int flags;
index b0bb3f6..29cef81 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the LGPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: ts_attach.c,v 1.2 2004/07/21 19:12:59 dlowder Exp $
+ * $Id: ts_attach.c,v 1.3 2004/10/19 22:01:27 dlowder Exp $
  *
  * Attach a filter to a touchscreen device.
  */
@@ -42,12 +42,10 @@ int __ts_attach_raw(struct tsdev *ts, struct tslib_module_info *info)
                return 0;
        }
 
-       next = ts->list;
-       
-       while (next != NULL && next != prev_list)
-               prev = next, next = prev->next;
+       for(next = ts->list, prev=next;
+           next != NULL && next != prev_list;
+           next = prev->next, prev = next);
 
        prev->next = info;
-
        return 0;
 }
index 9d221e7..fa732d6 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the LGPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: ts_config.c,v 1.4 2004/07/21 19:12:59 dlowder Exp $
+ * $Id: ts_config.c,v 1.5 2004/10/19 22:01:27 dlowder Exp $
  *
  * Read the configuration and load the appropriate drivers.
  */
@@ -28,7 +28,7 @@ int ts_config(struct tsdev *ts)
        char buf[BUF_SIZE], *p;
        FILE *f;
        int line = 0;
-       int ret;
+       int ret = 0;
 
        char *conffile;
 
@@ -91,7 +91,7 @@ int ts_config(struct tsdev *ts)
 
        if (ts->list_raw == NULL) {
                ts_error("No raw modules loaded.\n");
-               return -1;
+               ret = -1;
        }
 
        fclose(f);
index a132584..266740e 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the LGPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: ts_load_module.c,v 1.3 2004/07/21 19:12:59 dlowder Exp $
+ * $Id: ts_load_module.c,v 1.4 2004/10/19 22:01:27 dlowder Exp $
  *
  * Close a touchscreen device.
  */
@@ -79,10 +79,10 @@ int __ts_load_module(struct tsdev *ts, const char *module, const char *params, i
 
 int ts_load_module(struct tsdev *ts, const char *module, const char *params)
 {
-       __ts_load_module(ts, module, params, 0);
+       return __ts_load_module(ts, module, params, 0);
 }
 
 int ts_load_module_raw(struct tsdev *ts, const char *module, const char *params)
 {
-       __ts_load_module(ts, module, params, 1);
+       return __ts_load_module(ts, module, params, 1);
 }
index 26d3a3d..2e41db0 100644 (file)
@@ -42,7 +42,7 @@ static unsigned char **line_addr;
 static int fb_fd=0;
 static int bytes_per_pixel;
 static unsigned colormap [256];
-int xres, yres;
+__u32 xres, yres;
 
 static char *defaultfbdevice = "/dev/fb0";
 static char *defaultconsoledevice = "/dev/tty";
@@ -136,7 +136,7 @@ int open_framebuffer(void)
        memset(fbuffer,0,fix.smem_len);
 
        bytes_per_pixel = (var.bits_per_pixel + 7) / 8;
-       line_addr = malloc (sizeof (unsigned) * var.yres_virtual);
+       line_addr = malloc (sizeof (__u32) * var.yres_virtual);
        addr = 0;
        for (y = 0; y < var.yres_virtual; y++, addr += fix.line_length)
                line_addr [y] = fbuffer + addr;
@@ -288,8 +288,8 @@ void pixel (int x, int y, unsigned colidx)
        unsigned xormode;
        union multiptr loc;
 
-       if ((x < 0) || (x >= var.xres_virtual) ||
-           (y < 0) || (y >= var.yres_virtual))
+       if ((x < 0) || ((__u32)x >= var.xres_virtual) ||
+           (y < 0) || ((__u32)y >= var.yres_virtual))
                return;
 
        xormode = colidx & XORMODE;
@@ -360,10 +360,10 @@ void fillrect (int x1, int y1, int x2, int y2, unsigned colidx)
        /* Clipping and sanity checking */
        if (x1 > x2) { tmp = x1; x1 = x2; x2 = tmp; }
        if (y1 > y2) { tmp = y1; y1 = y2; y2 = tmp; }
-       if (x1 < 0) x1 = 0; if (x1 >= xres) x1 = xres - 1;
-       if (x2 < 0) x2 = 0; if (x2 >= xres) x2 = xres - 1;
-       if (y1 < 0) y1 = 0; if (y1 >= yres) y1 = yres - 1;
-       if (y2 < 0) y2 = 0; if (y2 >= yres) y2 = yres - 1;
+       if (x1 < 0) x1 = 0; if ((__u32)x1 >= xres) x1 = xres - 1;
+       if (x2 < 0) x2 = 0; if ((__u32)x2 >= xres) x2 = xres - 1;
+       if (y1 < 0) y1 = 0; if ((__u32)y1 >= yres) y1 = yres - 1;
+       if (y2 < 0) y2 = 0; if ((__u32)y2 >= yres) y2 = yres - 1;
 
        if ((x1 > x2) || (y1 > y2))
                return;
index b61113b..94a5157 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the GPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: testutils.c,v 1.1 2004/07/21 19:17:18 dlowder Exp $
+ * $Id: testutils.c,v 1.2 2004/10/19 22:01:27 dlowder Exp $
  *
  * Waits for the screen to be touched, averages x and y sample
  * coordinates until the end of contact
@@ -15,6 +15,7 @@
 #include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include <sys/time.h>
 #include "tslib.h"
 #include "fbutils.h"
index 1b024b6..004517b 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the GPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: ts_calibrate.c,v 1.7 2004/07/21 19:12:59 dlowder Exp $
+ * $Id: ts_calibrate.c,v 1.8 2004/10/19 22:01:27 dlowder Exp $
  *
  * Basic test program for touchscreen library.
  */
@@ -170,7 +170,7 @@ int main()
        char cal_buffer[256];
        char *tsdevice = NULL;
        char *calfile = NULL;
-       int i;
+       unsigned int i;
 
        signal(SIGSEGV, sig);
        signal(SIGINT, sig);
index ebc6129..1d77810 100644 (file)
@@ -21,6 +21,7 @@
 #include <sys/ioctl.h>
 #include <sys/mman.h>
 #include <sys/time.h>
+#include <unistd.h>
 
 #include "tslib.h"
 #include "fbutils.h"
@@ -63,7 +64,8 @@ static void ts_harvest_put_cross (int x, int y, unsigned colidx)
 int main()
 {
        struct tsdev *ts;
-       int i, x, y, x_incr, y_incr, x_ts, y_ts, xres_half, yres_half, x_new, y_new;
+       int x, y, x_incr, y_incr, x_ts, y_ts, xres_half, yres_half, x_new, y_new;
+       unsigned int i;
        char *tsdevice=NULL;
        struct ts_sample samp;
        FILE *output_fid;
@@ -200,4 +202,5 @@ int main()
        getxy (ts, &x_ts, &y_ts); 
        refresh_screen ();
        close_framebuffer();
+       return 0;
 }
index 59c3334..0ec02e8 100644 (file)
@@ -6,7 +6,7 @@
  * This file is placed under the GPL.  Please see the file
  * COPYING for more details.
  *
- * $Id: ts_test.c,v 1.5 2004/07/21 19:12:59 dlowder Exp $
+ * $Id: ts_test.c,v 1.6 2004/10/19 22:01:27 dlowder Exp $
  *
  * Basic test program for touchscreen library.
  */
@@ -109,8 +109,9 @@ static void refresh_screen ()
 int main()
 {
        struct tsdev *ts;
-       int i, x, y;
-       int mode = 0;
+       int x, y;
+       unsigned int i;
+       unsigned int mode = 0;
 
        char *tsdevice=NULL;