From 0ccba6700665e9369f85bc56b0ccae4ff4415f19 Mon Sep 17 00:00:00 2001 From: Vitaly Karpenko Date: Tue, 29 Oct 2019 22:48:31 +0200 Subject: [PATCH] Fix compilation with GCC 8.2+ (#617) * GCC 8.2 support * Add GCC version check * -Werror=class-memaccess fix in code * Use assignment for Stats --- modules/cstrike/csx/CMisc.cpp | 2 +- modules/dod/dodx/CMisc.cpp | 4 ++-- modules/dod/dodx/moduleconfig.cpp | 2 +- modules/fakemeta/fm_tr2.cpp | 2 +- modules/hamsandwich/hook_callbacks.cpp | 32 +++++++++++++------------- modules/mysqlx/threading.cpp | 2 +- modules/sqlite/threading.cpp | 2 +- modules/tfcx/CMisc.cpp | 2 +- modules/ts/tsx/CMisc.cpp | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/modules/cstrike/csx/CMisc.cpp b/modules/cstrike/csx/CMisc.cpp index 218b0373..101dfbe9 100644 --- a/modules/cstrike/csx/CMisc.cpp +++ b/modules/cstrike/csx/CMisc.cpp @@ -131,7 +131,7 @@ void CPlayer::restartStats(bool all) memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats memset(attackers,0,sizeof(attackers)); memset(victims,0,sizeof(victims)); - memset(&life,0,sizeof(life)); + life = {}; } void CPlayer::Init( int pi, edict_t* pe ) diff --git a/modules/dod/dodx/CMisc.cpp b/modules/dod/dodx/CMisc.cpp index 7a2cdcaa..13641899 100644 --- a/modules/dod/dodx/CMisc.cpp +++ b/modules/dod/dodx/CMisc.cpp @@ -95,14 +95,14 @@ void CPlayer::restartStats(bool all) if ( all ) { memset(weapons,0,sizeof(weapons)); - memset(&round,0,sizeof(round)); + memset(static_cast(&round),0,sizeof(round)); memset(weaponsRnd,0,sizeof(weaponsRnd)); } memset(weaponsLife,0,sizeof(weaponsLife)); //DEC-Weapon (Round) stats memset(attackers,0,sizeof(attackers)); memset(victims,0,sizeof(victims)); - memset(&life,0,sizeof(life)); + life = {}; } void CPlayer::Init( int pi, edict_t* pe ) diff --git a/modules/dod/dodx/moduleconfig.cpp b/modules/dod/dodx/moduleconfig.cpp index 00606bfb..8ca5851a 100644 --- a/modules/dod/dodx/moduleconfig.cpp +++ b/modules/dod/dodx/moduleconfig.cpp @@ -172,7 +172,7 @@ void PlayerPreThink_Post(edict_t *pEntity) if(pPlayer->clearRound && pPlayer->clearRound < gpGlobals->time) { pPlayer->clearRound = 0.0f; - memset(&pPlayer->round,0,sizeof(pPlayer->round)); + memset(static_cast(&pPlayer->round),0,sizeof(pPlayer->round)); memset(pPlayer->weaponsRnd,0,sizeof(pPlayer->weaponsRnd)); } diff --git a/modules/fakemeta/fm_tr2.cpp b/modules/fakemeta/fm_tr2.cpp index 4b5a0e07..83edbc7a 100644 --- a/modules/fakemeta/fm_tr2.cpp +++ b/modules/fakemeta/fm_tr2.cpp @@ -1255,7 +1255,7 @@ static cell AMX_NATIVE_CALL create_tr2(AMX *amx, cell *params) tr = g_FreeTRs.front(); g_FreeTRs.pop(); } - memset(tr, 0, sizeof(TraceResult)); + memset(static_cast(tr), 0, sizeof(TraceResult)); return reinterpret_cast(tr); } diff --git a/modules/hamsandwich/hook_callbacks.cpp b/modules/hamsandwich/hook_callbacks.cpp index 9ba1dab9..fcf02170 100644 --- a/modules/hamsandwich/hook_callbacks.cpp +++ b/modules/hamsandwich/hook_callbacks.cpp @@ -136,7 +136,7 @@ extern bool gDoForwards; #define CHECK_RETURN_VEC() \ if (thisresult < HAM_OVERRIDE) \ { \ - memcpy(out, &origret, sizeof(Vector)); \ + memcpy(static_cast(out), &origret, sizeof(Vector)); \ return; \ } @@ -852,8 +852,8 @@ void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1, MAKE_VECTOR() - memset(&ret, 0x0, sizeof(Vector)); - memset(&origret, 0x0, sizeof(Vector)); + memset(static_cast(&ret), 0x0, sizeof(Vector)); + memset(static_cast(&origret), 0x0, sizeof(Vector)); int iEnt = TypeConversion.cbase_to_id(cb); @@ -879,7 +879,7 @@ void Hook_Vector_Float_Cbase_Int(Hook *hook, Vector *out, void *pthis, float f1, POP() CHECK_RETURN_VEC() - memcpy(out, &ret, sizeof(Vector)); + memcpy(static_cast(out), &ret, sizeof(Vector)); } void Hook_Void_Cbase_Cbase_Int_Float(Hook *hook, void *pthis, void *cb1, void *cb2, int i1, float f1) @@ -1038,8 +1038,8 @@ void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis) MAKE_VECTOR() - memset(&ret, 0x0, sizeof(Vector)); - memset(&origret, 0x0, sizeof(Vector)); + memset(static_cast(&ret), 0x0, sizeof(Vector)); + memset(static_cast(&origret), 0x0, sizeof(Vector)); PRE_START() PRE_END() @@ -1056,7 +1056,7 @@ void Hook_Vector_Void(Hook *hook, Vector *out, void *pthis) KILL_VECTOR() POP() CHECK_RETURN_VEC() - memcpy(out, &ret, sizeof(Vector)); + memcpy(static_cast(out), &ret, sizeof(Vector)); } @@ -1074,8 +1074,8 @@ void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1) MAKE_VECTOR() P_PTRVECTOR(v1) - memset(&ret, 0x0, sizeof(Vector)); - memset(&origret, 0x0, sizeof(Vector)); + memset(static_cast(&ret), 0x0, sizeof(Vector)); + memset(static_cast(&origret), 0x0, sizeof(Vector)); PRE_START() , MF_PrepareCellArrayA(reinterpret_cast(v1), 3, false) @@ -1094,7 +1094,7 @@ void Hook_Vector_pVector(Hook *hook, Vector *out, void *pthis, Vector *v1) KILL_VECTOR() POP() CHECK_RETURN_VEC() - memcpy(out, &ret, sizeof(Vector)); + memcpy(static_cast(out), &ret, sizeof(Vector)); } int Hook_Int_pVector(Hook *hook, void *pthis, Vector *v1) @@ -1476,8 +1476,8 @@ void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1) MAKE_VECTOR() P_FLOAT(f1) - memset(&ret, 0x0, sizeof(Vector)); - memset(&origret, 0x0, sizeof(Vector)); + memset(static_cast(&ret), 0x0, sizeof(Vector)); + memset(static_cast(&origret), 0x0, sizeof(Vector)); PRE_START() , f1 @@ -1496,7 +1496,7 @@ void Hook_Vector_Float(Hook *hook, Vector *out, void *pthis, float f1) KILL_VECTOR() POP() CHECK_RETURN_VEC() - memcpy(out, &ret, sizeof(Vector)); + memcpy(static_cast(out), &ret, sizeof(Vector)); } @@ -3269,8 +3269,8 @@ void Hook_Vector_Vector_Vector_Vector(Hook *hook, Vector *out, void *pthis, Vect P_VECTOR(v2) P_VECTOR(v3) - memset(&ret, 0x0, sizeof(Vector)); - memset(&origret, 0x0, sizeof(Vector)); + memset(static_cast(&ret), 0x0, sizeof(Vector)); + memset(static_cast(&origret), 0x0, sizeof(Vector)); PRE_START() , MF_PrepareCellArrayA(reinterpret_cast(&v1), 3, false) @@ -3294,7 +3294,7 @@ void Hook_Vector_Vector_Vector_Vector(Hook *hook, Vector *out, void *pthis, Vect POP() CHECK_RETURN_VEC() - memcpy(out, &ret, sizeof(Vector)); + memcpy(static_cast(out), &ret, sizeof(Vector)); } const char *Hook_Str_Str(Hook *hook, void *pthis, const char* str) diff --git a/modules/mysqlx/threading.cpp b/modules/mysqlx/threading.cpp index 27b87557..4f2cbfba 100644 --- a/modules/mysqlx/threading.cpp +++ b/modules/mysqlx/threading.cpp @@ -178,7 +178,7 @@ void MysqlThread::RunThread(IThreadHandle *pHandle) float save_time = m_qrInfo.queue_time; - memset(&m_qrInfo, 0, sizeof(m_qrInfo)); + memset(static_cast(&m_qrInfo), 0, sizeof(m_qrInfo)); m_qrInfo.queue_time = save_time; diff --git a/modules/sqlite/threading.cpp b/modules/sqlite/threading.cpp index e33f7467..2512cbfd 100644 --- a/modules/sqlite/threading.cpp +++ b/modules/sqlite/threading.cpp @@ -162,7 +162,7 @@ void MysqlThread::RunThread(IThreadHandle *pHandle) float save_time = m_qrInfo.queue_time; - memset(&m_qrInfo, 0, sizeof(m_qrInfo)); + memset(static_cast(&m_qrInfo), 0, sizeof(m_qrInfo)); m_qrInfo.queue_time = save_time; diff --git a/modules/tfcx/CMisc.cpp b/modules/tfcx/CMisc.cpp index 82cc1aee..6733b875 100644 --- a/modules/tfcx/CMisc.cpp +++ b/modules/tfcx/CMisc.cpp @@ -130,7 +130,7 @@ void CPlayer::restartStats(bool all) memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats memset(attackers,0,sizeof(attackers)); memset(victims,0,sizeof(victims)); - memset(&life,0,sizeof(life)); + life = {}; } void CPlayer::Init( int pi, edict_t* pe ) diff --git a/modules/ts/tsx/CMisc.cpp b/modules/ts/tsx/CMisc.cpp index fed2c32e..316254e8 100644 --- a/modules/ts/tsx/CMisc.cpp +++ b/modules/ts/tsx/CMisc.cpp @@ -82,7 +82,7 @@ void CPlayer::restartStats(bool all) memset(weaponsRnd,0,sizeof(weaponsRnd)); //DEC-Weapon (Round) stats memset(attackers,0,sizeof(attackers)); memset(victims,0,sizeof(victims)); - memset(&life,0,sizeof(life)); + life = {}; } void CPlayer::Init( int pi, edict_t* pe )