remove excess string overflow checks, fix warnings

This commit is contained in:
Garux 2021-01-29 05:14:33 +03:00
parent b9d5f091e0
commit 40ab7fa26c
2 changed files with 6 additions and 5 deletions

View File

@ -161,7 +161,8 @@ void SwapBSPFile( void ){
si = ShaderInfoForShader( bspShaders[ i ].shader ); si = ShaderInfoForShader( bspShaders[ i ].shader );
if ( !strEmptyOrNull( si->remapShader ) ) { if ( !strEmptyOrNull( si->remapShader ) ) {
// copy and clear the rest of memory // check for overflow by String64 // copy and clear the rest of memory // check for overflow by String64
strncpy( bspShaders[ i ].shader, String64()( si->remapShader ), sizeof( bspShaders[ i ].shader ) ); const auto remap = String64()( si->remapShader );
strncpy( bspShaders[ i ].shader, remap, sizeof( bspShaders[ i ].shader ) );
} }
} }
bspShaders[ i ].contentFlags = LittleLong( bspShaders[ i ].contentFlags ); bspShaders[ i ].contentFlags = LittleLong( bspShaders[ i ].contentFlags );

View File

@ -79,8 +79,8 @@ int EmitShader( const char *shader, int *contentFlags, int *surfaceFlags ){
AUTOEXPAND_BY_REALLOC_BSP( Shaders, 1024 ); AUTOEXPAND_BY_REALLOC_BSP( Shaders, 1024 );
numBSPShaders++; numBSPShaders++;
// copy and clear the rest of memory // check for overflow by String64 // copy and clear the rest of memory
strncpy( bspShaders[ i ].shader, String64()( shader ), sizeof( bspShaders[ i ].shader ) ); strncpy( bspShaders[ i ].shader, si->shader, sizeof( bspShaders[ i ].shader ) );
bspShaders[ i ].surfaceFlags = si->surfaceFlags; bspShaders[ i ].surfaceFlags = si->surfaceFlags;
bspShaders[ i ].contentFlags = si->contentFlags; bspShaders[ i ].contentFlags = si->contentFlags;
@ -497,8 +497,8 @@ void EmitFogs( void ){
for ( i = 0; i < numMapFogs; i++ ) for ( i = 0; i < numMapFogs; i++ )
{ {
/* set shader */ /* set shader */
// copy and clear the rest of memory // check for overflow by String64 // copy and clear the rest of memory
strncpy( bspFogs[ i ].shader, String64()( mapFogs[ i ].si->shader ), sizeof( bspFogs[ i ].shader ) ); strncpy( bspFogs[ i ].shader, mapFogs[ i ].si->shader, sizeof( bspFogs[ i ].shader ) );
/* global fog doesn't have an associated brush */ /* global fog doesn't have an associated brush */
if ( mapFogs[ i ].brush == NULL ) { if ( mapFogs[ i ].brush == NULL ) {