fix warnings for gcc 10 and clang 10

This commit is contained in:
aurhat
2021-10-05 22:12:49 +02:00
parent 4aa520515c
commit fcd0fd8980
9 changed files with 27 additions and 11 deletions
+1 -1
View File
@@ -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++;
}
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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();
+1 -1
View File
@@ -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++;
}
+1 -1
View File
@@ -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)
{
+16 -2
View File
@@ -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<char *> &subdirs)
{
#if defined(WIN32)
@@ -293,7 +307,7 @@ bool listsubdir(const char *dir, vector<char *> &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<char *> &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
+1
View File
@@ -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);
+2 -2
View File
@@ -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;
+3 -2
View File
@@ -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;
}