summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/qbluetoothsocket_win.cpp
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/bluetooth/qbluetoothsocket_win.cpp
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/bluetooth/qbluetoothsocket_win.cpp')
-rw-r--r--src/bluetooth/qbluetoothsocket_win.cpp16
1 files changed, 8 insertions, 8 deletions
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) {