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>
This commit is contained in:
Giuseppe D'Angelo 2015-10-09 11:13:27 +02:00
parent 0cfdfcc82e
commit a2f6ece27f

View File

@ -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);