qlockfile_unix - code cleanup

Coverity's CID 157687: QCache::insert, indeed, can delete (immediately)
the object we're trying to insert. While this never happens actually in
qlockfile_unix since we have max cost 10 and insert with cost 1, the
code does not look good and Coverity is not happy.

Change-Id: I16a428017bf86e151afe5256906e4cab1ef4044a
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
bb10
Timur Pocheptsov 2016-04-15 13:49:25 +02:00 committed by Joerg Bornemann
parent eb786d600c
commit ea64dc9a11
1 changed files with 7 additions and 5 deletions

View File

@ -139,12 +139,14 @@ static bool fcntlWorksAfterFlock(const QString &fn)
if (fcntlOK.isDestroyed())
return QLockFilePrivate::checkFcntlWorksAfterFlock(fn);
bool *worksPtr = fcntlOK->object(fn);
if (!worksPtr) {
worksPtr = new bool(QLockFilePrivate::checkFcntlWorksAfterFlock(fn));
fcntlOK->insert(fn, worksPtr);
}
if (worksPtr)
return *worksPtr;
return *worksPtr;
const bool val = QLockFilePrivate::checkFcntlWorksAfterFlock(fn);
worksPtr = new bool(val);
fcntlOK->insert(fn, worksPtr);
return val;
}
static bool setNativeLocks(const QString &fileName, int fd)