From: havoc Date: Tue, 5 Jul 2005 11:33:02 +0000 (+0000) Subject: fixed signed/unsigned mismatch warnings X-Git-Tag: xonotic-v0.1.0preview~4687 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5d00fdd2bc32e9635c51a22bace2e0a883f3561f;p=xonotic%2Fdarkplaces.git fixed signed/unsigned mismatch warnings more size_t changes git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5499 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_input.c b/cl_input.c index b24d8ea1..3c8a5140 100644 --- a/cl_input.c +++ b/cl_input.c @@ -513,7 +513,7 @@ void CL_ClientMovement_Input(qboolean buttonjump, qboolean buttoncrouch) cl.movement_queue[cl.movement_numqueue++] = cl.movement_queue[i]; } // add to input queue if there is room - if (cl_movement.integer && cl.movement_numqueue < sizeof(cl.movement_queue)/sizeof(cl.movement_queue[0]) && cl.mtime[0] > cl.mtime[1]) + if (cl_movement.integer && cl.movement_numqueue < (int)(sizeof(cl.movement_queue)/sizeof(cl.movement_queue[0])) && cl.mtime[0] > cl.mtime[1]) { // add to input queue cl.movement_queue[cl.movement_numqueue].sequence = cl.movesequence; diff --git a/cl_screen.c b/cl_screen.c index c11c4966..34a3ee34 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -117,7 +117,7 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float do { colorindex = colorindex * 10 + (*current - '0'); // only read as long as it makes a valid index - if( colorindex >= STRING_COLORS_COUNT ) { + if( colorindex >= (int)STRING_COLORS_COUNT ) { // undo the last operation colorindex /= 10; break; @@ -943,7 +943,7 @@ void SCR_CaptureVideo_EndVideo(void) // finish the wave file if (cl_capturevideo_soundfile) { - i = FS_Tell (cl_capturevideo_soundfile); + i = (int)FS_Tell (cl_capturevideo_soundfile); //"RIFF", (int) unknown (chunk size), "WAVE", //"fmt ", (int) 16 (chunk size), (short) format 1 (uncompressed PCM), (short) 2 channels, (int) unknown rate, (int) unknown bytes per second, (short) 4 bytes per sample (channels * bytes per channel), (short) 16 bits per channel //"data", (int) unknown (chunk size) diff --git a/console.c b/console.c index 3cb08835..dca8f08a 100644 --- a/console.c +++ b/console.c @@ -571,7 +571,7 @@ void Con_Print(const char *msg) } // store timestamp for (;*timestamp;index++, timestamp++) - if (index < sizeof(line) - 2) + if (index < (int)sizeof(line) - 2) line[index] = *timestamp; } // append the character diff --git a/fs.c b/fs.c index bfab7a8b..d914b717 100644 --- a/fs.c +++ b/fs.c @@ -1686,7 +1686,7 @@ Print a string into a file */ int FS_Print (qfile_t* file, const char *msg) { - return FS_Write (file, msg, strlen (msg)); + return (int)FS_Write (file, msg, strlen (msg)); } /* @@ -2114,7 +2114,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) { // look through all the pak file elements pak = searchpath->pack; - for (i = 0;i < pak->numfiles;i++) + for (i = 0;i < (size_t)pak->numfiles;i++) { strcpy(temp, pak->files[i].name); while (temp[0]) @@ -2191,7 +2191,7 @@ fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet) search = Z_Malloc(sizeof(fssearch_t) + numchars + numfiles * sizeof(char *)); search->filenames = (char **)((char *)search + sizeof(fssearch_t)); search->filenamesbuffer = (char *)((char *)search + sizeof(fssearch_t) + numfiles * sizeof(char *)); - search->numfilenames = numfiles; + search->numfilenames = (int)numfiles; numfiles = 0; numchars = 0; for (listtemp = liststart;listtemp;listtemp = listtemp->next) @@ -2280,7 +2280,7 @@ int FS_ListDirectory(const char *pattern, int oneperline) for (i = 0;i < numfiles;i++) Con_Printf("%s\n", search->filenames[i]); FS_FreeSearch(search); - return numfiles; + return (int)numfiles; } static void FS_ListDirectoryCmd (const char* cmdname, int oneperline) diff --git a/host_cmd.c b/host_cmd.c index 3a62b1df..00ea8a1a 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -1024,7 +1024,7 @@ void Host_Tell_f(void) text[j++] = 0; save = host_client; - for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++) + for (j = 0, host_client = svs.clients;j < (size_t)svs.maxclients;j++, host_client++) if (host_client->spawned && !strcasecmp(host_client->name, Cmd_Argv(1))) SV_ClientPrint(text); host_client = save; diff --git a/image.c b/image.c index 4e372a85..6af0ee2a 100644 --- a/image.c +++ b/image.c @@ -568,7 +568,7 @@ qbyte *LoadLMP (const qbyte *f, int matchwidth, int matchheight, qboolean loadAs if ((matchwidth && image_width != matchwidth) || (matchheight && image_height != matchheight)) return NULL; - if (fs_filesize < 8 + image_width * image_height) + if (fs_filesize < (size_t)(8 + image_width * image_height)) { Con_Print("LoadLMP: invalid LMP file\n"); return NULL; diff --git a/lhnet.c b/lhnet.c index 91805d6f..f2f7b570 100644 --- a/lhnet.c +++ b/lhnet.c @@ -152,7 +152,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int def address->addressdata.inet6.family = hostentry->h_addrtype; address->addressdata.inet6.port = htons((unsigned short)port); memcpy(address->addressdata.inet6.address, hostentry->h_addr_list[0], sizeof(address->addressdata.inet6.address)); - for (i = 0;i < sizeof(namecache[namecacheposition].name)-1 && name[i];i++) + for (i = 0;i < (int)sizeof(namecache[namecacheposition].name)-1 && name[i];i++) namecache[namecacheposition].name[i] = name[i]; namecache[namecacheposition].name[i] = 0; namecache[namecacheposition].address = *address; @@ -169,7 +169,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int def address->addressdata.inet4.family = hostentry->h_addrtype; address->addressdata.inet4.port = htons((unsigned short)port); memcpy(address->addressdata.inet4.address, hostentry->h_addr_list[0], sizeof(address->addressdata.inet4.address)); - for (i = 0;i < sizeof(namecache[namecacheposition].name)-1 && name[i];i++) + for (i = 0;i < (int)sizeof(namecache[namecacheposition].name)-1 && name[i];i++) namecache[namecacheposition].name[i] = name[i]; namecache[namecacheposition].name[i] = 0; namecache[namecacheposition].address = *address; @@ -183,7 +183,7 @@ int LHNETADDRESS_FromString(lhnetaddress_t *address, const char *string, int def #ifdef STANDALONETEST printf("gethostbyname failed on address \"%s\"\n", name); #endif - for (i = 0;i < sizeof(namecache[namecacheposition].name)-1 && name[i];i++) + for (i = 0;i < (int)sizeof(namecache[namecacheposition].name)-1 && name[i];i++) namecache[namecacheposition].name[i] = name[i]; namecache[namecacheposition].name[i] = 0; namecache[namecacheposition].address.addresstype = LHNETADDRESSTYPE_NONE; diff --git a/makefile.inc b/makefile.inc index b4201038..d5b6ee96 100644 --- a/makefile.inc +++ b/makefile.inc @@ -134,7 +134,7 @@ OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o $(OBJ_SND_COMMON) snd_sdl.o cd_sdl.o $( # Compilation # CFLAGS_COMMON=-MD -Wall -Werror -CFLAGS_COMMON=-MD -Wall +CFLAGS_COMMON=-MD -Wall -Wsign-compare CFLAGS_DEBUG=-ggdb CFLAGS_PROFILE=-g -pg -ggdb CFLAGS_RELEASE= diff --git a/menu.c b/menu.c index a3b37a62..efbe4e3b 100644 --- a/menu.c +++ b/menu.c @@ -3676,7 +3676,7 @@ gamelevels_t openquartzgame = {"OpenQuartz", openquartzlevels, openquartzepisode typedef struct { - int gameid; + gamemode_t gameid; gamelevels_t *notregistered; gamelevels_t *registered; } diff --git a/model_brush.c b/model_brush.c index 4815fbe2..b5c5cb94 100644 --- a/model_brush.c +++ b/model_brush.c @@ -1337,7 +1337,7 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l) data = (qbyte*) FS_LoadFile(litfilename, tempmempool, false); if (data) { - if (fs_filesize == 8 + l->filelen * 3 && data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' && data[3] == 'T') + if (fs_filesize == (size_t)(8 + l->filelen * 3) && data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' && data[3] == 'T') { i = LittleLong(((int *)data)[1]); if (i == 1) diff --git a/netconn.c b/netconn.c index 9c6d50be..a82f9774 100755 --- a/netconn.c +++ b/netconn.c @@ -208,10 +208,10 @@ static qboolean _ServerList_CompareStr( const char *A, serverlist_maskop_t op, c { int i; char bufferA[ 256 ], bufferB[ 256 ]; // should be more than enough - for (i = 0;i < sizeof(bufferA)-1 && A[i];i++) + for (i = 0;i < (int)sizeof(bufferA)-1 && A[i];i++) bufferA[i] = (A[i] >= 'A' && A[i] <= 'Z') ? (A[i] + 'a' - 'A') : A[i]; bufferA[i] = 0; - for (i = 0;i < sizeof(bufferB)-1 && B[i];i++) + for (i = 0;i < (int)sizeof(bufferB)-1 && B[i];i++) bufferB[i] = (B[i] >= 'A' && B[i] <= 'Z') ? (B[i] + 'a' - 'A') : B[i]; bufferB[i] = 0; @@ -887,7 +887,7 @@ int NetConn_ReceivedMessage(netconn_t *conn, qbyte *data, int length) conn->lastMessageTime = realtime; conn->timeout = realtime + net_messagetimeout.value; conn->receiveSequence++; - if( conn->receiveMessageLength + length <= sizeof( conn->receiveMessage ) ) { + if( conn->receiveMessageLength + length <= (int)sizeof( conn->receiveMessage ) ) { memcpy(conn->receiveMessage + conn->receiveMessageLength, data, length); conn->receiveMessageLength += length; } else { diff --git a/prvm_cmds.c b/prvm_cmds.c index c2d32dbe..cf72710d 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -87,11 +87,8 @@ static qboolean checkextension(const char *name) start = e; while (*e && *e != ' ') e++; - if (e - start == len) - if (!strncasecmp(start, name, len)) - { - return true; - } + if ((size_t)(e - start) == len && !strncasecmp(start, name, len)) + return true; } return false; } diff --git a/prvm_edict.c b/prvm_edict.c index e3652387..1d28aa26 100644 --- a/prvm_edict.c +++ b/prvm_edict.c @@ -870,7 +870,7 @@ returns false if error */ qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s) { - size_t i, l; + int i, l; char *new_p; ddef_t *def; prvm_eval_t *val; @@ -883,7 +883,7 @@ qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s) switch (key->type & ~DEF_SAVEGLOBAL) { case ev_string: - l = strlen(s) + 1; + l = (int)strlen(s) + 1; val->string = PRVM_AllocString(l, &new_p); for (i = 0;i < l;i++) { @@ -926,7 +926,7 @@ qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s) case ev_entity: while (*s && *s <= ' ') s++; - i = (unsigned int)atoi(s); + i = atoi(s); if (i >= prog->limit_edicts) Con_Printf("PRVM_ED_ParseEpair: ev_entity reference too large (edict %u >= MAX_EDICTS %u) on %s\n", (unsigned int)i, (unsigned int)MAX_EDICTS, PRVM_NAME); while (i >= prog->max_edicts) @@ -935,7 +935,7 @@ qboolean PRVM_ED_ParseEpair(prvm_edict_t *ent, ddef_t *key, const char *s) // if SV_IncreaseEdicts was called the base pointer needs to be updated if (ent) val = (prvm_eval_t *)((int *)ent->fields.vp + key->ofs); - val->edict = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM(i)); + val->edict = PRVM_EDICT_TO_PROG(PRVM_EDICT_NUM((int)i)); break; case ev_field: @@ -1306,7 +1306,7 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required prog->stringssize = 0; for (i = 0;i < prog->progs->numstrings;i++) { - if (prog->progs->ofs_strings + prog->stringssize >= fs_filesize) + if (prog->progs->ofs_strings + prog->stringssize >= (int)fs_filesize) PRVM_ERROR ("%s: %s strings go past end of file\n", PRVM_NAME, filename); prog->stringssize += (int)strlen (prog->strings + prog->stringssize) + 1; } diff --git a/snd_main.c b/snd_main.c index 1e9fd6ec..6451829f 100644 --- a/snd_main.c +++ b/snd_main.c @@ -1023,7 +1023,7 @@ void S_SoundList(void) { if (sfx->fetcher != NULL) { - size = sfx->mempool->totalsize; + size = (int)sfx->mempool->totalsize; total += size; Con_Printf ("%c%c%c%c(%2db, %6s) %8i : %s\n", (sfx->loopstart >= 0) ? 'L' : ' ', diff --git a/snd_ogg.c b/snd_ogg.c index 3dda63e4..cdc41f75 100644 --- a/snd_ogg.c +++ b/snd_ogg.c @@ -452,7 +452,7 @@ static const sfxbuffer_t* OGG_FetchSound (channel_t* ch, unsigned int start, uns if (sb->offset <= start && sb->offset + sb->length >= start + nbsamples) return sb; - newlength = (int)(sb->offset + sb->length) - start; + newlength = sb->offset + sb->length - start; // If we need to skip some data before decompressing the rest, or if the stream has looped if (newlength < 0 || sb->offset > start) @@ -492,7 +492,7 @@ static const sfxbuffer_t* OGG_FetchSound (channel_t* ch, unsigned int start, uns done += ret; // Resample in the sfxbuffer - newlength = ResampleSfx (resampling_buffer, (size_t)done / (size_t)factor, &per_sfx->format, sb->data + sb->length * (size_t)factor, sfx->name); + newlength = (int)ResampleSfx (resampling_buffer, (size_t)done / (size_t)factor, &per_sfx->format, sb->data + sb->length * (size_t)factor, sfx->name); sb->length += newlength; return sb; @@ -579,7 +579,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s) // Decide if we go for a stream or a simple PCM cache buff_len = ceil (STREAM_BUFFER_DURATION * (shm->format.speed * 2 * vi->channels)); - if (snd_streaming.integer && len > fs_filesize + 3 * buff_len) + if (snd_streaming.integer && len > (ogg_int64_t)fs_filesize + 3 * buff_len) { ogg_stream_persfx_t* per_sfx; @@ -636,7 +636,7 @@ qboolean OGG_LoadVorbisFile (const char *filename, sfx_t *s) s->loopstart = -1; s->flags &= ~SFXFLAG_STREAMED; - sb->length = ResampleSfx (buff, (size_t)done / (vi->channels * 2), &s->format, sb->data, s->name); + sb->length = (unsigned int)ResampleSfx (buff, (size_t)done / (vi->channels * 2), &s->format, sb->data, s->name); s->format.speed = shm->format.speed; s->total_length = sb->length; sb->offset = 0; diff --git a/snd_wav.c b/snd_wav.c index 041a2552..439ec73c 100644 --- a/snd_wav.c +++ b/snd_wav.c @@ -264,7 +264,7 @@ qboolean S_LoadWavFile (const char *filename, sfx_t *s) Con_DPrintf ("Loading WAV file \"%s\"\n", filename); - info = GetWavinfo (s->name, data, fs_filesize); + info = GetWavinfo (s->name, data, (int)fs_filesize); // Stereo sounds are allowed (intended for music) if (info.channels < 1 || info.channels > 2) { @@ -313,7 +313,7 @@ qboolean S_LoadWavFile (const char *filename, sfx_t *s) } #endif - sb->length = ResampleSfx (data + info.dataofs, info.samples, &s->format, sb->data, s->name); + sb->length = (int)ResampleSfx (data + info.dataofs, info.samples, &s->format, sb->data, s->name); s->format.speed = shm->format.speed; s->total_length = sb->length; sb->offset = 0; diff --git a/zone.c b/zone.c index 30965833..7b83e25a 100644 --- a/zone.c +++ b/zone.c @@ -352,7 +352,7 @@ mempool_t *zonemempool; void Mem_PrintStats(void) { - int count = 0, size = 0; + size_t count = 0, size = 0; mempool_t *pool; memheader_t *mem; Mem_CheckSentinelsGlobal(); @@ -361,14 +361,14 @@ void Mem_PrintStats(void) count++; size += pool->totalsize; } - Con_Printf("%i memory pools, totalling %i bytes (%.3fMB)\n", count, size, size / 1048576.0); + Con_Printf("%lu memory pools, totalling %lu bytes (%.3fMB)\n", (unsigned long)count, (unsigned long)size, size / 1048576.0); for (pool = poolchain;pool;pool = pool->next) { if ((pool->flags & POOLFLAG_TEMP) && pool->chain) { - Con_Printf("Memory pool %p has sprung a leak totalling %i bytes (%.3fMB)! Listing contents...\n", pool, pool->totalsize, pool->totalsize / 1048576.0); + Con_Printf("Memory pool %p has sprung a leak totalling %lu bytes (%.3fMB)! Listing contents...\n", pool, (unsigned long)pool->totalsize, pool->totalsize / 1048576.0); for (mem = pool->chain;mem;mem = mem->next) - Con_Printf("%10i bytes allocated at %s:%i\n", mem->size, mem->filename, mem->fileline); + Con_Printf("%10lu bytes allocated at %s:%i\n", (unsigned long)mem->size, mem->filename, mem->fileline); } } } @@ -382,11 +382,11 @@ void Mem_PrintList(int listallocations) "size name\n"); for (pool = poolchain;pool;pool = pool->next) { - Con_Printf("%10ik (%10ik actual) %s (%+i byte change) %s\n", (pool->totalsize + 1023) / 1024, (pool->realsize + 1023) / 1024, pool->name, pool->totalsize - pool->lastchecksize, (pool->flags & POOLFLAG_TEMP) ? "TEMP" : ""); + Con_Printf("%10luk (%10luk actual) %s (%+li byte change) %s\n", (unsigned long) ((pool->totalsize + 1023) / 1024), (unsigned long)((pool->realsize + 1023) / 1024), pool->name, (long)pool->totalsize - pool->lastchecksize, (pool->flags & POOLFLAG_TEMP) ? "TEMP" : ""); pool->lastchecksize = pool->totalsize; if (listallocations) for (mem = pool->chain;mem;mem = mem->next) - Con_Printf("%10i bytes allocated at %s:%i\n", mem->size, mem->filename, mem->fileline); + Con_Printf("%10lu bytes allocated at %s:%i\n", (unsigned long)mem->size, mem->filename, mem->fileline); } }