From eaebc23452813a8709d2bbb4d17fddb1b4f29d91 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 15 Nov 2016 12:13:40 +0100 Subject: Increase compiler warnings, fix a lot of those instances - Add explicit casts - Comment out unused params - Remove ignored const return types --- src/client/clientapp/clientapp.h | 4 ++-- src/client/connectwindow/connectwindow.cpp | 7 +++++-- src/client/net/serverconnection.cpp | 9 +++++---- src/client/net/serverconnection.h | 2 +- src/client/net/serverdiscovery.cpp | 6 +++--- src/client/vnc/vncserver.cpp | 8 ++++---- src/client/vnc/vncthread.h | 2 +- src/client/vnc/vncwindow.cpp | 4 ++-- 8 files changed, 23 insertions(+), 19 deletions(-) (limited to 'src/client') diff --git a/src/client/clientapp/clientapp.h b/src/client/clientapp/clientapp.h index dbfbc32..0f7cb5b 100644 --- a/src/client/clientapp/clientapp.h +++ b/src/client/clientapp/clientapp.h @@ -56,9 +56,9 @@ public: ConnectWindow* connectWindow() const { return _connectWindow; } - const bool isConfiguredAsManager() const { return _isManagerPc; } + bool isConfiguredAsManager() { return _isManagerPc; } - const bool isConnectedToLocalManager() const { return _connection != NULL && _connection->isLocalConnection(); } + bool isConnectedToLocalManager() { return _connection != NULL && _connection->isLocalConnection(); } private slots: diff --git a/src/client/connectwindow/connectwindow.cpp b/src/client/connectwindow/connectwindow.cpp index 18ceb9c..b1f583a 100644 --- a/src/client/connectwindow/connectwindow.cpp +++ b/src/client/connectwindow/connectwindow.cpp @@ -114,6 +114,9 @@ void ConnectWindow::updateUserInterface() case InvalidSslHash: _ui->lblStatus->setText(tr("Invalid TLS hash: %1.").arg(_hashSslErrorCount)); break; + default: + _ui->lblStatus->setText(tr("Unknown state :-(")); + break; } } @@ -162,7 +165,7 @@ void ConnectWindow::doShow() * Gives the keyboard input focus to the input line. * @param event */ -void ConnectWindow::showEvent(QShowEvent* event) +void ConnectWindow::showEvent(QShowEvent* /* event */ ) { activateWindow(); raise(); @@ -341,7 +344,7 @@ void ConnectWindow::onComboBox_keyPressed(QKeyEvent* e) * If connection is closed set _pendingConnection = NULL. * @param connection */ -void ConnectWindow::onConnectionClosed(QObject* connection) +void ConnectWindow::onConnectionClosed(QObject* /* connection */ ) { _pendingConnection = NULL; } diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index 826cf06..e9cc72c 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -110,8 +110,9 @@ void ServerConnection::handleMsg() // Initial challenge request by server emit stateChange(ConnectWindow::AwaitingChallengeResponse); _myChallenge.resize(CHALLENGE_LEN); - for (int i = 0; i < CHALLENGE_LEN; ++i) - _myChallenge[i] = qrand() & 0xff; + for (int i = 0; i < CHALLENGE_LEN; ++i) { + _myChallenge[i] = (char)(qrand() & 0xff); + } QByteArray serverChallenge(_fromServer.getFieldBytes(_CHALLENGE)); _toServer.reset(); _toServer.setField(_ID, _CHALLENGE); @@ -141,13 +142,13 @@ void ServerConnection::handleMsg() return; } emit stateChange(ConnectWindow::LoggingIn); - char *user = getpwuid(getuid())->pw_name; + const char *user = getpwuid(getuid())->pw_name; if (user == NULL || *user == '\0') user = getenv("USER"); if (user == NULL || *user == '\0') user = getenv("USERNAME"); if (user == NULL || *user == '\0') - user = (char*)"Hans Affe"; + user = "Hans Affe"; _toServer.reset(); _toServer.setField(_ID, _LOGIN); _toServer.setField("HOST", QHostInfo::localHostName()); diff --git a/src/client/net/serverconnection.h b/src/client/net/serverconnection.h index 17fa20a..9db9b02 100644 --- a/src/client/net/serverconnection.h +++ b/src/client/net/serverconnection.h @@ -36,7 +36,7 @@ public: ServerConnection(const QString& host, const quint16 port, const QByteArray& sessionName, const QByteArray& certHash, bool autoConnect); void disconnectFromServer(); ~ServerConnection(); - const inline bool isConnected() const + inline bool isConnected() const { return _socket != NULL && _socket->state() == QAbstractSocket::ConnectedState; } diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp index 99a0dcd..5ca0eba 100644 --- a/src/client/net/serverdiscovery.cpp +++ b/src/client/net/serverdiscovery.cpp @@ -21,7 +21,7 @@ ServerDiscovery::ServerDiscovery(QObject *parent) /* Try to get a UDP port for server discovery */ int tries = 10; while (tries-- != 0) { - const quint16 port = (quint16)(qrand() % 10000) + 10000; + const quint16 port = (quint16)(qrand() % 10000 + 10000); if (_discoverySocket.bind(QHostAddress::Any, port)) break; if (tries == 0) @@ -98,8 +98,8 @@ void ServerDiscovery::doDiscovery() if (_salt2.size() < SALT_LEN) _salt2.resize(SALT_LEN); for (int i = 0; i < SALT_LEN; ++i) { - salt1[i] = qrand() & 0xff; - _salt2[i] = qrand() & 0xff; + salt1[i] = (char)(qrand() & 0xff); + _salt2[i] = (char)(qrand() & 0xff); } _packet.reset(); _packet.setField(_HASH, genSha1(&_nameBytes, &salt1, &iplist)); diff --git a/src/client/vnc/vncserver.cpp b/src/client/vnc/vncserver.cpp index 496a84d..165ba6d 100644 --- a/src/client/vnc/vncserver.cpp +++ b/src/client/vnc/vncserver.cpp @@ -34,7 +34,7 @@ static QString makePassword(int len = 10) { char pass[len]; for (int i = 0; i < len; ++i) - pass[i] = 43 + qrand() % 80; + pass[i] = (char)(43 + qrand() % 80); return QString::fromUtf8(pass, len); } @@ -167,7 +167,7 @@ void VncServer::stop() * after 3 seconds... * @param event */ -void VncServer::timerEvent(QTimerEvent *event) +void VncServer::timerEvent(QTimerEvent * /* event */ ) { // Error timeout (3s), tell server that vnc setup failed this->stop(); @@ -222,7 +222,7 @@ void VncServer::onStdErr() * @brief VncServer::onError * @param error */ -void VncServer::onError(QProcess::ProcessError error) +void VncServer::onError(QProcess::ProcessError /* error */ ) { this->stop(); emit started(0, _ropass, _rwpass); @@ -232,7 +232,7 @@ void VncServer::onError(QProcess::ProcessError error) * @brief VncServer::onFinished * @param exitCode */ -void VncServer::onFinished(int exitCode) +void VncServer::onFinished(int /* exitCode */ ) { this->stop(); emit started(0, _ropass, _rwpass); diff --git a/src/client/vnc/vncthread.h b/src/client/vnc/vncthread.h index a75ca0f..afdb92a 100644 --- a/src/client/vnc/vncthread.h +++ b/src/client/vnc/vncthread.h @@ -76,7 +76,7 @@ public: const QImage& getImage() const { if (_srcStepX > 1 || _srcStepY > 1) return _imgScaled; return _img; } const QSize& getSourceSize() const { return _clientSize; } const QString getDesktopName() const; - const bool isConnected() const { return _connected; } + bool isConnected() { return _connected; } void stop() { _run = false; } void setTargetSize(const QSize size); void run(); diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp index 8cd7534..b7690b8 100644 --- a/src/client/vnc/vncwindow.cpp +++ b/src/client/vnc/vncwindow.cpp @@ -92,7 +92,7 @@ void VncWindow::draw(const int x, const int y, const int w, const int h) * @param caption caption of window (only visible if not running in fullscreen mode) * @param clientId the ID of the client we're connecting to (echoed back to server, not used locally) */ -void VncWindow::open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb) +void VncWindow::open(const QString& host, int port, const QString& passwd, bool /* ro */ , bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb) { this->terminateVncThread(); _clientId = clientId; @@ -139,7 +139,7 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool * * @param e close event data */ -void VncWindow::closeEvent(QCloseEvent *e) +void VncWindow::closeEvent(QCloseEvent * /* e */ ) { qDebug("Closing VNC viewer window."); this->terminateVncThread(); -- cgit v1.2.3-55-g7522