diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-10-09 11:13:27 +0200 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2015-10-12 15:09:53 +0000 |
commit | a2f6ece27f95eb7cb9940af6ba734d4ba52bf4cb (patch) | |
tree | 36aa1e57bdcaf6280d14b23ffff09cc17a181d6e /src/corelib/io/qlockfile_unix.cpp | |
parent | 0cfdfcc82ec58b2016f4ab2973343eb85874f27d (diff) |
QLockFile: fix errno handling
In case of a lock failure, we potentially pollute the errno value
before printing it. Also, switch to qt_error_string, as strerror
is not reentrant.
Change-Id: I952aac14204637155726bcefc0ed8a21d7fcd501
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/io/qlockfile_unix.cpp')
-rw-r--r-- | src/corelib/io/qlockfile_unix.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/corelib/io/qlockfile_unix.cpp b/src/corelib/io/qlockfile_unix.cpp index 5ff4b1cbe1..bd9f8a5988 100644 --- a/src/corelib/io/qlockfile_unix.cpp +++ b/src/corelib/io/qlockfile_unix.cpp @@ -171,8 +171,10 @@ QLockFile::LockError QLockFilePrivate::tryLock_sys() } } // Ensure nobody else can delete the file while we have it - if (!setNativeLocks(fd)) - qWarning() << "setNativeLocks failed:" << strerror(errno); + if (!setNativeLocks(fd)) { + const int errnoSaved = errno; + qWarning() << "setNativeLocks failed:" << qt_error_string(errnoSaved); + } if (qt_write_loop(fd, fileData.constData(), fileData.size()) < fileData.size()) { close(fd); |