summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@theqtcompany.com>2016-04-15 13:49:25 +0200
committerJoerg Bornemann <joerg.bornemann@theqtcompany.com>2016-04-22 08:45:48 +0000
commitea64dc9a113a850334fbf47ca2cdc3b447945c25 (patch)
tree4c40b0ef4d8cf86c776bcbe12e2791a00d3bb43b /src
parenteb786d600cf0b994089dacd7e2ed9a02b1ac0552 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/io/qlockfile_unix.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp
index bcef84206e..f23a232fb8 100644
--- a/src/corelib/io/qlockfile_unix.cpp
+++ b/src/corelib/io/qlockfile_unix.cpp
@@ -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;
+
+ const bool val = QLockFilePrivate::checkFcntlWorksAfterFlock(fn);
+ worksPtr = new bool(val);
+ fcntlOK->insert(fn, worksPtr);
- return *worksPtr;
+ return val;
}
static bool setNativeLocks(const QString &fileName, int fd)