Skip to content

Commit

Permalink
Fixes for -Wformat=2 on 64-bit targets
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Jun 22, 2024
1 parent d054782 commit e18b61e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/mainui
Submodule mainui updated 1 files
+1 −1 miniutl
4 changes: 2 additions & 2 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2736,7 +2736,7 @@ static void CL_SetInfo_f( void )
{
Con_Printf( "User info settings:\n" );
Info_Print( cls.userinfo );
Con_Printf( "Total %i symbols\n", Q_strlen( cls.userinfo ));
Con_Printf( "Total %zu symbols\n", Q_strlen( cls.userinfo ));
return;
}

Expand Down Expand Up @@ -2772,7 +2772,7 @@ static void CL_Physinfo_f( void )
{
Con_Printf( "Phys info settings:\n" );
Info_Print( cls.physinfo );
Con_Printf( "Total %i symbols\n", Q_strlen( cls.physinfo ));
Con_Printf( "Total %zu symbols\n", Q_strlen( cls.physinfo ));
}

static qboolean CL_ShouldRescanFilesystem( void )
Expand Down
23 changes: 12 additions & 11 deletions engine/common/identification.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/

#include <inttypes.h>
#include "common.h"
#include <fcntl.h>
#if !XASH_WIN32
Expand Down Expand Up @@ -104,7 +105,7 @@ static void ID_BloomFilter_f( void )
for( i = 1; i < Cmd_Argc(); i++ )
value |= BloomFilter_ProcessStr( Cmd_Argv( i ) );

Msg( "%d %016llX\n", BloomFilter_Weight( value ), value );
Msg( "%d %016"PRIX64"\n", BloomFilter_Weight( value ), value );

// test
// for( i = 1; i < Cmd_Argc(); i++ )
Expand Down Expand Up @@ -283,7 +284,7 @@ static void ID_TestCPUInfo_f( void )
bloomfilter_t value = 0;

if( ID_ProcessCPUInfo( &value ) )
Msg( "Got %016llX\n", value );
Msg( "Got %016"PRIX64"\n", value );
else
Msg( "Could not get serial\n" );
}
Expand Down Expand Up @@ -621,7 +622,7 @@ void ID_Init( void )
#endif

#if XASH_ANDROID && !XASH_DEDICATED
sscanf( Android_LoadID(), "%016llX", &id );
sscanf( Android_LoadID(), "%016"PRIX64, &id );
if( id )
{
id ^= SYSTEM_XOR_MASK;
Expand All @@ -633,7 +634,7 @@ void ID_Init( void )
CHAR szBuf[MAX_PATH];
ID_GetKeyData( HKEY_CURRENT_USER, "Software\\Xash3D\\", "xash_id", szBuf, MAX_PATH );

sscanf(szBuf, "%016llX", &id);
sscanf(szBuf, "%016"PRIX64, &id);
id ^= SYSTEM_XOR_MASK;
ID_Check();
}
Expand All @@ -649,7 +650,7 @@ void ID_Init( void )
cfg = fopen( va( "%s/.xash_id", home ), "r" );
if( cfg )
{
if( fscanf( cfg, "%016llX", &id ) > 0 )
if( fscanf( cfg, "%016"PRIX64, &id ) > 0 )
{
id ^= SYSTEM_XOR_MASK;
ID_Check();
Expand All @@ -664,7 +665,7 @@ void ID_Init( void )
const char *buf = (const char*) FS_LoadFile( ".xash_id", NULL, false );
if( buf )
{
sscanf( buf, "%016llX", &id );
sscanf( buf, "%016"PRIX64, &id );
id ^= GAME_XOR_MASK;
ID_Check();
}
Expand All @@ -680,11 +681,11 @@ void ID_Init( void )
Q_snprintf( &id_md5[i*2], sizeof( id_md5 ) - i * 2, "%02hhx", md5[i] );

#if XASH_ANDROID && !XASH_DEDICATED
Android_SaveID( va("%016llX", id^SYSTEM_XOR_MASK ) );
Android_SaveID( va("%016"PRIX64, id^SYSTEM_XOR_MASK ) );
#elif XASH_WIN32
{
CHAR Buf[MAX_PATH];
sprintf( Buf, "%016llX", id^SYSTEM_XOR_MASK );
sprintf( Buf, "%016"PRIX64, id^SYSTEM_XOR_MASK );
ID_SetKeyData( HKEY_CURRENT_USER, "Software\\Xash3D\\", REG_SZ, "xash_id", Buf, Q_strlen(Buf) );
}
#else
Expand All @@ -699,14 +700,14 @@ void ID_Init( void )
cfg = fopen( va( "%s/.xash_id", home ), "w" );
if( cfg )
{
fprintf( cfg, "%016llX", id^SYSTEM_XOR_MASK );
fprintf( cfg, "%016"PRIX64, id^SYSTEM_XOR_MASK );
fclose( cfg );
}
}
}
#endif
FS_WriteFile( ".xash_id", va("%016llX", id^GAME_XOR_MASK), 16 );
FS_WriteFile( ".xash_id", va("%016"PRIX64, id^GAME_XOR_MASK), 16 );
#if 0
Msg("MD5 id: %s\nRAW id:%016llX\n", id_md5, id );
Msg("MD5 id: %s\nRAW id:%016"PRIX64"\n", id_md5, id );
#endif
}
6 changes: 3 additions & 3 deletions engine/common/mod_bmodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ static qboolean Mod_LoadColoredLighting( model_t *mod, dbspmodel_t *bmod )

