Merge pull request #6045 from symless/v1.9-pvs-studio
PVS Studio related bugfixes for v1.9
This commit is contained in:
commit
0953ac069b
|
@ -19,6 +19,7 @@
|
|||
|
||||
DataDownloader::DataDownloader(QObject* parent) :
|
||||
QObject(parent),
|
||||
m_pReply(nullptr),
|
||||
m_IsFinished(false)
|
||||
{
|
||||
connect(&m_NetworkManager, SIGNAL(finished(QNetworkReply*)),
|
||||
|
|
|
@ -38,7 +38,7 @@ ScreenSetupView::ScreenSetupView(QWidget* parent) :
|
|||
verticalHeader()->hide();
|
||||
}
|
||||
|
||||
void ScreenSetupView::setModel(ScreenSetupModel* model)
|
||||
void ScreenSetupView::setModel(QAbstractItemModel* model)
|
||||
{
|
||||
QTableView::setModel(model);
|
||||
setTableSize();
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -30,7 +30,7 @@ public:
|
|||
ZeroconfServer(QObject* parent = 0);
|
||||
|
||||
protected:
|
||||
void incomingConnection(int socketDescriptor);
|
||||
void incomingConnection(qintptr socketDescriptor) override;
|
||||
|
||||
private:
|
||||
QStringList fortunes;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
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);
|
||||
if (addr) {
|
||||
*addr = NULL;
|
||||
}
|
||||
throw;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
#include <cerrno>
|
||||
|
||||
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<size_t> pos;
|
||||
std::vector<size_t> width;
|
||||
std::vector<int> index;
|
||||
int maxIndex = 0;
|
||||
std::vector<size_t> 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<int>(scan - 1 - fmt));
|
||||
pos.push_back(static_cast<size_t>((scan - 1) - fmt));
|
||||
width.push_back(2);
|
||||
}
|
||||
else if (*scan == '{') {
|
||||
// get argument index
|
||||
char* end;
|
||||
int i = static_cast<int>(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<int>(scan - 1 - fmt));
|
||||
width.push_back(static_cast<int>(end - scan + 2));
|
||||
pos.push_back(static_cast<size_t>((scan - 1) - fmt));
|
||||
width.push_back(static_cast<size_t>((end - scan) + 2));
|
||||
if (i > maxIndex) {
|
||||
maxIndex = i;
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -114,7 +114,6 @@ private:
|
|||
double m_bufferRateTimeLimit;
|
||||
UInt16 m_bufferWriteCount;
|
||||
double m_bufferRateStart;
|
||||
bool m_useThread;
|
||||
EIpcClientType m_clientType;
|
||||
ArchMutex m_runningMutex;
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ void
|
|||
MSWindowsDesks::destroyClass(ATOM windowClass) const
|
||||
{
|
||||
if (windowClass != 0) {
|
||||
UnregisterClass(reinterpret_cast<LPCTSTR>(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<LPCTSTR>(windowClass),
|
||||
MAKEINTATOM(windowClass),
|
||||
name,
|
||||
WS_POPUP,
|
||||
0, 0, 1, 1,
|
||||
|
|
|
@ -858,7 +858,7 @@ void
|
|||
MSWindowsScreen::destroyClass(ATOM windowClass) const
|
||||
{
|
||||
if (windowClass != 0) {
|
||||
UnregisterClass(reinterpret_cast<LPCTSTR>(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<LPCTSTR>(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<LPCTSTR>(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,31 +29,14 @@
|
|||
String
|
||||
MSWindowsUtil::getString(HINSTANCE instance, DWORD id)
|
||||
{
|
||||
char buffer[1024];
|
||||
int size = static_cast<int>(sizeof(buffer) / sizeof(buffer[0]));
|
||||
char* msg = buffer;
|
||||
char* msg = NULL;
|
||||
int n = LoadString(instance, id, reinterpret_cast<LPSTR>(&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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue