From: Douglas Lowder Date: Wed, 20 Oct 2004 05:01:27 +0000 (-0700) Subject: Patch from Chris Larson to clean up comparisons between mismatched types X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5843689bb5269cf559122bfb2373be15b1e3c744;p=android-x86%2Fexternal-tslib.git Patch from Chris Larson to clean up comparisons between mismatched types (signed and unsigned), some of which can break Xfbdev. -DML --- diff --git a/ChangeLog b/ChangeLog index 4fd537a..1b4aecd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-10-19 Chris Larson + + * 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 * plugins/input-raw.c: As EV_SYN can be checked for at runtime rather diff --git a/plugins/arctic2-raw.c b/plugins/arctic2-raw.c index 98f6f37..b55218c 100644 --- a/plugins/arctic2-raw.c +++ b/plugins/arctic2-raw.c @@ -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; diff --git a/plugins/collie-raw.c b/plugins/collie-raw.c index 33faffd..b5398f1 100644 --- a/plugins/collie-raw.c +++ b/plugins/collie-raw.c @@ -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; diff --git a/plugins/corgi-raw.c b/plugins/corgi-raw.c index f758719..9c7abd9 100644 --- a/plugins/corgi-raw.c +++ b/plugins/corgi-raw.c @@ -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; diff --git a/plugins/dejitter.c b/plugins/dejitter.c index cea8f5c..c99a28c 100644 --- a/plugins/dejitter.c +++ b/plugins/dejitter.c @@ -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]; diff --git a/plugins/h3600-raw.c b/plugins/h3600-raw.c index 33031ec..ad29f32 100644 --- a/plugins/h3600-raw.c +++ b/plugins/h3600-raw.c @@ -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; diff --git a/plugins/input-raw.c b/plugins/input-raw.c index cc9de62..ccc644c 100644 --- a/plugins/input-raw.c +++ b/plugins/input-raw.c @@ -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 */ diff --git a/plugins/mk712-raw.c b/plugins/mk712-raw.c index f589c24..ed802cf 100644 --- a/plugins/mk712-raw.c +++ b/plugins/mk712-raw.c @@ -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) diff --git a/plugins/pthres.c b/plugins/pthres.c index df81410..e9eae68 100644 --- a/plugins/pthres.c +++ b/plugins/pthres.c @@ -25,8 +25,8 @@ struct tslib_pthres { struct tslib_module_info module; - int pmin; - int pmax; + unsigned int pmin; + unsigned int pmax; }; static int diff --git a/plugins/ucb1x00-raw.c b/plugins/ucb1x00-raw.c index 864c7e3..69e2454 100644 --- a/plugins/ucb1x00-raw.c +++ b/plugins/ucb1x00-raw.c @@ -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; diff --git a/plugins/variance.c b/plugins/variance.c index 93b4413..471914b 100644 --- a/plugins/variance.c +++ b/plugins/variance.c @@ -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; diff --git a/src/ts_attach.c b/src/ts_attach.c index b0bb3f6..29cef81 100644 --- a/src/ts_attach.c +++ b/src/ts_attach.c @@ -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; } diff --git a/src/ts_config.c b/src/ts_config.c index 9d221e7..fa732d6 100644 --- a/src/ts_config.c +++ b/src/ts_config.c @@ -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); diff --git a/src/ts_load_module.c b/src/ts_load_module.c index a132584..266740e 100644 --- a/src/ts_load_module.c +++ b/src/ts_load_module.c @@ -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); } diff --git a/tests/fbutils.c b/tests/fbutils.c index 26d3a3d..2e41db0 100644 --- a/tests/fbutils.c +++ b/tests/fbutils.c @@ -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; diff --git a/tests/testutils.c b/tests/testutils.c index b61113b..94a5157 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -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 #include +#include #include #include "tslib.h" #include "fbutils.h" diff --git a/tests/ts_calibrate.c b/tests/ts_calibrate.c index 1b024b6..004517b 100644 --- a/tests/ts_calibrate.c +++ b/tests/ts_calibrate.c @@ -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); diff --git a/tests/ts_harvest.c b/tests/ts_harvest.c index ebc6129..1d77810 100644 --- a/tests/ts_harvest.c +++ b/tests/ts_harvest.c @@ -21,6 +21,7 @@ #include #include #include +#include #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; } diff --git a/tests/ts_test.c b/tests/ts_test.c index 59c3334..0ec02e8 100644 --- a/tests/ts_test.c +++ b/tests/ts_test.c @@ -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;