summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2014-12-09 23:19:44 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2014-12-10 09:49:23 +0100
commitcd9c48833cf4fbf73df68dcdb83f261c03950f91 (patch)
tree4f99e51cb4b12bb5cc07e6a1dd6a7f0a3ee5eb12
parent160efdbbf51c38ac973b0e36b98b72e2439f51e6 (diff)
downloadqtserialport-cd9c48833cf4fbf73df68dcdb83f261c03950f91.tar.gz
Use Q_NULLPTR where it is possible
Change-Id: I7261a92ea4405c8aeab7670f73e7225ed7e4d9d0 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r--src/serialport/qserialport_unix.cpp10
-rw-r--r--src/serialport/qserialport_win.cpp24
-rw-r--r--src/serialport/qserialport_wince.cpp18
-rw-r--r--src/serialport/qserialportinfo.cpp2
-rw-r--r--src/serialport/qserialportinfo_win.cpp12
-rw-r--r--src/serialport/qserialportinfo_wince.cpp12
6 files changed, 39 insertions, 39 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 838210a..648b6fc 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -148,8 +148,8 @@ private:
QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
: QSerialPortPrivateData(q)
, descriptor(-1)
- , readNotifier(0)
- , writeNotifier(0)
+ , readNotifier(Q_NULLPTR)
+ , writeNotifier(Q_NULLPTR)
, readPortNotifierCalled(false)
, readPortNotifierState(false)
, readPortNotifierStateSet(false)
@@ -227,19 +227,19 @@ void QSerialPortPrivate::close()
if (readNotifier) {
readNotifier->setEnabled(false);
readNotifier->deleteLater();
- readNotifier = 0;
+ readNotifier = Q_NULLPTR;
}
if (writeNotifier) {
writeNotifier->setEnabled(false);
writeNotifier->deleteLater();
- writeNotifier = 0;
+ writeNotifier = Q_NULLPTR;
}
if (qt_safe_close(descriptor) == -1)
q->setError(decodeSystemError());
- lockFileScopedPointer.reset(0);
+ lockFileScopedPointer.reset(Q_NULLPTR);
descriptor = -1;
pendingBytesWritten = 0;
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index fabfac2..0e9f187 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -94,13 +94,13 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
, communicationNotifier(new QWinEventNotifier(q))
, readCompletionNotifier(new QWinEventNotifier(q))
, writeCompletionNotifier(new QWinEventNotifier(q))
- , startAsyncWriteTimer(0)
+ , startAsyncWriteTimer(Q_NULLPTR)
, originalEventMask(0)
, triggeredEventMask(0)
, actualBytesToWrite(0)
{
::ZeroMemory(&communicationOverlapped, sizeof(communicationOverlapped));
- communicationOverlapped.hEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL);
+ communicationOverlapped.hEvent = ::CreateEvent(Q_NULLPTR, FALSE, FALSE, Q_NULLPTR);
if (!communicationOverlapped.hEvent)
q->setError(decodeSystemError());
else {
@@ -109,7 +109,7 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
}
::ZeroMemory(&readCompletionOverlapped, sizeof(readCompletionOverlapped));
- readCompletionOverlapped.hEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL);
+ readCompletionOverlapped.hEvent = ::CreateEvent(Q_NULLPTR, FALSE, FALSE, Q_NULLPTR);
if (!readCompletionOverlapped.hEvent)
q->setError(decodeSystemError());
else {
@@ -118,7 +118,7 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
}
::ZeroMemory(&writeCompletionOverlapped, sizeof(writeCompletionOverlapped));
- writeCompletionOverlapped.hEvent = ::CreateEvent(NULL, FALSE, FALSE, NULL);
+ writeCompletionOverlapped.hEvent = ::CreateEvent(Q_NULLPTR, FALSE, FALSE, Q_NULLPTR);
if (!writeCompletionOverlapped.hEvent)
q->setError(decodeSystemError());
else {
@@ -152,7 +152,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
desiredAccess |= GENERIC_WRITE;
handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation.utf16()),
- desiredAccess, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
+ desiredAccess, 0, Q_NULLPTR, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, Q_NULLPTR);
if (handle == INVALID_HANDLE_VALUE) {
q->setError(decodeSystemError());
@@ -223,9 +223,9 @@ QSerialPort::PinoutSignals QSerialPortPrivate::pinoutSignals()
ret |= QSerialPort::DataCarrierDetectSignal;
DWORD bytesReturned = 0;
- if (!::DeviceIoControl(handle, IOCTL_SERIAL_GET_DTRRTS, NULL, 0,
+ if (!::DeviceIoControl(handle, IOCTL_SERIAL_GET_DTRRTS, Q_NULLPTR, 0,
&modemStat, sizeof(modemStat),
- &bytesReturned, NULL)) {
+ &bytesReturned, Q_NULLPTR)) {
q->setError(decodeSystemError());
return ret;
}
@@ -348,7 +348,7 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs)
stopWatch.start();
do {
- HANDLE triggeredEvent = 0;
+ HANDLE triggeredEvent = Q_NULLPTR;
if (!waitAnyEvent(timeoutValue(msecs, stopWatch.elapsed()), &triggeredEvent) || !triggeredEvent)
return false;
@@ -391,7 +391,7 @@ bool QSerialPortPrivate::waitForBytesWritten(int msecs)
stopWatch.start();
forever {
- HANDLE triggeredEvent = 0;
+ HANDLE triggeredEvent = Q_NULLPTR;
if (!waitAnyEvent(timeoutValue(msecs, stopWatch.elapsed()), &triggeredEvent) || !triggeredEvent)
return false;
@@ -598,7 +598,7 @@ bool QSerialPortPrivate::startAsyncRead()
}
initializeOverlappedStructure(readCompletionOverlapped);
- if (::ReadFile(handle, readChunkBuffer.data(), bytesToRead, NULL, &readCompletionOverlapped)) {
+ if (::ReadFile(handle, readChunkBuffer.data(), bytesToRead, Q_NULLPTR, &readCompletionOverlapped)) {
readStarted = true;
return true;
}
@@ -629,7 +629,7 @@ bool QSerialPortPrivate::_q_startAsyncWrite()
const int writeBytes = writeBuffer.nextDataBlockSize();
if (!::WriteFile(handle, writeBuffer.readPointer(),
writeBytes,
- NULL, &writeCompletionOverlapped)) {
+ Q_NULLPTR, &writeCompletionOverlapped)) {
QSerialPort::SerialPortError error = decodeSystemError();
if (error != QSerialPort::NoError) {
@@ -709,7 +709,7 @@ void QSerialPortPrivate::handleLineStatusErrors()
Q_Q(QSerialPort);
DWORD errors = 0;
- if (!::ClearCommError(handle, &errors, NULL)) {
+ if (!::ClearCommError(handle, &errors, Q_NULLPTR)) {
q->setError(decodeSystemError());
return;
}
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp
index d7441e6..99cc603 100644
--- a/src/serialport/qserialport_wince.cpp
+++ b/src/serialport/qserialport_wince.cpp
@@ -183,7 +183,7 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
: QSerialPortPrivateData(q)
, handle(INVALID_HANDLE_VALUE)
, parityErrorOccurred(false)
- , eventNotifier(0)
+ , eventNotifier(Q_NULLPTR)
{
}
@@ -204,7 +204,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode)
}
handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation.utf16()),
- desiredAccess, 0, NULL, OPEN_EXISTING, 0, NULL);
+ desiredAccess, 0, Q_NULLPTR, OPEN_EXISTING, 0, Q_NULLPTR);
if (handle == INVALID_HANDLE_VALUE) {
q->setError(decodeSystemError());
@@ -222,7 +222,7 @@ void QSerialPortPrivate::close()
{
if (eventNotifier) {
eventNotifier->deleteLater();
- eventNotifier = 0;
+ eventNotifier = Q_NULLPTR;
}
if (settingsRestoredOnClose) {
@@ -257,9 +257,9 @@ QSerialPort::PinoutSignals QSerialPortPrivate::pinoutSignals()
ret |= QSerialPort::DataCarrierDetectSignal;
DWORD bytesReturned = 0;
- if (!::DeviceIoControl(handle, IOCTL_SERIAL_GET_DTRRTS, NULL, 0,
+ if (!::DeviceIoControl(handle, IOCTL_SERIAL_GET_DTRRTS, Q_NULLPTR, 0,
&modemStat, sizeof(modemStat),
- &bytesReturned, NULL)) {
+ &bytesReturned, Q_NULLPTR)) {
q->setError(decodeSystemError());
return ret;
}
@@ -513,7 +513,7 @@ bool QSerialPortPrivate::notifyRead()
char *ptr = readBuffer.reserve(bytesToRead);
DWORD readBytes = 0;
- BOOL sucessResult = ::ReadFile(handle, ptr, bytesToRead, &readBytes, NULL);
+ BOOL sucessResult = ::ReadFile(handle, ptr, bytesToRead, &readBytes, Q_NULLPTR);
if (!sucessResult) {
readBuffer.truncate(bytesToRead);
@@ -559,7 +559,7 @@ bool QSerialPortPrivate::notifyWrite()
const char *ptr = writeBuffer.readPointer();
DWORD bytesWritten = 0;
- if (!::WriteFile(handle, ptr, nextSize, &bytesWritten, NULL)) {
+ if (!::WriteFile(handle, ptr, nextSize, &bytesWritten, Q_NULLPTR)) {
q->setError(QSerialPort::WriteError);
return false;
}
@@ -595,7 +595,7 @@ void QSerialPortPrivate::processIoErrors(bool error)
}
DWORD errors = 0;
- if (!::ClearCommError(handle, &errors, NULL)) {
+ if (!::ClearCommError(handle, &errors, Q_NULLPTR)) {
q->setError(decodeSystemError());
return;
}
@@ -738,7 +738,7 @@ bool QSerialPortPrivate::waitForReadOrWrite(bool *selectForRead, bool *selectFor
// breaker can work out before you call a method WaitCommEvent()
// and so it will loop forever!
WaitCommEventBreaker breaker(handle, qMax(msecs, 0));
- ::WaitCommEvent(handle, &eventMask, NULL);
+ ::WaitCommEvent(handle, &eventMask, Q_NULLPTR);
breaker.stop();
if (breaker.isWorked()) {
diff --git a/src/serialport/qserialportinfo.cpp b/src/serialport/qserialportinfo.cpp
index ced4361..26b275d 100644
--- a/src/serialport/qserialportinfo.cpp
+++ b/src/serialport/qserialportinfo.cpp
@@ -72,7 +72,7 @@ QSerialPortInfo::QSerialPortInfo()
Constructs a copy of \a other.
*/
QSerialPortInfo::QSerialPortInfo(const QSerialPortInfo &other)
- : d_ptr(other.d_ptr ? new QSerialPortInfoPrivate(*other.d_ptr) : 0)
+ : d_ptr(other.d_ptr ? new QSerialPortInfoPrivate(*other.d_ptr) : Q_NULLPTR)
{
}
diff --git a/src/serialport/qserialportinfo_win.cpp b/src/serialport/qserialportinfo_win.cpp
index e595964..493c4d0 100644
--- a/src/serialport/qserialportinfo_win.cpp
+++ b/src/serialport/qserialportinfo_win.cpp
@@ -74,7 +74,7 @@ static QString toStringAndTrimNullCharacter(const QByteArray &buffer)
static QStringList portNamesFromHardwareDeviceMap()
{
- HKEY hKey = 0;
+ HKEY hKey = Q_NULLPTR;
if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_QUERY_VALUE, &hKey) != ERROR_SUCCESS)
return QStringList();
@@ -88,7 +88,7 @@ static QStringList portNamesFromHardwareDeviceMap()
forever {
DWORD requiredValueNameChars = maximumValueNameInChars;
const LONG ret = ::RegEnumValue(hKey, index, reinterpret_cast<wchar_t *>(outputValueName.data()), &requiredValueNameChars,
- NULL, NULL, reinterpret_cast<unsigned char *>(outputBuffer.data()), &requiredDataBytes);
+ Q_NULLPTR, Q_NULLPTR, reinterpret_cast<unsigned char *>(outputBuffer.data()), &requiredDataBytes);
if (ret == ERROR_MORE_DATA) {
outputBuffer.resize(requiredDataBytes);
} else if (ret == ERROR_SUCCESS) {
@@ -172,7 +172,7 @@ static QString devicePortName(HDEVINFO deviceInfoSet, PSP_DEVINFO_DATA deviceInf
DWORD dataType = 0;
QByteArray outputBuffer;
forever {
- const LONG ret = ::RegQueryValueEx(key, reinterpret_cast<const wchar_t *>(portNameKey.utf16()), NULL, &dataType,
+ const LONG ret = ::RegQueryValueEx(key, reinterpret_cast<const wchar_t *>(portNameKey.utf16()), Q_NULLPTR, &dataType,
reinterpret_cast<unsigned char *>(outputBuffer.data()), &bytesRequired);
if (ret == ERROR_MORE_DATA) {
outputBuffer.resize(bytesRequired);
@@ -293,7 +293,7 @@ QList<QSerialPortInfo> QSerialPortInfo::availablePorts()
QList<QSerialPortInfo> serialPortInfoList;
foreach (const GuidFlagsPair &uniquePair, guidFlagsPairs()) {
- const HDEVINFO deviceInfoSet = ::SetupDiGetClassDevs(reinterpret_cast<const GUID *>(&uniquePair.first), NULL, 0, uniquePair.second);
+ const HDEVINFO deviceInfoSet = ::SetupDiGetClassDevs(reinterpret_cast<const GUID *>(&uniquePair.first), Q_NULLPTR, Q_NULLPTR, uniquePair.second);
if (deviceInfoSet == INVALID_HANDLE_VALUE)
return serialPortInfoList;
@@ -354,7 +354,7 @@ QList<qint32> QSerialPortInfo::standardBaudRates()
bool QSerialPortInfo::isBusy() const
{
const HANDLE handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation().utf16()),
- GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, Q_NULLPTR);
if (handle == INVALID_HANDLE_VALUE) {
if (::GetLastError() == ERROR_ACCESS_DENIED)
@@ -368,7 +368,7 @@ bool QSerialPortInfo::isBusy() const
bool QSerialPortInfo::isValid() const
{
const HANDLE handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation().utf16()),
- GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, Q_NULLPTR);
if (handle == INVALID_HANDLE_VALUE) {
if (::GetLastError() != ERROR_ACCESS_DENIED)
diff --git a/src/serialport/qserialportinfo_wince.cpp b/src/serialport/qserialportinfo_wince.cpp
index 5a7ce62..78439c9 100644
--- a/src/serialport/qserialportinfo_wince.cpp
+++ b/src/serialport/qserialportinfo_wince.cpp
@@ -46,7 +46,7 @@ static QString findDescription(HKEY parentKeyHandle, const QString &subKey)
const static QString valueName(QStringLiteral("FriendlyName"));
QString result;
- HKEY hSubKey = 0;
+ HKEY hSubKey = Q_NULLPTR;
LONG res = ::RegOpenKeyEx(parentKeyHandle, reinterpret_cast<const wchar_t *>(subKey.utf16()),
0, KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS, &hSubKey);
@@ -55,12 +55,12 @@ static QString findDescription(HKEY parentKeyHandle, const QString &subKey)
DWORD dataType = 0;
DWORD dataSize = 0;
res = ::RegQueryValueEx(hSubKey, reinterpret_cast<const wchar_t *>(valueName.utf16()),
- NULL, &dataType, NULL, &dataSize);
+ Q_NULLPTR, &dataType, Q_NULLPTR, &dataSize);
if (res == ERROR_SUCCESS) {
QByteArray data(dataSize, 0);
res = ::RegQueryValueEx(hSubKey, reinterpret_cast<const wchar_t *>(valueName.utf16()),
- NULL, NULL,
+ Q_NULLPTR, Q_NULLPTR,
reinterpret_cast<unsigned char *>(data.data()),
&dataSize);
@@ -81,7 +81,7 @@ static QString findDescription(HKEY parentKeyHandle, const QString &subKey)
QByteArray data(dataSize, 0);
while (::RegEnumKeyEx(hSubKey, index++,
reinterpret_cast<wchar_t *>(data.data()), &dataSize,
- NULL, NULL, NULL, NULL) == ERROR_SUCCESS) {
+ Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR) == ERROR_SUCCESS) {
result = findDescription(hSubKey,
QString::fromUtf16(reinterpret_cast<ushort *>(data.data()), dataSize));
@@ -128,7 +128,7 @@ QList<qint32> QSerialPortInfo::standardBaudRates()
bool QSerialPortInfo::isBusy() const
{
const HANDLE handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation().utf16()),
- GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ GENERIC_READ | GENERIC_WRITE, 0, Q_NULLPTR, OPEN_EXISTING, 0, Q_NULLPTR);
if (handle == INVALID_HANDLE_VALUE) {
if (::GetLastError() == ERROR_ACCESS_DENIED)
@@ -142,7 +142,7 @@ bool QSerialPortInfo::isBusy() const
bool QSerialPortInfo::isValid() const
{
const HANDLE handle = ::CreateFile(reinterpret_cast<const wchar_t*>(systemLocation().utf16()),
- GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
+ GENERIC_READ | GENERIC_WRITE, 0, Q_NULLPTR, OPEN_EXISTING, 0, Q_NULLPTR);
if (handle == INVALID_HANDLE_VALUE) {
if (::GetLastError() != ERROR_ACCESS_DENIED)