#6380 Fixed warnings for VS2017

This commit is contained in:
Nick Bolton 2018-08-01 13:03:41 +01:00
parent e555d5d651
commit 8dc868a206
13 changed files with 40 additions and 42 deletions

View File

@ -106,7 +106,7 @@ void IpcClient::sendCommand(const QString& command, ElevateMode const elevate)
std::string stdStringCommand = command.toStdString();
const char* charCommand = stdStringCommand.c_str();
int length = strlen(charCommand);
int length = static_cast<int>(strlen(charCommand));
char lenBuf[4];
intToBytes(length, lenBuf, 4);

View File

@ -138,7 +138,7 @@ LicenseManager::getEditionName(Edition const edition, bool trial)
switch (edition) {
case kUnregistered:
name += " (UNREGISTERED)";
return QString::fromUtf8 (name.c_str(), name.size());
return QString::fromUtf8 (name.c_str(), static_cast<int>(name.size()));
case kBasic:
name += " Basic";
break;
@ -148,7 +148,7 @@ LicenseManager::getEditionName(Edition const edition, bool trial)
if (trial) {
name += " (Trial)";
}
return QString::fromUtf8 (name.c_str(), name.size());
return QString::fromUtf8 (name.c_str(), static_cast<int>(name.size()));
}
void LicenseManager::notifyActivation(QString identity)

View File

@ -60,7 +60,8 @@ ServerConfigDialog::ServerConfigDialog(QWidget* parent, ServerConfig& config, co
m_pCheckBoxEnableDragAndDrop->setChecked(serverConfig().enableDragAndDrop());
m_pCheckBoxEnableClipboard->setChecked(serverConfig().clipboardSharing());
m_pSpinBoxClipboardSizeLimit->setValue(serverConfig().clipboardSharingSize() / 1024);
int clipboardSharingSizeM = static_cast<int>(serverConfig().clipboardSharingSize() / 1024);
m_pSpinBoxClipboardSizeLimit->setValue(clipboardSharingSizeM);
m_pSpinBoxClipboardSizeLimit->setEnabled(serverConfig().clipboardSharing());
foreach(const Hotkey& hotkey, serverConfig().hotkeys())
@ -222,7 +223,7 @@ void ServerConfigDialog::on_m_pCheckBoxEnableClipboard_stateChanged(int const st
{
m_pSpinBoxClipboardSizeLimit->setEnabled (state == Qt::Checked);
if ((state == Qt::Checked) && (!m_pSpinBoxClipboardSizeLimit->value())) {
int size = (serverConfig().defaultClipboardSharingSize() + 512) / 1024;
int size = static_cast<int>((serverConfig().defaultClipboardSharingSize() + 512) / 1024);
m_pSpinBoxClipboardSizeLimit->setValue (size ? size : 1);
}
}

View File

@ -91,7 +91,7 @@ IArchString::convStringWCToMB(char* dst,
}
ARCH->unlockMutex(s_mutex);
return len;
return static_cast<int>(len);
}
int
@ -141,8 +141,8 @@ IArchString::convStringMBToWC(wchar_t* dst,
default:
// normal character
len += 1;
scan += mblen;
n -= mblen;
scan += static_cast<int>(mblen);
n -= static_cast<int>(mblen);
break;
}
}
@ -176,8 +176,8 @@ IArchString::convStringMBToWC(wchar_t* dst,
default:
// normal character
scan += mblen;
n -= mblen;
scan += static_cast<int>(mblen);
n -= static_cast<int>(mblen);
break;
}
}
@ -185,5 +185,5 @@ IArchString::convStringMBToWC(wchar_t* dst,
}
ARCH->unlockMutex(s_mutex);
return len;
return static_cast<int>(len);
}

View File

@ -56,11 +56,4 @@ public:
*/
virtual void setting(const std::string& valueName, const std::string& valueString) const = 0;
//@}
//! Get the pathnames of the libraries used by Synergy
/*
Returns a string containing the full path names of all loaded libraries at the point it is called.
*/
virtual std::string getLibsUsed(void) const = 0;
//@}
};

View File

