diff options
author | Simon Rettberg | 2018-07-26 16:11:31 +0200 |
---|---|---|
committer | Simon Rettberg | 2018-07-26 16:11:31 +0200 |
commit | 0d1984357f9bc8aac671e8907208a8581a1f42db (patch) | |
tree | 09dd65975ff5e5074fdbc708504ab1d84b073c2b /src/server | |
parent | [server] Cleanup and simplify SslServer (diff) | |
download | pvs2-0d1984357f9bc8aac671e8907208a8581a1f42db.tar.gz pvs2-0d1984357f9bc8aac671e8907208a8581a1f42db.tar.xz pvs2-0d1984357f9bc8aac671e8907208a8581a1f42db.zip |
[*] Convert old C-Style casts
Primitive types now use type(x) instead of (type)x,
pointers should use appropriate long versions
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/main.cpp | 2 | ||||
-rw-r--r-- | src/server/mainwindow/mainwindow.cpp | 10 | ||||
-rw-r--r-- | src/server/net/client.cpp | 2 | ||||
-rw-r--r-- | src/server/net/discoverylistener.cpp | 18 | ||||
-rw-r--r-- | src/server/net/listenserver.cpp | 2 | ||||
-rw-r--r-- | src/server/net/sslserver.cpp | 2 |
6 files changed, 18 insertions, 18 deletions
diff --git a/src/server/main.cpp b/src/server/main.cpp index 34a585c..769fedb 100644 --- a/src/server/main.cpp +++ b/src/server/main.cpp @@ -22,7 +22,7 @@ void usage() int main(int argc, char** argv) { - qsrand((uint)QDateTime::currentMSecsSinceEpoch()); + qsrand(uint(QDateTime::currentMSecsSinceEpoch())); ServerApp app(argc, argv); for (QString a : app.arguments()) { diff --git a/src/server/mainwindow/mainwindow.cpp b/src/server/mainwindow/mainwindow.cpp index dcf8973..73fcbaf 100644 --- a/src/server/mainwindow/mainwindow.cpp +++ b/src/server/mainwindow/mainwindow.cpp @@ -243,7 +243,7 @@ int distance(QPointF a, QPointF b) const qreal dx = a.x() - b.x(); const qreal dy = a.y() - b.y(); const qreal sum = dx * dx + dy * dy; - return (int)sum; + return int(sum); } /***************************************************************************//** @@ -460,13 +460,13 @@ enum AspectStatus { GRID_OK, GRID_TOO_WIDE, GRID_TOO_TALL }; * */ AspectStatus checkAspectRatio(const QSize& frameSize, const QSize& gridSize) { - float aspectRoom = ((float) gridSize.height()) / ((float) gridSize.width()); - float aspectFrame = ((float) frameSize.height()) / ((float) frameSize.width()); + float aspectRoom = float(gridSize.height()) / float(gridSize.width()); + float aspectFrame = float(frameSize.height()) / float(frameSize.width()); - if (aspectRoom / aspectFrame < 0.8) { + if (aspectRoom / aspectFrame < 0.8f) { return GRID_TOO_WIDE; } - if ( aspectFrame / aspectRoom < 0.8) { + if ( aspectFrame / aspectRoom < 0.8f) { return GRID_TOO_TALL; } return GRID_OK; diff --git a/src/server/net/client.cpp b/src/server/net/client.cpp index 9e96dec..9b2101f 100644 --- a/src/server/net/client.cpp +++ b/src/server/net/client.cpp @@ -44,7 +44,7 @@ Client::Client(QTcpSocket* socket) : _socket(socket) // Send challenge _challenge.resize(CHALLENGE_LEN); for (int i = 0; i < CHALLENGE_LEN; ++i) { - _challenge[i] = (char)(qrand() & 0xff); + _challenge[i] = char(qrand() & 0xff); } NetworkMessage msgChlng; msgChlng.setField(_ID, _CHALLENGE); 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)); diff --git a/src/server/net/listenserver.cpp b/src/server/net/listenserver.cpp index 628b62d..0438fb4 100644 --- a/src/server/net/listenserver.cpp +++ b/src/server/net/listenserver.cpp @@ -11,7 +11,7 @@ ListenServer::ListenServer(quint16 port) { if (!_server.listen(QHostAddress::AnyIPv4, port) || !_server.isListening()) - qFatal("Cannot bind to TCP port %d (incoming SSL clients)", (int)port); + qFatal("Cannot bind to TCP port %d (incoming SSL clients)", int(port)); connect(&_server, SIGNAL(newConnection()), this, SLOT(newClientConnection())); } diff --git a/src/server/net/sslserver.cpp b/src/server/net/sslserver.cpp index 9e1e82d..62fe3da 100644 --- a/src/server/net/sslserver.cpp +++ b/src/server/net/sslserver.cpp @@ -61,7 +61,7 @@ void SslServer::incomingConnection(qintptr socketDescriptor) if (++certFails > 5) { CertManager::fatal(); } - ::close((int)socketDescriptor); + ::close(int(socketDescriptor)); return; } QSslSocket *serverSocket = new QSslSocket(nullptr); |