From: havoc Date: Wed, 4 Jun 2003 19:22:31 +0000 (+0000) Subject: fixed a bunch of signed/unsigned mismatch warnings in newer gcc versions (mostly... X-Git-Tag: xonotic-v0.1.0preview~6599 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fdarkplaces.git;a=commitdiff_plain;h=3f2bc4a392c209700360c90bcfcf826b135c898d;ds=sidebyside fixed a bunch of signed/unsigned mismatch warnings in newer gcc versions (mostly related to size_t being unsigned) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@3065 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/common.c b/common.c index 8987d7f3..875c8d37 100644 --- a/common.c +++ b/common.c @@ -339,7 +339,7 @@ char *MSG_ReadString (void) { static char string[2048]; int l,c; - for (l = 0;l < sizeof(string) - 1 && (c = MSG_ReadChar()) != -1 && c != 0;l++) + for (l = 0;l < (int) sizeof(string) - 1 && (c = MSG_ReadChar()) != -1 && c != 0;l++) string[l] = c; string[l] = 0; return string; diff --git a/fs.c b/fs.c index 4aead3ec..d7379121 100644 --- a/fs.c +++ b/fs.c @@ -383,7 +383,7 @@ qboolean PK3_GetEndOfCentralDir (const char *packfile, FILE *packhandle, pk3_end maxsize = ZIP_MAX_COMMENTS_SIZE + ZIP_END_CDIR_SIZE; buffer = Mem_Alloc (tempmempool, maxsize); fseek (packhandle, filesize - maxsize, SEEK_SET); - if (fread (buffer, 1, maxsize, packhandle) != maxsize) + if (fread (buffer, 1, maxsize, packhandle) != (unsigned long) maxsize) { Mem_Free (buffer); return false; @@ -475,7 +475,7 @@ int PK3_BuildFileList (pack_t *pack, const pk3_endOfCentralDir_t *eocd) if ((ptr[8] & 0x29) == 0 && (ptr[38] & 0x18) == 0) { // Still enough bytes for the name? - if (remaining < namesize || namesize >= sizeof (*pack->files)) + if ((size_t) remaining < namesize || namesize >= sizeof (*pack->files)) { Mem_Free (central_dir); return -1; @@ -538,8 +538,9 @@ pack_t *FS_LoadPackPK3 (const char *packfile) if (eocd.disknum != 0 || eocd.cdir_disknum != 0) Sys_Error ("%s is a multi-volume ZIP archive", packfile); - if (eocd.nbentries > MAX_FILES_IN_PACK) - Sys_Error ("%s contains too many files (%hu)", packfile, eocd.nbentries); + // LordHavoc: was always false because nbentries is an unsigned short and MAX_FILES_IN_PACK is 65536 + //if (eocd.nbentries > (unsigned int) MAX_FILES_IN_PACK) + // Sys_Error ("%s contains too many files (%hu)", packfile, eocd.nbentries); // Create a package structure in memory pack = Mem_Alloc (pak_mempool, sizeof (pack_t)); @@ -1369,7 +1370,7 @@ int FS_Seek (qfile_t* file, long offset, int whence) } // If we need to go back in the file - if (offset <= crt_offset) + if (offset <= (long) crt_offset) { // If we still have the data we need in the output buffer if (crt_offset - offset <= ztk->out_ind) @@ -1395,7 +1396,7 @@ int FS_Seek (qfile_t* file, long offset, int whence) } // Skip all data until we reach the requested offset - while (crt_offset < offset) + while ((long) crt_offset < offset) { size_t diff = offset - crt_offset; size_t count, len; @@ -1428,7 +1429,7 @@ int FS_Seek (qfile_t* file, long offset, int whence) default: return -1; } - if (offset < 0 || offset > file->length) + if (offset < 0 || offset > (long) file->length) return -1; if (fseek (file->stream, file->offset + offset, SEEK_SET) == -1) @@ -1477,7 +1478,7 @@ char* FS_Gets (qfile_t* file, char* buffer, int buffersize) if (! (file->flags & FS_FLAG_PACKED)) return fgets (buffer, buffersize, file->stream); - for (ind = 0; ind < buffersize - 1; ind++) + for (ind = 0; ind < (size_t) buffersize - 1; ind++) { int c = FS_Getc (file); switch (c) diff --git a/image.c b/image.c index 4c7aa0f6..c1615d4c 100644 --- a/image.c +++ b/image.c @@ -482,7 +482,7 @@ qbyte *LoadWAL (qbyte *f, int matchwidth, int matchheight) qbyte *image_rgba; const q2wal_t *inwal = (const void *)f; - if (fs_filesize < sizeof(q2wal_t)) + if (fs_filesize < (int) sizeof(q2wal_t)) { Con_Printf("LoadWAL: invalid WAL file\n"); return NULL; @@ -498,7 +498,7 @@ qbyte *LoadWAL (qbyte *f, int matchwidth, int matchheight) if ((matchwidth && image_width != matchwidth) || (matchheight && image_height != matchheight)) return NULL; - if (fs_filesize < sizeof(q2wal_t) + LittleLong(inwal->offsets[0]) + image_width * image_height) + if ((int) fs_filesize < (int) sizeof(q2wal_t) + (int) LittleLong(inwal->offsets[0]) + image_width * image_height) { Con_Printf("LoadWAL: invalid WAL file\n"); return NULL; diff --git a/net_udp.c b/net_udp.c index 353fc7be..3dbb8957 100644 --- a/net_udp.c +++ b/net_udp.c @@ -47,7 +47,7 @@ static int net_controlsocket; static int net_broadcastsocket = 0; static struct qsockaddr broadcastaddr; -static union {int i;unsigned char d[4];} myAddr; +static union {unsigned int i;unsigned char d[4];} myAddr; //============================================================================= diff --git a/r_shadow.c b/r_shadow.c index 19e36e79..16cb6eda 100644 --- a/r_shadow.c +++ b/r_shadow.c @@ -2088,7 +2088,7 @@ void R_Shadow_SaveWorldLights(void) for (light = r_shadow_worldlightchain;light;light = light->next) { sprintf(line, "%s%g %g %g %g %g %g %g %d %s\n", light->castshadows ? "" : "!", light->origin[0], light->origin[1], light->origin[2], light->lightradius / r_editlights_rtlightssizescale.value, light->light[0] / r_editlights_rtlightscolorscale.value, light->light[1] / r_editlights_rtlightscolorscale.value, light->light[2] / r_editlights_rtlightscolorscale.value, light->style, light->cubemapname ? light->cubemapname : ""); - if (bufchars + strlen(line) > bufmaxchars) + if (bufchars + (int) strlen(line) > bufmaxchars) { bufmaxchars = bufchars + strlen(line) + 2048; oldbuf = buf; diff --git a/vid_glx.c b/vid_glx.c index f6b67a64..1ea67984 100644 --- a/vid_glx.c +++ b/vid_glx.c @@ -471,7 +471,7 @@ static void HandleEvents(void) break; case ClientMessage: // window manager messages - if ((event.xclient.format == 32) && (event.xclient.data.l[0] == wm_delete_window_atom)) + if ((event.xclient.format == 32) && ((unsigned int)event.xclient.data.l[0] == wm_delete_window_atom)) Sys_Quit(); break; case MapNotify: diff --git a/wad.c b/wad.c index e5b53c35..36a5ede2 100644 --- a/wad.c +++ b/wad.c @@ -183,7 +183,7 @@ void W_LoadTextureWadFile (char *filename, int complain) if (!(lumps = Mem_Alloc(tempmempool, sizeof(lumpinfo_t)*numlumps))) {Con_Printf ("W_LoadTextureWadFile: unable to allocate temporary memory for lump table");return;} - if (FS_Read(file, lumps, sizeof(lumpinfo_t) * numlumps) != (int)sizeof(lumpinfo_t) * numlumps) + if (FS_Read(file, lumps, sizeof(lumpinfo_t) * numlumps) != sizeof(lumpinfo_t) * (size_t)numlumps) {Con_Printf ("W_LoadTextureWadFile: unable to read lump table");return;} for (i=0, lump_p = lumps ; iwidth = LittleLong(tex->width);