From c07109e69c53a83cd07804e20bccb0558da8388e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 28 Nov 2019 19:18:50 +0300 Subject: [PATCH] engine: fix -Wincompatible-pointer-types, add it to Werror list --- engine/client/ref_common.c | 2 +- engine/common/cvar.c | 6 +++--- engine/common/lib_common.c | 2 +- engine/common/mod_bmodel.c | 4 ++-- engine/common/net_ws.c | 2 +- ref_gl/gl_sprite.c | 2 +- wscript | 1 + 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/engine/client/ref_common.c b/engine/client/ref_common.c index 7758fee5..d7e5519d 100644 --- a/engine/client/ref_common.c +++ b/engine/client/ref_common.c @@ -612,7 +612,7 @@ void R_CollectRendererNames( void ) pfn = COM_GetProcAddress( dll, GET_REF_HUMANREADABLE_NAME ); if( !pfn ) // just in case { - Con_Reportf( "R_CollectRendererNames: can't find GetHumanReadableName export in %s\n", temp, COM_GetLibraryError() ); + Con_Reportf( "R_CollectRendererNames: can't find GetHumanReadableName export in %s\n", temp ); Q_strncpy( ref.readableNames[i], renderers[i], sizeof( ref.readableNames[i] )); } else diff --git a/engine/common/cvar.c b/engine/common/cvar.c index 27477362..923257a7 100644 --- a/engine/common/cvar.c +++ b/engine/common/cvar.c @@ -595,7 +595,7 @@ void Cvar_Set( const char *var_name, const char *value ) if( !var_name ) { // there is an error in C code if this happens - Con_Printf( "Cvar_Set: passed NULL variable name\n", var_name ); + Con_Printf( "Cvar_Set: passed NULL variable name\n" ); return; } @@ -649,7 +649,7 @@ float Cvar_VariableValue( const char *var_name ) if( !var_name ) { // there is an error in C code if this happens - Con_Printf( "Cvar_VariableValue: passed NULL variable name\n", var_name ); + Con_Printf( "Cvar_VariableValue: passed NULL variable name\n" ); return 0.0f; } @@ -686,7 +686,7 @@ const char *Cvar_VariableString( const char *var_name ) if( !var_name ) { // there is an error in C code if this happens - Con_Printf( "Cvar_VariableString: passed NULL variable name\n", var_name ); + Con_Printf( "Cvar_VariableString: passed NULL variable name\n" ); return ""; } diff --git a/engine/common/lib_common.c b/engine/common/lib_common.c index 737610f4..a4df4f30 100644 --- a/engine/common/lib_common.c +++ b/engine/common/lib_common.c @@ -116,7 +116,7 @@ static void COM_GenerateServerLibraryPath( char *out, size_t size ) #else string dllpath; - char *ext; + const char *ext; #if XASH_WIN32 Q_strncpy( dllpath, GI->game_dll, sizeof( dllpath ) ); diff --git a/engine/common/mod_bmodel.c b/engine/common/mod_bmodel.c index 1d27c93e..2d6a6e3b 100644 --- a/engine/common/mod_bmodel.c +++ b/engine/common/mod_bmodel.c @@ -65,14 +65,14 @@ typedef struct dleaf_t *leafs; dleaf32_t *leafs32; }; - int numleafs; + size_t numleafs; union { dclipnode_t *clipnodes; dclipnode32_t *clipnodes32; }; - int numclipnodes; + size_t numclipnodes; dtexinfo_t *texinfo; size_t numtexinfo; diff --git a/engine/common/net_ws.c b/engine/common/net_ws.c index c2c29712..39e51fa4 100644 --- a/engine/common/net_ws.c +++ b/engine/common/net_ws.c @@ -97,7 +97,7 @@ static int ioctl_stub( int d, unsigned long r, ... ) #define closesocket close #define SOCKET int #define INVALID_SOCKET -1 -typedef size_t WSAsize_t; +typedef socklen_t WSAsize_t; #else // WIN32 typedef int WSAsize_t; // for some reason, MS has signed size. We won't exceed 2^32, probably, so just typedef it #endif diff --git a/ref_gl/gl_sprite.c b/ref_gl/gl_sprite.c index bc65eeb2..36e9a08e 100644 --- a/ref_gl/gl_sprite.c +++ b/ref_gl/gl_sprite.c @@ -87,7 +87,7 @@ static const dframetype_t *R_SpriteLoadFrame( model_t *mod, const void *pin, msp pspriteframe->gl_texturenum = gl_texturenum; *ppframe = pspriteframe; - return ( const dspriteframe_t* )(( const byte* )pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes ); + return ( const dframetype_t* )(( const byte* )pin + sizeof( dspriteframe_t ) + pinframe.width * pinframe.height * bytes ); } /* diff --git a/wscript b/wscript index 67fbe940..1c886995 100644 --- a/wscript +++ b/wscript @@ -235,6 +235,7 @@ def configure(conf): '-Werror=duplicated-branches', # BEWARE: buggy '-Werror=bool-compare', '-Werror=bool-operation', + '-Werror=incompatible-pointer-types', # '-Wdouble-promotion', # disable warning flood '-Wstrict-aliasing', ]