From dbe4174c0b56ce81f8e0ef7d06cf6aa531eebca2 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Thu, 5 Jan 2023 08:07:51 +0100 Subject: [PATCH] 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, except for some in idParser::ExpandBuiltinDefine() that I'll fix in the next commit --- neo/cm/CollisionModel_load.cpp | 9 +++++++++ neo/d3xp/AF.cpp | 5 +++++ neo/d3xp/Pvs.cpp | 3 ++- neo/d3xp/anim/Anim_Blend.cpp | 4 +++- neo/game/AF.cpp | 5 +++++ neo/game/Pvs.cpp | 3 ++- neo/game/anim/Anim_Blend.cpp | 4 +++- 7 files changed, 29 insertions(+), 4 deletions(-) diff --git a/neo/cm/CollisionModel_load.cpp b/neo/cm/CollisionModel_load.cpp index acd2a3d7..0f69d0ce 100644 --- a/neo/cm/CollisionModel_load.cpp +++ b/neo/cm/CollisionModel_load.cpp @@ -3479,6 +3479,11 @@ idCollisionModelManagerLocal::GetModelPolygon =================== */ bool idCollisionModelManagerLocal::GetModelPolygon( cmHandle_t model, int polygonNum, idFixedWinding &winding ) const { + + assert(0 && "if this is ever called, it must be fixed first!"); // DG: see below + return false; + +#if 0 int i, edgeNum; cm_polygon_t *poly; @@ -3487,6 +3492,9 @@ bool idCollisionModelManagerLocal::GetModelPolygon( cmHandle_t model, int polygo return false; } + // FIXME: DG: WTF is this, casting an int to a pointer?! we're lucky this is unused.. + // (it's called by idClip::GetModelContactFeature() which is called by + // idClip()::DrawModelContactFeatuer(), but that is never called) poly = *reinterpret_cast(&polygonNum); winding.Clear(); for ( i = 0; i < poly->numEdges; i++ ) { @@ -3495,6 +3503,7 @@ bool idCollisionModelManagerLocal::GetModelPolygon( cmHandle_t model, int polygo } return true; +#endif // 0 } /* diff --git a/neo/d3xp/AF.cpp b/neo/d3xp/AF.cpp index e527b14e..1a97edc3 100644 --- a/neo/d3xp/AF.cpp +++ b/neo/d3xp/AF.cpp @@ -892,6 +892,11 @@ bool idAF::Load( idEntity *ent, const char *fileName ) { for ( i = 0; i < physicsObj.GetNumConstraints(); i++ ) { idAFConstraint *constraint = physicsObj.GetConstraint( i ); 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 && file->constraints[j]->type == constraint->GetType() ) { break; diff --git a/neo/d3xp/Pvs.cpp b/neo/d3xp/Pvs.cpp index 46e16f11..4894eb1a 100644 --- a/neo/d3xp/Pvs.cpp +++ b/neo/d3xp/Pvs.cpp @@ -872,7 +872,8 @@ void idPVS::Shutdown( void ) { delete[] areaPVS; areaPVS = NULL; } - if ( currentPVS ) { + // if ( currentPVS ) - DG: can't be NULL + { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { delete[] currentPVS[i].pvs; currentPVS[i].pvs = NULL; diff --git a/neo/d3xp/anim/Anim_Blend.cpp b/neo/d3xp/anim/Anim_Blend.cpp index da1249a6..7df2552c 100644 --- a/neo/d3xp/anim/Anim_Blend.cpp +++ b/neo/d3xp/anim/Anim_Blend.cpp @@ -172,7 +172,7 @@ index 0 will never be NULL. Any anim >= NumAnims will return NULL. ===================== */ const idMD5Anim *idAnim::MD5Anim( int num ) const { - if ( anims == NULL || anims[0] == NULL ) { + if ( anims[0] == NULL ) { return NULL; } return anims[ num ]; @@ -3057,6 +3057,7 @@ idDeclModelDef::NumJointsOnChannel int idDeclModelDef::NumJointsOnChannel( int channel ) const { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { gameLocal.Error( "idDeclModelDef::NumJointsOnChannel : channel out of range" ); + return 0; // unreachable, (Error() doesn't return) just to shut up compiler } return channelJoints[ channel ].Num(); } @@ -3069,6 +3070,7 @@ idDeclModelDef::GetChannelJoints const int * idDeclModelDef::GetChannelJoints( int channel ) const { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { gameLocal.Error( "idDeclModelDef::GetChannelJoints : channel out of range" ); + return NULL; // unreachable, (Error() doesn't return) just to shut up compiler } return channelJoints[ channel ].Ptr(); } diff --git a/neo/game/AF.cpp b/neo/game/AF.cpp index e527b14e..1a97edc3 100644 --- a/neo/game/AF.cpp +++ b/neo/game/AF.cpp @@ -892,6 +892,11 @@ bool idAF::Load( idEntity *ent, const char *fileName ) { for ( i = 0; i < physicsObj.GetNumConstraints(); i++ ) { idAFConstraint *constraint = physicsObj.GetConstraint( i ); 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 && file->constraints[j]->type == constraint->GetType() ) { break; diff --git a/neo/game/Pvs.cpp b/neo/game/Pvs.cpp index 16e845a6..4536710e 100644 --- a/neo/game/Pvs.cpp +++ b/neo/game/Pvs.cpp @@ -872,7 +872,8 @@ void idPVS::Shutdown( void ) { delete[] areaPVS; areaPVS = NULL; } - if ( currentPVS ) { + // if ( currentPVS ) - DG: can't be NULL + { for ( int i = 0; i < MAX_CURRENT_PVS; i++ ) { delete[] currentPVS[i].pvs; currentPVS[i].pvs = NULL; diff --git a/neo/game/anim/Anim_Blend.cpp b/neo/game/anim/Anim_Blend.cpp index 0cbd4af7..3f25a3dc 100644 --- a/neo/game/anim/Anim_Blend.cpp +++ b/neo/game/anim/Anim_Blend.cpp @@ -172,7 +172,7 @@ index 0 will never be NULL. Any anim >= NumAnims will return NULL. ===================== */ const idMD5Anim *idAnim::MD5Anim( int num ) const { - if ( anims == NULL || anims[0] == NULL ) { + if ( anims[0] == NULL ) { return NULL; } return anims[ num ]; @@ -2971,6 +2971,7 @@ idDeclModelDef::NumJointsOnChannel int idDeclModelDef::NumJointsOnChannel( int channel ) const { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { gameLocal.Error( "idDeclModelDef::NumJointsOnChannel : channel out of range" ); + return 0; // unreachable, (Error() doesn't return) just to shut up compiler } return channelJoints[ channel ].Num(); } @@ -2983,6 +2984,7 @@ idDeclModelDef::GetChannelJoints const int * idDeclModelDef::GetChannelJoints( int channel ) const { if ( ( channel < 0 ) || ( channel >= ANIM_NumAnimChannels ) ) { gameLocal.Error( "idDeclModelDef::GetChannelJoints : channel out of range" ); + return NULL; // unreachable, (Error() doesn't return) just to shut up compiler } return channelJoints[ channel ].Ptr(); }