From 0d1984357f9bc8aac671e8907208a8581a1f42db Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 26 Jul 2018 16:11:31 +0200 Subject: [*] Convert old C-Style casts Primitive types now use type(x) instead of (type)x, pointers should use appropriate long versions --- src/server/net/discoverylistener.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/server/net/discoverylistener.cpp') diff --git a/src/server/net/discoverylistener.cpp b/src/server/net/discoverylistener.cpp index 978794e..cfeef82 100644 --- a/src/server/net/discoverylistener.cpp +++ b/src/server/net/discoverylistener.cpp @@ -33,7 +33,7 @@ DiscoveryListener::DiscoveryListener() : _socket(this), _counterResetPos(0) { if (!_socket.bind(QHostAddress::AnyIPv4, SERVICE_DISCOVERY_PORT)) - qFatal("Could not bind to service discovery port %d", (int)SERVICE_DISCOVERY_PORT); + qFatal("Could not bind to service discovery port %d", int(SERVICE_DISCOVERY_PORT)); connect(&_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead())); for (int i = 0; i < SD_PACKET_TABLE_SIZE; ++i) _packetCounter[i] = 0; @@ -57,8 +57,8 @@ static quint16 hash(const QHostAddress& host) static quint16 seed1 = 0, seed2 = 0; while (seed1 == 0) { // Make sure the algorithm uses different seeds each time the program is // run to prevent hash collision attacks - seed1 = (quint16)(qrand() & 0xffff); - seed2 = (quint16)(qrand() & 0xffff); + seed1 = quint16(qrand() & 0xffff); + seed2 = quint16(qrand() & 0xffff); } quint8 data[16], len; if (host.protocol() == QAbstractSocket::IPv4Protocol) { @@ -79,14 +79,14 @@ static quint16 hash(const QHostAddress& host) } else { // Durr? len = 2; - data[0] = (quint8)qrand(); - data[1] = (quint8)qrand(); + data[0] = quint8(qrand()); + data[1] = quint8(qrand()); } quint16 result = 0; quint16 mod = seed1; for (quint8 i = 0; i < len; ++i) { - result = (quint16)(((result << 1) + data[i]) ^ mod); // because of the shift this algo is not suitable for len(input) > 8 - mod = (quint16)(mod + seed2 + data[i]); + result = quint16(((result << 1) + data[i]) ^ mod); // because of the shift this algo is not suitable for len(input) > 8 + mod = quint16(mod + seed2 + data[i]); } return result; } @@ -105,7 +105,7 @@ void DiscoveryListener::timerEvent(QTimerEvent* /* event */ ) if (++_counterResetPos >= SD_PACKET_TABLE_SIZE) _counterResetPos = 0; if (_packetCounter[_counterResetPos] > 10) { - _packetCounter[_counterResetPos] = (quint8)(_packetCounter[_counterResetPos] - 10); + _packetCounter[_counterResetPos] = quint8(_packetCounter[_counterResetPos] - 10); } else if (_packetCounter[_counterResetPos] != 0) { _packetCounter[_counterResetPos] = 0; } @@ -138,7 +138,7 @@ void DiscoveryListener::onReadyRead() } ++_packetCounter[bucket]; _packet.reset(); - if (_packet.readMessage(data, (quint32)size) != NM_READ_OK) + if (_packet.readMessage(data, quint32(size)) != NM_READ_OK) continue; // Valid packet, process it: const QByteArray iplist(_packet.getFieldBytes(_IPLIST)); -- cgit v1.2.3-55-g7522