diff --git a/src/gui/src/DataDownloader.cpp b/src/gui/src/DataDownloader.cpp index 50e5a1b2..4f778489 100644 --- a/src/gui/src/DataDownloader.cpp +++ b/src/gui/src/DataDownloader.cpp @@ -19,6 +19,7 @@ DataDownloader::DataDownloader(QObject* parent) : QObject(parent), + m_pReply(nullptr), m_IsFinished(false) { connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply*)), diff --git a/src/gui/src/ScreenSetupView.cpp b/src/gui/src/ScreenSetupView.cpp index a06dc269..f26d9700 100644 --- a/src/gui/src/ScreenSetupView.cpp +++ b/src/gui/src/ScreenSetupView.cpp @@ -38,7 +38,7 @@ ScreenSetupView::ScreenSetupView(QWidget* parent) : verticalHeader()->hide(); } -void ScreenSetupView::setModel(ScreenSetupModel* model) +void ScreenSetupView::setModel(QAbstractItemModel* model) { QTableView::setModel(model); setTableSize(); diff --git a/src/gui/src/ScreenSetupView.h b/src/gui/src/ScreenSetupView.h index a4f04923..38eae2a4 100644 --- a/src/gui/src/ScreenSetupView.h +++ b/src/gui/src/ScreenSetupView.h @@ -39,7 +39,7 @@ class ScreenSetupView : public QTableView ScreenSetupView(QWidget* parent); public: - void setModel(ScreenSetupModel* model); + void setModel(QAbstractItemModel* model) override; ScreenSetupModel* model() const; protected: diff --git a/src/gui/src/ZeroconfServer.cpp b/src/gui/src/ZeroconfServer.cpp index d3d98518..e4d6dfd8 100644 --- a/src/gui/src/ZeroconfServer.cpp +++ b/src/gui/src/ZeroconfServer.cpp @@ -25,7 +25,7 @@ ZeroconfServer::ZeroconfServer(QObject* parent) : { } -void ZeroconfServer::incomingConnection(int socketDescriptor) +void ZeroconfServer::incomingConnection(qintptr socketDescriptor) { ZeroconfThread* thread = new ZeroconfThread(socketDescriptor, this); connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater())); diff --git a/src/gui/src/ZeroconfServer.h b/src/gui/src/ZeroconfServer.h index 01e713d7..2f6c6f11 100644 --- a/src/gui/src/ZeroconfServer.h +++ b/src/gui/src/ZeroconfServer.h @@ -30,7 +30,7 @@ public: ZeroconfServer(QObject* parent = 0); protected: - void incomingConnection(int socketDescriptor); + void incomingConnection(qintptr socketDescriptor) override; private: QStringList fortunes; diff --git a/src/lib/arch/IArchString.cpp b/src/lib/arch/IArchString.cpp index 05cc2dfb..57365363 100644 --- a/src/lib/arch/IArchString.cpp +++ b/src/lib/arch/IArchString.cpp @@ -42,7 +42,7 @@ int IArchString::convStringWCToMB(char* dst, const wchar_t* src, UInt32 n, bool* errors) { - int len = 0; + ptrdiff_t len = 0; bool dummyErrors; if (errors == NULL) { @@ -58,14 +58,14 @@ IArchString::convStringWCToMB(char* dst, if (dst == NULL) { char dummy[MB_LEN_MAX]; for (const wchar_t* scan = src; n > 0; ++scan, --n) { - int mblen = wctomb(dummy, *scan); + ptrdiff_t mblen = wctomb(dummy, *scan); if (mblen == -1) { *errors = true; mblen = 1; } len += mblen; } - int mblen = wctomb(dummy, L'\0'); + ptrdiff_t mblen = wctomb(dummy, L'\0'); if (mblen != -1) { len += mblen - 1; } @@ -73,7 +73,7 @@ IArchString::convStringWCToMB(char* dst, else { char* dst0 = dst; for (const wchar_t* scan = src; n > 0; ++scan, --n) { - int mblen = wctomb(dst, *scan); + ptrdiff_t mblen = wctomb(dst, *scan); if (mblen == -1) { *errors = true; *dst++ = '?'; @@ -82,12 +82,12 @@ IArchString::convStringWCToMB(char* dst, dst += mblen; } } - int mblen = wctomb(dst, L'\0'); + ptrdiff_t mblen = wctomb(dst, L'\0'); if (mblen != -1) { // don't include nul terminator dst += mblen - 1; } - len = (int)(dst - dst0); + len = dst - dst0; } ARCH->unlockMutex(s_mutex); @@ -98,7 +98,7 @@ int IArchString::convStringMBToWC(wchar_t* dst, const char* src, UInt32 n, bool* errors) { - int len = 0; + ptrdiff_t len = 0; wchar_t dummy; bool dummyErrors; @@ -114,7 +114,7 @@ IArchString::convStringMBToWC(wchar_t* dst, if (dst == NULL) { for (const char* scan = src; n > 0; ) { - int mblen = mbtowc(&dummy, scan, n); + ptrdiff_t mblen = mbtowc(&dummy, scan, n); switch (mblen) { case -2: // incomplete last character. convert to unknown character. @@ -150,7 +150,7 @@ IArchString::convStringMBToWC(wchar_t* dst, else { wchar_t* dst0 = dst; for (const char* scan = src; n > 0; ++dst) { - int mblen = mbtowc(dst, scan, n); + ptrdiff_t mblen = mbtowc(dst, scan, n); switch (mblen) { case -2: // incomplete character. convert to unknown character. @@ -181,7 +181,7 @@ IArchString::convStringMBToWC(wchar_t* dst, break; } } - len = (int)(dst - dst0); + len = dst - dst0; } ARCH->unlockMutex(s_mutex); diff --git a/src/lib/arch/win32/ArchNetworkWinsock.cpp b/src/lib/arch/win32/ArchNetworkWinsock.cpp index 24310402..65a5b320 100644 --- a/src/lib/arch/win32/ArchNetworkWinsock.cpp +++ b/src/lib/arch/win32/ArchNetworkWinsock.cpp @@ -311,7 +311,7 @@ ArchNetworkWinsock::listenOnSocket(ArchSocket s) } ArchSocket -ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* addr) +ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* const addr) { assert(s != NULL); @@ -325,7 +325,9 @@ ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* addr) int err = getsockerror_winsock(); delete socket; free(tmp); - *addr = NULL; + if (addr) { + *addr = NULL; + } if (err == WSAEWOULDBLOCK) { return NULL; } @@ -339,7 +341,9 @@ ArchNetworkWinsock::acceptSocket(ArchSocket s, ArchNetAddress* addr) close_winsock(fd); delete socket; free(tmp); - *addr = NULL; + if (addr) { + *addr = NULL; + } throw; } diff --git a/src/lib/arch/win32/ArchTaskBarWindows.cpp b/src/lib/arch/win32/ArchTaskBarWindows.cpp index 3ec3b21b..61376674 100644 --- a/src/lib/arch/win32/ArchTaskBarWindows.cpp +++ b/src/lib/arch/win32/ArchTaskBarWindows.cpp @@ -39,10 +39,14 @@ static const UINT kFirstReceiverID = WM_USER + 14; ArchTaskBarWindows* ArchTaskBarWindows::s_instance = NULL; ArchTaskBarWindows::ArchTaskBarWindows() : - m_nextID(kFirstReceiverID), - m_thread(NULL), + m_mutex(NULL), m_condVar(NULL), - m_mutex(NULL) + m_ready(false), + m_result(0), + m_thread(NULL), + m_hwnd(NULL), + m_taskBarRestart(0), + m_nextID(kFirstReceiverID) { // save the singleton instance s_instance = this; diff --git a/src/lib/base/String.cpp b/src/lib/base/String.cpp index e1da621f..8349715b 100644 --- a/src/lib/base/String.cpp +++ b/src/lib/base/String.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace synergy { namespace string { @@ -50,8 +51,8 @@ vformat(const char* fmt, va_list args) // find highest indexed substitution and the locations of substitutions std::vector pos; std::vector width; - std::vector index; - int maxIndex = 0; + std::vector index; + size_t maxIndex = 0; for (const char* scan = fmt; *scan != '\0'; ++scan) { if (*scan == '%') { ++scan; @@ -61,21 +62,22 @@ vformat(const char* fmt, va_list args) else if (*scan == '%') { // literal index.push_back(0); - pos.push_back(static_cast(scan - 1 - fmt)); + pos.push_back(static_cast((scan - 1) - fmt)); width.push_back(2); } else if (*scan == '{') { // get argument index char* end; - int i = static_cast(strtol(scan + 1, &end, 10)); - if (*end != '}') { + errno = 0; + long i = strtol(scan + 1, &end, 10); + if (errno || (i < 0) || (*end != '}')) { // invalid index -- ignore - scan = end - 1; + scan = end - 1; // BUG if there are digits? } else { index.push_back(i); - pos.push_back(static_cast(scan - 1 - fmt)); - width.push_back(static_cast(end - scan + 2)); + pos.push_back(static_cast((scan - 1) - fmt)); + width.push_back(static_cast((end - scan) + 2)); if (i > maxIndex) { maxIndex = i; } diff --git a/src/lib/ipc/IpcLogOutputter.cpp b/src/lib/ipc/IpcLogOutputter.cpp index f215750a..120fd66f 100644 --- a/src/lib/ipc/IpcLogOutputter.cpp +++ b/src/lib/ipc/IpcLogOutputter.cpp @@ -45,6 +45,7 @@ IpcLogOutputter::IpcLogOutputter(IpcServer& ipcServer, EIpcClientType clientType m_running(false), m_notifyCond(ARCH->newCondVar()), m_notifyMutex(ARCH->newMutex()), + m_bufferThreadId(0), m_bufferWaiting(false), m_bufferMaxSize(kBufferMaxSize), m_bufferRateWriteLimit(kBufferRateWriteLimit), diff --git a/src/lib/ipc/IpcLogOutputter.h b/src/lib/ipc/IpcLogOutputter.h index dd2bada6..b6b285b8 100644 --- a/src/lib/ipc/IpcLogOutputter.h +++ b/src/lib/ipc/IpcLogOutputter.h @@ -114,7 +114,6 @@ private: double m_bufferRateTimeLimit; UInt16 m_bufferWriteCount; double m_bufferRateStart; - bool m_useThread; EIpcClientType m_clientType; ArchMutex m_runningMutex; }; diff --git a/src/lib/ipc/IpcServer.cpp b/src/lib/ipc/IpcServer.cpp index 390310ec..791595f2 100644 --- a/src/lib/ipc/IpcServer.cpp +++ b/src/lib/ipc/IpcServer.cpp @@ -80,7 +80,7 @@ IpcServer::~IpcServer() for (it = m_clients.begin(); it != m_clients.end(); it++) { deleteClient(*it); } - m_clients.empty(); + m_clients.clear(); ARCH->unlockMutex(m_clientsMutex); ARCH->closeMutex(m_clientsMutex); diff --git a/src/lib/net/SecureSocket.cpp b/src/lib/net/SecureSocket.cpp index c190750b..9dd3a816 100644 --- a/src/lib/net/SecureSocket.cpp +++ b/src/lib/net/SecureSocket.cpp @@ -57,6 +57,7 @@ SecureSocket::SecureSocket( IEventQueue* events, SocketMultiplexer* socketMultiplexer) : TCPSocket(events, socketMultiplexer), + m_ssl(nullptr), m_secureReady(false), m_fatal(false) { @@ -67,6 +68,7 @@ SecureSocket::SecureSocket( SocketMultiplexer* socketMultiplexer, ArchSocket socket) : TCPSocket(events, socketMultiplexer, socket), + m_ssl(nullptr), m_secureReady(false), m_fatal(false) { diff --git a/src/lib/net/TCPSocket.cpp b/src/lib/net/TCPSocket.cpp index 9498e946..ff69ab2b 100644 --- a/src/lib/net/TCPSocket.cpp +++ b/src/lib/net/TCPSocket.cpp @@ -330,7 +330,7 @@ TCPSocket::doRead() memset(buffer, 0, sizeof(buffer)); size_t bytesRead = 0; - bytesRead = (int) ARCH->readSocket(m_socket, buffer, sizeof(buffer)); + bytesRead = ARCH->readSocket(m_socket, buffer, sizeof(buffer)); if (bytesRead > 0) { bool wasEmpty = (m_inputBuffer.getSize() == 0); diff --git a/src/lib/platform/MSWindowsClipboard.cpp b/src/lib/platform/MSWindowsClipboard.cpp index 2373d255..5a807a0c 100644 --- a/src/lib/platform/MSWindowsClipboard.cpp +++ b/src/lib/platform/MSWindowsClipboard.cpp @@ -88,7 +88,11 @@ MSWindowsClipboard::empty() // mark clipboard as being owned by synergy HGLOBAL data = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, 1); - SetClipboardData(getOwnershipFormat(), data); + if (NULL == SetClipboardData(getOwnershipFormat(), data)) { + LOG((CLOG_DEBUG "failed to set clipboard data")); + GlobalFree(data); + return false; + } return true; } diff --git a/src/lib/platform/MSWindowsDesks.cpp b/src/lib/platform/MSWindowsDesks.cpp index 325e4578..c377ab76 100644 --- a/src/lib/platform/MSWindowsDesks.cpp +++ b/src/lib/platform/MSWindowsDesks.cpp @@ -427,7 +427,7 @@ void MSWindowsDesks::destroyClass(ATOM windowClass) const { if (windowClass != 0) { - UnregisterClass(reinterpret_cast(windowClass), + UnregisterClass(MAKEINTATOM(windowClass), MSWindowsScreen::getWindowInstance()); } } @@ -437,7 +437,7 @@ MSWindowsDesks::createWindow(ATOM windowClass, const char* name) const { HWND window = CreateWindowEx(WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, - reinterpret_cast(windowClass), + MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, diff --git a/src/lib/platform/MSWindowsScreen.cpp b/src/lib/platform/MSWindowsScreen.cpp index bcb794e1..080db53d 100644 --- a/src/lib/platform/MSWindowsScreen.cpp +++ b/src/lib/platform/MSWindowsScreen.cpp @@ -858,7 +858,7 @@ void MSWindowsScreen::destroyClass(ATOM windowClass) const { if (windowClass != 0) { - UnregisterClass(reinterpret_cast(windowClass), s_windowInstance); + UnregisterClass(MAKEINTATOM(windowClass), s_windowInstance); } } @@ -868,7 +868,7 @@ MSWindowsScreen::createWindow(ATOM windowClass, const char* name) const HWND window = CreateWindowEx(WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW, - reinterpret_cast(windowClass), + MAKEINTATOM(windowClass), name, WS_POPUP, 0, 0, 1, 1, @@ -889,7 +889,7 @@ MSWindowsScreen::createDropWindow(ATOM windowClass, const char* name) const WS_EX_TOPMOST | WS_EX_TRANSPARENT | WS_EX_ACCEPTFILES, - reinterpret_cast(m_class), + MAKEINTATOM(m_class), name, WS_POPUP, 0, 0, m_dropWindowSize, m_dropWindowSize, @@ -1129,7 +1129,7 @@ MSWindowsScreen::onKey(WPARAM wParam, LPARAM lParam) KeyModifierMask oldState = pollActiveModifiers(); // check for autorepeat - if (m_keyState->testAutoRepeat(down, (lParam & 0x40000000u) == 1, button)) { + if (m_keyState->testAutoRepeat(down, (lParam & 0x40000000u), button)) { lParam |= 0x40000000u; } diff --git a/src/lib/platform/MSWindowsScreenSaver.cpp b/src/lib/platform/MSWindowsScreenSaver.cpp index f6a9d386..96771b27 100644 --- a/src/lib/platform/MSWindowsScreenSaver.cpp +++ b/src/lib/platform/MSWindowsScreenSaver.cpp @@ -50,6 +50,9 @@ MSWindowsScreenSaver::MSWindowsScreenSaver() : m_process(NULL), m_watch(NULL), m_threadID(0), + m_msg(0), + m_wParam(0), + m_lParam(0), m_active(false) { // check if screen saver is enabled diff --git a/src/lib/platform/MSWindowsSession.cpp b/src/lib/platform/MSWindowsSession.cpp index 9e817b1e..b70de74c 100644 --- a/src/lib/platform/MSWindowsSession.cpp +++ b/src/lib/platform/MSWindowsSession.cpp @@ -187,7 +187,7 @@ MSWindowsSession::getActiveDesktopName() CloseDesktop(hd); } } - catch (std::exception error) { + catch (std::exception& error) { LOG((CLOG_ERR "failed to get active desktop name: %s", error.what())); } diff --git a/src/lib/platform/MSWindowsUtil.cpp b/src/lib/platform/MSWindowsUtil.cpp index 811c6be2..7ce6e2dc 100644 --- a/src/lib/platform/MSWindowsUtil.cpp +++ b/src/lib/platform/MSWindowsUtil.cpp @@ -29,31 +29,14 @@ String MSWindowsUtil::getString(HINSTANCE instance, DWORD id) { - char buffer[1024]; - int size = static_cast(sizeof(buffer) / sizeof(buffer[0])); - char* msg = buffer; + char* msg = NULL; + int n = LoadString(instance, id, reinterpret_cast(&msg), 0); - // load string - int n = LoadString(instance, id, msg, size); - msg[n] = '\0'; - if (n < size) { - return msg; + if (n <= 0) { + return String(); } - // not enough buffer space. keep trying larger buffers until - // we get the whole string. - msg = NULL; - do { - size <<= 1; - delete[] msg; - char* msg = new char[size]; - n = LoadString(instance, id, msg, size); - } while (n == size); - msg[n] = '\0'; - - String result(msg); - delete[] msg; - return result; + return String (msg, n); } String diff --git a/src/lib/synergy/App.cpp b/src/lib/synergy/App.cpp index 81ab826c..4c8c1808 100644 --- a/src/lib/synergy/App.cpp +++ b/src/lib/synergy/App.cpp @@ -62,9 +62,11 @@ App::App(IEventQueue* events, CreateTaskBarReceiverFunc createTaskBarReceiver, A m_suspended(false), m_events(events), m_args(args), + m_fileLog(nullptr), m_createTaskBarReceiver(createTaskBarReceiver), m_appUtil(events), - m_ipcClient(nullptr) + m_ipcClient(nullptr), + m_socketMultiplexer(nullptr) { assert(s_instance == nullptr); s_instance = this; diff --git a/src/lib/synergy/Chunk.cpp b/src/lib/synergy/Chunk.cpp index 0bd8a62c..71464f70 100644 --- a/src/lib/synergy/Chunk.cpp +++ b/src/lib/synergy/Chunk.cpp @@ -18,7 +18,7 @@ #include "synergy/Chunk.h" #include "base/String.h" -Chunk::Chunk(size_t size) +Chunk::Chunk(size_t size): m_dataSize(0) { m_chunk = new char[size]; memset(m_chunk, 0, size);