if( litdatasize != ( bmod->lightdatasize * 3 ))
{
Con_Printf( S_ERROR "%s has mismatched size (%llu should be %zu)\n", path, litdatasize, bmod->lightdatasize * 3 );
Con_Printf( S_ERROR "%s has mismatched size (%li should be %zu)\n", path, (long)litdatasize, bmod->lightdatasize * 3 );
Mem_Free( in );
return false;
}
Expand Down Expand Up @@ -1603,7 +1603,7 @@ static void Mod_LoadDeluxemap( model_t *mod, dbspmodel_t *bmod )

if( deluxdatasize != bmod->lightdatasize )
{
Con_Reportf( S_ERROR "%s has mismatched size (%llu should be %zu)\n", path, deluxdatasize, bmod->lightdatasize );
Con_Reportf( S_ERROR "%s has mismatched size (%li should be %zu)\n", path, (long)deluxdatasize, bmod->lightdatasize );
Mem_Free( in );
return;
}
Expand Down Expand Up @@ -3084,7 +3084,7 @@ static void Mod_CalcPHS( model_t *mod )
t2 = Platform_DoubleTime();

if( vis_stats )
Con_Reportf( "Average leaves visible / audible / total: %i / %i / %i\n", vcount / count, hcount / count, count );
Con_Reportf( "Average leaves visible / audible / total: %zu / %zu / %zu\n", vcount / count, hcount / count, count );
Con_Reportf( "Uncompressed PHS size: %s\n", Q_memprint( rowbytes * count ));
Con_Reportf( "Compressed PHS size: %s\n", Q_memprint( total_compressed_size + sizeof( *world.phsofs ) * count ));
Con_Reportf( "PHS building time: %.2f ms\n", ( t2 - t1 ) * 1000.0f );
Expand Down
2 changes: 1 addition & 1 deletion engine/common/soundlib/snd_wav.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static void FindNextChunk( const char *filename, const char *name )
|| IsFourCC( iff_lastChunk, "LIST" )
|| IsFourCC( iff_lastChunk, "data" ))
{
Con_DPrintf( "%s: '%s' truncated by %i bytes\n", __func__, filename, iff_chunkLen - remaining );
Con_DPrintf( "%s: '%s' truncated by %zi bytes\n", __func__, filename, iff_chunkLen - remaining );
}
iff_chunkLen = remaining;
}
Expand Down
8 changes: 4 additions & 4 deletions ref/gl/gl_backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@ void GL_BackendEndFrame( void )
{
case 1:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i wpoly, %3i apoly\n%3i epoly, %3i spoly",
r_stats.c_world_polys, r_stats.c_alias_polys, r_stats.c_studio_polys, r_stats.c_sprite_polys );
r_stats.c_world_polys, r_stats.c_alias_polys, r_stats.c_studio_polys, r_stats.c_sprite_polys );
break;
case 2:
R_Speeds_Printf( "visible leafs:\n%3i leafs\ncurrent leaf %3i\n", r_stats.c_world_leafs, curleaf - WORLDMODEL->leafs );
R_Speeds_Printf( "ReciusiveWorldNode: %3lf secs\nDrawTextureChains %lf\n", r_stats.t_world_node, r_stats.t_world_draw );
break;
case 3:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i alias models drawn\n%3i studio models drawn\n%3i sprites drawn",
r_stats.c_alias_models_drawn, r_stats.c_studio_models_drawn, r_stats.c_sprite_models_drawn );
r_stats.c_alias_models_drawn, r_stats.c_studio_models_drawn, r_stats.c_sprite_models_drawn );
break;
case 4:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i static entities\n%3i normal entities\n%3i server entities",
r_numStatics, r_numEntities - r_numStatics, ENGINE_GET_PARM( PARM_NUMENTITIES ));
r_numStatics, r_numEntities - r_numStatics, (int)ENGINE_GET_PARM( PARM_NUMENTITIES ));
break;
case 5:
Q_snprintf( r_speeds_msg, sizeof( r_speeds_msg ), "%3i tempents\n%3i viewbeams\n%3i particles",
r_stats.c_active_tents_count, r_stats.c_view_beams_count, r_stats.c_particle_count );
r_stats.c_active_tents_count, r_stats.c_view_beams_count, r_stats.c_particle_count );
break;
}

Expand Down
2 changes: 1 addition & 1 deletion ref/gl/gl_rpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers )

if( p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
{
gEngfuncs.Con_Printf( S_ERROR "UserTracer with color(%d) > %d\n", p->color, sizeof( gTracerColors ) / sizeof( gTracerColors[0] ));
gEngfuncs.Con_Printf( S_ERROR "UserTracer with color(%d) > %zu\n", p->color, sizeof( gTracerColors ) / sizeof( gTracerColors[0] ));
p->color = 0;
}

Expand Down
2 changes: 1 addition & 1 deletion ref/soft/r_part.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers

if( p->color > sizeof( gTracerColors ) / sizeof( gTracerColors[0] ))
{
gEngfuncs.Con_Printf( S_ERROR "UserTracer with color(%d) > %d\n", p->color, sizeof( gTracerColors ) / sizeof( gTracerColors[0] ));
gEngfuncs.Con_Printf( S_ERROR "UserTracer with color(%d) > %zu\n", p->color, sizeof( gTracerColors ) / sizeof( gTracerColors[0] ));
p->color = 0;
}

Expand Down

0 comments on commit e18b61e

Please sign in to comment.