tools/wrc: fix some -Wsign-compare bugs

Stefan Huehner stefan at huehner.org
Thu Jun 30 09:13:52 CDT 2005


Hi,

attached patch fixes some -Wsign-compare warnings in wrc. It switches
the res_t struct to unsigned ints. As the size and allocsize members are
initialized with 0 and are only incremented this shouldn't alter
functionality.

The res_t.dataidx members isn't used at all. It is writte to in a couple
of places be never used. Some planned extension? Or a candidate for
removal?

ChangeLog:
- fix some -Wsign-compare warnings

Regards,
Stefan
-------------- next part --------------
Index: tools/wrc/genres.c
===================================================================
RCS file: /home/wine/wine/tools/wrc/genres.c,v
retrieving revision 1.25
diff -u -p -r1.25 genres.c
--- tools/wrc/genres.c	7 Dec 2004 14:48:46 -0000	1.25
+++ tools/wrc/genres.c	30 Jun 2005 14:07:32 -0000
@@ -55,7 +55,7 @@ res_t *new_res(void)
 	return r;
 }
 
-res_t *grow_res(res_t *r, int add)
+res_t *grow_res(res_t *r, unsigned int add)
 {
 	r->allocsize += add;
 	r->data = (char *)xrealloc(r->data, r->allocsize);
@@ -407,7 +407,7 @@ static void put_lvc(res_t *res, lvc_t *l
 */
 static void put_raw_data(res_t *res, raw_data_t *raw, int offset)
 {
-	int wsize = raw->size - offset;
+	unsigned int wsize = raw->size - offset;
 	if(res->allocsize - res->size < wsize)
 		grow_res(res, wsize);
 	memcpy(&(res->data[res->size]), raw->data + offset, wsize);
Index: tools/wrc/genres.h
===================================================================
RCS file: /home/wine/wine/tools/wrc/genres.h,v
retrieving revision 1.4
diff -u -p -r1.4 genres.h
--- tools/wrc/genres.h	14 Oct 2003 01:19:27 -0000	1.4
+++ tools/wrc/genres.h	30 Jun 2005 14:07:32 -0000
@@ -24,7 +24,7 @@
 #include "wrctypes.h"
 
 res_t *new_res(void);
-res_t *grow_res(res_t *r, int add);
+res_t *grow_res(res_t *r, unsigned int add);
 void put_byte(res_t *res, unsigned c);
 void put_word(res_t *res, unsigned w);
 void put_dword(res_t *res, unsigned d);
Index: tools/wrc/wrctypes.h
===================================================================
RCS file: /home/wine/wine/tools/wrc/wrctypes.h,v
retrieving revision 1.18
diff -u -p -r1.18 wrctypes.h
--- tools/wrc/wrctypes.h	9 May 2005 09:26:28 -0000	1.18
+++ tools/wrc/wrctypes.h	30 Jun 2005 14:07:32 -0000
@@ -87,10 +87,10 @@
 #define RES_BLOCKSIZE	512
 
 typedef struct res {
-	int	allocsize;	/* Allocated datablock size */
-	int	size;		/* Actual size of data */
-	int	dataidx;	/* Tag behind the resource-header */
-	char	*data;
+	unsigned int	allocsize;	/* Allocated datablock size */
+	unsigned int	size;		/* Actual size of data */
+	unsigned int	dataidx;	/* Tag behind the resource-header */
+	char		*data;
 } res_t;
 
 /* Resource strings are slightly more complex because they include '\0' */
Index: tools/wrc/writeres.c
===================================================================
RCS file: /home/wine/wine/tools/wrc/writeres.c,v
retrieving revision 1.27
diff -u -p -r1.27 writeres.c
--- tools/wrc/writeres.c	26 Feb 2003 05:04:12 -0000	1.27
+++ tools/wrc/writeres.c	30 Jun 2005 14:07:32 -0000
@@ -47,7 +47,7 @@
 void write_resfile(char *outname, resource_t *top)
 {
 	FILE *fo;
-	int ret;
+	unsigned int ret;
 	char zeros[3] = {0, 0, 0};
 
 	fo = fopen(outname, "wb");


More information about the wine-patches mailing list