From 762017f03ca530937dfe24cc822065e08111f985 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 11 Oct 2022 16:46:11 -0700 Subject: [PATCH] IPC: move the *_unix.cpp contents to the main files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's just the setUnixErrorString() functions. Change-Id: I12a088d1ae424825abd3fffd171d2880ebaf49c7 Reviewed-by: Tor Arne Vestbø Reviewed-by: Mårten Nordheim --- src/corelib/CMakeLists.txt | 2 - src/corelib/ipc/qsharedmemory.cpp | 31 ++++++++++++ src/corelib/ipc/qsharedmemory_unix.cpp | 45 ----------------- src/corelib/ipc/qsystemsemaphore.cpp | 35 +++++++++++++ src/corelib/ipc/qsystemsemaphore_unix.cpp | 61 ----------------------- 5 files changed, 66 insertions(+), 108 deletions(-) delete mode 100644 src/corelib/ipc/qsharedmemory_unix.cpp delete mode 100644 src/corelib/ipc/qsystemsemaphore_unix.cpp diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 73675110ae..19393c5d7e 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -1139,10 +1139,8 @@ qt_internal_extend_target(Core CONDITION UNIX SOURCES ipc/qsharedmemory_posix.cpp ipc/qsharedmemory_systemv.cpp - ipc/qsharedmemory_unix.cpp ipc/qsystemsemaphore_posix.cpp ipc/qsystemsemaphore_systemv.cpp - ipc/qsystemsemaphore_unix.cpp ) qt_internal_extend_target(Core CONDITION VXWORKS diff --git a/src/corelib/ipc/qsharedmemory.cpp b/src/corelib/ipc/qsharedmemory.cpp index 696dcb785b..e9a57c6cec 100644 --- a/src/corelib/ipc/qsharedmemory.cpp +++ b/src/corelib/ipc/qsharedmemory.cpp @@ -647,6 +647,37 @@ QString QSharedMemory::errorString() const return d->errorString; } +void QSharedMemoryPrivate::setUnixErrorString(QLatin1StringView function) +{ + // EINVAL is handled in functions so they can give better error strings + switch (errno) { + case EACCES: + errorString = QSharedMemory::tr("%1: permission denied").arg(function); + error = QSharedMemory::PermissionDenied; + break; + case EEXIST: + errorString = QSharedMemory::tr("%1: already exists").arg(function); + error = QSharedMemory::AlreadyExists; + break; + case ENOENT: + errorString = QSharedMemory::tr("%1: doesn't exist").arg(function); + error = QSharedMemory::NotFound; + break; + case EMFILE: + case ENOMEM: + case ENOSPC: + errorString = QSharedMemory::tr("%1: out of resources").arg(function); + error = QSharedMemory::OutOfResources; + break; + default: + errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(errno); + error = QSharedMemory::UnknownError; +#if defined QSHAREDMEMORY_DEBUG + qDebug() << errorString << "key" << key << "errno" << errno << EINVAL; +#endif + } +} + #endif // QT_CONFIG(sharedmemory) QT_END_NAMESPACE diff --git a/src/corelib/ipc/qsharedmemory_unix.cpp b/src/corelib/ipc/qsharedmemory_unix.cpp deleted file mode 100644 index 1d79240c8b..0000000000 --- a/src/corelib/ipc/qsharedmemory_unix.cpp +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include "qsharedmemory.h" - -#if QT_CONFIG(sharedmemory) -# include "qsharedmemory_p.h" -# include - -QT_BEGIN_NAMESPACE - -void QSharedMemoryPrivate::setUnixErrorString(QLatin1StringView function) -{ - // EINVAL is handled in functions so they can give better error strings - switch (errno) { - case EACCES: - errorString = QSharedMemory::tr("%1: permission denied").arg(function); - error = QSharedMemory::PermissionDenied; - break; - case EEXIST: - errorString = QSharedMemory::tr("%1: already exists").arg(function); - error = QSharedMemory::AlreadyExists; - break; - case ENOENT: - errorString = QSharedMemory::tr("%1: doesn't exist").arg(function); - error = QSharedMemory::NotFound; - break; - case EMFILE: - case ENOMEM: - case ENOSPC: - errorString = QSharedMemory::tr("%1: out of resources").arg(function); - error = QSharedMemory::OutOfResources; - break; - default: - errorString = QSharedMemory::tr("%1: unknown error %2").arg(function).arg(errno); - error = QSharedMemory::UnknownError; -#if defined QSHAREDMEMORY_DEBUG - qDebug() << errorString << "key" << key << "errno" << errno << EINVAL; -#endif - } -} - -QT_END_NAMESPACE - -#endif // QT_CONFIG(sharedmemory) diff --git a/src/corelib/ipc/qsystemsemaphore.cpp b/src/corelib/ipc/qsystemsemaphore.cpp index 68500a6153..a457271943 100644 --- a/src/corelib/ipc/qsystemsemaphore.cpp +++ b/src/corelib/ipc/qsystemsemaphore.cpp @@ -323,6 +323,41 @@ QString QSystemSemaphore::errorString() const return d->errorString; } +void QSystemSemaphorePrivate::setUnixErrorString(QLatin1StringView function) +{ + // EINVAL is handled in functions so they can give better error strings + switch (errno) { + case EPERM: + case EACCES: + errorString = QSystemSemaphore::tr("%1: permission denied").arg(function); + error = QSystemSemaphore::PermissionDenied; + break; + case EEXIST: + errorString = QSystemSemaphore::tr("%1: already exists").arg(function); + error = QSystemSemaphore::AlreadyExists; + break; + case ENOENT: + errorString = QSystemSemaphore::tr("%1: does not exist").arg(function); + error = QSystemSemaphore::NotFound; + break; + case ERANGE: + case ENOSPC: + errorString = QSystemSemaphore::tr("%1: out of resources").arg(function); + error = QSystemSemaphore::OutOfResources; + break; + case ENAMETOOLONG: + errorString = QSystemSemaphore::tr("%1: key too long").arg(function); + error = QSystemSemaphore::KeyError; + break; + default: + errorString = QSystemSemaphore::tr("%1: unknown error %2").arg(function).arg(errno); + error = QSystemSemaphore::UnknownError; +#if defined QSYSTEMSEMAPHORE_DEBUG + qDebug() << errorString << "key" << key << "errno" << errno << EINVAL; +#endif + } +} + #endif // QT_CONFIG(systemsemaphore) QT_END_NAMESPACE diff --git a/src/corelib/ipc/qsystemsemaphore_unix.cpp b/src/corelib/ipc/qsystemsemaphore_unix.cpp deleted file mode 100644 index 2b66d1ef5f..0000000000 --- a/src/corelib/ipc/qsystemsemaphore_unix.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only - -#include "qsystemsemaphore.h" -#include "qsystemsemaphore_p.h" - -#include -#include - -#if QT_CONFIG(systemsemaphore) - -#include -#ifndef QT_POSIX_IPC -#include -#include -#endif -#include -#include - -#include "private/qcore_unix_p.h" - -QT_BEGIN_NAMESPACE - -void QSystemSemaphorePrivate::setUnixErrorString(QLatin1StringView function) -{ - // EINVAL is handled in functions so they can give better error strings - switch (errno) { - case EPERM: - case EACCES: - errorString = QSystemSemaphore::tr("%1: permission denied").arg(function); - error = QSystemSemaphore::PermissionDenied; - break; - case EEXIST: - errorString = QSystemSemaphore::tr("%1: already exists").arg(function); - error = QSystemSemaphore::AlreadyExists; - break; - case ENOENT: - errorString = QSystemSemaphore::tr("%1: does not exist").arg(function); - error = QSystemSemaphore::NotFound; - break; - case ERANGE: - case ENOSPC: - errorString = QSystemSemaphore::tr("%1: out of resources").arg(function); - error = QSystemSemaphore::OutOfResources; - break; - case ENAMETOOLONG: - errorString = QSystemSemaphore::tr("%1: key too long").arg(function); - error = QSystemSemaphore::KeyError; - break; - default: - errorString = QSystemSemaphore::tr("%1: unknown error %2").arg(function).arg(errno); - error = QSystemSemaphore::UnknownError; -#if defined QSYSTEMSEMAPHORE_DEBUG - qDebug() << errorString << "key" << key << "errno" << errno << EINVAL; -#endif - } -} - -QT_END_NAMESPACE - -#endif // QT_CONFIG(systemsemaphore)