fix stuff found by cppcheck
almost 3000 lines of "errors" contained one actual memleak, one actually unused variable and three actual ambiguous code parts from cppcheck website: "The goal is to detect only real errors in the code (i.e. have zero false positives)." :) thx for finding five problems in our code
This commit is contained in:
@@ -305,7 +305,7 @@ void processdownload(package *pck, stream *f) // write downloaded data to file(s
|
||||
else
|
||||
{ // any name with listed extension, written to subdirectory
|
||||
int zlen = (int)strlen(zname), elen = (int)strlen(pck->exts[n]);
|
||||
if((isok = zlen > elen && !strcmp(zname + zlen - elen, pck->exts[n]))) formatstring(filename)("%s/%s", pck->fullpath, zname);
|
||||
if((isok = (zlen > elen && !strcmp(zname + zlen - elen, pck->exts[n])))) formatstring(filename)("%s/%s", pck->fullpath, zname);
|
||||
}
|
||||
if(isok) break;
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ struct mitemcheckbox : mitem
|
||||
{
|
||||
bool sel = isselection();
|
||||
const static int boxsize = FONTH;
|
||||
int offs = ((menurighttabwidth - FONTH) * (msctrl % 41 ? pos : 50 + 50 * sinf(totalmillis / 300.0f + y))) / 100;
|
||||
int offs = ((menurighttabwidth - FONTH) * ((msctrl % 41) ? pos : (50 + 50 * sinf(totalmillis / 300.0f + y)))) / 100;
|
||||
|
||||
draw_text(text, x, y);
|
||||
if(sel)
|
||||
|
||||
@@ -956,7 +956,6 @@ bool preload_mapmodels(bool trydl)
|
||||
|
||||
void renderclient(playerent *d, const char *mdlname, const char *vwepname, int tex)
|
||||
{
|
||||
int varseed = (int)(size_t)d;
|
||||
int anim = ANIM_IDLE|ANIM_LOOP;
|
||||
float speed = 0.0;
|
||||
vec o(d->o);
|
||||
@@ -968,7 +967,6 @@ void renderclient(playerent *d, const char *mdlname, const char *vwepname, int t
|
||||
loopv(bounceents) if(bounceents[i]->bouncetype==BT_GIB && bounceents[i]->owner==d) return;
|
||||
d->pitch = 0.1f;
|
||||
anim = ANIM_DEATH;
|
||||
varseed += d->lastpain;
|
||||
basetime = d->lastpain;
|
||||
int t = lastmillis-d->lastpain;
|
||||
if(t<0 || t>20000) return;
|
||||
@@ -982,7 +980,7 @@ void renderclient(playerent *d, const char *mdlname, const char *vwepname, int t
|
||||
}
|
||||
else if(d->state==CS_EDITING) { anim = ANIM_JUMP|ANIM_END; }
|
||||
else if(d->state==CS_LAGGED) { anim = ANIM_SALUTE|ANIM_LOOP|ANIM_TRANSLUCENT; }
|
||||
else if(lastmillis-d->lastpain<300) { anim = d->crouching ? ANIM_CROUCH_PAIN : ANIM_PAIN; speed = 300.0f/4; varseed += d->lastpain; basetime = d->lastpain; }
|
||||
else if(lastmillis-d->lastpain<300) { anim = d->crouching ? ANIM_CROUCH_PAIN : ANIM_PAIN; speed = 300.0f/4; basetime = d->lastpain; }
|
||||
else if(d->weaponsel==d->lastattackweapon && lastmillis-d->lastaction<300 && d->lastpain < d->lastaction && !d->weaponsel->reloading && (d->weaponsel->type != GUN_GRENADE || ((grenades *)d->weaponsel)->cookingmillis))
|
||||
{ anim = d->crouching ? ANIM_CROUCH_ATTACK : ANIM_ATTACK; speed = 300.0f/8; basetime = d->lastaction; }
|
||||
else if(!d->onfloor && d->timeinair>50) { anim = (d->crouching ? ANIM_CROUCH_WALK : ANIM_JUMP)|ANIM_END; }
|
||||
|
||||
@@ -458,7 +458,7 @@ const char *asciiscores(bool destjpg)
|
||||
buf[0] = '\0';
|
||||
if(destjpg)
|
||||
{
|
||||
formatstring(text)("AssaultCube Screenshot (%s)\n", asctime());
|
||||
formatstring(text)("AssaultCube Screenshot (%s)\n", asctimestr());
|
||||
addstr(buf, text);
|
||||
}
|
||||
if(getclientmap()[0])
|
||||
|
||||
@@ -669,7 +669,7 @@ void enddemorecord()
|
||||
demofile &d = demofiles.add();
|
||||
|
||||
//2010oct10:ft: suggests : formatstring(d.info)("%s, %s, %.2f%s", modestr(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB"); // the datetime bit is pretty useless in the servmesg, no?!
|
||||
formatstring(d.info)("%s: %s, %s, %.2f%s", asctime(), modestr(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB");
|
||||
formatstring(d.info)("%s: %s, %s, %.2f%s", asctimestr(), modestr(gamemode), smapname, len > 1024*1024 ? len/(1024*1024.f) : len/1024.0f, len > 1024*1024 ? "MB" : "kB");
|
||||
if(mr) { concatformatstring(d.info, ", %d mr", mr); concatformatstring(d.file, "_%dmr", mr); }
|
||||
defformatstring(msg)("Demo \"%s\" recorded\nPress F10 to download it from the server..", d.info);
|
||||
sendservmsg(msg);
|
||||
@@ -740,9 +740,9 @@ void setupdemorecord()
|
||||
lilswap(&hdr.version, 1);
|
||||
lilswap(&hdr.protocol, 1);
|
||||
memset(hdr.desc, 0, DHDR_DESCCHARS);
|
||||
defformatstring(desc)("%s, %s, %s %s", modestr(gamemode, false), behindpath(smapname), asctime(), servdesc_current);
|
||||
defformatstring(desc)("%s, %s, %s %s", modestr(gamemode, false), behindpath(smapname), asctimestr(), servdesc_current);
|
||||
if(strlen(desc) > DHDR_DESCCHARS)
|
||||
formatstring(desc)("%s, %s, %s %s", modestr(gamemode, true), behindpath(smapname), asctime(), servdesc_current);
|
||||
formatstring(desc)("%s, %s, %s %s", modestr(gamemode, true), behindpath(smapname), asctimestr(), servdesc_current);
|
||||
desc[DHDR_DESCCHARS - 1] = '\0';
|
||||
strcpy(hdr.desc, desc);
|
||||
memset(hdr.plist, 0, DHDR_PLISTCHARS);
|
||||
|
||||
@@ -30,7 +30,7 @@ const char *timestring(time_t t, bool local, const char *fmt, char *buf)
|
||||
return buf;
|
||||
}
|
||||
|
||||
const char *asctime()
|
||||
const char *asctimestr()
|
||||
{
|
||||
return timestring(true, "%c");
|
||||
}
|
||||
|
||||
+1
-1
@@ -924,7 +924,7 @@ struct stream
|
||||
extern string _timestringbuffer;
|
||||
extern const char *timestring(time_t t, bool local = false, const char *fmt = NULL, char *buf = _timestringbuffer);
|
||||
inline const char *timestring(bool local = false, const char *fmt = NULL, char *buf = _timestringbuffer) { return timestring(time(NULL), local, fmt, buf); }
|
||||
extern const char *asctime();
|
||||
extern const char *asctimestr();
|
||||
extern const char *numtime();
|
||||
extern void transformoldentitytypes(int mapversion, uchar &enttype);
|
||||
extern int fixmapheadersize(int version, int headersize);
|
||||
|
||||
@@ -864,7 +864,7 @@ int load_world(char *mname) // still supports all map formats that have e
|
||||
if(extrasize)
|
||||
{ // map file actually has extra header data that we want too preserve
|
||||
uchar *extrabuf = new uchar[extrasize];
|
||||
if(f->read(extrabuf, extrasize) != extrasize) { conoutf("\f3while reading map: header malformatted (3)"); delete f; return -7; }
|
||||
if(f->read(extrabuf, extrasize) != extrasize) { conoutf("\f3while reading map: header malformatted (3)"); delete f; delete[] extrabuf; return -7; }
|
||||
unpackheaderextra(extrabuf, extrasize);
|
||||
delete[] extrabuf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user