From 9ba63d1460db41c219b638212b42476164fcfdff Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 24 Jul 2018 13:08:25 +0200 Subject: Update code style, fix compiler warnings - Use nullptr instead of NULL for better warnings in case of mistakes - Get rid of VLAs which are not in C++11 actually - Fix implicit signed <-> unsigned mismatches by adding checks and casts --- src/client/vnc/vncserver.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/client/vnc/vncserver.cpp') diff --git a/src/client/vnc/vncserver.cpp b/src/client/vnc/vncserver.cpp index 165ba6d..a016f08 100644 --- a/src/client/vnc/vncserver.cpp +++ b/src/client/vnc/vncserver.cpp @@ -12,7 +12,7 @@ #include "vncserver.h" #include "../util/util.h" -VncServer* VncServer::me = NULL; +VncServer* VncServer::me = nullptr; /***************************************************************************//** * @brief VncServer::instance @@ -20,7 +20,7 @@ VncServer* VncServer::me = NULL; */ VncServer* VncServer::instance() { - if (me == NULL) + if (me == nullptr) me = new VncServer(); return me; } @@ -32,10 +32,10 @@ VncServer* VncServer::instance() */ static QString makePassword(int len = 10) { - char pass[len]; + QString ret(len, Qt::Uninitialized); for (int i = 0; i < len; ++i) - pass[i] = (char)(43 + qrand() % 80); - return QString::fromUtf8(pass, len); + ret[i] = QChar(43 + qrand() % 80); + return ret; } /***************************************************************************//** @@ -48,7 +48,7 @@ struct Sleeper : public QThread { /***************************************************************************//** * @brief VncServer::VncServer */ -VncServer::VncServer() : _process(NULL), _port(0), _timerId(0) {} +VncServer::VncServer() : _process(nullptr), _port(0), _timerId(0) {} /***************************************************************************//** * @brief VncServer::~VncServer @@ -73,7 +73,7 @@ QSharedPointer VncServer::createPwFile(const QDir& dir) void VncServer::start() { // Keep things clean - if (_process != NULL) { + if (_process != nullptr) { disconnect(_process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(onError(QProcess::ProcessError))); disconnect(_process, SIGNAL(finished(int)), this, SLOT(onFinished(int))); } @@ -138,13 +138,13 @@ void VncServer::stop() killTimer(_timerId); _timerId = 0; } - if (_process == NULL) + if (_process == nullptr) return; qDebug("Stopping old VNC server."); disconnect(_process, SIGNAL(readyReadStandardOutput()), this, SLOT(onStdOut())); disconnect(_process, SIGNAL(readyReadStandardError()), this, SLOT(onStdErr())); QProcess *process = _process; - _process = NULL; + _process = nullptr; _port = 0; process->terminate(); for (int i = 0; i < 10 && process->state() != QProcess::NotRunning; ++i) @@ -185,7 +185,7 @@ void VncServer::timerEvent(QTimerEvent * /* event */ ) */ void VncServer::onStdOut() { - if (_process == NULL) { + if (_process == nullptr) { qDebug("VncServer::onStdOut() called in bad state."); return; } @@ -211,7 +211,7 @@ void VncServer::onStdOut() */ void VncServer::onStdErr() { - if (_process == NULL) { + if (_process == nullptr) { qDebug("VncServer::onStdErr() called in bad state."); return; } -- cgit v1.2.3-55-g7522