Fixed compilation warnings (mostly size_t->int, signed/unsigned conversions).

This commit is contained in:
Artem Kharytoniuk
2014-07-08 23:32:09 +03:00
parent 0f690ecf79
commit 3cc9bcd542
70 changed files with 316 additions and 311 deletions

View File

@@ -88,7 +88,7 @@ Adds command text at the end of the buffer, does NOT add a final \n
void Cbuf_AddText( const char *text ) {
int l;
l = strlen (text);
l = (int)strlen (text);
if (cmd_text.cursize + l >= cmd_text.maxsize)
{
@@ -112,7 +112,7 @@ void Cbuf_InsertText( const char *text ) {
int len;
int i;
len = strlen( text ) + 1;
len = (int)strlen( text ) + 1;
if ( len + cmd_text.cursize > cmd_text.maxsize ) {
Com_Printf( "Cbuf_InsertText overflowed\n" );
return;
@@ -143,7 +143,7 @@ void Cbuf_ExecuteText (int exec_when, const char *text)
switch (exec_when)
{
case EXEC_NOW:
if (text && strlen(text) > 0) {
if (text && (int)strlen(text) > 0) {
Cmd_ExecuteString (text);
} else {
Cbuf_Execute();

View File

@@ -150,7 +150,7 @@ void QDECL Com_Printf( const char *fmt, ... ) {
va_end (argptr);
if ( rd_buffer ) {
if ((strlen (msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {
if ((strlen (msg) + (int)strlen(rd_buffer)) > (rd_buffersize - 1)) {
rd_flush(rd_buffer);
*rd_buffer = 0;
}
@@ -193,7 +193,7 @@ void QDECL Com_Printf( const char *fmt, ... ) {
opening_qconsole = qfalse;
}
if ( logfile && FS_Initialized()) {
FS_Write(msg, strlen(msg), logfile);
FS_Write(msg, (int)strlen(msg), logfile);
}
}
}
@@ -525,7 +525,7 @@ Com_StringContains
char *Com_StringContains(char *str1, char *str2, int casesensitive) {
int len, i, j;
len = strlen(str1) - strlen(str2);
len = (int)strlen(str1) - (int)strlen(str2);
for (i = 0; i <= len; i++, str1++) {
for (j = 0; str2[j]; j++) {
if (casesensitive) {
@@ -569,7 +569,7 @@ int Com_Filter(char *filter, char *name, int casesensitive)
if (strlen(buf)) {
ptr = Com_StringContains(name, buf, casesensitive);
if (!ptr) return qfalse;
name = ptr + strlen(buf);
name = ptr + (int)strlen(buf);
}
}
else if (*filter == '?') {
@@ -1062,7 +1062,7 @@ void Z_LogZoneHeap( memzone_t *zone, char *name ) {
return;
size = allocSize = numBlocks = 0;
Com_sprintf(buf, sizeof(buf), "\r\n================\r\n%s log\r\n================\r\n", name);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
for (block = zone->blocklist.next ; block->next != &zone->blocklist; block = block->next) {
if (block->tag) {
#ifdef ZONE_DEBUG
@@ -1078,7 +1078,7 @@ void Z_LogZoneHeap( memzone_t *zone, char *name ) {
}
dump[j] = '\0';
Com_sprintf(buf, sizeof(buf), "size = %8d: %s, line: %d (%s) [%s]\r\n", block->d.allocSize, block->d.file, block->d.line, block->d.label, dump);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
allocSize += block->d.allocSize;
#endif
size += block->size;
@@ -1092,9 +1092,9 @@ void Z_LogZoneHeap( memzone_t *zone, char *name ) {
allocSize = numBlocks * sizeof(memblock_t); // + 32 bit alignment
#endif
Com_sprintf(buf, sizeof(buf), "%d %s memory in %d blocks\r\n", size, name, numBlocks);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
Com_sprintf(buf, sizeof(buf), "%d %s memory overhead\r\n", size - allocSize, name);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
}
/*
@@ -1148,7 +1148,7 @@ char *CopyString( const char *in ) {
return ((char *)&numberstring[in[0]-'0']) + sizeof(memblock_t);
}
}
out = S_Malloc (strlen(in)+1);
out = S_Malloc ((int)strlen(in)+1);
strcpy (out, in);
return out;
}
@@ -1417,19 +1417,19 @@ void Hunk_Log( void) {
size = 0;
numBlocks = 0;
Com_sprintf(buf, sizeof(buf), "\r\n================\r\nHunk log\r\n================\r\n");
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
for (block = hunkblocks ; block; block = block->next) {
#ifdef HUNK_DEBUG
Com_sprintf(buf, sizeof(buf), "size = %8d: %s, line: %d (%s)\r\n", block->size, block->file, block->line, block->label);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
#endif
size += block->size;
numBlocks++;
}
Com_sprintf(buf, sizeof(buf), "%d Hunk memory\r\n", size);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
Com_sprintf(buf, sizeof(buf), "%d hunk blocks\r\n", numBlocks);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
}
/*
@@ -1450,7 +1450,7 @@ void Hunk_SmallLog( void) {
size = 0;
numBlocks = 0;
Com_sprintf(buf, sizeof(buf), "\r\n================\r\nHunk Small log\r\n================\r\n");
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
for (block = hunkblocks; block; block = block->next) {
if (block->printed) {
continue;
@@ -1469,15 +1469,15 @@ void Hunk_SmallLog( void) {
}
#ifdef HUNK_DEBUG
Com_sprintf(buf, sizeof(buf), "size = %8d: %s, line: %d (%s)\r\n", locsize, block->file, block->line, block->label);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
#endif
size += block->size;
numBlocks++;
}
Com_sprintf(buf, sizeof(buf), "%d Hunk memory\r\n", size);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
Com_sprintf(buf, sizeof(buf), "%d hunk blocks\r\n", numBlocks);
FS_Write(buf, strlen(buf), logfile);
FS_Write(buf, (int)strlen(buf), logfile);
}
/*
@@ -3191,7 +3191,7 @@ FindMatches
static void FindMatches( const char *s ) {
int i;
if ( Q_stricmpn( s, completionString, strlen( completionString ) ) ) {
if ( Q_stricmpn( s, completionString, (int)strlen( completionString ) ) ) {
return;
}
matchCount++;
@@ -3215,7 +3215,7 @@ PrintMatches
===============
*/
static void PrintMatches( const char *s ) {
if ( !Q_stricmpn( s, shortestMatch, strlen( shortestMatch ) ) ) {
if ( !Q_stricmpn( s, shortestMatch, (int)strlen( shortestMatch ) ) ) {
Com_Printf( " %s\n", s );
}
}
@@ -3250,7 +3250,7 @@ static void ConcatRemaining( const char *src, const char *start ) {
return;
}
str += strlen(start);
str += (int)strlen(start);
Q_strcat( completionField->buffer, sizeof( completionField->buffer ), str);
}
@@ -3278,7 +3278,7 @@ void Field_CompleteCommand( field_t *field ) {
matchCount = 0;
shortestMatch[0] = 0;
if ( strlen( completionString ) == 0 ) {
if ( (int)strlen( completionString ) == 0 ) {
return;
}
@@ -3298,13 +3298,13 @@ void Field_CompleteCommand( field_t *field ) {
} else {
ConcatRemaining( temp.buffer, completionString );
}
completionField->cursor = strlen( completionField->buffer );
completionField->cursor = (int)strlen( completionField->buffer );
return;
}
// multiple matches, complete to shortest
Com_sprintf( completionField->buffer, sizeof( completionField->buffer ), "\\%s", shortestMatch );
completionField->cursor = strlen( completionField->buffer );
completionField->cursor = (int)strlen( completionField->buffer );
ConcatRemaining( temp.buffer, completionString );
Com_Printf( "]%s\n", completionField->buffer );

View File

@@ -534,7 +534,7 @@ void Cvar_Set_f( void ) {
combined[0] = 0;
l = 0;
for ( i = 2 ; i < c ; i++ ) {
len = strlen ( Cmd_Argv( i ) + 1 );
len = (int)strlen ( Cmd_Argv( i ) + 1 );
if ( l + len >= MAX_STRING_TOKENS - 2 ) {
break;
}
@@ -868,10 +868,10 @@ void Cvar_Update( vmCvar_t *vmCvar ) {
}
vmCvar->modificationCount = cv->modificationCount;
// bk001129 - mismatches.
if ( strlen(cv->string)+1 > MAX_CVAR_VALUE_STRING )
if ( (int)strlen(cv->string)+1 > MAX_CVAR_VALUE_STRING )
Com_Error( ERR_DROP, "Cvar_Update: src %s length %d exceeds MAX_CVAR_VALUE_STRING",
cv->string,
strlen(cv->string),
(int)strlen(cv->string),
sizeof(vmCvar->string) );
// bk001212 - Q_strncpyz guarantees zero padding and dest[MAX_CVAR_VALUE_STRING-1]==0
// bk001129 - paranoia. Never trust the destination string.

View File

@@ -1094,7 +1094,7 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
// shaders, txt, arena files by themselves do not count as a reference as
// these are loaded from all pk3s
// from every pk3 file..
l = strlen( filename );
l = (int)strlen( filename );
if ( !(pak->referenced & FS_GENERAL_REF)) {
if ( Q_stricmp(filename + l - 7, ".shader") != 0 &&
Q_stricmp(filename + l - 4, ".txt") != 0 &&
@@ -1161,7 +1161,7 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
// if we are running restricted, the only files we
// will allow to come from the directory are .cfg files
l = strlen( filename );
l = (int)strlen( filename );
// FIXME TTimo I'm not sure about the fs_numServerPaks test
// if you are using FS_ReadFile to find out if a file exists,
// this test can make the search fail although the file is in the directory
@@ -1172,7 +1172,7 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
if ( Q_stricmp( filename + l - 4, ".cfg" ) // for config files
&& Q_stricmp( filename + l - 5, ".menu" ) // menu files
&& Q_stricmp( filename + l - 5, ".game" ) // menu files
&& Q_stricmp( filename + l - strlen(demoExt), demoExt ) // menu files
&& Q_stricmp( filename + l - (int)strlen(demoExt), demoExt ) // menu files
&& Q_stricmp( filename + l - 4, ".dat" ) ) { // for journal files
continue;
}
@@ -1189,7 +1189,7 @@ int FS_FOpenFileRead( const char *filename, fileHandle_t *file, qboolean uniqueF
if ( Q_stricmp( filename + l - 4, ".cfg" ) // for config files
&& Q_stricmp( filename + l - 5, ".menu" ) // menu files
&& Q_stricmp( filename + l - 5, ".game" ) // menu files
&& Q_stricmp( filename + l - strlen(demoExt), demoExt ) // menu files
&& Q_stricmp( filename + l - (int)strlen(demoExt), demoExt ) // menu files
&& Q_stricmp( filename + l - 4, ".dat" ) ) { // for journal files
fs_fakeChkSum = random();
}
@@ -1273,7 +1273,7 @@ int FS_Read( void *buffer, int len, fileHandle_t f ) {
tries = 0;
while (remaining) {
block = remaining;
read = fread (buf, 1, block, fsh[f].handleFiles.file.o);
read = (int)fread (buf, 1, block, fsh[f].handleFiles.file.o);
if (read == 0) {
// we might have been trying to read from a CD, which
// sometimes returns a 0 read on windows
@@ -1326,7 +1326,7 @@ int FS_Write( const void *buffer, int len, fileHandle_t h ) {
tries = 0;
while (remaining) {
block = remaining;
written = fwrite (buf, 1, block, f);
written = (int)fwrite (buf, 1, block, f);
if (written == 0) {
if (!tries) {
tries = 1;
@@ -1358,7 +1358,7 @@ void QDECL FS_Printf( fileHandle_t h, const char *fmt, ... ) {
Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
va_end (argptr);
FS_Write(msg, strlen(msg), h);
FS_Write(msg, (int)strlen(msg), h);
}
/*
@@ -1707,7 +1707,7 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename )
if (err != UNZ_OK) {
break;
}
len += strlen(filename_inzip) + 1;
len += (int)strlen(filename_inzip) + 1;
unzGoToNextFile(uf);
}
@@ -1734,7 +1734,7 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename )
Q_strncpyz( pack->pakBasename, basename, sizeof( pack->pakBasename ) );
// strip .pk3 if needed
if ( strlen( pack->pakBasename ) > 4 && !Q_stricmp( pack->pakBasename + strlen( pack->pakBasename ) - 4, ".pk3" ) ) {
if ( (int)strlen( pack->pakBasename ) > 4 && !Q_stricmp( pack->pakBasename + (int)strlen( pack->pakBasename ) - 4, ".pk3" ) ) {
pack->pakBasename[strlen( pack->pakBasename ) - 4] = 0;
}
@@ -1755,7 +1755,7 @@ static pack_t *FS_LoadZipFile( char *zipfile, const char *basename )
hash = FS_HashFileName(filename_inzip, pack->hashSize);
buildBuffer[i].name = namePtr;
strcpy( buildBuffer[i].name, filename_inzip );
namePtr += strlen(filename_inzip) + 1;
namePtr += (int)strlen(filename_inzip) + 1;
// store the file position in the zip
unzGetCurrentFileInfoPosition(uf, &buildBuffer[i].pos);
//
@@ -1863,11 +1863,11 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt
extension = "";
}
pathLength = strlen( path );
pathLength = (int)strlen( path );
if ( path[pathLength-1] == '\\' || path[pathLength-1] == '/' ) {
pathLength--;
}
extensionLength = strlen( extension );
extensionLength = (int)strlen( extension );
nfiles = 0;
FS_ReturnPath(path, zpath, &pathDepth);
@@ -1910,7 +1910,7 @@ char **FS_ListFilteredFiles( const char *path, const char *extension, char *filt
}
// check for extension match
length = strlen( name );
length = (int)strlen( name );
if ( length < extensionLength ) {
continue;
}
@@ -2018,7 +2018,7 @@ int FS_GetFileList( const char *path, const char *extension, char *listbuf, int
pFiles = FS_ListFiles(path, extension, &nFiles);
for (i =0; i < nFiles; i++) {
nLen = strlen(pFiles[i]) + 1;
nLen = (int)strlen(pFiles[i]) + 1;
if (nTotal + nLen + 1 < bufsize) {
strcpy(listbuf, pFiles[i]);
listbuf += nLen;
@@ -2184,7 +2184,7 @@ int FS_GetModList( char *listbuf, int bufsize ) {
}
if (nPaks > 0) {
nLen = strlen(name) + 1;
nLen = (int)strlen(name) + 1;
// nLen is the length of the mod path
// we need to see if there is a description available
descPath[0] = '\0';
@@ -2195,7 +2195,7 @@ int FS_GetModList( char *listbuf, int bufsize ) {
FILE *file;
file = FS_FileForHandle(descHandle);
Com_Memset( descPath, 0, sizeof( descPath ) );
nDescLen = fread(descPath, 1, 48, file);
nDescLen = (int)fread(descPath, 1, 48, file);
if (nDescLen >= 0) {
descPath[nDescLen] = '\0';
}
@@ -2203,7 +2203,7 @@ int FS_GetModList( char *listbuf, int bufsize ) {
} else {
strcpy(descPath, name);
}
nDescLen = strlen(descPath) + 1;
nDescLen = (int)strlen(descPath) + 1;
if (nTotal + nLen + 1 + nDescLen + 1 < bufsize) {
strcpy(listbuf, name);
@@ -2490,7 +2490,7 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) {
// find all pak files in this directory
pakfile = FS_BuildOSPath( path, dir, "" );
pakfile[ strlen(pakfile) - 1 ] = 0; // strip the trailing slash
pakfile[ (int)strlen(pakfile) - 1 ] = 0; // strip the trailing slash
pakfiles = Sys_ListFiles( pakfile, ".pk3", NULL, &numfiles, qfalse );
@@ -3012,7 +3012,7 @@ const char *FS_ReferencedPakChecksums( void ) {
for ( search = fs_searchpaths ; search ; search = search->next ) {
// is the element a pak file?
if ( search->pack ) {
if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) {
if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, (int)strlen(BASEGAME))) {
Q_strcat( info, sizeof( info ), va("%i ", search->pack->checksum ) );
}
}
@@ -3094,7 +3094,7 @@ const char *FS_ReferencedPakNames( void ) {
if (*info) {
Q_strcat(info, sizeof( info ), " " );
}
if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, strlen(BASEGAME))) {
if (search->pack->referenced || Q_stricmpn(search->pack->pakGamename, BASEGAME, (int)strlen(BASEGAME))) {
Q_strcat( info, sizeof( info ), search->pack->pakGamename );
Q_strcat( info, sizeof( info ), "/" );
Q_strcat( info, sizeof( info ), search->pack->pakBasename );

View File

@@ -307,7 +307,7 @@ void MSG_WriteString( msg_t *sb, const char *s ) {
int l,i;
char string[MAX_STRING_CHARS];
l = strlen( s );
l = (int)strlen( s );
if ( l >= MAX_STRING_CHARS ) {
Com_Printf( "MSG_WriteString: MAX_STRING_CHARS" );
MSG_WriteData (sb, "", 1);
@@ -333,7 +333,7 @@ void MSG_WriteBigString( msg_t *sb, const char *s ) {
int l,i;
char string[BIG_INFO_STRING];
l = strlen( s );
l = (int)strlen( s );
if ( l >= BIG_INFO_STRING ) {
Com_Printf( "MSG_WriteString: BIG_INFO_STRING" );
MSG_WriteData (sb, "", 1);

View File

@@ -660,7 +660,7 @@ void QDECL NET_OutOfBandPrint( netsrc_t sock, netadr_t adr, const char *format,
va_end( argptr );
// send the datagram
NET_SendPacket( sock, strlen( string ), string, adr );
NET_SendPacket( sock, (int)strlen( string ), string, adr );
}
/*

View File

@@ -264,7 +264,7 @@ void VM_LoadSymbols( vm_t *vm ) {
Com_Printf( "WARNING: incomplete line at end of file\n" );
break;
}
chars = strlen( token );
chars = (int)strlen( token );
sym = Hunk_Alloc( sizeof( *sym ) + chars, h_high );
*prev = sym;
prev = &sym->next;
@@ -723,7 +723,7 @@ int QDECL VM_Call( vm_t *vm, int callnum, ... ) {
}
va_end(ap);
r = VM_CallInterpreted( vm, &a );
r = VM_CallInterpreted( vm, &a.callnum );
}
if ( oldVM != NULL ) // bk001220 - assert(currentVM!=NULL) for oldVM==NULL

View File

@@ -21,6 +21,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// vm_x86.c -- load time compiler and execution environment for x86
; // to shut up compiler in x64
#ifndef _WIN64
#include "vm_local.h"