From a467362aa871105e0f153dc40fbafb4c66254a69 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 13 Oct 2022 14:38:44 -0700 Subject: [PATCH] IPC: include the error text instead of errno code in errorString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's much easier to tell what happened. Change-Id: I12a088d1ae424825abd3fffd171dbeb58c46fd6d Reviewed-by: Tor Arne Vestbø Reviewed-by: Mårten Nordheim --- src/corelib/ipc/qsharedmemory.cpp | 3 ++- src/corelib/ipc/qsharedmemory_win.cpp | 3 ++- src/corelib/ipc/qsystemsemaphore.cpp | 3 ++- src/corelib/ipc/qsystemsemaphore_win.cpp | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/corelib/ipc/qsharedmemory.cpp b/src/corelib/ipc/qsharedmemory.cpp index e9a57c6cec..dea41c798e 100644 --- a/src/corelib/ipc/qsharedmemory.cpp +++ b/src/corelib/ipc/qsharedmemory.cpp @@ -670,7 +670,8 @@ void QSharedMemoryPrivate::setUnixErrorString(QLatin1StringView function) error = QSharedMemory::OutOfResources; break; default: - errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(errno); + errorString = QSharedMemory::tr("%1: unknown error: %2") + .arg(function, qt_error_string(errno)); error = QSharedMemory::UnknownError; #if defined QSHAREDMEMORY_DEBUG qDebug() << errorString << "key" << key << "errno" << errno << EINVAL; diff --git a/src/corelib/ipc/qsharedmemory_win.cpp b/src/corelib/ipc/qsharedmemory_win.cpp index 0cb32296ec..593c312f47 100644 --- a/src/corelib/ipc/qsharedmemory_win.cpp +++ b/src/corelib/ipc/qsharedmemory_win.cpp @@ -41,7 +41,8 @@ void QSharedMemoryPrivate::setWindowsErrorString(QLatin1StringView function) errorString = QSharedMemory::tr("%1: permission denied").arg(function); break; default: - errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(windowsError); + errorString = QSharedMemory::tr("%1: unknown error: %2") + .arg(function, qt_error_string(windowsError)); error = QSharedMemory::UnknownError; #if defined QSHAREDMEMORY_DEBUG qDebug() << errorString << "key" << key; diff --git a/src/corelib/ipc/qsystemsemaphore.cpp b/src/corelib/ipc/qsystemsemaphore.cpp index 3f9a7018da..9b42b93995 100644 --- a/src/corelib/ipc/qsystemsemaphore.cpp +++ b/src/corelib/ipc/qsystemsemaphore.cpp @@ -351,7 +351,8 @@ void QSystemSemaphorePrivate::setUnixErrorString(QLatin1StringView function) error = QSystemSemaphore::KeyError; break; default: - errorString = QSystemSemaphore::tr("%1: unknown error %2").arg(function).arg(errno); + errorString = QSystemSemaphore::tr("%1: unknown error: %2") + .arg(function, qt_error_string(errno)); error = QSystemSemaphore::UnknownError; #if defined QSYSTEMSEMAPHORE_DEBUG qDebug() << errorString << "key" << key << "errno" << errno << EINVAL; diff --git a/src/corelib/ipc/qsystemsemaphore_win.cpp b/src/corelib/ipc/qsystemsemaphore_win.cpp index 3d04694461..13da3f301c 100644 --- a/src/corelib/ipc/qsystemsemaphore_win.cpp +++ b/src/corelib/ipc/qsystemsemaphore_win.cpp @@ -30,7 +30,8 @@ void QSystemSemaphorePrivate::setWindowsErrorString(QLatin1StringView function) errorString = QCoreApplication::translate("QSystemSemaphore", "%1: permission denied").arg(function); break; default: - errorString = QCoreApplication::translate("QSystemSemaphore", "%1: unknown error %2").arg(function).arg(windowsError); + errorString = QCoreApplication::translate("QSystemSemaphore", "%1: unknown error: %2") + .arg(function, qt_error_string(windowsError)); error = QSystemSemaphore::UnknownError; #if defined QSYSTEMSEMAPHORE_DEBUG qDebug() << errorString << "key" << key;