From 21860bd9dc6366ecf87b89e13a2b20d3d5b779de Mon Sep 17 00:00:00 2001 From: Lance Date: Wed, 1 Jun 2011 13:21:54 +0000 Subject: [PATCH] Fixed more GCC warnings, alot of 64bit portability things mostly. Minor PNG header fix. Changed instances of errno to strerror(errno). git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3805 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/image.c | 2 +- engine/client/m_mp3.c | 2 +- engine/client/quakedef.h | 10 ++++++++-- engine/client/snd_mem.c | 2 +- engine/client/sys_linux.c | 2 +- engine/common/com_mesh.c | 2 +- engine/common/common.c | 2 +- engine/common/fs_stdio.c | 2 +- engine/common/gl_q2bsp.c | 2 +- engine/common/plugin.c | 6 +++++- engine/common/translate.c | 2 +- engine/gl/gl_rsurf.c | 10 +++++----- engine/server/sv_rankin.c | 6 +++--- engine/server/sv_sys_unix.c | 2 +- 14 files changed, 31 insertions(+), 21 deletions(-) diff --git a/engine/client/image.c b/engine/client/image.c index a152c689a..9648c66ab 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -573,7 +573,7 @@ void (PNGAPI *qpng_read_end) PNGARG((png_structp png_ptr, png_infop info_ptr)) P void (PNGAPI *qpng_read_image) PNGARG((png_structp png_ptr, png_bytepp image)) PSTATIC(png_read_image); png_byte (PNGAPI *qpng_get_bit_depth) PNGARG((png_structp png_ptr, png_infop info_ptr)) PSTATIC(png_get_bit_depth); png_byte (PNGAPI *qpng_get_channels) PNGARG((png_structp png_ptr, png_infop info_ptr)) PSTATIC(png_get_channels); -png_size_t (PNGAPI *qpng_get_rowbytes) PNGARG((png_structp png_ptr, png_infop info_ptr)) PSTATIC(png_get_rowbytes); +png_uint_32 (PNGAPI *qpng_get_rowbytes) PNGARG((png_structp png_ptr, png_infop info_ptr)) PSTATIC(png_get_rowbytes); void (PNGAPI *qpng_read_update_info) PNGARG((png_structp png_ptr, png_infop info_ptr)) PSTATIC(png_read_update_info); void (PNGAPI *qpng_set_strip_16) PNGARG((png_structp png_ptr)) PSTATIC(png_set_strip_16); void (PNGAPI *qpng_set_expand) PNGARG((png_structp png_ptr)) PSTATIC(png_set_expand); diff --git a/engine/client/m_mp3.c b/engine/client/m_mp3.c index 293e621ef..af3dcef72 100644 --- a/engine/client/m_mp3.c +++ b/engine/client/m_mp3.c @@ -2027,7 +2027,7 @@ static void MSD_Unlock (soundcardinfo_t *sc, void *buffer) { } -static int MSD_GetDMAPos(soundcardinfo_t *sc) +static unsigned int MSD_GetDMAPos(soundcardinfo_t *sc) { int s; diff --git a/engine/client/quakedef.h b/engine/client/quakedef.h index 4ad8500f5..6ee65337d 100644 --- a/engine/client/quakedef.h +++ b/engine/client/quakedef.h @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -111,7 +111,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include #if defined(AVAIL_PNGLIB) && defined(PNG_SUCKS_WITH_SETJMP) && !defined(SERVERONLY) -#include + #if defined(MINGW) + #include "./mingw-libs/png.h" + #elif defined(_WIN32) + #include "png.h" + #else + #include + #endif #else #include #endif diff --git a/engine/client/snd_mem.c b/engine/client/snd_mem.c index 09f92c9f8..118cd9218 100644 --- a/engine/client/snd_mem.c +++ b/engine/client/snd_mem.c @@ -809,7 +809,7 @@ sfxcache_t *S_LoadSound (sfx_t *s) result = fread(data, 1, com_filesize, f); //do something with result if (result != com_filesize) - Con_SafePrintf("S_LoadSound() fread: Filename: %s, expected %i, result was %i (%i)\n",name,com_filesize,result,errno); + Con_SafePrintf("S_LoadSound() fread: Filename: %s, expected %i, result was %u (%s)\n",name,com_filesize,(unsigned int)result,strerror(errno)); fclose(f); } diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index dc8d6b683..96158dc58 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -357,7 +357,7 @@ int Sys_DebugLog(char *file, char *fmt, ...) result = write(fd, data, strlen(data)); // do something with result if (result != strlen(data)) - Con_SafePrintf("Sys_DebugLog() write: Filename: %s, expected %i, result was %i (%i)\n",file,strlen(data),result,errno); + Con_SafePrintf("Sys_DebugLog() write: Filename: %s, expected %lu, result was %lu (%s)\n",file,(unsigned long)strlen(data),(unsigned long)result,strerror(errno)); close(fd); return 0; diff --git a/engine/common/com_mesh.c b/engine/common/com_mesh.c index f5ef5e557..778e6fd1a 100644 --- a/engine/common/com_mesh.c +++ b/engine/common/com_mesh.c @@ -2391,7 +2391,7 @@ qboolean Mod_LoadQ1Model (model_t *mod, void *buffer) version = LittleLong(pq1inmodel->version); if (version == QTESTALIAS_VERSION) { - hdrsize = (unsigned int)&((dmdl_t*)NULL)->flags; + hdrsize = (size_t)&((dmdl_t*)NULL)->flags; qtest = true; } else if (version == 50) diff --git a/engine/common/common.c b/engine/common/common.c index e880e7856..9a7b0daf9 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -3035,7 +3035,7 @@ void COM_InitArgv (int argc, const char **argv) //not allowed to tprint result = fread(buffer, 1, len, f); // do something with result if (result != len) - Con_Printf("COM_InitArgv() fread: Filename: %s, expected %i, result was %i (%i)\n",va("%s_p.txt", argv[0]),len,result,errno); + Con_Printf("COM_InitArgv() fread: Filename: %s, expected %i, result was %u (%s)\n",va("%s_p.txt", argv[0]),len,(unsigned int)result,strerror(errno)); buffer[len] = '\0'; diff --git a/engine/common/fs_stdio.c b/engine/common/fs_stdio.c index de585d28e..d865bb656 100644 --- a/engine/common/fs_stdio.c +++ b/engine/common/fs_stdio.c @@ -224,7 +224,7 @@ static void FSSTDIO_ReadFile(void *handle, flocation_t *loc, char *buffer) result = fread(buffer, 1, loc->len, f); // do soemthing with result if (result != loc->len) - Con_Printf("FSSTDIO_ReadFile() fread: Filename: %s, expected %i, result was %i (%i)\n",loc->rawname,loc->len,result,errno); + Con_Printf("FSSTDIO_ReadFile() fread: Filename: %s, expected %i, result was %u (%s)\n",loc->rawname,loc->len,(unsigned int)result,strerror(errno)); fclose(f); } diff --git a/engine/common/gl_q2bsp.c b/engine/common/gl_q2bsp.c index 323132692..6733e294e 100644 --- a/engine/common/gl_q2bsp.c +++ b/engine/common/gl_q2bsp.c @@ -5666,7 +5666,7 @@ void CM_ReadPortalState (FILE *f) result = fread (portalopen, 1, sizeof(portalopen), f); // do something with result if (result != sizeof(portalopen)) - Con_Printf("CM_ReadPortalState() fread: expected %i, result was %i (%i)\n",sizeof(portalopen),result,errno); + Con_Printf("CM_ReadPortalState() fread: expected %lu, result was %u (%s)\n",(long unsigned int)sizeof(portalopen),(unsigned int)result,strerror(errno)); FloodAreaConnections (); } diff --git a/engine/common/plugin.c b/engine/common/plugin.c index 118713f55..dcf675125 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -265,7 +265,11 @@ int Plug_SystemCallsVM(void *offset, quintptr_t mask, int fn, const int *arg) fn = fn+1; if (fn>=0 && fn < numplugbuiltins && plugbuiltins[fn].func!=NULL) - return plugbuiltins[fn].func(offset, mask, (const long*)args); + #ifdef _M_AMD64 + return plugbuiltins[fn].func(offset, mask, (const long long int*)args); + #else + return plugbuiltins[fn].func(offset, mask, (const long int*)args); + #endif #undef args Sys_Error("QVM Plugin tried calling invalid builtin %i", fn); return 0; diff --git a/engine/common/translate.c b/engine/common/translate.c index 6a27c76c2..65b446276 100644 --- a/engine/common/translate.c +++ b/engine/common/translate.c @@ -585,7 +585,7 @@ void TL_LoadLanguage (char *name, char *shortname, int num) //this is one of the result = fread(buffer, 1, size, f); // do something with result if (result != size) - Con_Printf("TL_LoadLanguage() fread: Filename: %s, expected %i, result was %i (%i)\n",va("%s.trl", shortname),size,result,errno); + Con_Printf("TL_LoadLanguage() fread: Filename: %s, expected %i, result was %u (%s)\n",va("%s.trl", shortname),size,(unsigned int)result,strerror(errno)); fclose(f); diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index cc04ce608..544220956 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -133,7 +133,7 @@ void *allocbuf(char **p, int elements, int elementsize) { void *ret; *p += elementsize - 1; - *p -= (unsigned int)*p & (elementsize-1); + *p -= (size_t)*p & (elementsize-1); ret = *p; *p += elements*elementsize; return ret; @@ -312,12 +312,12 @@ void GLBE_UploadAllLightmaps(void) switch (lightmap_bytes) { case 4: - qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, + qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, LMBLOCK_WIDTH, LMBLOCK_WIDTH, 0, (lightmap_bgra?GL_BGRA_EXT:GL_RGBA), GL_UNSIGNED_INT_8_8_8_8_REV, lightmap[i]->lightmaps); break; case 3: - qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, + qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, LMBLOCK_WIDTH, LMBLOCK_WIDTH, 0, (lightmap_bgra?GL_BGR_EXT:GL_RGB), GL_UNSIGNED_BYTE, lightmap[i]->lightmaps); break; @@ -338,7 +338,7 @@ void GLBE_UploadAllLightmaps(void) qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); qglTexImage2D (GL_TEXTURE_2D, 0, 3 - , LMBLOCK_WIDTH, LMBLOCK_HEIGHT, 0, + , LMBLOCK_WIDTH, LMBLOCK_HEIGHT, 0, GL_RGB, GL_UNSIGNED_BYTE, lightmap[i]->deluxmaps); } } diff --git a/engine/server/sv_rankin.c b/engine/server/sv_rankin.c index fbd51b625..41c0403e8 100644 --- a/engine/server/sv_rankin.c +++ b/engine/server/sv_rankin.c @@ -43,7 +43,7 @@ void inline READ_PLAYERSTATS(int x, rankstats_t *os) result = fread(os, sizeof(rankstats_t), 1, rankfile); if (result != sizeof(rankstats_t)) - Con_Printf("READ_PLAYERSTATS() fread: expected %i, result was %i (%i)\n",sizeof(rankstats_t),result,errno); + Con_Printf("READ_PLAYERSTATS() fread: expected %lu, result was %u (%s)\n",(long unsigned int)sizeof(rankstats_t),(unsigned int)result,strerror(errno)); os->kills = swaplong(os->kills); os->deaths = swaplong(os->deaths); @@ -85,7 +85,7 @@ void inline READ_PLAYERHEADER(int x, rankheader_t *oh) result = fread(oh, sizeof(rankheader_t), 1, rankfile); if (result != sizeof(rankheader_t)) - Con_Printf("READ_PLAYERHEADER() fread: expected %i, result was %i (%i)\n",sizeof(rankheader_t),result,errno); + Con_Printf("READ_PLAYERHEADER() fread: expected %lu, result was %u (%s)\n",(long unsigned int)sizeof(rankheader_t),(unsigned int)result,strerror(errno)); oh->prev = swaplong(oh->prev); //score is held for convineance. oh->next = swaplong(oh->next); @@ -164,7 +164,7 @@ qboolean Rank_OpenRankings(void) result = fread(&rankfileheader, sizeof(rankfileheader_t), 1, rankfile); if (result != sizeof(rankfileheader_t)) - Con_Printf("Rank_OpenRankings() fread: expected %i, result was %i (%i)\n",sizeof(rankfileheader_t),result,errno); + Con_Printf("Rank_OpenRankings() fread: expected %lu, result was %u (%s)\n",(long unsigned int)sizeof(rankfileheader_t),(unsigned int)result,strerror(errno)); rankfileheader.version = swaplong(rankfileheader.version); rankfileheader.usedslots = swaplong(rankfileheader.usedslots); diff --git a/engine/server/sv_sys_unix.c b/engine/server/sv_sys_unix.c index 5762dabe5..69af4d197 100644 --- a/engine/server/sv_sys_unix.c +++ b/engine/server/sv_sys_unix.c @@ -119,7 +119,7 @@ int Sys_DebugLog(char *file, char *fmt, ...) result = write(fd, data, strlen(data)); // do something with the result if (result != strlen(data)) - Con_Printf("Sys_DebugLog() write: Filename: %s, expected %i, result was %i (%i)\n",file,strlen(data),result,errno); + Con_Printf("Sys_DebugLog() write: Filename: %s, expected %lu, result was %lu (%s)\n",file,(unsigned long)strlen(data),(unsigned long)result,strerror(errno)); close(fd); return 0;