summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLubomir I. Ivanov <lubomirivanov@vmware.com>2019-02-11 02:08:53 +0200
committerLubomir I. Ivanov <neolit123@gmail.com>2019-02-13 14:17:42 +0000
commit5a2c8a39d76d634161e87b1c55d36cbbcc778289 (patch)
treeb5b5e18600ac5eddc53b24c6903d843a70fc75b8 /src
parent56c5b16dc1a394c72a004b71a9f5364059630d6c (diff)
win32-bt: fix warnings related to comparisons and initializers
Silence a couple of type of warnings: 1) warning: missing initializer for member '_BLUETOOTH_DEVICE_INFO::Address' [-Wmissing-field-initializers] BLUETOOTH_DEVICE_INFO deviceInfo = {0}; Unlike C, C++ is not happy about this type of initializer Use '{}' instead to init all members to zero or 'NULL' properly. 2) warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (socket != INVALID_SOCKET) { 'socket' is defined as 'int', while 'INVALID_SOCKET' is derived from 'SOCKET' which is of type UINT. Cast 'socket' to 'SOCKET' before performing the comparison. Change-Id: I9fcbff1c60ae36b8a8fed63382a8ffc0157f4923 Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp10
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_win.cpp2
-rw-r--r--src/bluetooth/qbluetoothsocket_win.cpp16
3 files changed, 14 insertions, 14 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
index 7509c5f6..3645bd21 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_win.cpp
@@ -132,7 +132,7 @@ static QBluetoothDeviceInfo createClassicDeviceInfo(const BLUETOOTH_DEVICE_INFO
static QBluetoothDeviceInfo findFirstClassicDevice(
DWORD *systemErrorCode, HBLUETOOTH_DEVICE_FIND *hSearch)
{
- BLUETOOTH_DEVICE_SEARCH_PARAMS searchParams = {0};
+ BLUETOOTH_DEVICE_SEARCH_PARAMS searchParams = {};
searchParams.dwSize = sizeof(searchParams);
searchParams.cTimeoutMultiplier = 10; // 12.8 sec
searchParams.fIssueInquiry = TRUE;
@@ -142,7 +142,7 @@ static QBluetoothDeviceInfo findFirstClassicDevice(
searchParams.fReturnUnknown = TRUE;
searchParams.hRadio = nullptr;
- BLUETOOTH_DEVICE_INFO deviceInfo = {0};
+ BLUETOOTH_DEVICE_INFO deviceInfo = {};
deviceInfo.dwSize = sizeof(deviceInfo);
const HBLUETOOTH_DEVICE_FIND hFind = ::BluetoothFindFirstDevice(
@@ -163,7 +163,7 @@ static QBluetoothDeviceInfo findFirstClassicDevice(
static QBluetoothDeviceInfo findNextClassicDevice(
DWORD *systemErrorCode, HBLUETOOTH_DEVICE_FIND hSearch)
{
- BLUETOOTH_DEVICE_INFO deviceInfo = {0};
+ BLUETOOTH_DEVICE_INFO deviceInfo = {};
deviceInfo.dwSize = sizeof(deviceInfo);
QBluetoothDeviceInfo foundDevice;
@@ -204,7 +204,7 @@ static QVector<QBluetoothDeviceInfo> enumerateLeDevices(
QVector<LeDeviceEntry> cachedEntries;
for (;;) {
- SP_DEVICE_INTERFACE_DATA deviceInterfaceData = {0};
+ SP_DEVICE_INTERFACE_DATA deviceInterfaceData = {};
deviceInterfaceData.cbSize = sizeof(deviceInterfaceData);
if (!::SetupDiEnumDeviceInterfaces(
@@ -231,7 +231,7 @@ static QVector<QBluetoothDeviceInfo> enumerateLeDevices(
}
}
- SP_DEVINFO_DATA deviceInfoData = {0};
+ SP_DEVINFO_DATA deviceInfoData = {};
deviceInfoData.cbSize = sizeof(deviceInfoData);
QByteArray deviceInterfaceDetailDataBuffer(
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_win.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_win.cpp
index e76dd7b6..98ec1952 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_win.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_win.cpp
@@ -331,7 +331,7 @@ static FindServiceResult findFirstService(const QBluetoothAddress &address)
GUID protocol = L2CAP_PROTOCOL_UUID; //Search for L2CAP and RFCOMM services
- WSAQUERYSET serviceQuery = {0};
+ WSAQUERYSET serviceQuery = {};
serviceQuery.dwSize = sizeof(WSAQUERYSET); //As specified by the windows documentation
serviceQuery.lpServiceClassId = &protocol; //The protocal of the service what is being queried
serviceQuery.dwNameSpace = NS_BTH; //As specified by the windows documentation
diff --git a/src/bluetooth/qbluetoothsocket_win.cpp b/src/bluetooth/qbluetoothsocket_win.cpp
index 14c780d1..781decad 100644
--- a/src/bluetooth/qbluetoothsocket_win.cpp
+++ b/src/bluetooth/qbluetoothsocket_win.cpp
@@ -68,7 +68,7 @@ bool QBluetoothSocketPrivateWin::ensureNativeSocket(QBluetoothServiceInfo::Proto
{
Q_Q(QBluetoothSocket);
- if (socket != INVALID_SOCKET) {
+ if (static_cast<SOCKET>(socket) != INVALID_SOCKET) {
if (socketType == type)
return true;
abort();
@@ -87,7 +87,7 @@ bool QBluetoothSocketPrivateWin::ensureNativeSocket(QBluetoothServiceInfo::Proto
return false;
}
- if (socket == INVALID_SOCKET) {
+ if (static_cast<SOCKET>(socket) == INVALID_SOCKET) {
const int error = ::WSAGetLastError();
qCWarning(QT_BT_WINDOWS) << "Failed to create socket:" << error << qt_error_string(error);
errorString = QBluetoothSocket::tr("Failed to create socket");
@@ -105,13 +105,13 @@ void QBluetoothSocketPrivateWin::connectToServiceHelper(const QBluetoothAddress
{
Q_Q(QBluetoothSocket);
- if (socket == INVALID_SOCKET && !ensureNativeSocket(socketType))
+ if (static_cast<SOCKET>(socket) == INVALID_SOCKET && !ensureNativeSocket(socketType))
return;
if (!configureSecurity())
return;
- SOCKADDR_BTH addr = {0};
+ SOCKADDR_BTH addr = {};
addr.addressFamily = AF_BTH;
addr.port = port;
addr.btAddr = address.toUInt64();
@@ -377,9 +377,9 @@ quint16 QBluetoothSocketPrivateWin::localPort() const
QString QBluetoothSocketPrivateWin::peerName() const
{
- if (socket == INVALID_SOCKET)
+ if (static_cast<SOCKET>(socket) == INVALID_SOCKET)
return {};
- BLUETOOTH_DEVICE_INFO bdi = {0};
+ BLUETOOTH_DEVICE_INFO bdi = {};
bdi.dwSize = sizeof(bdi);
bdi.Address.ullLong = m_peerAddress.toUInt64();
const DWORD res = ::BluetoothGetDeviceInfo(nullptr, &bdi);
@@ -528,7 +528,7 @@ bool QBluetoothSocketPrivateWin::createNotifiers()
void QBluetoothSocketPrivateWin::updateAddressesAndPorts()
{
- SOCKADDR_BTH localAddr = {0};
+ SOCKADDR_BTH localAddr = {};
int localAddrLength = sizeof(localAddr);
const int localResult = ::getsockname(socket, reinterpret_cast<sockaddr *>(&localAddr), &localAddrLength);
if (localResult != SOCKET_ERROR) {
@@ -540,7 +540,7 @@ void QBluetoothSocketPrivateWin::updateAddressesAndPorts()
errorString = QBluetoothSocket::tr("Cannot get socket's local address and port");
}
- SOCKADDR_BTH peerAddr = {0};
+ SOCKADDR_BTH peerAddr = {};
int peerAddrLength = sizeof(peerAddr);
const int peerResult = ::getpeername(socket, reinterpret_cast<sockaddr *>(&peerAddr), &peerAddrLength);
if (peerResult != SOCKET_ERROR) {