From 42b0324d3c37d9bde5e06e183ec770c7556341c2 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Thu, 28 Sep 2017 13:22:28 +0300 Subject: Use C++11 member class initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I427b993a3a71f199029a8956cdf0dc2c98f0e444 Reviewed-by: Alex Blasche Reviewed-by: André Hartmann --- src/serialport/qwinoverlappedionotifier.cpp | 32 ++++++++++++----------------- 1 file changed, 13 insertions(+), 19 deletions(-) (limited to 'src/serialport/qwinoverlappedionotifier.cpp') diff --git a/src/serialport/qwinoverlappedionotifier.cpp b/src/serialport/qwinoverlappedionotifier.cpp index 6ec7463..dfae3b0 100644 --- a/src/serialport/qwinoverlappedionotifier.cpp +++ b/src/serialport/qwinoverlappedionotifier.cpp @@ -101,13 +101,13 @@ QT_BEGIN_NAMESPACE struct IOResult { - IOResult(DWORD n = 0, DWORD e = 0, OVERLAPPED *p = 0) + IOResult(DWORD n = 0, DWORD e = 0, OVERLAPPED *p = nullptr) : numberOfBytes(n), errorCode(e), overlapped(p) {} - DWORD numberOfBytes; - DWORD errorCode; - OVERLAPPED *overlapped; + DWORD numberOfBytes = 0; + DWORD errorCode = 0; + OVERLAPPED *overlapped = nullptr; }; @@ -117,11 +117,6 @@ class QWinOverlappedIoNotifierPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QWinOverlappedIoNotifier) public: - QWinOverlappedIoNotifierPrivate() - : hHandle(INVALID_HANDLE_VALUE) - { - } - OVERLAPPED *waitForAnyNotified(QDeadlineTimer deadline); void notify(DWORD numberOfBytes, DWORD errorCode, OVERLAPPED *overlapped); void _q_notified(); @@ -130,9 +125,9 @@ public: static QWinIoCompletionPort *iocp; static HANDLE iocpInstanceLock; static unsigned int iocpInstanceRefCount; - HANDLE hHandle; - HANDLE hSemaphore; - HANDLE hResultsMutex; + HANDLE hHandle = INVALID_HANDLE_VALUE; + HANDLE hSemaphore = nullptr; + HANDLE hResultsMutex = nullptr; QAtomicInt waiting; QQueue results; }; @@ -147,8 +142,7 @@ class QWinIoCompletionPort : protected QThread public: QWinIoCompletionPort() : finishThreadKey(reinterpret_cast(this)), - drainQueueKey(reinterpret_cast(this + 1)), - hPort(INVALID_HANDLE_VALUE) + drainQueueKey(reinterpret_cast(this + 1)) { setObjectName(QLatin1String("I/O completion port thread")); HANDLE hIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); @@ -208,9 +202,9 @@ public: protected: void run() { - DWORD dwBytesRead; - ULONG_PTR pulCompletionKey; - OVERLAPPED *overlapped; + DWORD dwBytesRead = 0; + ULONG_PTR pulCompletionKey = 0; + OVERLAPPED *overlapped = nullptr; DWORD msecs = INFINITE; forever { @@ -253,11 +247,11 @@ protected: private: const ULONG_PTR finishThreadKey; const ULONG_PTR drainQueueKey; - HANDLE hPort; + HANDLE hPort = INVALID_HANDLE_VALUE; QSet notifiers; QMutex mutex; QMutex drainQueueMutex; - HANDLE hQueueDrainedEvent; + HANDLE hQueueDrainedEvent = nullptr; }; -- cgit v1.2.1