@ -181,11 +181,11 @@ Log::print(const char* file, int line, const char* fmt, ...)
// square brackets, spaces, comma and null terminator take about 10
int size = 10;
size += strlen(timestamp);
size += strlen(g_priority[priority]);
size += strlen(buffer);
size += static_cast<int>(strlen(timestamp));
size += static_cast<int>(strlen(g_priority[priority]));
size += static_cast<int>(strlen(buffer));
#ifndef NDEBUG
size += strlen(file);
size += static_cast<int>(strlen(file));
// assume there is no file contains over 100k lines of code
size += 6;
#endif

View File

@ -18,7 +18,14 @@
#pragma once
#include "common/common.h"
// VC++ has built-in sized types
// moved from common.h (why was it there?)
#if defined(_MSC_VER)
# include <wchar.h>
# define TYPE_OF_SIZE_1 __int8
# define TYPE_OF_SIZE_2 __int16
# define TYPE_OF_SIZE_4 __int32
#endif
//
// pick types of particular sizes

View File

@ -27,19 +27,6 @@
# error "config.h missing"
#endif
// VC++ has built-in sized types
#if defined(_MSC_VER)
# include <wchar.h>
# define TYPE_OF_SIZE_1 __int8
# define TYPE_OF_SIZE_2 __int16
# define TYPE_OF_SIZE_4 __int32
#else
# define SIZE_OF_CHAR 1
# define SIZE_OF_SHORT 2
# define SIZE_OF_INT 4
# define SIZE_OF_LONG 4
#endif
// define NULL
#include <stddef.h>

View File

@ -17,6 +17,7 @@
*/
#include "io/StreamBuffer.h"
#include "common/common.h"
//
// StreamBuffer

View File

@ -28,6 +28,7 @@
#include "base/Log.h"
#include "base/IEventQueue.h"
#include "base/IEventJob.h"
#include "common/convert_types.h"
#include <cstring>
#include <cstdlib>
@ -337,7 +338,7 @@ TCPSocket::doRead()
// slurp up as much as possible
do {
m_inputBuffer.write(buffer, bytesRead);
m_inputBuffer.write(buffer, static_cast<UInt32>(bytesRead));
bytesRead = ARCH->readSocket(m_socket, buffer, sizeof(buffer));
} while (bytesRead > 0);

View File

@ -47,6 +47,9 @@
#include <comutil.h>
#include <algorithm>
// suppress warning about GetVersionEx, which is used indirectly in this compilation unit.
#pragma warning(disable: 4996)
//
// add backwards compatible multihead support (and suppress bogus warning).
// this isn't supported on MinGW yet AFAICT.

View File

@ -2123,7 +2123,9 @@ ConfigReadContext::parseInterval(const ArgList& args) const
throw XConfigRead(*this, "invalid interval \"%{1}\"", concatArgs(args));
}
return Config::Interval(startValue / 100.0f, endValue / 100.0f);
float startInterval = static_cast<float>(startValue / 100.0f);
float endInterval = static_cast<float>(endValue / 100.0f);
return Config::Interval(startInterval, endInterval);
}
void

View File

@ -60,7 +60,8 @@ SerialKey::isExpiring(time_t currentTime) const
bool result = false;
if (m_trial) {
if (m_warnTime <= currentTime && currentTime < m_expireTime) {
unsigned long long currentTimeAsLL = static_cast<unsigned long long>(currentTime);
if ((m_warnTime <= currentTimeAsLL) && (currentTimeAsLL < m_expireTime)) {
result = true;
}
}
@ -74,7 +75,8 @@ SerialKey::isExpired(time_t currentTime) const
bool result = false;
if (m_trial) {
if (m_expireTime <= currentTime) {
unsigned long long currentTimeAsLL = static_cast<unsigned long long>(currentTime);
if (m_expireTime <= currentTimeAsLL) {
result = true;
}
}
@ -150,8 +152,9 @@ SerialKey::daysLeft(time_t currentTime) const
unsigned long long timeLeft = 0;
unsigned long long const day = 60 * 60 * 24;
if (currentTime < m_expireTime) {
timeLeft = m_expireTime - currentTime;
unsigned long long currentTimeAsLL = static_cast<unsigned long long>(currentTime);
if (currentTimeAsLL < m_expireTime) {
timeLeft = m_expireTime - currentTimeAsLL;
}
unsigned long long daysLeft = 0;