diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index 44b269f8..8d8e7372 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -929,7 +929,7 @@ void deletemapsoundslot(int *n, char *opt) // delete mapsound slot - only if unu { // delete entity deleted_ents.add(e); deletesoundentity(e); - memset(&e, 0, sizeof(persistent_entity)); + memset((void *)&e, 0, sizeof(persistent_entity)); e.type = NOTUSED; deld++; } diff --git a/source/src/console.cpp b/source/src/console.cpp index 7f1b9bca..77465026 100644 --- a/source/src/console.cpp +++ b/source/src/console.cpp @@ -633,7 +633,7 @@ bool textinputbuffer::say(const char *c) int buflen = (int)strlen(buf), txtlen = (int)strlen(txt); if(txtlen && buflen < maxlen() && buflen + txtlen < (int)sizeof(buf)) { - if(pos < 0) strncpy(buf + buflen, txt, txtlen); + if(pos < 0) memcpy(buf + buflen, txt, txtlen); else { memmove(&buf[pos + txtlen], &buf[pos], buflen - pos); diff --git a/source/src/http.cpp b/source/src/http.cpp index a8e85f03..48e2555f 100644 --- a/source/src/http.cpp +++ b/source/src/http.cpp @@ -328,7 +328,7 @@ int httpget::get(const char *url1, uint timeout, uint totaltimeout, int range, b if(gzipped) { z_stream zs; - memset(&zs, 0, sizeof(zs)); + memset((void *)&zs, 0, sizeof(zs)); if(inflateInit2(&zs, 15 + 32) == Z_OK) { zs.next_in = (Bytef*)content->getbuf(); diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index 9c218630..b030cf86 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -179,7 +179,7 @@ void deletemapmodelslot(int *n, char *opt) // delete mapmodel slot - only if unu if(e.attr2 == *n) { // delete entity deleted_ents.add(e); - memset(&e, 0, sizeof(persistent_entity)); + memset((void *)&e, 0, sizeof(persistent_entity)); e.type = NOTUSED; deld++; } diff --git a/source/src/scoreboard.cpp b/source/src/scoreboard.cpp index 27114283..b1cc6dd2 100644 --- a/source/src/scoreboard.cpp +++ b/source/src/scoreboard.cpp @@ -420,7 +420,7 @@ void renderscores(void *menu, bool init) #define MAXJPGCOM 65533 // maximum JPEG comment length -static void addstr(char *&dest, const char *end, const char *src) { size_t l = strlen(src); if(dest + l < end) copystring(dest, src, l + 1), dest += l; } +static void addstr(char *&dest, const char *end, const char *src) { size_t l = strlen(src); if(dest + l < end) memcpy(dest, src, l + 1), dest += l; } const char *asciiscores(bool destjpg) { diff --git a/source/src/stream.cpp b/source/src/stream.cpp index 829deb3f..cfe5c4df 100644 --- a/source/src/stream.cpp +++ b/source/src/stream.cpp @@ -272,6 +272,20 @@ const char *stream_capabilities() #endif } +#if !defined(WIN32) +int readdir_r_(DIR *d, struct dirent *b, struct dirent **de) +{ + #ifdef __USE_POSIX + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wdeprecated-declarations" + #endif + return readdir_r(d, b, de); + #ifdef __USE_POSIX + #pragma GCC diagnostic pop + #endif +} +#endif + bool listsubdir(const char *dir, vector &subdirs) { #if defined(WIN32) @@ -293,7 +307,7 @@ bool listsubdir(const char *dir, vector &subdirs) if(d) { struct dirent *de, b; - while(!readdir_r(d, &b, &de) && de != NULL) + while(!readdir_r_(d, &b, &de) && de != NULL) { #ifdef _DIRENT_HAVE_D_TYPE if(de->d_type == DT_DIR && de->d_name[0] != '.') subdirs.add(newstring(de->d_name)); @@ -361,7 +375,7 @@ bool listdir(const char *dir, const char *ext, vector &files) if(d) { struct dirent *de, b; - while(!readdir_r(d, &b, &de) && de != NULL) + while(!readdir_r_(d, &b, &de) && de != NULL) { bool isreg = false; #ifdef _DIRENT_HAVE_D_TYPE diff --git a/source/src/tools.h b/source/src/tools.h index bd35136a..953c0ddc 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -119,6 +119,7 @@ typedef char string[MAXSTRLEN]; #define vformatstring(d,last,fmt) { va_list ap; va_start(ap, last); vformatstring_(d, fmt, ap); va_end(ap); } inline void vformatstring_(char* d, const char* fmt, va_list v, int len = MAXSTRLEN) { _vsnprintf(d, len, fmt, v); d[len - 1] = 0; } +//#pragma GCC diagnostic ignored "-Wstringop-truncation" // moved to makefile, because it doesn't work from precompiled header inline char *copystring(char *d, const char *s, size_t len = MAXSTRLEN) { strncpy(d, s, len); d[len-1] = 0; return d; } inline char *concatstring(char *d, const char *s, size_t len = MAXSTRLEN) { size_t used = strlen(d); return used < len ? copystring(d+used, s, len-used) : d; } extern char *concatformatstring(char *d, const char *s, ...) PRINTFARGS(2, 3); diff --git a/source/src/world.cpp b/source/src/world.cpp index 05448862..3c73309f 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -478,7 +478,7 @@ void deleteentity(char *ns) if(t == SOUND) deletesoundentity(e); conoutf("deleted entity #%d (%s)", n, entnames[e.type]); deleted_ents.add(e); - memset(&e, 0, sizeof(persistent_entity)); + memset((void *)&e, 0, sizeof(persistent_entity)); e.type = NOTUSED; if(t == LIGHT) calclight(); unsavededits++; @@ -751,7 +751,7 @@ bool empty_world(int factor, bool force) // main empty world creation routine clearheaderextras(); unsavededits = oldunsavededits; } - strncpy(hdr.head, "ACMP", 4); + memcpy(hdr.head, "ACMP", 4); hdr.version = MAPVERSION; hdr.headersize = sizeof(header); hdr.sfactor = sfactor; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 6f9d74d9..6c212af5 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -741,6 +741,7 @@ void save_world(char *mname, bool skipoptimise, bool addcomfort) } // update (and fix) map header + memcpy(hdr.head, "ACMP", 4); // ensure map now declares itself as an AssaultCube map, even if imported as CUBE hdr.version = MAPVERSION; hdr.headersize = sizeof(header); hdr.timestamp = (int) time(NULL); @@ -1046,7 +1047,7 @@ int load_world(char *mname) // still supports all map formats that have e loopi(hdr.numents) { entity &e = ents.add(); - memcpy(&e, &tempents[i], sizeof(persistent_entity)); + memcpy((void *)&e, &tempents[i], sizeof(persistent_entity)); e.spawned = false; } delete[] tempents; @@ -1327,7 +1328,7 @@ struct xmap void restoreent(int i) { entity &e = ::ents.add(); - memcpy(&e, &ents[i], sizeof(persistent_entity)); + memcpy((void *)&e, &ents[i], sizeof(persistent_entity)); e.spawned = true; }