1
0
Fork 0

Codechange: Silence -Wclass-memaccess warnings with GCC8

pull/6843/head
Charles Pigott 2018-05-13 18:34:57 +01:00 committed by frosch
parent e1b9187e9b
commit 5f86e1a390
9 changed files with 12 additions and 15 deletions

View File

@ -90,7 +90,7 @@ public:
{ {
_vals[idx].~T(); _vals[idx].~T();
if(idx < (_size - 1)) { if(idx < (_size - 1)) {
memmove(&_vals[idx], &_vals[idx+1], sizeof(T) * (_size - (size_t)idx - 1)); memmove(static_cast<void *>(&_vals[idx]), &_vals[idx+1], sizeof(T) * (_size - (size_t)idx - 1));
} }
_size--; _size--;
} }

View File

@ -378,8 +378,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
} }
if (!tailcall) { if (!tailcall) {
CallInfo lc; CallInfo lc = {};
memset(&lc, 0, sizeof(lc));
lc._generator = NULL; lc._generator = NULL;
lc._etraps = 0; lc._etraps = 0;
lc._prevstkbase = (SQInt32) ( stackbase - _stackbase ); lc._prevstkbase = (SQInt32) ( stackbase - _stackbase );
@ -1159,8 +1158,7 @@ bool SQVM::CallNative(SQNativeClosure *nclosure,SQInteger nargs,SQInteger stackb
SQInteger oldtop = _top; SQInteger oldtop = _top;
SQInteger oldstackbase = _stackbase; SQInteger oldstackbase = _stackbase;
_top = stackbase + nargs; _top = stackbase + nargs;
CallInfo lci; CallInfo lci = {};
memset(&lci, 0, sizeof(lci));
lci._closure = nclosure; lci._closure = nclosure;
lci._generator = NULL; lci._generator = NULL;
lci._etraps = 0; lci._etraps = 0;

View File

@ -40,8 +40,6 @@
template <class T, size_t Tnum_files, bool Tsearch_in_tars> template <class T, size_t Tnum_files, bool Tsearch_in_tars>
bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const char *path, const char *full_filename, bool allow_empty_filename) bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const char *path, const char *full_filename, bool allow_empty_filename)
{ {
memset(this, 0, sizeof(*this));
IniGroup *metadata = ini->GetGroup("metadata"); IniGroup *metadata = ini->GetGroup("metadata");
IniItem *item; IniItem *item;

View File

@ -361,7 +361,7 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
Colour *dst_pal = dst; Colour *dst_pal = dst;
uint16 *anim_pal = anim_line; uint16 *anim_pal = anim_line;
memcpy(dst, usrc, width * sizeof(uint32)); memcpy(static_cast<void *>(dst), usrc, width * sizeof(uint32));
usrc += width; usrc += width;
dst += _screen.pitch; dst += _screen.pitch;
/* Copy back the anim-buffer */ /* Copy back the anim-buffer */

View File

@ -125,7 +125,7 @@ static inline T *ReallocT(T *t_ptr, size_t num_elements)
/* Ensure the size does not overflow. */ /* Ensure the size does not overflow. */
CheckAllocationConstraints<T>(num_elements); CheckAllocationConstraints<T>(num_elements);
t_ptr = (T*)realloc(t_ptr, num_elements * sizeof(T)); t_ptr = (T*)realloc(static_cast<void *>(t_ptr), num_elements * sizeof(T));
if (t_ptr == NULL) ReallocError(num_elements * sizeof(T)); if (t_ptr == NULL) ReallocError(num_elements * sizeof(T));
return t_ptr; return t_ptr;
} }

View File

@ -696,9 +696,10 @@ static void CompaniesGenStatistics()
if (!HasBit(1 << 0 | 1 << 3 | 1 << 6 | 1 << 9, _cur_month)) return; if (!HasBit(1 << 0 | 1 << 3 | 1 << 6 | 1 << 9, _cur_month)) return;
FOR_ALL_COMPANIES(c) { FOR_ALL_COMPANIES(c) {
memmove(&c->old_economy[1], &c->old_economy[0], sizeof(c->old_economy) - sizeof(c->old_economy[0])); /* Drop the oldest history off the end */
std::copy_backward(c->old_economy, c->old_economy + MAX_HISTORY_QUARTERS - 1, c->old_economy + MAX_HISTORY_QUARTERS);
c->old_economy[0] = c->cur_economy; c->old_economy[0] = c->cur_economy;
memset(&c->cur_economy, 0, sizeof(c->cur_economy)); c->cur_economy = {};
if (c->num_valid_stat_ent != MAX_HISTORY_QUARTERS) c->num_valid_stat_ent++; if (c->num_valid_stat_ent != MAX_HISTORY_QUARTERS) c->num_valid_stat_ent++;

View File

@ -1080,8 +1080,7 @@ static uint River_Hash(uint tile, uint dir)
*/ */
static void BuildRiver(TileIndex begin, TileIndex end) static void BuildRiver(TileIndex begin, TileIndex end)
{ {
AyStar finder; AyStar finder = {};
MemSetT(&finder, 0);
finder.CalculateG = River_CalculateG; finder.CalculateG = River_CalculateG;
finder.CalculateH = River_CalculateH; finder.CalculateH = River_CalculateH;
finder.GetNeighbours = River_GetNeighbours; finder.GetNeighbours = River_GetNeighbours;

View File

@ -96,7 +96,9 @@ uint ObjectSpec::Index() const
void ResetObjects() void ResetObjects()
{ {
/* Clean the pool. */ /* Clean the pool. */
MemSetT(_object_specs, 0, lengthof(_object_specs)); for (uint16 i = 0; i < NUM_OBJECTS; i++) {
_object_specs[i] = {};
}
/* And add our originals. */ /* And add our originals. */
MemCpyT(_object_specs, _original_objects, lengthof(_original_objects)); MemCpyT(_object_specs, _original_objects, lengthof(_original_objects));

View File

@ -498,7 +498,6 @@ static void Check_PLYR()
int index; int index;
while ((index = SlIterateArray()) != -1) { while ((index = SlIterateArray()) != -1) {
CompanyProperties *cprops = new CompanyProperties(); CompanyProperties *cprops = new CompanyProperties();
memset(cprops, 0, sizeof(*cprops));
SaveLoad_PLYR_common(NULL, cprops); SaveLoad_PLYR_common(NULL, cprops);
/* We do not load old custom names */ /* We do not load old custom names */