Fix warnings for gcc 9.3

This commit is contained in:
aurhat
2020-11-03 22:15:34 +01:00
parent 2ecb3646e1
commit 8bb1aba638
9 changed files with 21 additions and 16 deletions
+2 -2
View File
@@ -347,7 +347,7 @@ void teaminfo(const char *team, const char *attr)
t_deaths += players[i]->deaths;
t_points += players[i]->points;
t_flags += players[i]->flagscore;
sprintf(tmp, "%s%d ", teammembers, players[i]->clientnum);
formatstring(tmp)("%s%d ", teammembers, players[i]->clientnum);
concatstring(teammembers, tmp);
}
@@ -365,7 +365,7 @@ void teaminfo(const char *team, const char *attr)
t_deaths += player1->deaths;
t_points += player1->points;
t_flags += player1->flagscore;
sprintf(tmp, "%s%d ", teammembers, player1->clientnum);
formatstring(tmp)("%s%d ", teammembers, player1->clientnum);
concatstring(teammembers, tmp);
}
+1 -1
View File
@@ -799,7 +799,7 @@ void *genchallenge(void *pubkey, const void *seed, int seedlen, vector<char> &ch
tiger::hashval hash;
tiger::hash((const uchar *)seed, seedlen, hash);
gfint challenge;
memcpy(challenge.digits, hash.bytes, sizeof(challenge.digits));
memcpy(challenge.digits, hash.bytes, sizeof(hash.bytes));
challenge.len = 8*sizeof(hash.bytes)/BI_DIGIT_BITS;
challenge.shrink();
+4 -4
View File
@@ -3449,7 +3449,7 @@ void process(ENetPacket *packet, int sender, int chan)
}
else
{
strncpy(vi->text,text,MAXTRANS-1);
copystring(vi->text,text,MAXTRANS);
vi->num1 = mode;
vi->num2 = time;
}
@@ -3466,7 +3466,7 @@ void process(ENetPacket *packet, int sender, int chan)
{
vi->num1 = cn2boot = getint(p);
getstring(text, p);
strncpy(vi->text,text,128);
copystring(vi->text,text,128);
filtertext(text, text);
trimtrailingwhitespace(text);
vi->action = new kickaction(cn2boot, newstring(text, 128));
@@ -3477,7 +3477,7 @@ void process(ENetPacket *packet, int sender, int chan)
{
vi->num1 = cn2boot = getint(p);
getstring(text, p);
strncpy(vi->text,text,128);
copystring(vi->text,text,128);
filtertext(text, text);
trimtrailingwhitespace(text);
vi->action = new banaction(cn2boot, newstring(text, 128));
@@ -3515,7 +3515,7 @@ void process(ENetPacket *packet, int sender, int chan)
break;
case SA_SERVERDESC:
getstring(text, p);
strncpy(vi->text,text,MAXTRANS-1);
copystring(vi->text,text,MAXTRANS);
filtertext(text, text);
vi->action = new serverdescaction(newstring(text), sender);
break;
+1 -2
View File
@@ -1298,8 +1298,7 @@ void retrieveservers(vector<char> &data)
{
if(mastertype == AC_MASTER_HTTP)
{
string request;
sprintf(request, "http://%s/retrieve.do?action=list&name=%s&version=%d&build=%d", mastername, global_name, AC_VERSION, getbuildtype()|(1<<16));
defformatstring(request)("http://%s/retrieve.do?action=list&name=%s&version=%d&build=%d", mastername, global_name, AC_VERSION, getbuildtype()|(1<<16));
const char *tmpname = findfile(path("config/servers.cfg", true), "wb");
FILE *outfile = fopen(tmpname, "w+");
+2 -2
View File
@@ -669,8 +669,8 @@ struct serverforbiddenlist : serverconfigfile
char *c1 = s1, *c2 = s2;
if (num < 100 && (n = sscanf(s,"%s %s",s1,s2)) > 0 ) // no warnings
{
strncpy(entries[num][0],c1,FORBIDDENSIZE);
if ( n > 1 ) strncpy(entries[num][1],c2,FORBIDDENSIZE);
copystring(entries[num][0],c1,FORBIDDENSIZE);
if ( n > 1 ) copystring(entries[num][1],c2,FORBIDDENSIZE);
else entries[num][1][0]='\0';
num++;
}
+7 -1
View File
@@ -106,7 +106,13 @@ inline int iabs(int n) { return labs(n); }
typedef char string[MAXSTRLEN];
inline void vformatstring(char *d, const char *fmt, va_list v, int len = MAXSTRLEN) { _vsnprintf(d, len, fmt, v); d[len-1] = 0; }
inline char *copystring(char *d, const char *s, size_t len = MAXSTRLEN) { strncpy(d, s, len); d[len-1] = 0; return d; }
inline char *copystring(char *d, const char *s, size_t len = MAXSTRLEN)
{
size_t slen = min(strlen(s), len-1);
memcpy(d, s, slen);
d[slen] = 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, ...);
+1 -1
View File
@@ -698,7 +698,7 @@ struct vertmodel : model
ntags[numtags].name = newstring(name);
loopi(numframes)
{
memcpy(&ntags[(numtags + 1)*i], &tags[numtags*i], numtags*sizeof(tag));
memcpy((void *)&ntags[(numtags + 1)*i], (void *)&tags[numtags*i], numtags*sizeof(tag));
tag *t = &ntags[(numtags + 1)*i + numtags];
t->pos = m->verts[m->numverts*i + verts[0]];
+1 -1
View File
@@ -477,7 +477,7 @@ bool empty_world(int factor, bool force) // main empty world creation routine
checkselections(); // assert no selection became invalid
strncpy(hdr.head, "ACMP", 4);
copystring(hdr.head, "ACMP", 4);
hdr.version = MAPVERSION;
hdr.headersize = sizeof(header);
hdr.sfactor = sfactor;
+2 -2
View File
@@ -216,7 +216,7 @@ void save_world(char *mname)
if(mapbackupsonsave) backup(cgzname, bakname);
stream *f = opengzfile(cgzname, "wb");
if(!f) { conoutf("could not write map to %s", cgzname); return; }
strncpy(hdr.head, "ACMP", 4); // ensure map now declares itself as an AssaultCube map, even if imported as CUBE
copystring(hdr.head, "ACMP", 4); // ensure map now declares itself as an AssaultCube map, even if imported as CUBE
hdr.version = MAPVERSION;
hdr.numents = 0;
loopv(ents) if(ents[i].type!=NOTUSED) hdr.numents++;
@@ -565,4 +565,4 @@ bool load_world(char *mname) // still supports all map formats that have
return true;
}
COMMANDN(savemap, save_world, "s");
COMMANDN(savemap, save_world, "s");