From a2f6ece27f95eb7cb9940af6ba734d4ba52bf4cb Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 9 Oct 2015 11:13:27 +0200 Subject: 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 --- src/corelib/io/qlockfile_unix.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/corelib/io/qlockfile_unix.cpp') 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); -- cgit v1.2.3