]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
fixed signed/unsigned mismatch warnings
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 Jul 2005 11:33:02 +0000 (11:33 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 5 Jul 2005 11:33:02 +0000 (11:33 +0000)
more size_t changes

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5499 d7cf8633-e32d-0410-b094-e92efae38249

17 files changed:
cl_input.c
cl_screen.c
console.c
fs.c
host_cmd.c
image.c
lhnet.c
makefile.inc
menu.c
model_brush.c
netconn.c
prvm_cmds.c
prvm_edict.c
snd_main.c
snd_ogg.c
snd_wav.c
zone.c

index b24d8ea186d46da73167eff56d8f14da4fa98281..3c8a514082b54c47c96be1f0ad30d020cf372b0a 100644 (file)
@@ -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;
index c11c4966231d576a16c57f4354e50caac5761223..34a3ee340201390e12b9dbf75475040869a5d799 100644 (file)
@@ -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)
index 3cb08835c33335e1eada3588fc842973ec59cde9..dca8f08a571023540188fa3722b4fea564e1a1bc 100644 (file)
--- 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 bfab7a8b328aba39aa8207775da61b511dbf6c97..d914b717dce03c773e2975c4e5f07452dbb86dac 100644 (file)
--- 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)
index 3a62b1dfb75b2b62d6cc3f959c839a7ea0b9da24..00ea8a1a61b231eda7f8e2466472f970632d6c5e 100644 (file)
@@ -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 4e372a85aea5dbf3e2dd04a918ebb61ef0fd1b1e..6af0ee2a1689d04d340782af429029a5c8f9c601 100644 (file)
--- 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 91805d6f130f1415759eae4b7d5f8ca587e51afe..f2f7b570146296627419cd32aa19cbbb47e81037 100644 (file)
--- 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;
index b4201038e261fc9d5bd3fc30caff4786eebfc6a8..d5b6ee961ad3599699f7d11b7f31e30d9712d6d8 100644 (file)
@@ -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 a3b37a6290e7c0972d9184f3fe04dd6ed5b69fb9..efbe4e3bbe57083cccb6900052493a557c517a4b 100644 (file)
--- 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;
 }
index 4815fbe2c40bff3436767e739d8d7503337168d2..b5c5cb94330b05547406e942fcba72b56f3712f2 100644 (file)
@@ -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)
index 9c6d50be14057ea19854417e54c79f6b62385961..a82f977470f42546c82d0d0b9358e3cbfe119bd6 100755 (executable)
--- 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 {
index c2d32dbef80d5b1efd13a90af4850bfba1d9eced..cf72710d3674ccb847dfd3451afc8c824cd8bd98 100644 (file)
@@ -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;
 }
index e365238744ff07089e00e19a0ae2ea66094e9fd1..1d28aa26c194fc0385d1a773bac5bfd8bd59f169 100644 (file)
@@ -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;
        }
index 1e9fd6ecc7812ba7487b9f1ae32f04e4248b3717..6451829f10280fe9ed9afb3f45c7d682cd55b34b 100644 (file)
@@ -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' : ' ',
index 3dda63e458b7aacc6cef3f42d0fe8149dff0ae98..cdc41f759a62b1dd078a000c39a65844b0fea872 100644 (file)
--- 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;
index 041a25524cd6ded477c4611eb71fd5ccfa0f856b..439ec73cbaf4cab9dd281e75976cdb516785c966 100644 (file)
--- 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 309658339089c025b16db7d6d470b59b6608f98a..7b83e25a45f18752b50910adb771f75855959b0b 100644 (file)
--- 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);
        }
 }