aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@theqtcompany.com>2016-04-20 09:33:21 +0200
committerDavid Schulz <david.schulz@theqtcompany.com>2016-04-22 07:37:31 +0000
commitcc04b84917ef0f90e2017bf652b7327ce5edda9c (patch)
treefe374cd50bb8e9f18c4b747f97a0712e41124d16 /src
parent89c2b2cd327a1f929924265622c80e22719998d4 (diff)
Fix compiler warnings on windows.
Ignore some warnings inside 3rd party code and fix a lot of conversion warnings. Change-Id: I909f2f31a4639015bf7dd028d2d435ff1d1167bc Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com> Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/libs/3rdparty/botan/botan.pri2
-rw-r--r--src/libs/clangbackendipc/connectionserver.cpp2
-rw-r--r--src/libs/glsl/glslparser.cpp12
-rw-r--r--src/libs/glsl/glslparser.h2
-rw-r--r--src/libs/qtcreatorcdbext/common.h2
-rw-r--r--src/libs/ssh/sshbotanconversions_p.h2
-rw-r--r--src/libs/ssh/sshcryptofacility.cpp15
-rw-r--r--src/libs/ssh/sshkeygenerator.cpp5
-rw-r--r--src/libs/ssh/sshpacket.cpp2
-rw-r--r--src/libs/utils/mapreduce.h2
-rw-r--r--src/libs/utils/savefile.cpp3
-rw-r--r--src/shared/json/json.cpp29
12 files changed, 43 insertions, 35 deletions
diff --git a/src/libs/3rdparty/botan/botan.pri b/src/libs/3rdparty/botan/botan.pri
index b3a26e4e84c..1da11b47517 100644
--- a/src/libs/3rdparty/botan/botan.pri
+++ b/src/libs/3rdparty/botan/botan.pri
@@ -36,7 +36,7 @@ win32 {
win32-msvc* {
QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHs
- QMAKE_CXXFLAGS += -wd4251 -wd4290 -wd4250
+ QMAKE_CXXFLAGS += -wd4251 -wd4290 -wd4250 -wd4297 -wd4267 -wd4334
DEFINES += BOTAN_BUILD_COMPILER_IS_MSVC BOTAN_TARGET_OS_HAS_GMTIME_S _SCL_SECURE_NO_WARNINGS
} else {
QMAKE_CFLAGS += -fpermissive -finline-functions -Wno-long-long
diff --git a/src/libs/clangbackendipc/connectionserver.cpp b/src/libs/clangbackendipc/connectionserver.cpp
index 20c79dfc047..9926b5dd187 100644
--- a/src/libs/clangbackendipc/connectionserver.cpp
+++ b/src/libs/clangbackendipc/connectionserver.cpp
@@ -70,7 +70,7 @@ void ConnectionServer::setIpcServer(IpcServerInterface *ipcServer)
int ConnectionServer::clientProxyCount() const
{
- return ipcClientProxies.size();
+ return static_cast<int>(ipcClientProxies.size());
}
void ConnectionServer::timerEvent(QTimerEvent *timerEvent)
diff --git a/src/libs/glsl/glslparser.cpp b/src/libs/glsl/glslparser.cpp
index 58869349026..6d8401531e8 100644
--- a/src/libs/glsl/glslparser.cpp
+++ b/src/libs/glsl/glslparser.cpp
@@ -58,30 +58,30 @@ Parser::Parser(Engine *engine, const char *source, unsigned size, int variant)
switch (tk.kind) {
case T_LEFT_PAREN:
- parenStack.push(_tokens.size());
+ parenStack.push(static_cast<int>(_tokens.size()));
break;
case T_LEFT_BRACKET:
- bracketStack.push(_tokens.size());
+ bracketStack.push(static_cast<int>(_tokens.size()));
break;
case T_LEFT_BRACE:
- braceStack.push(_tokens.size());
+ braceStack.push(static_cast<int>(_tokens.size()));
break;
case T_RIGHT_PAREN:
if (! parenStack.empty()) {
- _tokens[parenStack.top()].matchingBrace = _tokens.size();
+ _tokens[parenStack.top()].matchingBrace = static_cast<int>(_tokens.size());
parenStack.pop();
}
break;
case T_RIGHT_BRACKET:
if (! bracketStack.empty()) {
- _tokens[bracketStack.top()].matchingBrace = _tokens.size();
+ _tokens[bracketStack.top()].matchingBrace = static_cast<int>(_tokens.size());
bracketStack.pop();
}
break;
case T_RIGHT_BRACE:
if (! braceStack.empty()) {
- _tokens[braceStack.top()].matchingBrace = _tokens.size();
+ _tokens[braceStack.top()].matchingBrace = static_cast<int>(_tokens.size());
braceStack.pop();
}
break;
diff --git a/src/libs/glsl/glslparser.h b/src/libs/glsl/glslparser.h
index 0eb54df0d27..7b44f2870fd 100644
--- a/src/libs/glsl/glslparser.h
+++ b/src/libs/glsl/glslparser.h
@@ -114,7 +114,7 @@ private:
inline int consumeToken() {
if (_index < int(_tokens.size()))
return _index++;
- return _tokens.size() - 1;
+ return static_cast<int>(_tokens.size()) - 1;
}
inline const Token &tokenAt(int index) const {
if (index == 0)
diff --git a/src/libs/qtcreatorcdbext/common.h b/src/libs/qtcreatorcdbext/common.h
index e41a71df12f..0bfbcda0384 100644
--- a/src/libs/qtcreatorcdbext/common.h
+++ b/src/libs/qtcreatorcdbext/common.h
@@ -34,7 +34,9 @@
#include <windows.h>
#define KDEXT_64BIT
+#pragma warning( disable : 4838 )
#include <wdbgexts.h>
+#pragma warning( default : 4838 )
#include <dbgeng.h>
typedef IDebugControl3 CIDebugControl;
diff --git a/src/libs/ssh/sshbotanconversions_p.h b/src/libs/ssh/sshbotanconversions_p.h
index 30849ad25ca..f54ca843a2c 100644
--- a/src/libs/ssh/sshbotanconversions_p.h
+++ b/src/libs/ssh/sshbotanconversions_p.h
@@ -45,7 +45,7 @@ inline Botan::byte *convertByteArray(QByteArray &a)
inline QByteArray convertByteArray(const Botan::SecureVector<Botan::byte> &v)
{
- return QByteArray(reinterpret_cast<const char *>(v.begin()), v.size());
+ return QByteArray(reinterpret_cast<const char *>(v.begin()), static_cast<int>(v.size()));
}
inline const char *botanKeyExchangeAlgoName(const QByteArray &rfcAlgoName)
diff --git a/src/libs/ssh/sshcryptofacility.cpp b/src/libs/ssh/sshcryptofacility.cpp
index 95991778779..bfd853be42b 100644
--- a/src/libs/ssh/sshcryptofacility.cpp
+++ b/src/libs/ssh/sshcryptofacility.cpp
@@ -82,11 +82,11 @@ void SshAbstractCryptoFacility::recreateKeys(const SshKeyExchange &kex)
BlockCipher * const cipher
= af.prototype_block_cipher(botanCryptAlgoName(rfcCryptAlgoName))->clone();
- m_cipherBlockSize = cipher->block_size();
+ m_cipherBlockSize = static_cast<quint32>(cipher->block_size());
const QByteArray ivData = generateHash(kex, ivChar(), m_cipherBlockSize);
const InitializationVector iv(convertByteArray(ivData), m_cipherBlockSize);
- const quint32 keySize = cipher->key_spec().maximum_keylength();
+ const quint32 keySize = static_cast<quint32>(cipher->key_spec().maximum_keylength());
const QByteArray cryptKeyData = generateHash(kex, keyChar(), keySize);
SymmetricKey cryptKey(convertByteArray(cryptKeyData), keySize);
Keyed_Filter * const cipherMode
@@ -118,8 +118,9 @@ void SshAbstractCryptoFacility::convert(QByteArray &data, quint32 offset,
}
m_pipe->process_msg(reinterpret_cast<const byte *>(data.constData()) + offset,
dataSize);
- quint32 bytesRead = m_pipe->read(reinterpret_cast<byte *>(data.data()) + offset,
- dataSize, m_pipe->message_count() - 1); // Can't use Pipe::LAST_MESSAGE because of a VC bug.
+ // Can't use Pipe::LAST_MESSAGE because of a VC bug.
+ quint32 bytesRead = static_cast<quint32>(m_pipe->read(
+ reinterpret_cast<byte *>(data.data()) + offset, dataSize, m_pipe->message_count() - 1));
if (bytesRead != dataSize) {
throw SshClientException(SshInternalError,
QLatin1String("Internal error: Botan::Pipe::read() returned unexpected value"));
@@ -261,7 +262,8 @@ bool SshEncryptionFacility::createAuthenticationKeyFromPKCS8(const QByteArray &p
<< rsaKey->get_d();
} else if (auto * const ecdsaKey = dynamic_cast<ECDSA_PrivateKey *>(m_authKey.data())) {
const BigInt value = ecdsaKey->private_value();
- m_authKeyAlgoName = SshCapabilities::ecdsaPubKeyAlgoForKeyWidth(value.bytes());
+ m_authKeyAlgoName = SshCapabilities::ecdsaPubKeyAlgoForKeyWidth(
+ static_cast<int>(value.bytes()));
pubKeyParams << ecdsaKey->public_point().get_affine_x()
<< ecdsaKey->public_point().get_affine_y();
allKeyParams << pubKeyParams << value;
@@ -346,7 +348,8 @@ bool SshEncryptionFacility::createAuthenticationKeyFromOpenSSL(const QByteArray
} else {
BigInt privKey;
sequence.decode_octet_string_bigint(privKey);
- m_authKeyAlgoName = SshCapabilities::ecdsaPubKeyAlgoForKeyWidth(privKey.bytes());
+ m_authKeyAlgoName = SshCapabilities::ecdsaPubKeyAlgoForKeyWidth(
+ static_cast<int>(privKey.bytes()));
const EC_Group group(SshCapabilities::oid(m_authKeyAlgoName));
auto * const key = new ECDSA_PrivateKey(m_rng, group, privKey);
m_authKey.reset(key);
diff --git a/src/libs/ssh/sshkeygenerator.cpp b/src/libs/ssh/sshkeygenerator.cpp
index 8365069115a..3f03e8ba9b4 100644
--- a/src/libs/ssh/sshkeygenerator.cpp
+++ b/src/libs/ssh/sshkeygenerator.cpp
@@ -115,7 +115,7 @@ void SshKeyGenerator::generatePkcs8KeyString(const KeyPtr &key, bool privateKey,
keyData = &m_publicKey;
}
pipe.end_msg();
- keyData->resize(pipe.remaining(pipe.message_count() - 1));
+ keyData->resize(static_cast<int>(pipe.remaining(pipe.message_count()) - 1));
pipe.read(convertByteArray(*keyData), keyData->size(),
pipe.message_count() - 1);
}
@@ -147,7 +147,8 @@ void SshKeyGenerator::generateOpenSslPublicKeyString(const KeyPtr &key)
case Ecdsa: {
const auto ecdsaKey = key.dynamicCast<ECDSA_PrivateKey>();
q = convertByteArray(EC2OSP(ecdsaKey->public_point(), PointGFp::UNCOMPRESSED));
- keyId = SshCapabilities::ecdsaPubKeyAlgoForKeyWidth(ecdsaKey->private_value().bytes());
+ keyId = SshCapabilities::ecdsaPubKeyAlgoForKeyWidth(
+ static_cast<int>(ecdsaKey->private_value().bytes()));
break;
}
}
diff --git a/src/libs/ssh/sshpacket.cpp b/src/libs/ssh/sshpacket.cpp
index ec563a2251f..1b35037fb0e 100644
--- a/src/libs/ssh/sshpacket.cpp
+++ b/src/libs/ssh/sshpacket.cpp
@@ -96,7 +96,7 @@ QByteArray AbstractSshPacket::encodeMpInt(const Botan::BigInt &number)
if (number.is_zero())
return QByteArray(4, 0);
- int stringLength = number.bytes();
+ int stringLength = static_cast<int>(number.bytes());
const bool positiveAndMsbSet = number.sign() == Botan::BigInt::Positive
&& (number.byte_at(stringLength - 1) & 0x80);
if (positiveAndMsbSet)
diff --git a/src/libs/utils/mapreduce.h b/src/libs/utils/mapreduce.h
index 8df540aa0dc..fbaa8f8bb01 100644
--- a/src/libs/utils/mapreduce.h
+++ b/src/libs/utils/mapreduce.h
@@ -296,7 +296,7 @@ void blockingContainerMapReduce(QFutureInterface<ReduceResult> &futureInterface,
std::forward<InitFunction>(init), std::forward<MapFunction>(map),
std::forward<ReduceFunction>(reduce),
std::forward<CleanUpFunction>(cleanup),
- option, container.size());
+ option, static_cast<int>(container.size()));
}
template <typename Container, typename InitFunction, typename MapFunction, typename ReduceResult,
diff --git a/src/libs/utils/savefile.cpp b/src/libs/utils/savefile.cpp
index 0af644a2727..b514d6233d0 100644
--- a/src/libs/utils/savefile.cpp
+++ b/src/libs/utils/savefile.cpp
@@ -28,6 +28,7 @@
#include "fileutils.h"
#ifdef Q_OS_WIN
# include <windows.h>
+# include <io.h>
#else
# include <unistd.h>
# include <sys/stat.h>
@@ -97,7 +98,7 @@ bool SaveFile::commit()
return false;
}
#ifdef Q_OS_WIN
- FlushFileBuffers(reinterpret_cast<HANDLE>(handle()));
+ FlushFileBuffers(reinterpret_cast<HANDLE>(_get_osfhandle(handle())));
#elif _POSIX_SYNCHRONIZED_IO > 0
fdatasync(handle());
#else
diff --git a/src/shared/json/json.cpp b/src/shared/json/json.cpp
index 4becf92274d..1ae076ad22a 100644
--- a/src/shared/json/json.cpp
+++ b/src/shared/json/json.cpp
@@ -203,7 +203,7 @@ int alignedSize(int size) { return (size + 3) & ~3; }
static int qStringSize(const std::string &ba)
{
- int l = 4 + ba.length();
+ int l = 4 + static_cast<int>(ba.length());
return alignedSize(l);
}
@@ -252,7 +252,7 @@ public:
void operator=(const std::string &ba)
{
- d->length = ba.length();
+ d->length = static_cast<int>(ba.length());
memcpy(d->utf8, ba.data(), ba.length());
}
@@ -581,7 +581,7 @@ public:
int objectPosition;
std::vector<uint32_t> offsets;
- Entry *entryAt(int i) const {
+ Entry *entryAt(size_t i) const {
return reinterpret_cast<Entry *>(parser->data + objectPosition + offsets[i]);
}
};
@@ -2505,7 +2505,8 @@ JsonObject::iterator JsonObject::insert(const std::string &key, const JsonValue
Internal::Entry *e = o->entryAt(pos);
e->value.type = val.t;
e->value.intValue = isIntValue;
- e->value.value = Internal::Value::valueToStore(val, (char *)e - (char *)o + valueOffset);
+ e->value.value = Internal::Value::valueToStore(val, static_cast<uint32_t>((char *)e - (char *)o)
+ + valueOffset);
Internal::copyString((char *)(e + 1), key);
if (valueSize)
Internal::Value::copyData(val, (char *)e + valueOffset, isIntValue);
@@ -3475,7 +3476,7 @@ std::string JsonDocument::toJson(JsonFormat format) const
*/
JsonDocument JsonDocument::fromJson(const std::string &json, JsonParseError *error)
{
- Internal::Parser parser(json.data(), json.length());
+ Internal::Parser parser(json.data(), static_cast<int>(json.length()));
return parser.parse(error);
}
@@ -4008,7 +4009,7 @@ JsonDocument Parser::parse(JsonParseError *error)
std::cerr << ">>>>> parser begin";
#endif
// allocate some space
- dataLength = std::max(end - json, std::ptrdiff_t(256));
+ dataLength = static_cast<int>(std::max(end - json, std::ptrdiff_t(256)));
data = (char *)malloc(dataLength);
// fill in Header data
@@ -4054,7 +4055,7 @@ error:
std::cerr << ">>>>> parser error";
#endif
if (error) {
- error->offset = json - head;
+ error->offset = static_cast<int>(json - head);
error->error = lastError;
}
free(data);
@@ -4068,8 +4069,8 @@ void Parser::ParsedObject::insert(uint32_t offset)
size_t min = 0;
size_t n = offsets.size();
while (n > 0) {
- int half = n >> 1;
- int middle = min + half;
+ size_t half = n >> 1;
+ size_t middle = min + half;
if (*entryAt(middle) >= *newEntry) {
n = half;
} else {
@@ -4127,7 +4128,7 @@ bool Parser::parseObject()
int table = objectOffset;
// finalize the object
if (parsedObject.offsets.size()) {
- int tableSize = parsedObject.offsets.size()*sizeof(uint32_t);
+ int tableSize = static_cast<int>(parsedObject.offsets.size()) * sizeof(uint32_t);
table = reserveSpace(tableSize);
memcpy(data + table, &*parsedObject.offsets.begin(), tableSize);
}
@@ -4136,7 +4137,7 @@ bool Parser::parseObject()
o->tableOffset = table - objectOffset;
o->size = current - objectOffset;
o->is_object = true;
- o->length = parsedObject.offsets.size();
+ o->length = static_cast<int>(parsedObject.offsets.size());
DEBUG << "current=" << current;
END;
@@ -4218,7 +4219,7 @@ bool Parser::parseArray()
int table = arrayOffset;
// finalize the object
if (values.size()) {
- int tableSize = values.size()*sizeof(Value);
+ int tableSize = static_cast<int>(values.size() * sizeof(Value));
table = reserveSpace(tableSize);
memcpy(data + table, values.data(), tableSize);
}
@@ -4227,7 +4228,7 @@ bool Parser::parseArray()
a->tableOffset = table - arrayOffset;
a->size = current - arrayOffset;
a->is_object = false;
- a->length = values.size();
+ a->length = static_cast<int>(values.size());
DEBUG << "current=" << current;
END;
@@ -4558,7 +4559,7 @@ bool Parser::parseString()
const char c = *json;
if (c == '"') {
// write string length and padding.
- const int len = json - inStart;
+ const int len = static_cast<int>(json - inStart);
const int pos = reserveSpace(4 + alignedSize(len));
toInternal(data + pos, inStart, len);
END;