summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2018-05-13 18:34:57 +0100
committerfrosch <github@elsenhans.name>2018-06-27 22:54:46 +0200
commit5f86e1a390b4aa9510d43f97251484ca67934f1c (patch)
tree8a9a74e4beeefb3ebe5585f0f10aac80d2ba078a /src
parente1b9187e9b39ff2ce1982a8fbcb4f2a018662ce7 (diff)
downloadopenttd-5f86e1a390b4aa9510d43f97251484ca67934f1c.tar.xz
Codechange: Silence -Wclass-memaccess warnings with GCC8
Diffstat (limited to 'src')
-rw-r--r--src/3rdparty/squirrel/squirrel/squtils.h2
-rw-r--r--src/3rdparty/squirrel/squirrel/sqvm.cpp6
-rw-r--r--src/base_media_func.h2
-rw-r--r--src/blitter/32bpp_anim.cpp2
-rw-r--r--src/core/alloc_func.hpp2
-rw-r--r--src/economy.cpp5
-rw-r--r--src/landscape.cpp3
-rw-r--r--src/newgrf_object.cpp4
-rw-r--r--src/saveload/company_sl.cpp1
9 files changed, 12 insertions, 15 deletions
diff --git a/src/3rdparty/squirrel/squirrel/squtils.h b/src/3rdparty/squirrel/squirrel/squtils.h
index 28c6cbec2..b1138dcb1 100644
--- a/src/3rdparty/squirrel/squirrel/squtils.h
+++ b/src/3rdparty/squirrel/squirrel/squtils.h
@@ -90,7 +90,7 @@ public:
{
_vals[idx].~T();
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--;
}
diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp
index c66c4aca5..03ffea230 100644
--- a/src/3rdparty/squirrel/squirrel/sqvm.cpp
+++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp
@@ -378,8 +378,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
}
if (!tailcall) {
- CallInfo lc;
- memset(&lc, 0, sizeof(lc));
+ CallInfo lc = {};
lc._generator = NULL;
lc._etraps = 0;
lc._prevstkbase = (SQInt32) ( stackbase - _stackbase );
@@ -1159,8 +1158,7 @@ bool SQVM::CallNative(SQNativeClosure *nclosure,SQInteger nargs,SQInteger stackb
SQInteger oldtop = _top;
SQInteger oldstackbase = _stackbase;
_top = stackbase + nargs;
- CallInfo lci;
- memset(&lci, 0, sizeof(lci));
+ CallInfo lci = {};
lci._closure = nclosure;
lci._generator = NULL;
lci._etraps = 0;
diff --git a/src/base_media_func.h b/src/base_media_func.h
index 2cb751fe0..f7afca0ed 100644
--- a/src/base_media_func.h
+++ b/src/base_media_func.h
@@ -40,8 +40,6 @@
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)
{
- memset(this, 0, sizeof(*this));
-
IniGroup *metadata = ini->GetGroup("metadata");
IniItem *item;
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index 578d85f18..98ae22b00 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -361,7 +361,7 @@ void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width,
Colour *dst_pal = dst;
uint16 *anim_pal = anim_line;
- memcpy(dst, usrc, width * sizeof(uint32));
+ memcpy(static_cast<void *>(dst), usrc, width * sizeof(uint32));
usrc += width;
dst += _screen.pitch;
/* Copy back the anim-buffer */
diff --git a/src/core/alloc_func.hpp b/src/core/alloc_func.hpp
index c7e17421f..c33e73301 100644
--- a/src/core/alloc_func.hpp
+++ b/src/core/alloc_func.hpp
@@ -125,7 +125,7 @@ static inline T *ReallocT(T *t_ptr, size_t num_elements)
/* Ensure the size does not overflow. */
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));
return t_ptr;
}
diff --git a/src/economy.cpp b/src/economy.cpp
index 70b0bd837..fae71f3e4 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -696,9 +696,10 @@ static void CompaniesGenStatistics()
if (!HasBit(1 << 0 | 1 << 3 | 1 << 6 | 1 << 9, _cur_month)) return;
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;
- 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++;
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 185e84a80..a29c97b9d 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -1080,8 +1080,7 @@ static uint River_Hash(uint tile, uint dir)
*/
static void BuildRiver(TileIndex begin, TileIndex end)
{
- AyStar finder;
- MemSetT(&finder, 0);
+ AyStar finder = {};
finder.CalculateG = River_CalculateG;
finder.CalculateH = River_CalculateH;
finder.GetNeighbours = River_GetNeighbours;
diff --git a/src/newgrf_object.cpp b/src/newgrf_object.cpp
index 78bbc5244..40a966a16 100644
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -96,7 +96,9 @@ uint ObjectSpec::Index() const
void ResetObjects()
{
/* 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. */
MemCpyT(_object_specs, _original_objects, lengthof(_original_objects));
diff --git a/src/saveload/company_sl.cpp b/src/saveload/company_sl.cpp
index 07d685e92..ce388e214 100644
--- a/src/saveload/company_sl.cpp
+++ b/src/saveload/company_sl.cpp
@@ -498,7 +498,6 @@ static void Check_PLYR()
int index;
while ((index = SlIterateArray()) != -1) {
CompanyProperties *cprops = new CompanyProperties();
- memset(cprops, 0, sizeof(*cprops));
SaveLoad_PLYR_common(NULL, cprops);
/* We do not load old custom names */