Fix/work around other misc. compiler warnings

or, in the case of AF.cpp, at least comment on them

I think this fixes most of the remaining "interesting" GCC 12 on Linux
warnings
This commit is contained in:
Daniel Gibson 2023-01-05 08:07:51 +01:00
parent 3fa9770f78
commit e9873fd364
6 changed files with 20 additions and 4 deletions

View file

@ -892,6 +892,11 @@ bool idAF::Load( idEntity *ent, const char *fileName ) {
for ( i = 0; i < physicsObj.GetNumConstraints(); i++ ) { for ( i = 0; i < physicsObj.GetNumConstraints(); i++ ) {
idAFConstraint *constraint = physicsObj.GetConstraint( i ); idAFConstraint *constraint = physicsObj.GetConstraint( i );
for ( j = 0; j < file->constraints.Num(); j++ ) { for ( j = 0; j < file->constraints.Num(); j++ ) {
// DG: FIXME: GCC rightfully complains that file->constraints[j]->type and constraint->GetType()
// are of different enum types, and their values are different in some cases:
// CONSTRAINT_HINGESTEERING has no DECLAF_CONSTRAINT_ equivalent,
// and thus DECLAF_CONSTRAINT_SLIDER != CONSTRAINT_SLIDER (5 != 6)
// and DECLAF_CONSTRAINT_SPRING != CONSTRAINT_SPRING (6 != 10)
if ( file->constraints[j]->name.Icmp( constraint->GetName() ) == 0 && if ( file->constraints[j]->name.Icmp( constraint->GetName() ) == 0 &&
file->constraints[j]->type == constraint->GetType() ) { file->constraints[j]->type == constraint->GetType() ) {
break; break;

View file

@ -872,7 +872,8 @@ void idPVS::Shutdown( void ) {
delete[] areaPVS; delete[] areaPVS;
areaPVS = NULL; areaPVS = NULL;
} }
if ( currentPVS ) { // if ( currentPVS ) - DG: can't be NULL
{
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
delete[] currentPVS[i].pvs; delete[] currentPVS[i].pvs;
currentPVS[i].pvs = NULL; currentPVS[i].pvs = NULL;

View file

@ -172,7 +172,7 @@ index 0 will never be NULL. Any anim >= NumAnims will return NULL.
===================== =====================
*/ */
const idMD5Anim *idAnim::MD5Anim( int num ) const { const idMD5Anim *idAnim::MD5Anim( int num ) const {
if ( anims == NULL || anims[0] == NULL ) { if ( anims[0] == NULL ) {
return NULL; return NULL;
} }
return anims[ num ]; return anims[ num ];
@ -3057,6 +3057,7 @@ idDeclModelDef::NumJointsOnChannel
int idDeclModelDef::NumJointsOnChannel( int channel ) const { int idDeclModelDef::NumJointsOnChannel( int channel ) const {
if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) {
gameLocal.Error( "idDeclModelDef::NumJointsOnChannel : channel out of range" ); gameLocal.Error( "idDeclModelDef::NumJointsOnChannel : channel out of range" );
return 0; // unreachable, (Error() doesn't return) just to shut up compiler
} }
return channelJoints[ channel ].Num(); return channelJoints[ channel ].Num();
} }
@ -3069,6 +3070,7 @@ idDeclModelDef::GetChannelJoints
const int * idDeclModelDef::GetChannelJoints( int channel ) const { const int * idDeclModelDef::GetChannelJoints( int channel ) const {
if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) {
gameLocal.Error( "idDeclModelDef::GetChannelJoints : channel out of range" ); gameLocal.Error( "idDeclModelDef::GetChannelJoints : channel out of range" );
return NULL; // unreachable, (Error() doesn't return) just to shut up compiler
} }
return channelJoints[ channel ].Ptr(); return channelJoints[ channel ].Ptr();
} }

View file

@ -892,6 +892,11 @@ bool idAF::Load( idEntity *ent, const char *fileName ) {
for ( i = 0; i < physicsObj.GetNumConstraints(); i++ ) { for ( i = 0; i < physicsObj.GetNumConstraints(); i++ ) {
idAFConstraint *constraint = physicsObj.GetConstraint( i ); idAFConstraint *constraint = physicsObj.GetConstraint( i );
for ( j = 0; j < file->constraints.Num(); j++ ) { for ( j = 0; j < file->constraints.Num(); j++ ) {
// DG: FIXME: GCC rightfully complains that file->constraints[j]->type and constraint->GetType()
// are of different enum types, and their values are different in some cases:
// CONSTRAINT_HINGESTEERING has no DECLAF_CONSTRAINT_ equivalent,
// and thus DECLAF_CONSTRAINT_SLIDER != CONSTRAINT_SLIDER (5 != 6)
// and DECLAF_CONSTRAINT_SPRING != CONSTRAINT_SPRING (6 != 10)
if ( file->constraints[j]->name.Icmp( constraint->GetName() ) == 0 && if ( file->constraints[j]->name.Icmp( constraint->GetName() ) == 0 &&
file->constraints[j]->type == constraint->GetType() ) { file->constraints[j]->type == constraint->GetType() ) {
break; break;

View file

@ -872,7 +872,8 @@ void idPVS::Shutdown( void ) {
delete[] areaPVS; delete[] areaPVS;
areaPVS = NULL; areaPVS = NULL;
} }
if ( currentPVS ) { // if ( currentPVS ) - DG: can't be NULL
{
for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) {
delete[] currentPVS[i].pvs; delete[] currentPVS[i].pvs;
currentPVS[i].pvs = NULL; currentPVS[i].pvs = NULL;

View file

@ -172,7 +172,7 @@ index 0 will never be NULL. Any anim >= NumAnims will return NULL.
===================== =====================
*/ */
const idMD5Anim *idAnim::MD5Anim( int num ) const { const idMD5Anim *idAnim::MD5Anim( int num ) const {
if ( anims == NULL || anims[0] == NULL ) { if ( anims[0] == NULL ) {
return NULL; return NULL;
} }
return anims[ num ]; return anims[ num ];
@ -2971,6 +2971,7 @@ idDeclModelDef::NumJointsOnChannel
int idDeclModelDef::NumJointsOnChannel( int channel ) const { int idDeclModelDef::NumJointsOnChannel( int channel ) const {
if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) {
gameLocal.Error( "idDeclModelDef::NumJointsOnChannel : channel out of range" ); gameLocal.Error( "idDeclModelDef::NumJointsOnChannel : channel out of range" );
return 0; // unreachable, (Error() doesn't return) just to shut up compiler
} }
return channelJoints[ channel ].Num(); return channelJoints[ channel ].Num();
} }
@ -2983,6 +2984,7 @@ idDeclModelDef::GetChannelJoints
const int * idDeclModelDef::GetChannelJoints( int channel ) const { const int * idDeclModelDef::GetChannelJoints( int channel ) const {
if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) {
gameLocal.Error( "idDeclModelDef::GetChannelJoints : channel out of range" ); gameLocal.Error( "idDeclModelDef::GetChannelJoints : channel out of range" );
return NULL; // unreachable, (Error() doesn't return) just to shut up compiler
} }
return channelJoints[ channel ].Ptr(); return channelJoints[ channel ].Ptr();
} }