summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/include/Ice/IconvStringConverter.h7
-rw-r--r--cpp/include/Ice/InputStream.h8
-rw-r--r--cpp/include/Ice/OutputStream.h10
-rw-r--r--cpp/include/Ice/StreamHelpers.h2
-rw-r--r--cpp/include/IceUtil/ScannerConfig.h5
-rw-r--r--cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp22
-rw-r--r--cpp/src/Ice/ArgVector.cpp6
-rw-r--r--cpp/src/Ice/Base64.cpp22
-rw-r--r--cpp/src/Ice/BatchRequestQueue.cpp2
-rw-r--r--cpp/src/Ice/Buffer.cpp4
-rw-r--r--cpp/src/Ice/ConnectionI.cpp12
-rw-r--r--cpp/src/Ice/HashUtil.h2
-rw-r--r--cpp/src/Ice/Initialize.cpp7
-rw-r--r--cpp/src/Ice/InputStream.cpp38
-rw-r--r--cpp/src/Ice/Instance.cpp13
-rwxr-xr-xcpp/src/Ice/Network.cpp15
-rw-r--r--cpp/src/Ice/OutputStream.cpp48
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp2
-rw-r--r--cpp/src/Ice/ReferenceFactory.cpp2
-rw-r--r--cpp/src/Ice/SHA1.cpp4
-rw-r--r--cpp/src/Ice/Selector.cpp17
-rw-r--r--cpp/src/Ice/Service.cpp6
-rwxr-xr-xcpp/src/Ice/StreamSocket.cpp12
-rwxr-xr-xcpp/src/Ice/UdpTransceiver.cpp12
-rw-r--r--cpp/src/Ice/WSTransceiver.cpp31
-rw-r--r--cpp/src/IceDB/IceDB.cpp7
-rw-r--r--cpp/src/IceGrid/Activator.cpp12
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp4
-rw-r--r--cpp/src/IceGrid/Client.cpp2
-rw-r--r--cpp/src/IceGrid/FileCache.cpp2
-rw-r--r--cpp/src/IceGrid/Grammar.cpp8
-rw-r--r--cpp/src/IceGrid/Grammar.y8
-rw-r--r--cpp/src/IceGrid/LocatorI.cpp2
-rw-r--r--cpp/src/IceGrid/ServerI.cpp4
-rw-r--r--cpp/src/IcePatch2/Client.cpp2
-rw-r--r--cpp/src/IcePatch2/FileServerI.cpp6
-rw-r--r--cpp/src/IcePatch2Lib/ClientUtil.cpp17
-rw-r--r--cpp/src/IcePatch2Lib/Util.cpp20
-rw-r--r--cpp/src/IceSSL/SecureTransportCertificateI.cpp29
-rw-r--r--cpp/src/IceSSL/SecureTransportTransceiverI.cpp12
-rw-r--r--cpp/src/IceSSL/SecureTransportUtil.cpp32
-rwxr-xr-xcpp/src/IceSSL/Util.cpp8
-rw-r--r--cpp/src/IceStorm/Grammar.cpp8
-rw-r--r--cpp/src/IceStorm/Grammar.y8
-rw-r--r--cpp/src/IceStorm/IceStormDB.cpp2
-rw-r--r--cpp/src/IceStorm/NodeI.cpp13
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp2
-rw-r--r--cpp/src/IceUtil/Options.cpp2
-rw-r--r--cpp/src/IceUtil/Random.cpp4
-rw-r--r--cpp/src/IceUtil/StringConverter.cpp10
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp6
-rw-r--r--cpp/src/IceUtil/Time.cpp6
-rw-r--r--cpp/src/IceUtil/UUID.cpp10
-rw-r--r--cpp/src/IceUtil/UtilException.cpp6
-rw-r--r--cpp/src/IceXML/Parser.cpp2
-rw-r--r--cpp/src/Slice/Grammar.cpp8
-rw-r--r--cpp/src/Slice/Grammar.y8
-rw-r--r--cpp/src/Slice/MD5I.cpp8
-rw-r--r--cpp/src/Slice/Preprocessor.cpp3
-rw-r--r--cpp/src/Slice/PythonUtil.cpp18
-rw-r--r--cpp/src/Slice/Scanner.cpp8
-rw-r--r--cpp/src/Slice/Scanner.l8
-rw-r--r--cpp/src/icegriddb/IceGridDB.cpp5
-rw-r--r--cpp/src/slice2confluence/Gen.cpp1
-rw-r--r--cpp/src/slice2cs/CsUtil.cpp6
-rw-r--r--cpp/src/slice2cs/CsUtil.h4
-rw-r--r--cpp/src/slice2cs/DotNetNames.cpp4
-rw-r--r--cpp/src/slice2cs/DotNetNames.h2
-rw-r--r--cpp/src/slice2cs/Gen.cpp8
-rw-r--r--cpp/src/slice2cs/Gen.h6
-rw-r--r--cpp/src/slice2html/Gen.cpp1
-rw-r--r--cpp/src/slice2js/JsUtil.cpp2
-rw-r--r--cpp/src/slice2objc/Gen.cpp2
-rw-r--r--cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp8
-rw-r--r--cpp/test/Ice/background/Transceiver.cpp4
-rw-r--r--cpp/test/Ice/binding/AllTests.cpp2
-rw-r--r--cpp/test/Ice/custom/AllTests.cpp12
-rw-r--r--cpp/test/Ice/custom/CustomBuffer.h2
-rw-r--r--cpp/test/Ice/custom/StringConverterI.cpp2
-rw-r--r--cpp/test/Ice/gc/Client.cpp8
-rw-r--r--cpp/test/Ice/hold/AllTests.cpp4
-rw-r--r--cpp/test/Ice/operations/Test.ice2
-rw-r--r--cpp/test/Ice/operations/Twoways.cpp2
-rw-r--r--cpp/test/Ice/operations/TwowaysAMI.cpp2
-rw-r--r--cpp/test/Ice/optional/AllTests.cpp6
-rw-r--r--cpp/test/Ice/slicing/objects/AllTests.cpp4
-rw-r--r--cpp/test/Ice/stream/Client.cpp4
-rw-r--r--cpp/test/IceGrid/allocation/AllTests.cpp2
-rw-r--r--cpp/test/IceGrid/session/AllTests.cpp3
-rw-r--r--cpp/test/IceSSL/configuration/AllTests.cpp4
-rw-r--r--cpp/test/IceStorm/rep1/Publisher.cpp8
-rw-r--r--cpp/test/IceUtil/sha1/Client.cpp3
-rw-r--r--cpp/test/IceUtil/uuid/Client.cpp2
93 files changed, 437 insertions, 312 deletions
diff --git a/cpp/include/Ice/IconvStringConverter.h b/cpp/include/Ice/IconvStringConverter.h
index 81aaf544f2e..a7cee796db8 100644
--- a/cpp/include/Ice/IconvStringConverter.h
+++ b/cpp/include/Ice/IconvStringConverter.h
@@ -267,7 +267,7 @@ IconvStringConverter<charT>::toUTF8(const charT* sourceStart,
#else
char* inbuf = reinterpret_cast<char*>(const_cast<charT*>(sourceStart));
#endif
- size_t inbytesleft = (sourceEnd - sourceStart) * sizeof(charT);
+ size_t inbytesleft = static_cast<size_t>(sourceEnd - sourceStart) * sizeof(charT);
char* outbuf = 0;
size_t count = 0;
@@ -311,7 +311,8 @@ IconvStringConverter<charT>::fromUTF8(const Ice::Byte* sourceStart, const Ice::B
#else
char* inbuf = reinterpret_cast<char*>(const_cast<Ice::Byte*>(sourceStart));
#endif
- size_t inbytesleft = sourceEnd - sourceStart;
+ assert(sourceEnd > sourceStart);
+ size_t inbytesleft = static_cast<size_t>(sourceEnd - sourceStart);
char* outbuf = 0;
size_t outbytesleft = 0;
@@ -325,7 +326,7 @@ IconvStringConverter<charT>::fromUTF8(const Ice::Byte* sourceStart, const Ice::B
size_t bytesused = 0;
if(outbuf != 0)
{
- bytesused = outbuf - reinterpret_cast<const char*>(target.data());
+ bytesused = static_cast<size_t>(outbuf - reinterpret_cast<const char*>(target.data()));
}
const size_t increment = std::max<size_t>(inbytesleft, 4);
diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h
index c9ffe9c20b0..4c00ef0fa8c 100644
--- a/cpp/include/Ice/InputStream.h
+++ b/cpp/include/Ice/InputStream.h
@@ -382,7 +382,7 @@ public:
_currentEncaps = new Encaps();
_currentEncaps->previous = oldEncaps;
}
- _currentEncaps->start = i - b.begin();
+ _currentEncaps->start = static_cast<size_t>(i - b.begin());
//
// I don't use readSize() and writeSize() for encapsulations,
@@ -484,7 +484,7 @@ public:
{
// Skip the optional content of the encapsulation if we are expecting an
// empty encapsulation.
- i += sz - sizeof(Ice::Int) - 2;
+ i += static_cast<size_t>(sz) - sizeof(Ice::Int) - 2;
}
return encoding;
}
@@ -511,7 +511,7 @@ public:
}
read(encoding);
- i += sz - sizeof(Int) - 2;
+ i += static_cast<size_t>(sz) - sizeof(Int) - 2;
return encoding;
}
@@ -1174,7 +1174,7 @@ public:
*/
size_type pos()
{
- return i - b.begin();
+ return static_cast<size_t>(i - b.begin());
}
/**
diff --git a/cpp/include/Ice/OutputStream.h b/cpp/include/Ice/OutputStream.h
index 4d119a850e4..886ec28fa49 100644
--- a/cpp/include/Ice/OutputStream.h
+++ b/cpp/include/Ice/OutputStream.h
@@ -261,8 +261,8 @@ public:
}
Container::size_type position = b.size();
- resize(position + sz);
- memcpy(&b[position], &v[0], sz);
+ resize(position + static_cast<size_t>(sz));
+ memcpy(&b[position], &v[0], static_cast<size_t>(sz));
}
/**
@@ -680,8 +680,8 @@ public:
if(sz > 0)
{
Container::size_type position = b.size();
- resize(position + sz);
- memcpy(&b[position], v.data(), sz);
+ resize(position + static_cast<size_t>(sz));
+ memcpy(&b[position], v.data(), static_cast<size_t>(sz));
}
}
}
@@ -706,7 +706,7 @@ public:
if(sz > 0)
{
Container::size_type position = b.size();
- resize(position + sz);
+ resize(position + static_cast<size_t>(sz));
memcpy(&b[position], vdata, vsize);
}
}
diff --git a/cpp/include/Ice/StreamHelpers.h b/cpp/include/Ice/StreamHelpers.h
index 5c5fd267e02..16292f9d9f7 100644
--- a/cpp/include/Ice/StreamHelpers.h
+++ b/cpp/include/Ice/StreamHelpers.h
@@ -583,7 +583,7 @@ struct StreamHelper<T, StreamHelperCategorySequence>
read(S* stream, T& v)
{
Int sz = stream->readAndCheckSeqSize(StreamableTraits<typename T::value_type>::minWireSize);
- T(sz).swap(v);
+ T(static_cast<size_t>(sz)).swap(v);
for(typename T::iterator p = v.begin(); p != v.end(); ++p)
{
stream->read(*p);
diff --git a/cpp/include/IceUtil/ScannerConfig.h b/cpp/include/IceUtil/ScannerConfig.h
index 2a94a677ab9..46cc75b4523 100644
--- a/cpp/include/IceUtil/ScannerConfig.h
+++ b/cpp/include/IceUtil/ScannerConfig.h
@@ -30,4 +30,9 @@
# pragma warning(disable:5033)
#endif
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
#endif
diff --git a/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp b/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp
index 70c8e977f5f..fa7ceb7fa3a 100644
--- a/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp
+++ b/cpp/src/Glacier2CryptPermissionsVerifier/CryptPermissionsVerifierI.cpp
@@ -288,7 +288,7 @@ CryptPermissionsVerifierI::checkPermissions(const string& userId, const string&
# else
LPCWSTR algorithmId = 0;
# endif
- int checksumLength = 0;
+ size_t checksumLength = 0;
const string pbkdf2SHA1Token = "$pbkdf2$";
@@ -397,7 +397,8 @@ CryptPermissionsVerifierI::checkPermissions(const string& userId, const string&
UniqueRef<CFDataRef> data(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
reinterpret_cast<const uint8_t*>(salt.c_str()),
- salt.size(), kCFAllocatorNull));
+ static_cast<CFIndex>(salt.size()),
+ kCFAllocatorNull));
SecTransformSetAttribute(decoder.get(), kSecTransformInputAttributeName, data.get(), &error.get());
if(error)
@@ -412,9 +413,15 @@ CryptPermissionsVerifierI::checkPermissions(const string& userId, const string&
}
vector<uint8_t> checksumBuffer1(checksumLength);
- OSStatus status = CCKeyDerivationPBKDF(kCCPBKDF2, password.c_str(), password.size(),
- CFDataGetBytePtr(saltBuffer.get()), CFDataGetLength(saltBuffer.get()),
- algorithmId, rounds, &checksumBuffer1[0], checksumLength);
+ OSStatus status = CCKeyDerivationPBKDF(kCCPBKDF2,
+ password.c_str(),
+ password.size(),
+ CFDataGetBytePtr(saltBuffer.get()),
+ static_cast<size_t>(CFDataGetLength(saltBuffer.get())),
+ algorithmId,
+ static_cast<unsigned int>(rounds),
+ &checksumBuffer1[0],
+ checksumLength);
if(status != errSecSuccess)
{
return false;
@@ -427,7 +434,8 @@ CryptPermissionsVerifierI::checkPermissions(const string& userId, const string&
}
data.reset(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
reinterpret_cast<const uint8_t*>(checksum.c_str()),
- checksum.size(), kCFAllocatorNull));
+ static_cast<CFIndex>(checksum.size()),
+ kCFAllocatorNull));
SecTransformSetAttribute(decoder.get(), kSecTransformInputAttributeName, data.get(), &error.get());
if(error)
{
@@ -474,7 +482,7 @@ CryptPermissionsVerifierI::checkPermissions(const string& userId, const string&
return false;
}
- DWORD checksumBuffer2Length = checksumLength;
+ DWORD checksumBuffer2Length = static_cast<DWORD>(checksumLength);
vector<BYTE> checksumBuffer2(checksumLength);
if(!CryptStringToBinary(checksum.c_str(), static_cast<DWORD>(checksum.size()),
diff --git a/cpp/src/Ice/ArgVector.cpp b/cpp/src/Ice/ArgVector.cpp
index ee1d60af61b..48ce959524f 100644
--- a/cpp/src/Ice/ArgVector.cpp
+++ b/cpp/src/Ice/ArgVector.cpp
@@ -8,8 +8,8 @@
IceInternal::ArgVector::ArgVector(int argcP, const char* const argvP[])
{
assert(argcP >= 0);
- _args.resize(argcP);
- for(int i = 0; i < argcP; ++i)
+ _args.resize(static_cast<size_t>(argcP));
+ for(size_t i = 0; i < static_cast<size_t>(argcP); ++i)
{
_args[i] = argvP[i];
}
@@ -51,7 +51,7 @@ IceInternal::ArgVector::setupArgcArgv()
{
throw ::std::bad_alloc();
}
- for(int i = 0; i < argc; i++)
+ for(size_t i = 0; i < static_cast<size_t>(argc); i++)
{
argv[i] = const_cast<char*>(_args[i].c_str());
}
diff --git a/cpp/src/Ice/Base64.cpp b/cpp/src/Ice/Base64.cpp
index 803d5b15b85..1dd81bb2f96 100644
--- a/cpp/src/Ice/Base64.cpp
+++ b/cpp/src/Ice/Base64.cpp
@@ -49,8 +49,8 @@ IceInternal::Base64::encode(const vector<unsigned char>& plainSeq)
}
by4 = by1 >> 2;
- by5 = ((by1 & 0x3) << 4) | (by2 >> 4);
- by6 = ((by2 & 0xf) << 2) | (by3 >> 6);
+ by5 = static_cast<unsigned char>((by1 & 0x3) << 4) | (by2 >> 4);
+ by6 = static_cast<unsigned char>((by2 & 0xf) << 2) | (by3 >> 6);
by7 = by3 & 0x3f;
retval += encode(by4);
@@ -159,16 +159,16 @@ IceInternal::Base64::decode(const string& str)
by3 = decode(c3);
by4 = decode(c4);
- retval.push_back((by1 << 2) | (by2 >> 4));
+ retval.push_back(static_cast<unsigned char>(by1 << 2) | (by2 >> 4));
if(c3 != '=')
{
- retval.push_back(((by2 & 0xf) << 4) | (by3 >> 2));
+ retval.push_back(static_cast<unsigned char>((by2 & 0xf) << 4) | (by3 >> 2));
}
if(c4 != '=')
{
- retval.push_back(((by3 & 0x3) << 6) | by4);
+ retval.push_back(static_cast<unsigned char>((by3 & 0x3) << 6) | by4);
}
}
@@ -216,17 +216,17 @@ IceInternal::Base64::encode(unsigned char uc)
{
if(uc < 26)
{
- return 'A' + uc;
+ return 'A' + static_cast<char>(uc);
}
if(uc < 52)
{
- return 'a' + (uc - 26);
+ return 'a' + static_cast<char>(uc) - 26;
}
if(uc < 62)
{
- return '0' + (uc - 52);
+ return '0' + static_cast<char>(uc) - 52;
}
if(uc == 62)
@@ -242,17 +242,17 @@ IceInternal::Base64::decode(char c)
{
if(c >= 'A' && c <= 'Z')
{
- return c - 'A';
+ return static_cast<unsigned char>(c - 'A');
}
if(c >= 'a' && c <= 'z')
{
- return c - 'a' + 26;
+ return static_cast<unsigned char>(c - 'a' + 26);
}
if(c >= '0' && c <= '9')
{
- return c - '0' + 52;
+ return static_cast<unsigned char>(c - '0' + 52);
}
if(c == '+')
diff --git a/cpp/src/Ice/BatchRequestQueue.cpp b/cpp/src/Ice/BatchRequestQueue.cpp
index 32ba60cc0f9..5fb44746696 100644
--- a/cpp/src/Ice/BatchRequestQueue.cpp
+++ b/cpp/src/Ice/BatchRequestQueue.cpp
@@ -76,7 +76,7 @@ BatchRequestQueue::BatchRequestQueue(const InstancePtr& instance, bool datagram)
if(_maxSize > 0 && datagram)
{
const Ice::InitializationData& initData = instance->initializationData();
- size_t udpSndSize = initData.properties->getPropertyAsIntWithDefault("Ice.UDP.SndSize", 65535 - udpOverhead);
+ size_t udpSndSize = static_cast<size_t>(initData.properties->getPropertyAsIntWithDefault("Ice.UDP.SndSize", 65535 - udpOverhead));
if(udpSndSize < _maxSize)
{
_maxSize = udpSndSize;
diff --git a/cpp/src/Ice/Buffer.cpp b/cpp/src/Ice/Buffer.cpp
index 8b4c6f9062a..50e5d52a9c7 100644
--- a/cpp/src/Ice/Buffer.cpp
+++ b/cpp/src/Ice/Buffer.cpp
@@ -27,8 +27,8 @@ IceInternal::Buffer::Container::Container() :
IceInternal::Buffer::Container::Container(const_iterator beg, const_iterator end) :
_buf(const_cast<iterator>(beg)),
- _size(end - beg),
- _capacity(end - beg),
+ _size(static_cast<size_t>(end - beg)),
+ _capacity(static_cast<size_t>(end - beg)),
_shrinkCounter(0),
_owned(false)
{
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index 1666717289f..176848c84f8 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -1685,11 +1685,11 @@ Ice::ConnectionI::message(ThreadPoolCurrent& current)
}
if(size > static_cast<Int>(_messageSizeMax))
{
- Ex::throwMemoryLimitException(__FILE__, __LINE__, size, _messageSizeMax);
+ Ex::throwMemoryLimitException(__FILE__, __LINE__, static_cast<size_t>(size), _messageSizeMax);
}
- if(size > static_cast<Int>(_readStream.b.size()))
+ if(static_cast<size_t>(size) > _readStream.b.size())
{
- _readStream.b.resize(size);
+ _readStream.b.resize(static_cast<size_t>(size));
}
_readStream.i = _readStream.b.begin() + pos;
}
@@ -3195,11 +3195,11 @@ Ice::ConnectionI::doUncompress(InputStream& compressed, InputStream& uncompresse
if(uncompressedSize > static_cast<Int>(_messageSizeMax))
{
- Ex::throwMemoryLimitException(__FILE__, __LINE__, uncompressedSize, _messageSizeMax);
+ Ex::throwMemoryLimitException(__FILE__, __LINE__, static_cast<size_t>(uncompressedSize), _messageSizeMax);
}
- uncompressed.resize(uncompressedSize);
+ uncompressed.resize(static_cast<size_t>(uncompressedSize));
- unsigned int uncompressedLen = uncompressedSize - headerSize;
+ unsigned int uncompressedLen = static_cast<unsigned int>(uncompressedSize - headerSize);
unsigned int compressedLen = static_cast<unsigned int>(compressed.b.size() - headerSize - sizeof(Int));
int bzError = BZ2_bzBuffToBuffDecompress(reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
&uncompressedLen,
diff --git a/cpp/src/Ice/HashUtil.h b/cpp/src/Ice/HashUtil.h
index e565bb5df28..1a543d9a21c 100644
--- a/cpp/src/Ice/HashUtil.h
+++ b/cpp/src/Ice/HashUtil.h
@@ -11,7 +11,7 @@ namespace IceInternal
inline void
hashAdd(Ice::Int& hashCode, Ice::Int value)
{
- hashCode = ((hashCode << 5) + hashCode) ^ (2654435761u * value);
+ hashCode = ((hashCode << 5) + hashCode) ^ static_cast<Ice::Int>(2654435761u) * value;
}
inline void
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp
index 70f48b781ac..1dfd7290b8f 100644
--- a/cpp/src/Ice/Initialize.cpp
+++ b/cpp/src/Ice/Initialize.cpp
@@ -570,11 +570,12 @@ Ice::stringToIdentity(const string& s)
// Find unescaped separator; note that the string may contain an escaped
// backslash before the separator.
//
- string::size_type slash = string::npos, pos = 0;
+ string::size_type slash = string::npos;
+ string::size_type pos = 0;
while((pos = s.find('/', pos)) != string::npos)
{
- int escapes = 0;
- while(static_cast<int>(pos) - escapes > 0 && s[pos - escapes - 1] == '\\')
+ string::size_type escapes = 0;
+ while(static_cast<int>(pos - escapes) > 0 && s[pos - escapes - 1] == '\\')
{
escapes++;
}
diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp
index 79ba83ed174..9f85122928d 100644
--- a/cpp/src/Ice/InputStream.cpp
+++ b/cpp/src/Ice/InputStream.cpp
@@ -331,7 +331,7 @@ Ice::InputStream::skipEncapsulation()
EncodingVersion encoding;
read(encoding.major);
read(encoding.minor);
- i += sz - sizeof(Int) - 2;
+ i += static_cast<size_t>(sz) - sizeof(Int) - 2;
return encoding;
}
@@ -432,7 +432,7 @@ Ice::InputStream::read(std::vector<Ice::Byte>& v)
read(p);
if(p.first != p.second)
{
- v.resize(static_cast<Ice::Int>(p.second - p.first));
+ v.resize(static_cast<size_t>(p.second - p.first));
copy(p.first, p.second, v.begin());
}
else
@@ -463,7 +463,7 @@ Ice::InputStream::read(vector<bool>& v)
Int sz = readAndCheckSeqSize(1);
if(sz > 0)
{
- v.resize(sz);
+ v.resize(static_cast<size_t>(sz));
copy(i, i + sz, v.begin());
i += sz;
}
@@ -571,7 +571,7 @@ Ice::InputStream::read(vector<Short>& v)
{
Container::iterator begin = i;
i += sz * static_cast<int>(sizeof(Short));
- v.resize(sz);
+ v.resize(static_cast<size_t>(sz));
#ifdef ICE_BIG_ENDIAN
const Byte* src = &(*begin);
Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Short) - 1;
@@ -651,7 +651,7 @@ Ice::InputStream::read(vector<Int>& v)
{
Container::iterator begin = i;
i += sz * static_cast<int>(sizeof(Int));
- v.resize(sz);
+ v.resize(static_cast<size_t>(sz));
#ifdef ICE_BIG_ENDIAN
const Byte* src = &(*begin);
Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Int) - 1;
@@ -768,7 +768,7 @@ Ice::InputStream::read(vector<Long>& v)
{
Container::iterator begin = i;
i += sz * static_cast<int>(sizeof(Long));
- v.resize(sz);
+ v.resize(static_cast<size_t>(sz));
#ifdef ICE_BIG_ENDIAN
const Byte* src = &(*begin);
Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Long) - 1;
@@ -885,7 +885,7 @@ Ice::InputStream::read(vector<Float>& v)
{
Container::iterator begin = i;
i += sz * static_cast<int>(sizeof(Float));
- v.resize(sz);
+ v.resize(static_cast<size_t>(sz));
#ifdef ICE_BIG_ENDIAN
const Byte* src = &(*begin);
Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Float) - 1;
@@ -1002,7 +1002,7 @@ Ice::InputStream::read(vector<Double>& v)
{
Container::iterator begin = i;
i += sz * static_cast<int>(sizeof(Double));
- v.resize(sz);
+ v.resize(static_cast<size_t>(sz));
#ifdef ICE_BIG_ENDIAN
const Byte* src = &(*begin);
Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Double) - 1;
@@ -1266,8 +1266,8 @@ Ice::InputStream::read(vector<string>& v, bool convert)
Int sz = readAndCheckSeqSize(1);
if(sz > 0)
{
- v.resize(sz);
- for(int j = 0; j < sz; ++j)
+ v.resize(static_cast<size_t>(sz));
+ for(size_t j = 0; j < static_cast<size_t>(sz); ++j)
{
read(v[j], convert);
}
@@ -1318,11 +1318,11 @@ Ice::InputStream::read(wstring& v)
void
Ice::InputStream::read(vector<wstring>& v)
{
- Int sz = readAndCheckSeqSize(1);
+ size_t sz = static_cast<size_t>(readAndCheckSeqSize(1));
if(sz > 0)
{
v.resize(sz);
- for(int j = 0; j < sz; ++j)
+ for(size_t j = 0; j < sz; ++j)
{
read(v[j]);
}
@@ -1479,7 +1479,7 @@ Ice::InputStream::skipOptional(OptionalFormat type)
}
case ICE_SCOPED_ENUM(OptionalFormat, VSize):
{
- skip(readSize());
+ skip(static_cast<size_t>(readSize()));
break;
}
case ICE_SCOPED_ENUM(OptionalFormat, FSize):
@@ -1490,7 +1490,7 @@ Ice::InputStream::skipOptional(OptionalFormat type)
{
throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
- skip(sz);
+ skip(static_cast<size_t>(sz));
break;
}
case ICE_SCOPED_ENUM(OptionalFormat, Class):
@@ -2116,7 +2116,7 @@ Ice::InputStream::EncapsDecoder10::skipSlice()
{
_stream->traceSkipSlice(_typeId, _sliceType);
assert(_sliceSize >= 4);
- _stream->skip(_sliceSize - sizeof(Int));
+ _stream->skip(static_cast<size_t>(_sliceSize) - sizeof(Int));
}
void
@@ -2446,7 +2446,7 @@ Ice::InputStream::EncapsDecoder11::endSlice()
//
if(_current->sliceFlags & FLAG_HAS_INDIRECTION_TABLE)
{
- IndexList indirectionTable(_stream->readAndCheckSeqSize(1));
+ IndexList indirectionTable(static_cast<size_t>(_stream->readAndCheckSeqSize(1)));
for(IndexList::iterator p = indirectionTable.begin(); p != indirectionTable.end(); ++p)
{
*p = readInstance(_stream->readSize(), 0, 0);
@@ -2477,7 +2477,7 @@ Ice::InputStream::EncapsDecoder11::endSlice()
{
throw MarshalException(__FILE__, __LINE__, "indirection out of range");
}
- addPatchEntry(indirectionTable[p->index], p->patchFunc, p->patchAddr);
+ addPatchEntry(indirectionTable[static_cast<size_t>(p->index)], p->patchFunc, p->patchAddr);
}
_current->indirectPatchList.clear();
}
@@ -2493,7 +2493,7 @@ Ice::InputStream::EncapsDecoder11::skipSlice()
if(_current->sliceFlags & FLAG_HAS_SLICE_SIZE)
{
assert(_current->sliceSize >= 4);
- _stream->skip(_current->sliceSize - sizeof(Int));
+ _stream->skip(static_cast<size_t>(_current->sliceSize) - sizeof(Int));
}
else
{
@@ -2544,7 +2544,7 @@ Ice::InputStream::EncapsDecoder11::skipSlice()
if(_current->sliceFlags & FLAG_HAS_INDIRECTION_TABLE)
{
IndexList& table = _current->indirectionTables.back();
- table.resize(_stream->readAndCheckSeqSize(1));
+ table.resize(static_cast<size_t>(_stream->readAndCheckSeqSize(1)));
for(IndexList::iterator p = table.begin(); p != table.end(); ++p)
{
*p = readInstance(_stream->readSize(), 0, 0);
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 8d448ee0ddb..1d1d8ce262f 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -1033,7 +1033,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
throw SyscallException(__FILE__, __LINE__, getSystemErrno());
}
- if(initgroups(pw->pw_name, pw->pw_gid) == -1)
+ if(initgroups(pw->pw_name, static_cast<int>(pw->pw_gid)) == -1)
{
throw SyscallException(__FILE__, __LINE__, getSystemErrno());
}
@@ -1107,8 +1107,13 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
#endif
if(!logfile.empty())
{
- _initData.logger = ICE_MAKE_SHARED(LoggerI, _initData.properties->getProperty("Ice.ProgramName"), logfile, true,
- _initData.properties->getPropertyAsIntWithDefault("Ice.LogFile.SizeMax", 0));
+ Int sz = _initData.properties->getPropertyAsIntWithDefault("Ice.LogFile.SizeMax", 0);
+ if(sz < 0)
+ {
+ sz = 0;
+ }
+ _initData.logger = ICE_MAKE_SHARED(LoggerI, _initData.properties->getProperty("Ice.ProgramName"),
+ logfile, true, static_cast<size_t>(sz));
}
else
{
@@ -1165,7 +1170,7 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.BatchAutoFlushSize", 1024); // 1MB default
if(num < 1)
{
- const_cast<size_t&>(_batchAutoFlushSize) = num;
+ const_cast<size_t&>(_batchAutoFlushSize) = static_cast<size_t>(num);
}
else if(static_cast<size_t>(num) > static_cast<size_t>(0x7fffffff / 1024))
{
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index 19aac9ec2c4..d1e4b8194ee 100755
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -660,7 +660,7 @@ getInterfaceIndex(const string& intf)
struct sockaddr_in6* ipv6Addr = reinterpret_cast<struct sockaddr_in6*>(curr->ifa_addr);
if(memcmp(&addr, &ipv6Addr->sin6_addr, sizeof(in6_addr)) == 0)
{
- index = if_nametoindex(curr->ifa_name);
+ index = static_cast<int>(if_nametoindex(curr->ifa_name));
break;
}
}
@@ -725,7 +725,7 @@ getInterfaceIndex(const string& intf)
struct sockaddr_in6* ipv6Addr = reinterpret_cast<struct sockaddr_in6*>(&ifr[i].ifr_addr);
if(memcmp(&addr, &ipv6Addr->sin6_addr, sizeof(in6_addr)) == 0)
{
- index = if_nametoindex(ifr[i].ifr_name);
+ index = static_cast<int>(if_nametoindex(ifr[i].ifr_name));
break;
}
}
@@ -736,7 +736,7 @@ getInterfaceIndex(const string& intf)
}
else // Look for an interface with the given name.
{
- index = if_nametoindex(name.c_str());
+ index = static_cast<int>(if_nametoindex(name.c_str()));
}
if(index <= 0)
{
@@ -1821,7 +1821,8 @@ IceInternal::inetAddrToString(const Address& ss)
char namebuf[1024];
namebuf[0] = '\0';
- getnameinfo(&ss.sa, size, namebuf, static_cast<socklen_t>(sizeof(namebuf)), 0, 0, NI_NUMERICHOST);
+ getnameinfo(&ss.sa, static_cast<socklen_t>(size), namebuf, static_cast<socklen_t>(sizeof(namebuf)), 0, 0,
+ NI_NUMERICHOST);
return string(namebuf);
#else
if(ss.host == nullptr)
@@ -2161,7 +2162,7 @@ IceInternal::setMcastGroup(SOCKET fd, const Address& group, const string& intf)
indexes.insert(index);
struct ipv6_mreq mreq;
mreq.ipv6mr_multiaddr = group.saIn6.sin6_addr;
- mreq.ipv6mr_interface = index;
+ mreq.ipv6mr_interface = static_cast<unsigned int>(index);
rc = setsockopt(fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, reinterpret_cast<char*>(&mreq), int(sizeof(mreq)));
}
}
@@ -2404,7 +2405,7 @@ IceInternal::doBind(SOCKET fd, const Address& addr, const string&)
int size = getAddressStorageSize(addr);
assert(size != 0);
- if(::bind(fd, &addr.sa, size) == SOCKET_ERROR)
+ if(::bind(fd, &addr.sa, static_cast<socklen_t>(size)) == SOCKET_ERROR)
{
closeSocketNoThrow(fd);
throw SocketException(__FILE__, __LINE__, getSocketErrno());
@@ -2626,7 +2627,7 @@ repeatConnect:
int size = getAddressStorageSize(addr);
assert(size != 0);
- if(::connect(fd, &addr.sa, size) == SOCKET_ERROR)
+ if(::connect(fd, &addr.sa, static_cast<socklen_t>(size)) == SOCKET_ERROR)
{
if(interrupted())
{
diff --git a/cpp/src/Ice/OutputStream.cpp b/cpp/src/Ice/OutputStream.cpp
index e316ec634f4..7493116de2d 100644
--- a/cpp/src/Ice/OutputStream.cpp
+++ b/cpp/src/Ice/OutputStream.cpp
@@ -42,7 +42,7 @@ public:
//
// Return unused bytes
//
- _stream.resize(firstUnused - _stream.b.begin());
+ _stream.resize(static_cast<size_t>(firstUnused - _stream.b.begin()));
}
//
@@ -255,8 +255,8 @@ Ice::OutputStream::write(const Byte* begin, const Byte* end)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz);
- memcpy(&b[pos], begin, sz);
+ resize(pos + static_cast<size_t>(sz));
+ memcpy(&b[pos], begin, static_cast<size_t>(sz));
}
}
@@ -268,7 +268,7 @@ Ice::OutputStream::write(const vector<bool>& v)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz);
+ resize(pos + static_cast<size_t>(sz));
copy(v.begin(), v.end(), b.begin() + pos);
}
}
@@ -281,9 +281,9 @@ struct WriteBoolHelper
{
static void write(const bool* begin, OutputStream::Container::size_type pos, OutputStream::Container& b, Int sz)
{
- for(int idx = 0; idx < sz; ++idx)
+ for(size_t idx = 0; idx < static_cast<size_t>(sz); ++idx)
{
- b[pos + idx] = static_cast<Byte>(*(begin + idx));
+ b[pos + idx] = static_cast<Byte>(*(begin + idx));
}
}
};
@@ -293,7 +293,7 @@ struct WriteBoolHelper<1>
{
static void write(const bool* begin, OutputStream::Container::size_type pos, OutputStream::Container& b, Int sz)
{
- memcpy(&b[pos], begin, sz);
+ memcpy(&b[pos], begin, static_cast<size_t>(sz));
}
};
@@ -307,7 +307,7 @@ Ice::OutputStream::write(const bool* begin, const bool* end)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz);
+ resize(pos + static_cast<size_t>(sz));
WriteBoolHelper<sizeof(bool)>::write(begin, pos, b, sz);
}
}
@@ -337,7 +337,7 @@ Ice::OutputStream::write(const Short* begin, const Short* end)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Short));
+ resize(pos + static_cast<size_t>(sz) * sizeof(Short));
#ifdef ICE_BIG_ENDIAN
const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Short) - 1;
Byte* dest = &(*(b.begin() + pos));
@@ -348,7 +348,7 @@ Ice::OutputStream::write(const Short* begin, const Short* end)
src += 2 * sizeof(Short);
}
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Short));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), static_cast<size_t>(sz) * sizeof(Short));
#endif
}
}
@@ -361,7 +361,7 @@ Ice::OutputStream::write(const Int* begin, const Int* end)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Int));
+ resize(pos + static_cast<size_t>(sz) * sizeof(Int));
#ifdef ICE_BIG_ENDIAN
const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Int) - 1;
Byte* dest = &(*(b.begin() + pos));
@@ -374,7 +374,7 @@ Ice::OutputStream::write(const Int* begin, const Int* end)
src += 2 * sizeof(Int);
}
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Int));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), static_cast<size_t>(sz) * sizeof(Int));
#endif
}
}
@@ -416,7 +416,7 @@ Ice::OutputStream::write(const Long* begin, const Long* end)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Long));
+ resize(pos + static_cast<size_t>(sz) * sizeof(Long));
#ifdef ICE_BIG_ENDIAN
const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Long) - 1;
Byte* dest = &(*(b.begin() + pos));
@@ -433,7 +433,7 @@ Ice::OutputStream::write(const Long* begin, const Long* end)
src += 2 * sizeof(Long);
}
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Long));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), static_cast<size_t>(sz) * sizeof(Long));
#endif
}
}
@@ -467,7 +467,7 @@ Ice::OutputStream::write(const Float* begin, const Float* end)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Float));
+ resize(pos + static_cast<size_t>(sz) * sizeof(Float));
#ifdef ICE_BIG_ENDIAN
const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Float) - 1;
Byte* dest = &(*(b.begin() + pos));
@@ -480,7 +480,7 @@ Ice::OutputStream::write(const Float* begin, const Float* end)
src += 2 * sizeof(Float);
}
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Float));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), static_cast<size_t>(sz) * sizeof(Float));
#endif
}
}
@@ -522,7 +522,7 @@ Ice::OutputStream::write(const Double* begin, const Double* end)
if(sz > 0)
{
Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Double));
+ resize(pos + static_cast<size_t>(sz) * sizeof(Double));
#ifdef ICE_BIG_ENDIAN
const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Double) - 1;
Byte* dest = &(*(b.begin() + pos));
@@ -539,7 +539,7 @@ Ice::OutputStream::write(const Double* begin, const Double* end)
src += 2 * sizeof(Double);
}
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Double));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), static_cast<size_t>(sz) * sizeof(Double));
#endif
}
}
@@ -605,7 +605,7 @@ Ice::OutputStream::writeConverted(const char* vdata, size_t vsize)
if(lastByte != b.end())
{
- resize(lastByte - b.begin());
+ resize(static_cast<size_t>(lastByte - b.begin()));
}
size_t lastIndex = b.size();
@@ -623,14 +623,14 @@ Ice::OutputStream::writeConverted(const char* vdata, size_t vsize)
// Use memmove instead of memcpy since the source and destination typically overlap.
//
resize(b.size() + 4);
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
+ memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
}
else if(guessedSize > 254 && actualSize <= 254)
{
//
// Move the UTF-8 sequence 4 bytes back
//
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
+ memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
resize(b.size() - 4);
}
@@ -700,7 +700,7 @@ Ice::OutputStream::write(const wstring& v)
if(lastByte != b.end())
{
- resize(lastByte - b.begin());
+ resize(static_cast<size_t>(lastByte - b.begin()));
}
size_t lastIndex = b.size();
@@ -718,14 +718,14 @@ Ice::OutputStream::write(const wstring& v)
// Use memmove instead of memcpy since the source and destination typically overlap.
//
resize(b.size() + 4);
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
+ memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
}
else if(guessedSize > 254 && actualSize <= 254)
{
//
// Move the UTF-8 sequence 4 bytes back
//
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
+ memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, static_cast<size_t>(actualSize));
resize(b.size() - 4);
}
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index e2ba9fdb923..db3ad7a5e63 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -237,7 +237,7 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
}
else
{
- interval = _retryIntervals[cnt - 1];
+ interval = _retryIntervals[static_cast<size_t>(cnt - 1)];
}
if(traceLevels->retry >= 1)
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp
index fcf016ac64a..7175eee5528 100644
--- a/cpp/src/Ice/ReferenceFactory.cpp
+++ b/cpp/src/Ice/ReferenceFactory.cpp
@@ -597,7 +597,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, InputStream* s)
if(sz > 0)
{
- endpoints.reserve(sz);
+ endpoints.reserve(static_cast<size_t>(sz));
while(sz--)
{
EndpointIPtr endpoint = _instance->endpointFactoryManager()->read(s);
diff --git a/cpp/src/Ice/SHA1.cpp b/cpp/src/Ice/SHA1.cpp
index e94c2ce2612..a1d79afa250 100644
--- a/cpp/src/Ice/SHA1.cpp
+++ b/cpp/src/Ice/SHA1.cpp
@@ -108,7 +108,7 @@ IceInternal::SHA1::Hasher::update(const unsigned char* data, size_t length)
throw IceUtil::SyscallException(__FILE__, __LINE__, GetLastError());
}
# elif defined(__APPLE__)
- CC_SHA1_Update(&_ctx, reinterpret_cast<const void*>(data), length);
+ CC_SHA1_Update(&_ctx, reinterpret_cast<const void*>(data), static_cast<CC_LONG>(length));
# else
SHA1_Update(&_ctx, reinterpret_cast<const void*>(data), length);
# endif
@@ -175,7 +175,7 @@ IceInternal::sha1(const unsigned char* data, size_t length, vector<unsigned char
hasher.finalize(md);
#elif defined(__APPLE__)
md.resize(CC_SHA1_DIGEST_LENGTH);
- CC_SHA1(&data[0], length, &md[0]);
+ CC_SHA1(&data[0], static_cast<CC_LONG>(length), &md[0]);
#else
md.resize(SHA_DIGEST_LENGTH);
::SHA1(&data[0], length, &md[0]);
diff --git a/cpp/src/Ice/Selector.cpp b/cpp/src/Ice/Selector.cpp
index 58f38e92506..0070f93fb3f 100644
--- a/cpp/src/Ice/Selector.cpp
+++ b/cpp/src/Ice/Selector.cpp
@@ -612,11 +612,11 @@ Selector::finishSelect(vector<pair<EventHandler*, SocketOperation> >& handlers)
((ev.events & (EPOLLOUT | EPOLLERR)) ?
SocketOperationWrite : SocketOperationNone));
#elif defined(ICE_USE_KQUEUE)
- struct kevent& ev = _events[i];
+ struct kevent& ev = _events[static_cast<size_t>(i)];
if(ev.flags & EV_ERROR)
{
Ice::Error out(_instance->initializationData().logger);
- out << "selector returned error:\n" << IceUtilInternal::errorToString(ev.data);
+ out << "selector returned error:\n" << IceUtilInternal::errorToString(static_cast<int>(ev.data));
continue;
}
p.first = reinterpret_cast<EventHandler*>(ev.udata);
@@ -729,11 +729,11 @@ Selector::select(int timeout)
struct timespec ts;
ts.tv_sec = timeout;
ts.tv_nsec = 0;
- _count = kevent(_queueFd, 0, 0, &_events[0], _events.size(), &ts);
+ _count = kevent(_queueFd, 0, 0, &_events[0], static_cast<int>(_events.size()), &ts);
}
else
{
- _count = kevent(_queueFd, 0, 0, &_events[0], _events.size(), 0);
+ _count = kevent(_queueFd, 0, 0, &_events[0], static_cast<int>(_events.size()), 0);
}
#elif defined(ICE_USE_SELECT)
fd_set* rFdSet = fdSetCopy(_selectedReadFdSet, _readFdSet);
@@ -807,7 +807,8 @@ void
Selector::updateSelector()
{
#if defined(ICE_USE_KQUEUE)
- int rs = kevent(_queueFd, &_changes[0], _changes.size(), &_changes[0], _changes.size(), &zeroTimeout);
+ int rs = kevent(_queueFd, &_changes[0], static_cast<int>(_changes.size()),
+ &_changes[0], static_cast<int>(_changes.size()), &zeroTimeout);
if(rs < 0)
{
Ice::Error out(_instance->initializationData().logger);
@@ -821,10 +822,12 @@ Selector::updateSelector()
// Check for errors, we ignore EINPROGRESS that started showing up with macOS Sierra
// and which occurs when another thread removes the FD from the kqueue (see ICE-7419).
//
- if(_changes[i].flags & EV_ERROR && _changes[i].data != EINPROGRESS)
+ if(_changes[static_cast<size_t>(i)].flags & EV_ERROR &&
+ _changes[static_cast<size_t>(i)].data != EINPROGRESS)
{
Ice::Error out(_instance->initializationData().logger);
- out << "error while updating selector:\n" << IceUtilInternal::errorToString(_changes[i].data);
+ out << "error while updating selector:\n"
+ << IceUtilInternal::errorToString(static_cast<int>(_changes[static_cast<size_t>(i)].data));
}
}
}
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index 9642c46617a..1ec6cb4dbf3 100644
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -1590,7 +1590,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
string message;
while((rs = read(fds[0], &s, 16)) > 0)
{
- message.append(s, rs);
+ message.append(s, static_cast<size_t>(rs));
}
if(argv[0])
@@ -1866,8 +1866,8 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
break;
}
}
- len -= n;
- pos += n;
+ len -= static_cast<size_t>(n);
+ pos += static_cast<size_t>(n);
}
close(fds[1]);
}
diff --git a/cpp/src/Ice/StreamSocket.cpp b/cpp/src/Ice/StreamSocket.cpp
index f335736f8ca..e3b41088347 100755
--- a/cpp/src/Ice/StreamSocket.cpp
+++ b/cpp/src/Ice/StreamSocket.cpp
@@ -178,7 +178,7 @@ StreamSocket::read(Buffer& buf)
{
while(true)
{
- ssize_t ret = read(reinterpret_cast<char*>(&*buf.i), buf.b.end() - buf.i);
+ ssize_t ret = read(reinterpret_cast<char*>(&*buf.i), static_cast<size_t>(buf.b.end() - buf.i));
if(ret == 0)
{
return SocketOperationRead;
@@ -191,7 +191,7 @@ StreamSocket::read(Buffer& buf)
}
}
}
- buf.i += read(reinterpret_cast<char*>(&*buf.i), buf.b.end() - buf.i);
+ buf.i += read(reinterpret_cast<char*>(&*buf.i), static_cast<size_t>(buf.b.end() - buf.i));
#endif
return buf.i != buf.b.end() ? SocketOperationRead : SocketOperationNone;
}
@@ -204,7 +204,7 @@ StreamSocket::write(Buffer& buf)
{
while(true)
{
- ssize_t ret = write(reinterpret_cast<const char*>(&*buf.i), buf.b.end() - buf.i);
+ ssize_t ret = write(reinterpret_cast<const char*>(&*buf.i), static_cast<size_t>(buf.b.end() - buf.i));
if(ret == 0)
{
return SocketOperationWrite;
@@ -217,7 +217,7 @@ StreamSocket::write(Buffer& buf)
}
}
}
- buf.i += write(reinterpret_cast<const char*>(&*buf.i), buf.b.end() - buf.i);
+ buf.i += write(reinterpret_cast<const char*>(&*buf.i), static_cast<size_t>(buf.b.end() - buf.i));
#endif
return buf.i != buf.b.end() ? SocketOperationWrite : SocketOperationNone;
}
@@ -272,7 +272,7 @@ StreamSocket::read(char* buf, size_t length)
buf += ret;
read += ret;
- length -= ret;
+ length -= static_cast<size_t>(ret);
if(packetSize > length)
{
@@ -339,7 +339,7 @@ StreamSocket::write(const char* buf, size_t length)
buf += ret;
sent += ret;
- length -= ret;
+ length -= static_cast<size_t>(ret);
if(packetSize > length)
{
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index 5d6b64cc058..4407ca72da0 100755
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -259,13 +259,21 @@ IceInternal::UdpTransceiver::read(Buffer& buf)
assert(buf.i == buf.b.begin());
assert(_fd != INVALID_SOCKET);
- const int packetSize = min(_maxPacketSize, _rcvSize - _udpOverhead);
+#ifdef _WIN32
+ int packetSize = min(_maxPacketSize, _rcvSize - _udpOverhead);
+#else
+ const size_t packetSize = static_cast<size_t>(min(_maxPacketSize, _rcvSize - _udpOverhead));
+#endif
buf.b.resize(packetSize);
buf.i = buf.b.begin();
repeat:
+#ifdef _WIN32
+ int ret;
+#else
ssize_t ret;
+#endif
if(_state == StateConnected)
{
ret = ::recv(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0);
@@ -341,7 +349,7 @@ repeat:
}
}
- buf.b.resize(ret);
+ buf.b.resize(static_cast<size_t>(ret));
buf.i = buf.b.end();
return SocketOperationNone;
#endif
diff --git a/cpp/src/Ice/WSTransceiver.cpp b/cpp/src/Ice/WSTransceiver.cpp
index 07ef68538f6..725b07c7249 100644
--- a/cpp/src/Ice/WSTransceiver.cpp
+++ b/cpp/src/Ice/WSTransceiver.cpp
@@ -588,11 +588,11 @@ IceInternal::WSTransceiver::read(Buffer& buf)
// no more than the payload length. The remaining of the buffer will be
// sent over in another frame.
//
- size_t readSz = _readPayloadLength - (buf.i - _readStart); // Already read
+ size_t readSz = _readPayloadLength - static_cast<size_t>(buf.i - _readStart); // Already read
if(static_cast<size_t>(buf.b.end() - buf.i) > readSz)
{
size_t size = buf.b.size();
- buf.b.resize(buf.i - buf.b.begin() + readSz);
+ buf.b.resize(static_cast<size_t>(buf.i - buf.b.begin()) + readSz);
s = _delegate->read(buf);
buf.b.resize(size);
}
@@ -1394,7 +1394,7 @@ IceInternal::WSTransceiver::preRead(Buffer& buf)
return false;
}
- size_t n = min(_readBuffer.i - _readI, buf.b.end() - buf.i);
+ size_t n = min(static_cast<size_t>(_readBuffer.i - _readI), static_cast<size_t>(buf.b.end() - buf.i));
if(n > _readPayloadLength)
{
@@ -1435,13 +1435,13 @@ IceInternal::WSTransceiver::postRead(Buffer& buf)
// Unmask the data we just read.
//
IceInternal::Buffer::Container::iterator p = _readStart;
- for(size_t n = _readStart - _readFrameStart; p < buf.i; ++p, ++n)
+ for(size_t n = static_cast<size_t>(_readStart - _readFrameStart); p < buf.i; ++p, ++n)
{
*p ^= _readMask[n % 4];
}
}
- _readPayloadLength -= buf.i - _readStart;
+ _readPayloadLength -= static_cast<size_t>(buf.i - _readStart);
_readStart = buf.i;
if(_readPayloadLength == 0)
{
@@ -1474,7 +1474,7 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
{
prepareWriteHeader(OP_PING, 0); // Don't send any payload
- _writeBuffer.b.resize(_writeBuffer.i - _writeBuffer.b.begin());
+ _writeBuffer.b.resize(static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin()));
_writeState = WriteStateControlFrame;
_writeBuffer.i = _writeBuffer.b.begin();
}
@@ -1483,7 +1483,7 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
prepareWriteHeader(OP_PONG, _pingPayload.size());
if(_pingPayload.size() > static_cast<size_t>(_writeBuffer.b.end() - _writeBuffer.i))
{
- size_t pos = _writeBuffer.i - _writeBuffer.b.begin();
+ size_t pos = static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin());
_writeBuffer.b.resize(pos + _pingPayload.size());
_writeBuffer.i = _writeBuffer.b.begin() + pos;
}
@@ -1491,7 +1491,7 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
_writeBuffer.i += _pingPayload.size();
_pingPayload.clear();
- _writeBuffer.b.resize(_writeBuffer.i - _writeBuffer.b.begin());
+ _writeBuffer.b.resize(static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin()));
_writeState = WriteStateControlFrame;
_writeBuffer.i = _writeBuffer.b.begin();
}
@@ -1513,7 +1513,7 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
}
_writeState = WriteStateControlFrame;
- _writeBuffer.b.resize(_writeBuffer.i - _writeBuffer.b.begin());
+ _writeBuffer.b.resize(static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin()));
_writeBuffer.i = _writeBuffer.b.begin();
}
else
@@ -1543,7 +1543,7 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
_writeBuffer.i = _writeBuffer.b.begin();
}
- size_t n = buf.i - buf.b.begin();
+ size_t n = static_cast<size_t>(buf.i - buf.b.begin());
for(; n < buf.b.size() && _writeBuffer.i < _writeBuffer.b.end(); ++_writeBuffer.i, ++n)
{
*_writeBuffer.i = buf.b[n] ^ _writeMask[n % 4];
@@ -1551,20 +1551,21 @@ IceInternal::WSTransceiver::preWrite(Buffer& buf)
_writePayloadLength = n;
if(_writeBuffer.i < _writeBuffer.b.end())
{
- _writeBuffer.b.resize(_writeBuffer.i - _writeBuffer.b.begin());
+ _writeBuffer.b.resize(static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin()));
}
_writeBuffer.i = _writeBuffer.b.begin();
}
else if(_writePayloadLength == 0)
{
- size_t n = min(_writeBuffer.b.end() - _writeBuffer.i, buf.b.end() - buf.i);
+ size_t n = min(static_cast<size_t>(_writeBuffer.b.end() - _writeBuffer.i),
+ static_cast<size_t>(buf.b.end() - buf.i));
memcpy(_writeBuffer.i, buf.i, n);
_writeBuffer.i += n;
buf.i += n;
_writePayloadLength = n;
if(_writeBuffer.i < _writeBuffer.b.end())
{
- _writeBuffer.b.resize(_writeBuffer.i - _writeBuffer.b.begin());
+ _writeBuffer.b.resize(static_cast<size_t>(_writeBuffer.i - _writeBuffer.b.begin()));
}
_writeBuffer.i = _writeBuffer.b.begin();
}
@@ -1670,7 +1671,7 @@ IceInternal::WSTransceiver::readBuffered(IceInternal::Buffer::Container::size_ty
}
else
{
- IceInternal::Buffer::Container::size_type available = _readBuffer.i - _readI;
+ size_t available = static_cast<size_t>(_readBuffer.i - _readI);
if(available < sz)
{
if(_readI != &_readBuffer.b[0])
@@ -1728,7 +1729,7 @@ IceInternal::WSTransceiver::prepareWriteHeader(Byte opCode, IceInternal::Buffer:
// Use an extra 64 bits to encode the payload length.
//
*_writeBuffer.i++ = static_cast<Byte>(127);
- ice_htonll(payloadLength, _writeBuffer.i);
+ ice_htonll(static_cast<Long>(payloadLength), _writeBuffer.i);
_writeBuffer.i += 8;
}
diff --git a/cpp/src/IceDB/IceDB.cpp b/cpp/src/IceDB/IceDB.cpp
index bce0ab96f0e..03701eff884 100644
--- a/cpp/src/IceDB/IceDB.cpp
+++ b/cpp/src/IceDB/IceDB.cpp
@@ -165,7 +165,8 @@ Env::Env(const string& path, MDB_dbi maxDbs, size_t mapSize, unsigned int maxRea
GetSystemInfo(&si);
pageSize = si.dwPageSize;
#else
- pageSize = sysconf(_SC_PAGESIZE);
+ long sz = sysconf(_SC_PAGESIZE);
+ pageSize = static_cast<size_t>(sz == -1 ? 4096 : sz);
#endif
size_t remainder = mapSize % pageSize;
if(remainder != 0)
@@ -194,7 +195,7 @@ Env::Env(const string& path, MDB_dbi maxDbs, size_t mapSize, unsigned int maxRea
throw LMDBException(__FILE__, __LINE__, rc);
}
- size_t envMaxKeySize = mdb_env_get_maxkeysize(_menv);
+ size_t envMaxKeySize = static_cast<size_t>(mdb_env_get_maxkeysize(_menv));
if(maxKeySize > envMaxKeySize)
{
throw BadEnvException(__FILE__, __LINE__, envMaxKeySize);
@@ -497,5 +498,5 @@ IceDB::getMapSize(int configValue)
const size_t defaultMapSize = 100;
#endif
- return ((configValue <= 0) ? defaultMapSize : configValue) * 1024 * 1024;
+ return ((configValue <= 0) ? defaultMapSize : static_cast<size_t>(configValue)) * 1024 * 1024;
}
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index a1d8657d510..46832e71757 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -644,14 +644,14 @@ Activator::activate(const string& name,
groups.resize(20);
int ngroups = static_cast<int>(groups.size());
#if defined(__APPLE__)
- if(getgrouplist(pw->pw_name, gid, reinterpret_cast<int*>(&groups[0]), &ngroups) < 0)
+ if(getgrouplist(pw->pw_name, static_cast<int>(gid), reinterpret_cast<int*>(&groups[0]), &ngroups) < 0)
#else
if(getgrouplist(pw->pw_name, gid, &groups[0], &ngroups) < 0)
#endif
{
- groups.resize(ngroups);
+ groups.resize(static_cast<size_t>(ngroups));
#if defined(__APPLE__)
- getgrouplist(pw->pw_name, gid, reinterpret_cast<int*>(&groups[0]), &ngroups);
+ getgrouplist(pw->pw_name, static_cast<int>(gid), reinterpret_cast<int*>(&groups[0]), &ngroups);
#else
getgrouplist(pw->pw_name, gid, &groups[0], &ngroups);
#endif
@@ -716,7 +716,7 @@ Activator::activate(const string& name,
//
// Don't initialize supplementary groups if we are not running as root.
//
- if(getuid() == 0 && setgroups(groups.size(), &groups[0]) == -1)
+ if(getuid() == 0 && setgroups(static_cast<int>(groups.size()), &groups[0]) == -1)
{
ostringstream os;
os << pw->pw_name;
@@ -811,7 +811,7 @@ Activator::activate(const string& name,
string message;
while((rs = read(errorFds[0], &s, 16)) > 0)
{
- message.append(s, rs);
+ message.append(s, static_cast<size_t>(rs));
}
//
@@ -1303,7 +1303,7 @@ Activator::terminationListener()
//
while((rs = read(fd, &s, 16)) > 0)
{
- message.append(s, rs);
+ message.append(s, static_cast<size_t>(rs));
}
//
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index 818f75d640a..de67ae58543 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -630,9 +630,9 @@ ReplicaGroupEntry::getLocatorAdapterInfo(LocatorAdapterInfoSeq& adapters, int& n
wait();
}
_requestInProgress = true;
- for(unsigned int i = 0; i < _replicas.size(); ++i)
+ for(size_t i = 0; i < _replicas.size(); ++i)
{
- replicas.push_back(_replicas[(_lastReplica + i) % _replicas.size()]);
+ replicas.push_back(_replicas[(static_cast<size_t>(_lastReplica) + i) % _replicas.size()]);
}
_lastReplica = (_lastReplica + 1) % static_cast<int>(_replicas.size());
roundRobin = true;
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index 6da67eb742e..df817c3e6d7 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -209,7 +209,7 @@ getPassword(const string& prompt)
struct termios newConf;
tcgetattr(0, &oldConf);
newConf = oldConf;
- newConf.c_lflag &= (~ECHO);
+ newConf.c_lflag &= static_cast<tcflag_t>(~(ECHO));
tcsetattr(0, TCSANOW, &newConf);
getline(cin, password);
tcsetattr(0, TCSANOW, &oldConf);
diff --git a/cpp/src/IceGrid/FileCache.cpp b/cpp/src/IceGrid/FileCache.cpp
index a93bca5440d..565e7896e62 100644
--- a/cpp/src/IceGrid/FileCache.cpp
+++ b/cpp/src/IceGrid/FileCache.cpp
@@ -174,7 +174,7 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
if(totalSize + 5 < size)
{
// There's some room left for a part of the string, return a partial string
- line = line.substr(0, size - totalSize - 5);
+ line = line.substr(0, static_cast<size_t>(size - totalSize - 5));
lines.push_back(line);
newOffset += line.size();
}
diff --git a/cpp/src/IceGrid/Grammar.cpp b/cpp/src/IceGrid/Grammar.cpp
index 652495f2296..93a23d12f24 100644
--- a/cpp/src/IceGrid/Grammar.cpp
+++ b/cpp/src/IceGrid/Grammar.cpp
@@ -91,6 +91,14 @@
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
using namespace std;
using namespace Ice;
using namespace IceGrid;
diff --git a/cpp/src/IceGrid/Grammar.y b/cpp/src/IceGrid/Grammar.y
index 1c4c5b1ec40..ce7a88bca7f 100644
--- a/cpp/src/IceGrid/Grammar.y
+++ b/cpp/src/IceGrid/Grammar.y
@@ -25,6 +25,14 @@
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
using namespace std;
using namespace Ice;
using namespace IceGrid;
diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp
index a66a5e037c3..ae21fa49175 100644
--- a/cpp/src/IceGrid/LocatorI.cpp
+++ b/cpp/src/IceGrid/LocatorI.cpp
@@ -233,7 +233,7 @@ public:
_encoding(encoding),
_adapters(adapters),
_traceLevels(locator->getTraceLevels()),
- _count(count),
+ _count(static_cast<unsigned int>(count)),
_lastAdapter(_adapters.begin())
{
assert(_adapters.empty() || _count > 0);
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 62401c15c63..ca9c6d24121 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -2599,12 +2599,12 @@ ServerI::checkAndUpdateUser(const InternalServerDescriptorPtr& desc, bool /*upda
// Get the uid/gid associated with the given user.
//
struct passwd pwbuf;
- int sz = sysconf(_SC_GETPW_R_SIZE_MAX);
+ long sz = sysconf(_SC_GETPW_R_SIZE_MAX);
if(sz == -1)
{
sz = 4096;
}
- vector<char> buffer(sz);
+ vector<char> buffer(static_cast<size_t>(sz));
struct passwd *pw;
int err = getpwnam_r(user.c_str(), &pwbuf, &buffer[0], buffer.size(), &pw);
while(err == ERANGE && buffer.size() < 1024 * 1024) // Limit buffer to 1MB
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp
index e63ff51781e..dc9b1cbc838 100644
--- a/cpp/src/IcePatch2/Client.cpp
+++ b/cpp/src/IcePatch2/Client.cpp
@@ -186,7 +186,7 @@ private:
{
termios term;
memcpy(&term, &_savedTerm, sizeof(termios));
- term.c_lflag &= ~(ECHO | ICANON);
+ term.c_lflag &= static_cast<tcflag_t>(~(ECHO | ICANON));
term.c_cc[VTIME] = 0;
term.c_cc[VMIN] = 1;
tcsetattr(0, TCSANOW, &term);
diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp
index f04e9319fa0..c1f57236027 100644
--- a/cpp/src/IcePatch2/FileServerI.cpp
+++ b/cpp/src/IcePatch2/FileServerI.cpp
@@ -43,7 +43,7 @@ IcePatch2::FileServerI::getLargeFileInfoSeq(Int node0, const Current&) const
throw PartitionOutOfRangeException();
}
- return _tree0.nodes[node0].files;
+ return _tree0.nodes[static_cast<size_t>(node0)].files;
}
ByteSeqSeq
@@ -51,7 +51,7 @@ IcePatch2::FileServerI::getChecksumSeq(const Current&) const
{
ByteSeqSeq checksums(256);
- for(int node0 = 0; node0 < 256; ++node0)
+ for(size_t node0 = 0; node0 < 256; ++node0)
{
checksums[node0] = _tree0.nodes[node0].checksum;
}
@@ -176,7 +176,7 @@ IcePatch2::FileServerI::getFileCompressedInternal(const std::string& pa, Ice::Lo
IceUtilInternal::errorToString(errno));
}
- buffer.resize(num);
+ buffer.resize(static_cast<size_t>(num));
#ifdef _WIN32
int r;
if((r = _read(fd, &buffer[0], static_cast<unsigned int>(num))) == -1)
diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp
index 4e97d3a502e..134fd1c2888 100644
--- a/cpp/src/IcePatch2Lib/ClientUtil.cpp
+++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp
@@ -341,15 +341,15 @@ PatcherI::prepare()
AsyncResultPtr nxtCB;
try
{
- for(int node0 = 0; node0 < 256; ++node0)
+ for(size_t node0 = 0; node0 < 256; ++node0)
{
if(tree0.nodes[node0].checksum != checksumSeq[node0])
{
if(!curCB)
{
assert(!nxtCB);
- curCB = _useSmallFileAPI ? _serverCompress->begin_getFileInfoSeq(node0) :
- _serverCompress->begin_getLargeFileInfoSeq(node0);
+ curCB = _useSmallFileAPI ? _serverCompress->begin_getFileInfoSeq(static_cast<Int>(node0)) :
+ _serverCompress->begin_getLargeFileInfoSeq(static_cast<Int>(node0));
}
else
{
@@ -357,7 +357,7 @@ PatcherI::prepare()
swap(nxtCB, curCB);
}
- int node0Nxt = node0;
+ size_t node0Nxt = node0;
do
{
@@ -367,8 +367,9 @@ PatcherI::prepare()
if(node0Nxt < 256)
{
- nxtCB = _useSmallFileAPI ? _serverCompress->begin_getFileInfoSeq(node0Nxt) :
- _serverCompress->begin_getLargeFileInfoSeq(node0Nxt);
+ nxtCB = _useSmallFileAPI ?
+ _serverCompress->begin_getFileInfoSeq(static_cast<Int>(node0Nxt)) :
+ _serverCompress->begin_getLargeFileInfoSeq(static_cast<Int>(node0Nxt));
}
LargeFileInfoSeq files;
@@ -434,7 +435,7 @@ PatcherI::prepare()
FileInfoLess());
}
- if(!_feedback->fileListProgress((node0 + 1) * 100 / 256))
+ if(!_feedback->fileListProgress(static_cast<Int>(node0 + 1) * 100 / 256))
{
return false;
}
@@ -859,7 +860,7 @@ PatcherI::updateFilesInternal(const LargeFileInfoSeq& files, const DecompressorP
// 'bytes' is always returned with size '_chunkSize'. When a file is smaller than '_chunkSize'
// or we are reading the last chunk of a file, 'bytes' will be larger than necessary. In this
// case we calculate the current position and updated size based on the known file size.
- size_t size = (pos + bytes.size()) > static_cast<size_t>(p->size) ?
+ size_t size = (static_cast<size_t>(pos) + bytes.size()) > static_cast<size_t>(p->size) ?
static_cast<size_t>(p->size - pos) : bytes.size();
pos += size;
diff --git a/cpp/src/IcePatch2Lib/Util.cpp b/cpp/src/IcePatch2Lib/Util.cpp
index 9bde18f915b..6080dd44558 100644
--- a/cpp/src/IcePatch2Lib/Util.cpp
+++ b/cpp/src/IcePatch2Lib/Util.cpp
@@ -159,7 +159,7 @@ IcePatch2Internal::stringToBytes(const string& str)
ByteSeq bytes;
bytes.reserve((str.size() + 1) / 2);
- for(unsigned int i = 0; i + 1 < str.size(); i += 2)
+ for(size_t i = 0; i + 1 < str.size(); i += 2)
{
/*
istringstream is(str.substr(i, 2));
@@ -169,7 +169,7 @@ IcePatch2Internal::stringToBytes(const string& str)
int byte = 0;
- for(int j = 0; j < 2; ++j)
+ for(size_t j = 0; j < 2; ++j)
{
char c = str[i + j];
@@ -500,7 +500,8 @@ IcePatch2Internal::readDirectory(const string& pa)
}
StringSeq result;
- result.reserve(n - 2);
+ assert(n >= 2);
+ result.reserve(static_cast<size_t>(n - 2));
for(int i = 0; i < n; ++i)
{
@@ -591,7 +592,8 @@ IcePatch2Internal::compressBytesToFile(const string& pa, const ByteSeq& bytes, I
throw runtime_error(reason);
}
- BZ2_bzWrite(&bzError, bzFile, const_cast<Byte*>(&bytes[pos]), static_cast<int>(bytes.size() - pos));
+ BZ2_bzWrite(&bzError, bzFile, const_cast<Byte*>(&bytes[static_cast<size_t>(pos)]),
+ static_cast<int>(bytes.size()) - pos);
if(bzError != BZ_OK)
{
string reason = "BZ2_bzWrite failed";
@@ -679,7 +681,7 @@ IcePatch2Internal::decompressFile(const string& pa)
throw runtime_error("cannot get read position for `" + pathBZ2 + "':\n" + IceUtilInternal::lastErrorToString());
}
- if(fwrite(bytesBZ2, sz, 1, fp) != 1)
+ if(fwrite(bytesBZ2, static_cast<size_t>(sz), 1, fp) != 1)
{
throw runtime_error("cannot write to `" + path + "':\n" + IceUtilInternal::lastErrorToString());
}
@@ -879,7 +881,7 @@ getFileInfoSeqInternal(const string& basePath, const string& relPath, int compre
ByteSeq bytesSHA;
- if(relPath.size() + buf.st_size == 0)
+ if(relPath.size() == 0 && buf.st_size == 0)
{
bytesSHA.resize(20);
fill(bytesSHA.begin(), bytesSHA.end(), Byte(0));
@@ -927,10 +929,10 @@ getFileInfoSeqInternal(const string& basePath, const string& relPath, int compre
}
}
- long bytesLeft = buf.st_size;
+ size_t bytesLeft = static_cast<size_t>(buf.st_size);
while(bytesLeft > 0)
{
- ByteSeq bytes(min(bytesLeft, 1024l*1024));
+ ByteSeq bytes(min(bytesLeft, static_cast<size_t>(1024 * 1024)));
if(
#if defined(_MSC_VER)
_read(fd, &bytes[0], static_cast<unsigned int>(bytes.size()))
@@ -1192,7 +1194,7 @@ IcePatch2Internal::getFileTree0(const LargeFileInfoSeq& infoSeq, FileTree0& tree
for(int i = 0; i < 256; ++i, c0 += 20)
{
- FileTree1& tree1 = tree0.nodes[i];
+ FileTree1& tree1 = tree0.nodes[static_cast<size_t>(i)];
tree1.files.clear();
tree1.checksum.resize(20);
diff --git a/cpp/src/IceSSL/SecureTransportCertificateI.cpp b/cpp/src/IceSSL/SecureTransportCertificateI.cpp
index 8ea6fb89f47..4e124c1202c 100644
--- a/cpp/src/IceSSL/SecureTransportCertificateI.cpp
+++ b/cpp/src/IceSSL/SecureTransportCertificateI.cpp
@@ -2,6 +2,12 @@
// Copyright (c) ZeroC, Inc. All rights reserved.
//
+//
+// Disable deprecation warnings for SecCertificateCopyNormalizedIssuerContent and
+// SecCertificateCopyNormalizedSubjectContent
+//
+#include <IceUtil/DisableWarnings.h>
+
#include <IceSSL/Plugin.h>
#include <IceSSL/SecureTransport.h>
#include <IceSSL/CertificateI.h>
@@ -293,8 +299,8 @@ getX509Name(SecCertificateRef cert, CFTypeRef key)
if(property)
{
CFArrayRef dn = static_cast<CFArrayRef>(CFDictionaryGetValue(property.get(), kSecPropertyKeyValue));
- int size = CFArrayGetCount(dn);
- for(int i = 0; i < size; ++i)
+ CFIndex size = CFArrayGetCount(dn);
+ for(CFIndex i = 0; i < size; ++i)
{
CFDictionaryRef dict = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(dn, i));
rdnPairs.push_front(make_pair(
@@ -317,9 +323,9 @@ getX509AltName(SecCertificateRef cert, CFTypeRef key)
if(property)
{
CFArrayRef names = static_cast<CFArrayRef>(CFDictionaryGetValue(property.get(), kSecPropertyKeyValue));
- int size = CFArrayGetCount(names);
+ CFIndex size = CFArrayGetCount(names);
- for(int i = 0; i < size; ++i)
+ for(CFIndex i = 0; i < size; ++i)
{
CFDictionaryRef dict = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(names, i));
@@ -341,7 +347,7 @@ getX509AltName(SecCertificateRef cert, CFTypeRef key)
{
CFArrayRef section = (CFArrayRef)v;
ostringstream os;
- for(int j = 0, count = CFArrayGetCount(section); j < count;)
+ for(CFIndex j = 0, count = CFArrayGetCount(section); j < count;)
{
CFDictionaryRef d = (CFDictionaryRef)CFArrayGetValueAtIndex(section, j);
@@ -453,8 +459,8 @@ SecureTransportCertificateI::getAuthorityKeyIdentifier() const
{
CFDataRef data = static_cast<CFDataRef>(
CFDictionaryGetValue(static_cast<CFDictionaryRef>(value), kSecPropertyKeyValue));
- keyid.resize(CFDataGetLength(data));
- memcpy(&keyid[0], CFDataGetBytePtr(data), CFDataGetLength(data));
+ keyid.resize(static_cast<size_t>(CFDataGetLength(data)));
+ memcpy(&keyid[0], CFDataGetBytePtr(data), static_cast<size_t>(CFDataGetLength(data)));
}
}
}
@@ -492,8 +498,8 @@ SecureTransportCertificateI::getSubjectKeyIdentifier() const
{
CFDataRef data = static_cast<CFDataRef>(
CFDictionaryGetValue(static_cast<CFDictionaryRef>(value), kSecPropertyKeyValue));
- keyid.resize(CFDataGetLength(data));
- memcpy(&keyid[0], CFDataGetBytePtr(data), CFDataGetLength(data));
+ keyid.resize(static_cast<size_t>(CFDataGetLength(data)));
+ memcpy(&keyid[0], CFDataGetBytePtr(data), static_cast<size_t>(CFDataGetLength(data)));
}
}
}
@@ -583,7 +589,8 @@ SecureTransportCertificateI::encode() const
{
throw CertificateEncodingException(__FILE__, __LINE__, sslErrorToString(err));
}
- return string(reinterpret_cast<const char*>(CFDataGetBytePtr(exported.get())), CFDataGetLength(exported.get()));
+ return string(reinterpret_cast<const char*>(CFDataGetBytePtr(exported.get())),
+ static_cast<size_t>(CFDataGetLength(exported.get())));
#endif
}
@@ -833,7 +840,7 @@ IceSSL::SecureTransport::Certificate::decode(const std::string& encoding)
UniqueRef<CFDataRef> data(
CFDataCreateWithBytesNoCopy(kCFAllocatorDefault,
reinterpret_cast<const UInt8*>(encoding.c_str()),
- encoding.size(), kCFAllocatorNull));
+ static_cast<CFIndex>(encoding.size()), kCFAllocatorNull));
SecExternalFormat format = kSecFormatUnknown;
SecExternalItemType type = kSecItemTypeCertificate;
diff --git a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp
index 7d33252b749..bbb7715e9f0 100644
--- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp
+++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp
@@ -212,8 +212,10 @@ IceSSL::SecureTransport::TransceiverI::initialize(IceInternal::Buffer& readBuffe
//
if(_delegate->getNativeInfo()->fd() != INVALID_SOCKET)
{
- _maxSendPacketSize = std::max(512, IceInternal::getSendBufferSize(_delegate->getNativeInfo()->fd()));
- _maxRecvPacketSize = std::max(512, IceInternal::getRecvBufferSize(_delegate->getNativeInfo()->fd()));
+ _maxSendPacketSize =
+ static_cast<size_t>(std::max(512, IceInternal::getSendBufferSize(_delegate->getNativeInfo()->fd())));
+ _maxRecvPacketSize =
+ static_cast<size_t>(std::max(512, IceInternal::getRecvBufferSize(_delegate->getNativeInfo()->fd())));
}
else
{
@@ -289,7 +291,7 @@ IceSSL::SecureTransport::TransceiverI::initialize(IceInternal::Buffer& readBuffe
throw ProtocolException(__FILE__, __LINE__, os.str());
}
- for(int i = 0, count = SecTrustGetCertificateCount(_trust.get()); i < count; ++i)
+ for(CFIndex i = 0, count = SecTrustGetCertificateCount(_trust.get()); i < count; ++i)
{
SecCertificateRef cert = SecTrustGetCertificateAtIndex(_trust.get(), i);
CFRetain(cert);
@@ -583,7 +585,7 @@ IceSSL::SecureTransport::TransceiverI::writeRaw(const char* data, size_t* length
IceInternal::SocketOperation op = _delegate->write(buf);
if(op == IceInternal::SocketOperationWrite)
{
- *length = buf.i - buf.b.begin();
+ *length = static_cast<size_t>(buf.i - buf.b.begin());
_tflags |= SSLWantWrite;
return errSSLWouldBlock;
}
@@ -616,7 +618,7 @@ IceSSL::SecureTransport::TransceiverI::readRaw(char* data, size_t* length) const
IceInternal::SocketOperation op = _delegate->read(buf);
if(op == IceInternal::SocketOperationRead)
{
- *length = buf.i - buf.b.begin();
+ *length = static_cast<size_t>(buf.i - buf.b.begin());
_tflags |= SSLWantRead;
return errSSLWouldBlock;
}
diff --git a/cpp/src/IceSSL/SecureTransportUtil.cpp b/cpp/src/IceSSL/SecureTransportUtil.cpp
index a3ae427d516..fbf7ebd53d1 100644
--- a/cpp/src/IceSSL/SecureTransportUtil.cpp
+++ b/cpp/src/IceSSL/SecureTransportUtil.cpp
@@ -36,12 +36,13 @@ readCertFile(const string& file)
}
is.seekg(0, is.end);
- size_t size = is.tellg();
+ size_t size = static_cast<size_t>(is.tellg());
is.seekg(0, is.beg);
- UniqueRef<CFMutableDataRef> data(CFDataCreateMutable(kCFAllocatorDefault, size));
- CFDataSetLength(data.get(), size);
- is.read(reinterpret_cast<char*>(CFDataGetMutableBytePtr(data.get())), size);
+ UniqueRef<CFMutableDataRef> data(CFDataCreateMutable(kCFAllocatorDefault, static_cast<CFIndex>(size)));
+ CFDataSetLength(data.get(), static_cast<CFIndex>(size));
+ is.read(reinterpret_cast<char*>(CFDataGetMutableBytePtr(data.get())),
+ static_cast<streamsize>(size));
if(!is.good())
{
throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file);
@@ -112,7 +113,7 @@ isCA(SecCertificateRef cert)
if(property)
{
CFArrayRef propertyValues = static_cast<CFArrayRef>(CFDictionaryGetValue(property.get(), kSecPropertyKeyValue));
- for(int i = 0, size = CFArrayGetCount(propertyValues); i < size; ++i)
+ for(CFIndex i = 0, size = CFArrayGetCount(propertyValues); i < size; ++i)
{
CFDictionaryRef dict = static_cast<CFDictionaryRef>(CFArrayGetValueAtIndex(propertyValues, i));
CFStringRef label = static_cast<CFStringRef>(CFDictionaryGetValue(dict, kSecPropertyKeyLabel));
@@ -243,7 +244,7 @@ openKeychain(const std::string& path, const std::string& keychainPassword)
if(err == noErr)
{
const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str();
- if((err = SecKeychainUnlock(keychain.get(), keychainPassword.size(), pass, pass != 0)))
+ if((err = SecKeychainUnlock(keychain.get(), static_cast<UInt32>(keychainPassword.size()), pass, pass != 0)))
{
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: unable to unlock keychain:\n" + sslErrorToString(err));
@@ -253,7 +254,8 @@ openKeychain(const std::string& path, const std::string& keychainPassword)
{
const char* pass = keychainPassword.empty() ? 0 : keychainPassword.c_str();
keychain.reset(0);
- if((err = SecKeychainCreate(keychainPath.c_str(), keychainPassword.size(), pass, pass == 0, 0, &keychain.get())))
+ if((err = SecKeychainCreate(keychainPath.c_str(),
+ static_cast<UInt32>(keychainPassword.size()), pass, pass == 0, 0, &keychain.get())))
{
throw PluginInitializationException(__FILE__, __LINE__,
"IceSSL: unable to create keychain:\n" + sslErrorToString(err));
@@ -354,9 +356,9 @@ loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRef keycha
// private key into the keychain and add the certificate.
//
UniqueRef<CFArrayRef> items(loadKeychainItems(file, kSecItemTypePrivateKey, keychain, password, prompt, retryMax));
- int count = CFArrayGetCount(items.get());
+ CFIndex count = CFArrayGetCount(items.get());
UniqueRef<SecKeyRef> key;
- for(int i = 0; i < count; ++i)
+ for(CFIndex i = 0; i < count; ++i)
{
SecKeychainItemRef itemRef =
static_cast<SecKeychainItemRef>(const_cast<void*>(CFArrayGetValueAtIndex(items.get(), 0)));
@@ -405,7 +407,7 @@ loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRef keycha
SecKeychainAttribute attr;
attr.tag = kSecKeyLabel;
attr.data = const_cast<UInt8*>(CFDataGetBytePtr(hash.get()));
- attr.length = CFDataGetLength(hash.get());
+ attr.length = static_cast<UInt32>(CFDataGetLength(hash.get()));
attributes.push_back(attr);
}
@@ -421,13 +423,13 @@ loadPrivateKey(const string& file, SecCertificateRef cert, SecKeychainRef keycha
SecKeychainAttribute attr;
attr.tag = kSecKeyPrintName;
attr.data = const_cast<char*>(label.c_str());
- attr.length = label.size();
+ attr.length = static_cast<UInt32>(label.size());
attributes.push_back(attr);
}
SecKeychainAttributeList attrs;
attrs.attr = &attributes[0];
- attrs.count = attributes.size();
+ attrs.count = static_cast<UInt32>(attributes.size());
SecKeychainItemModifyAttributesAndData(reinterpret_cast<SecKeychainItemRef>(key.get()), &attrs, 0, 0);
UniqueRef<SecIdentityRef> identity;
@@ -637,7 +639,7 @@ IceSSL::SecureTransport::loadCACertificates(const string& file)
#else
UniqueRef<CFArrayRef> items(loadKeychainItems(file, kSecItemTypeCertificate, 0, "", 0, 0));
UniqueRef<CFArrayRef> certificateAuthorities(CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks));
- int count = CFArrayGetCount(items.get());
+ CFIndex count = CFArrayGetCount(items.get());
for(CFIndex i = 0; i < count; ++i)
{
SecCertificateRef cert =
@@ -760,7 +762,7 @@ IceSSL::SecureTransport::findCertificateChain(const std::string& keychainPath,
{
throw PluginInitializationException(__FILE__, __LINE__, "IceSSL: invalid value `" + value + "'");
}
- UniqueRef<CFDataRef> v(CFDataCreate(kCFAllocatorDefault, &buffer[0], buffer.size()));
+ UniqueRef<CFDataRef> v(CFDataCreate(kCFAllocatorDefault, &buffer[0], static_cast<CFIndex>(buffer.size())));
CFDictionarySetValue(query.get(), field == "SUBJECTKEYID" ? kSecAttrSubjectKeyID : kSecAttrSerialNumber,
v.get());
valid = true;
@@ -800,7 +802,7 @@ IceSSL::SecureTransport::findCertificateChain(const std::string& keychainPath,
"IceSSL: error evaluating trust:\n" + sslErrorToString(err));
}
- int chainLength = SecTrustGetCertificateCount(trust.get());
+ CFIndex chainLength = SecTrustGetCertificateCount(trust.get());
UniqueRef<CFArrayRef> items(CFArrayCreateMutable(kCFAllocatorDefault, chainLength, &kCFTypeArrayCallBacks));
for(int i = 0; i < chainLength; ++i)
{
diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp
index 0d04ab423cd..e5832d8487a 100755
--- a/cpp/src/IceSSL/Util.cpp
+++ b/cpp/src/IceSSL/Util.cpp
@@ -36,8 +36,8 @@ IceSSL::fromCFString(CFStringRef v)
{
CFIndex size = CFStringGetMaximumSizeForEncoding(CFStringGetLength(v), kCFStringEncodingUTF8);
vector<char> buffer;
- buffer.resize(size + 1);
- CFStringGetCString(v, &buffer[0], buffer.size(), kCFStringEncodingUTF8);
+ buffer.resize(static_cast<size_t>(size + 1));
+ CFStringGetCString(v, &buffer[0], static_cast<CFIndex>(buffer.size()), kCFStringEncodingUTF8);
s.assign(&buffer[0]);
}
return s;
@@ -118,12 +118,12 @@ IceSSL::readFile(const string& file, vector<char>& buffer)
}
is.seekg(0, is.end);
- buffer.resize(static_cast<int>(is.tellg()));
+ buffer.resize(static_cast<size_t>(is.tellg()));
is.seekg(0, is.beg);
if(!buffer.empty())
{
- is.read(&buffer[0], buffer.size());
+ is.read(&buffer[0], static_cast<streamsize>(buffer.size()));
if(!is.good())
{
throw CertificateReadException(__FILE__, __LINE__, "error reading file " + file);
diff --git a/cpp/src/IceStorm/Grammar.cpp b/cpp/src/IceStorm/Grammar.cpp
index f1207cb59a6..0673c7b9e2d 100644
--- a/cpp/src/IceStorm/Grammar.cpp
+++ b/cpp/src/IceStorm/Grammar.cpp
@@ -91,6 +91,14 @@
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
using namespace std;
using namespace Ice;
using namespace IceStorm;
diff --git a/cpp/src/IceStorm/Grammar.y b/cpp/src/IceStorm/Grammar.y
index 2de164d74b3..d7b08996419 100644
--- a/cpp/src/IceStorm/Grammar.y
+++ b/cpp/src/IceStorm/Grammar.y
@@ -25,6 +25,14 @@
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
using namespace std;
using namespace Ice;
using namespace IceStorm;
diff --git a/cpp/src/IceStorm/IceStormDB.cpp b/cpp/src/IceStorm/IceStormDB.cpp
index 7eb11018ce0..ccd7d0e3d7f 100644
--- a/cpp/src/IceStorm/IceStormDB.cpp
+++ b/cpp/src/IceStorm/IceStormDB.cpp
@@ -316,7 +316,7 @@ run(const Ice::StringSeq& args)
<< endl;
return 1;
}
- fs.write(reinterpret_cast<const char*>(stream.b.begin()), stream.b.size());
+ fs.write(reinterpret_cast<const char*>(stream.b.begin()), static_cast<streamsize>(stream.b.size()));
fs.close();
}
}
diff --git a/cpp/src/IceStorm/NodeI.cpp b/cpp/src/IceStorm/NodeI.cpp
index 78c4c04cbc3..48563f2f701 100644
--- a/cpp/src/IceStorm/NodeI.cpp
+++ b/cpp/src/IceStorm/NodeI.cpp
@@ -207,7 +207,8 @@ NodeI::start()
Lock sync(*this);
_checkTask = new CheckTask(this);
- _timer->schedule(_checkTask, IceUtil::Time::seconds((_nodes.size() - _id) * 2));
+ _timer->schedule(_checkTask,
+ IceUtil::Time::seconds(static_cast<IceUtil::Int64>(_nodes.size() - static_cast<size_t>(_id)) * 2));
recovery();
}
@@ -660,7 +661,7 @@ NodeI::mergeContinue()
{
map<int, NodePrx>::const_iterator node = _nodes.find(p->id);
assert(node != _nodes.end());
- node->second->ready(_id, gp, _replicaProxy, max, maxllu.generation);
+ node->second->ready(_id, gp, _replicaProxy, static_cast<Ice::Int>(max), maxllu.generation);
}
catch(const Ice::Exception& ex)
{
@@ -773,7 +774,7 @@ NodeI::invitation(int j, const string& gn, const Ice::Current&)
_coord = j;
_group = gn;
- max = _max;
+ max = static_cast<Ice::Int>(_max);
}
Ice::IntSeq forwardedInvites;
@@ -852,7 +853,7 @@ NodeI::ready(int j, const string& gn, const Ice::ObjectPrx& coordinator, int max
if(static_cast<unsigned int>(max) > _max)
{
- _max = max;
+ _max = static_cast<unsigned int>(max);
}
_generation = generation;
@@ -888,7 +889,7 @@ NodeI::accept(int j, const string& gn, const Ice::IntSeq& forwardedInvites, cons
if(static_cast<unsigned int>(max) > _max)
{
- _max = max;
+ _max = static_cast<unsigned int>(max);
}
if(_traceLevels->election > 0)
@@ -979,7 +980,7 @@ NodeI::query(const Ice::Current&) const
info.group = _group;
info.replica = _replicaProxy;
info.state = _state;
- info.max = _max;
+ info.max = static_cast<Ice::Int>(_max);
for(set<GroupNodeInfo>::const_iterator p = _up.begin(); p != _up.end(); ++p)
{
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp
index c68c8a721af..2462ad9b17c 100644
--- a/cpp/src/IceUtil/FileUtil.cpp
+++ b/cpp/src/IceUtil/FileUtil.cpp
@@ -379,7 +379,7 @@ IceUtilInternal::rmdir(const string& path)
int
IceUtilInternal::mkdir(const string& path, int perm)
{
- return ::mkdir(path.c_str(), perm);
+ return ::mkdir(path.c_str(), static_cast<mode_t>(perm));
}
FILE*
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index 2f9d228cf72..e1b6babedcd 100644
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -431,7 +431,7 @@ IceUtilInternal::Options::split(const string& line)
j < i + 3 && j < l.size() && octalDigits.find_first_of(c = l[j]) != string::npos;
++j)
{
- us = us * 8 + c - '0';
+ us = us * 8 + static_cast<unsigned short>(c - '0');
}
i = j - 1;
arg.push_back(static_cast<char>(us));
diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp
index 7f639f2e89f..b0b9b0190c4 100644
--- a/cpp/src/IceUtil/Random.cpp
+++ b/cpp/src/IceUtil/Random.cpp
@@ -147,7 +147,7 @@ IceUtilInternal::generateRandom(char* buffer, size_t size)
}
else
{
- index += bytesRead;
+ index += static_cast<size_t>(bytesRead);
reads++;
}
}
@@ -174,7 +174,7 @@ IceUtilInternal::random(int limit)
#endif
if(limit > 0)
{
- r = r % limit;
+ r = r % static_cast<unsigned int>(limit);
}
return r;
}
diff --git a/cpp/src/IceUtil/StringConverter.cpp b/cpp/src/IceUtil/StringConverter.cpp
index 52f12c88cf2..73fee027596 100644
--- a/cpp/src/IceUtil/StringConverter.cpp
+++ b/cpp/src/IceUtil/StringConverter.cpp
@@ -92,7 +92,7 @@ public:
do
{
assert(factor <= 4);
- const size_t chunkSize = std::max<size_t>((sourceEnd - sourceStart) * factor, 4);
+ const size_t chunkSize = std::max<size_t>(static_cast<size_t>(sourceEnd - sourceStart) * factor, 4);
++factor; // at the next round, we'll allocate more bytes per remaining source character
targetStart = reinterpret_cast<char*>(buffer.getMoreBytes(chunkSize, reinterpret_cast<Byte*>(targetNext)));
@@ -145,7 +145,7 @@ public:
virtual void fromUTF8(const Byte* sourceStart, const Byte* sourceEnd, wstring& target) const
{
- const size_t sourceSize = sourceEnd - sourceStart;
+ const size_t sourceSize = static_cast<size_t>(sourceEnd - sourceStart);
if(sourceSize == 0)
{
@@ -173,7 +173,7 @@ public:
throw IllegalConversionException(__FILE__, __LINE__, "codecvt.in failure");
}
- target.resize(targetNext - targetStart);
+ target.resize(static_cast<size_t>(targetNext - targetStart));
}
}
@@ -275,7 +275,7 @@ public:
size_t bytesUsed = 0;
if(firstUnused != 0)
{
- bytesUsed = firstUnused - reinterpret_cast<const Byte*>(_buffer.data());
+ bytesUsed = static_cast<size_t>(firstUnused - reinterpret_cast<const Byte*>(_buffer.data()));
}
if(_buffer.size() < howMany + bytesUsed)
@@ -289,7 +289,7 @@ public:
void swap(string& other, const Byte* tail)
{
assert(tail >= reinterpret_cast<const Byte*>(_buffer.data()));
- _buffer.resize(tail - reinterpret_cast<const Byte*>(_buffer.data()));
+ _buffer.resize(static_cast<size_t>(tail - reinterpret_cast<const Byte*>(_buffer.data())));
other.swap(_buffer);
}
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index f78617c41dd..03cd429e622 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -22,11 +22,11 @@ toHexDigit(Byte b)
assert(b < 16);
if(b < 10)
{
- return '0' + b;
+ return static_cast<char>('0' + b);
}
else
{
- return 'a' - 10 + b;
+ return static_cast<char>('a' - 10 + b);
}
}
@@ -289,7 +289,7 @@ checkChar(const string& s, string::size_type pos)
ostr << " has invalid ordinal value " << static_cast<int>(c);
throw IllegalArgumentException(__FILE__, __LINE__, ostr.str());
}
- return c;
+ return static_cast<char>(c);
}
//
diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp
index 4c4dc4b68a4..b53e6757118 100644
--- a/cpp/src/IceUtil/Time.cpp
+++ b/cpp/src/IceUtil/Time.cpp
@@ -144,7 +144,7 @@ IceUtil::Time::now(Clock clock)
}
return Time(tv.tv_sec * ICE_INT64(1000000) + tv.tv_usec);
#elif defined(__APPLE__)
- return Time(mach_absolute_time() * machMultiplier);
+ return Time(static_cast<IceUtil::Int64>(mach_absolute_time() * machMultiplier));
#else
struct timespec ts;
if(clock_gettime(CLOCK_MONOTONIC, &ts) < 0)
@@ -197,8 +197,8 @@ IceUtil::Time::microSecondsDouble(double t)
IceUtil::Time::operator timeval() const
{
timeval tv;
- tv.tv_sec = static_cast<long>(_usec / 1000000);
- tv.tv_usec = static_cast<long>(_usec % 1000000);
+ tv.tv_sec = static_cast<time_t>(_usec / 1000000);
+ tv.tv_usec = static_cast<suseconds_t>(_usec % 1000000);
return tv;
}
#endif
diff --git a/cpp/src/IceUtil/UUID.cpp b/cpp/src/IceUtil/UUID.cpp
index 452ee3fffb0..0f14fd11b3b 100644
--- a/cpp/src/IceUtil/UUID.cpp
+++ b/cpp/src/IceUtil/UUID.cpp
@@ -47,7 +47,7 @@ public:
int p = GetCurrentProcessId();
#endif
myPid[0] = (p >> 8) & 0x7F;
- myPid[1] = p & 0xFF;
+ myPid[1] = static_cast<char>(p & 0xFF);
}
};
@@ -65,11 +65,11 @@ inline void halfByteToHex(unsigned char hb, char*& hexBuffer)
{
if(hb < 10)
{
- *hexBuffer++ = '0' + hb;
+ *hexBuffer++ = '0' + static_cast<char>(hb);
}
else
{
- *hexBuffer++ = 'A' + (hb - 10);
+ *hexBuffer++ = 'A' + static_cast<char>(hb - 10);
}
}
@@ -143,8 +143,8 @@ IceUtil::generateUUID()
//
// Replace the end of the node by myPid (15 bits)
//
- uuid.node[4] = (uuid.node[4] & 0x80) | myPid[0];
- uuid.node[5] = myPid[1];
+ uuid.node[4] = (uuid.node[4] & 0x80) | static_cast<unsigned char>(myPid[0]);
+ uuid.node[5] = static_cast<unsigned char>(myPid[1]);
//
// Convert to a UUID string
diff --git a/cpp/src/IceUtil/UtilException.cpp b/cpp/src/IceUtil/UtilException.cpp
index 9231cc5fffa..f42b86f89a6 100644
--- a/cpp/src/IceUtil/UtilException.cpp
+++ b/cpp/src/IceUtil/UtilException.cpp
@@ -350,8 +350,8 @@ getStackFrames()
#elif defined(ICE_BACKTRACE)
stackFrames.resize(100);
- size_t stackDepth = backtrace(&stackFrames.front(), stackFrames.size());
- stackFrames.resize(stackDepth);
+ int stackDepth = backtrace(&stackFrames.front(), static_cast<int>(stackFrames.size()));
+ stackFrames.resize(static_cast<size_t>(stackDepth));
if(!stackFrames.empty())
{
stackFrames.erase(stackFrames.begin()); // drop the first frame
@@ -468,7 +468,7 @@ getStackTrace(const vector<void*>& stackFrames)
// Initialize backtraceStrings immediately
if(p != stackFrames.end())
{
- backtraceStrings = backtrace_symbols(&*p, stackFrames.size());
+ backtraceStrings = backtrace_symbols(&*p, static_cast<int>(stackFrames.size()));
}
# endif
diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp
index 1463dc9c07a..21f2c737acc 100644
--- a/cpp/src/IceXML/Parser.cpp
+++ b/cpp/src/IceXML/Parser.cpp
@@ -361,7 +361,7 @@ characterDataHandler(void* data, const XML_Char* s, int len)
{
CallbackData* cb = static_cast<CallbackData*>(data);
- string str(s, len);
+ string str(s, static_cast<size_t>(len));
int line = static_cast<int>(XML_GetCurrentLineNumber(cb->parser));
int column = static_cast<int>(XML_GetCurrentColumnNumber(cb->parser));
cb->handler->characters(str, line, column);
diff --git a/cpp/src/Slice/Grammar.cpp b/cpp/src/Slice/Grammar.cpp
index 9d7b21e244f..3cb7c833df6 100644
--- a/cpp/src/Slice/Grammar.cpp
+++ b/cpp/src/Slice/Grammar.cpp
@@ -98,6 +98,14 @@
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
using namespace std;
using namespace Slice;
diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y
index a9af4724d8a..837ab577bc8 100644
--- a/cpp/src/Slice/Grammar.y
+++ b/cpp/src/Slice/Grammar.y
@@ -25,6 +25,14 @@
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
using namespace std;
using namespace Slice;
diff --git a/cpp/src/Slice/MD5I.cpp b/cpp/src/Slice/MD5I.cpp
index 79071b34452..66f4de545bc 100644
--- a/cpp/src/Slice/MD5I.cpp
+++ b/cpp/src/Slice/MD5I.cpp
@@ -58,6 +58,14 @@
# pragma GCC diagnostic ignored "-Wold-style-cast"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
#ifdef ARCH_IS_BIG_ENDIAN
# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 30430304020..958facf5f34 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -469,7 +469,8 @@ Slice::Preprocessor::printMakefileDependencies(ostream& out, Language lang, cons
{
if(file.compare(0, p->length(), *p) == 0)
{
- string s = includePaths[p - fullIncludePaths.begin()] + file.substr(p->length());
+ string s = includePaths[static_cast<size_t>(p - fullIncludePaths.begin())] +
+ file.substr(p->length());
if(IceUtilInternal::isAbsolutePath(newFile) || s.size() < newFile.size())
{
newFile = s;
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp
index 8e95f47b753..83d8a8341d3 100644
--- a/cpp/src/Slice/PythonUtil.cpp
+++ b/cpp/src/Slice/PythonUtil.cpp
@@ -2486,10 +2486,10 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c)
//
string name;
bool inParam = false, inException = false, inReturn = false;
- vector<string>::size_type i = 0;
- while(i < lines.size())
+ vector<string>::iterator i = lines.begin();
+ while(i != lines.end())
{
- string l = lines[i];
+ string l = *i;
string::size_type paramTag = l.find("@param");
string::size_type throwTag = l.find("@throw");
string::size_type returnTag = l.find("@return");
@@ -2533,7 +2533,7 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c)
}
}
}
- lines.erase(lines.begin() + i);
+ i = lines.erase(i);
continue;
}
else if(throwTag != string::npos)
@@ -2575,7 +2575,7 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c)
}
}
}
- lines.erase(lines.begin() + i);
+ i = lines.erase(i);
continue;
}
else if(returnTag != string::npos)
@@ -2592,7 +2592,7 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c)
inParam = false;
c.returns = l.substr(pos);
}
- lines.erase(lines.begin() + i);
+ i = lines.erase(i);
continue;
}
else
@@ -2612,7 +2612,7 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c)
c.params[name] += " ";
}
c.params[name] += l.substr(pos);
- lines.erase(lines.begin() + i);
+ i = lines.erase(i);
continue;
}
else if(inException)
@@ -2623,7 +2623,7 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c)
c.exceptions[name] += " ";
}
c.exceptions[name] += l.substr(pos);
- lines.erase(lines.begin() + i);
+ i = lines.erase(i);
continue;
}
else if(inReturn)
@@ -2633,7 +2633,7 @@ Slice::Python::CodeVisitor::parseOpComment(const string& comment, OpComment& c)
c.returns += " ";
}
c.returns += l.substr(pos);
- lines.erase(lines.begin() + i);
+ i = lines.erase(i);
continue;
}
}
diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp
index 0da441603bf..f9bb314f518 100644
--- a/cpp/src/Slice/Scanner.cpp
+++ b/cpp/src/Slice/Scanner.cpp
@@ -578,6 +578,14 @@ char *slice_text;
# pragma GCC diagnostic ignored "-Wsign-compare"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
#ifdef _MSC_VER
# ifdef slice_wrap
# undef slice_wrap
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index b93f13eb51b..0afdfebd34e 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -32,6 +32,14 @@
# pragma GCC diagnostic ignored "-Wsign-compare"
#endif
+//
+// Avoid clang conversion warnings
+//
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wsign-conversion"
+#endif
+
#ifdef _MSC_VER
# ifdef slice_wrap
# undef slice_wrap
diff --git a/cpp/src/icegriddb/IceGridDB.cpp b/cpp/src/icegriddb/IceGridDB.cpp
index cf6d2c83163..f403d3e94bf 100644
--- a/cpp/src/icegriddb/IceGridDB.cpp
+++ b/cpp/src/icegriddb/IceGridDB.cpp
@@ -551,10 +551,11 @@ run(const Ice::StringSeq& args)
ofstream fs(IceUtilInternal::streamFilename(dbFile).c_str(), ios::binary);
if(fs.fail())
{
- consoleErr << args[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno) << endl;
+ consoleErr << args[0] << ": could not open output file: " << IceUtilInternal::errorToString(errno)
+ << endl;
return 1;
}
- fs.write(reinterpret_cast<const char*>(stream.b.begin()), stream.b.size());
+ fs.write(reinterpret_cast<const char*>(stream.b.begin()), static_cast<streamsize>(stream.b.size()));
fs.close();
}
}
diff --git a/cpp/src/slice2confluence/Gen.cpp b/cpp/src/slice2confluence/Gen.cpp
index f3b4dde5d70..5cc4621b3d9 100644
--- a/cpp/src/slice2confluence/Gen.cpp
+++ b/cpp/src/slice2confluence/Gen.cpp
@@ -31,6 +31,7 @@
# pragma clang diagnostic ignored "-Wshadow"
# pragma clang diagnostic ignored "-Wshadow-all"
# pragma clang diagnostic ignored "-Wunused-parameter"
+# pragma clang diagnostic ignored "-Wsign-conversion"
#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wshadow"
# pragma GCC diagnostic ignored "-Wunused-parameter"
diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp
index 3c748ef88e9..de027895412 100644
--- a/cpp/src/slice2cs/CsUtil.cpp
+++ b/cpp/src/slice2cs/CsUtil.cpp
@@ -27,7 +27,7 @@ namespace
{
string
-lookupKwd(const string& name, int baseTypes, bool mangleCasts = false)
+lookupKwd(const string& name, unsigned int baseTypes, bool mangleCasts = false)
{
//
// Keyword list. *Must* be kept in alphabetical order.
@@ -210,7 +210,7 @@ Slice::CsGenerator::getUnqualified(const ContainedPtr& p, const string& package,
// if so, prefix it with ice_; otherwise, return the name unchanged.
//
string
-Slice::CsGenerator::fixId(const string& name, int baseTypes, bool mangleCasts)
+Slice::CsGenerator::fixId(const string& name, unsigned int baseTypes, bool mangleCasts)
{
if(name.empty())
{
@@ -239,7 +239,7 @@ Slice::CsGenerator::fixId(const string& name, int baseTypes, bool mangleCasts)
}
string
-Slice::CsGenerator::fixId(const ContainedPtr& cont, int baseTypes, bool mangleCasts)
+Slice::CsGenerator::fixId(const ContainedPtr& cont, unsigned int baseTypes, bool mangleCasts)
{
ContainerPtr container = cont->container();
ContainedPtr contained = ContainedPtr::dynamicCast(container);
diff --git a/cpp/src/slice2cs/CsUtil.h b/cpp/src/slice2cs/CsUtil.h
index 0cfc81fe6ae..fd438fafaf4 100644
--- a/cpp/src/slice2cs/CsUtil.h
+++ b/cpp/src/slice2cs/CsUtil.h
@@ -49,8 +49,8 @@ protected:
static std::string resultStructName(const std::string&, const std::string&, bool = false);
static std::string resultType(const OperationPtr&, const std::string&, bool = false);
static std::string taskResultType(const OperationPtr&, const std::string&, bool = false);
- static std::string fixId(const std::string&, int = 0, bool = false);
- static std::string fixId(const ContainedPtr&, int = 0, bool = false);
+ static std::string fixId(const std::string&, unsigned int = 0, bool = false);
+ static std::string fixId(const ContainedPtr&, unsigned int = 0, bool = false);
static std::string getOptionalFormat(const TypePtr&, const std::string&);
static std::string getStaticId(const TypePtr&);
static std::string typeToString(const TypePtr&, const std::string&, bool = false, bool = false,
diff --git a/cpp/src/slice2cs/DotNetNames.cpp b/cpp/src/slice2cs/DotNetNames.cpp
index 38649df2fa0..fc5a6e651c3 100644
--- a/cpp/src/slice2cs/DotNetNames.cpp
+++ b/cpp/src/slice2cs/DotNetNames.cpp
@@ -120,14 +120,14 @@ mangle(const string& s, const Node* np, string& newName)
}
string
-Slice::DotNet::mangleName(const string& s, int baseTypes)
+Slice::DotNet::mangleName(const string& s, unsigned int baseTypes)
{
if(baseTypes == 0)
{
return s;
}
string newName;
- for(unsigned int mask = 1, i=0; mask < END; mask <<= 1, ++i)
+ for(unsigned int mask = 1, i = 0; mask < END; mask <<= 1, ++i)
{
if(baseTypes & mask)
{
diff --git a/cpp/src/slice2cs/DotNetNames.h b/cpp/src/slice2cs/DotNetNames.h
index 9839c4f3e49..3379309ad58 100644
--- a/cpp/src/slice2cs/DotNetNames.h
+++ b/cpp/src/slice2cs/DotNetNames.h
@@ -20,7 +20,7 @@ enum BaseType
extern const char * manglePrefix;
-std::string mangleName(const std::string&, int baseTypes = 0);
+std::string mangleName(const std::string&, unsigned int baseTypes = 0);
}
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index 5b748b41a0a..221b3121fc7 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -1204,7 +1204,7 @@ Slice::CsVisitor::requiresDataMemberInitializers(const DataMemberList& members)
}
void
-Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, const string& ns, int baseTypes,
+Slice::CsVisitor::writeDataMemberInitializers(const DataMemberList& members, const string& ns, unsigned int baseTypes,
bool propertyMapping)
{
for(DataMemberList::const_iterator p = members.begin(); p != members.end(); ++p)
@@ -3381,7 +3381,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
void
Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
{
- int baseTypes = 0;
+ unsigned int baseTypes = 0;
bool isClass = false;
bool isProperty = false;
bool isValue = false;
@@ -3492,7 +3492,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
}
void
-Slice::Gen::TypesVisitor::writeMemberHashCode(const DataMemberList& dataMembers, int baseTypes)
+Slice::Gen::TypesVisitor::writeMemberHashCode(const DataMemberList& dataMembers, unsigned int baseTypes)
{
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
@@ -3506,7 +3506,7 @@ Slice::Gen::TypesVisitor::writeMemberHashCode(const DataMemberList& dataMembers,
}
void
-Slice::Gen::TypesVisitor::writeMemberEquals(const DataMemberList& dataMembers, int baseTypes)
+Slice::Gen::TypesVisitor::writeMemberEquals(const DataMemberList& dataMembers, unsigned int baseTypes)
{
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index b20c824e337..202998ea4ae 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -51,7 +51,7 @@ protected:
// Generate assignment statements for those data members that have default values.
//
bool requiresDataMemberInitializers(const DataMemberList&);
- void writeDataMemberInitializers(const DataMemberList&, const std::string&, int = 0, bool = false);
+ void writeDataMemberInitializers(const DataMemberList&, const std::string&, unsigned int = 0, bool = false);
std::string toCsIdent(const std::string&);
std::string editMarkup(const std::string&);
@@ -158,8 +158,8 @@ private:
private:
- void writeMemberHashCode(const DataMemberList&, int);
- void writeMemberEquals(const DataMemberList&, int);
+ void writeMemberHashCode(const DataMemberList&, unsigned int);
+ void writeMemberEquals(const DataMemberList&, unsigned int);
};
class AsyncDelegateVisitor : public CsVisitor
diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp
index 450f5211844..c35988b0fe5 100644
--- a/cpp/src/slice2html/Gen.cpp
+++ b/cpp/src/slice2html/Gen.cpp
@@ -29,6 +29,7 @@
# pragma clang diagnostic ignored "-Wshadow"
# pragma clang diagnostic ignored "-Wshadow-all"
# pragma clang diagnostic ignored "-Wunused-parameter"
+# pragma clang diagnostic ignored "-Wsign-conversion"
#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wshadow"
# pragma GCC diagnostic ignored "-Wunused-parameter"
diff --git a/cpp/src/slice2js/JsUtil.cpp b/cpp/src/slice2js/JsUtil.cpp
index ec5bbd8e098..07c2f9b5325 100644
--- a/cpp/src/slice2js/JsUtil.cpp
+++ b/cpp/src/slice2js/JsUtil.cpp
@@ -77,7 +77,7 @@ Slice::relativePath(const string& p1, const string& p2)
}
else
{
- for(size_t i = tokens2.end() - i2; i > 0; i--)
+ for(vector<string>::difference_type i = tokens2.end() - i2; i > 0; i--)
{
newPath += "../";
}
diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp
index 725452eaf05..0416e69ee76 100644
--- a/cpp/src/slice2objc/Gen.cpp
+++ b/cpp/src/slice2objc/Gen.cpp
@@ -2089,7 +2089,7 @@ Slice::Gen::TypesVisitor::writeMemberHashCode(const DataMemberList& dataMembers,
}
default:
{
- _M << nl << "h_ = ((h_ << 5) + h_) ^ (2654435761u * " << name << ");";
+ _M << nl << "h_ = ((h_ << 5) + h_) ^ (2654435761u * (uint)" << name << ");";
break;
}
}
diff --git a/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp b/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp
index b95aa4ffa07..e7490d220c3 100644
--- a/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp
+++ b/cpp/test/Glacier2/dynamicFiltering/TestControllerI.cpp
@@ -65,7 +65,7 @@ TestControllerI::step(const Glacier2::SessionPrx& currentSession, const TestToke
case Test::Running:
{
- TestConfiguration& config = _configurations[currentState.config];
+ TestConfiguration& config = _configurations[static_cast<size_t>(currentState.config)];
assert(!config.description.empty());
bool found = false;
@@ -113,14 +113,14 @@ TestControllerI::step(const Glacier2::SessionPrx& currentSession, const TestToke
//
// New test configuration!
//
- config = _configurations[newState.config];
+ config = _configurations[static_cast<size_t>(newState.config)];
newState.description = config.description;
newState.caseIndex = 0;
reconfigure = true;
}
- newState.expectedResult = config.cases[newState.caseIndex].expectedResult;
- newState.testReference = config.cases[newState.caseIndex].proxy;
+ newState.expectedResult = config.cases[static_cast<size_t>(newState.caseIndex)].expectedResult;
+ newState.testReference = config.cases[static_cast<size_t>(newState.caseIndex)].proxy;
if(reconfigure)
{
diff --git a/cpp/test/Ice/background/Transceiver.cpp b/cpp/test/Ice/background/Transceiver.cpp
index b59af9a782c..8bbd15f8a93 100644
--- a/cpp/test/Ice/background/Transceiver.cpp
+++ b/cpp/test/Ice/background/Transceiver.cpp
@@ -103,8 +103,8 @@ Transceiver::read(IceInternal::Buffer& buf)
}
}
assert(_readBuffer.i > _readBufferPos);
- size_t requested = buf.b.end() - buf.i;
- size_t available = _readBuffer.i - _readBufferPos;
+ size_t requested = static_cast<size_t>(buf.b.end() - buf.i);
+ size_t available = static_cast<size_t>(_readBuffer.i - _readBufferPos);
assert(available > 0);
if(available >= requested)
{
diff --git a/cpp/test/Ice/binding/AllTests.cpp b/cpp/test/Ice/binding/AllTests.cpp
index 39b6d1cc760..67c1e42ac0c 100644
--- a/cpp/test/Ice/binding/AllTests.cpp
+++ b/cpp/test/Ice/binding/AllTests.cpp
@@ -239,7 +239,7 @@ allTests(Test::TestHelper* helper)
#else
if(count < 20 && count % 4 == 0)
{
- com->deactivateObjectAdapter(adapters[count / 4 - 1]);
+ com->deactivateObjectAdapter(adapters[static_cast<size_t>(count / 4 - 1)]);
--adapterCount;
}
#endif
diff --git a/cpp/test/Ice/custom/AllTests.cpp b/cpp/test/Ice/custom/AllTests.cpp
index d5255a187a9..97831b435cb 100644
--- a/cpp/test/Ice/custom/AllTests.cpp
+++ b/cpp/test/Ice/custom/AllTests.cpp
@@ -621,7 +621,7 @@ allTests(Test::TestHelper* helper)
in[3] = 4 / 3;
in[4] = -5.725;
Ice::Double inArray[5];
- for(int i = 0; i < 5; ++i)
+ for(size_t i = 0; i < 5; ++i)
{
inArray[i] = in[i];
}
@@ -641,7 +641,7 @@ allTests(Test::TestHelper* helper)
in[3] = false;
in[4] = true;
bool inArray[5];
- for(int i = 0; i < 5; ++i)
+ for(size_t i = 0; i < 5; ++i)
{
inArray[i] = in[i];
}
@@ -1261,7 +1261,7 @@ allTests(Test::TestHelper* helper)
in[3] = 4 / 3;
in[4] = -5.725;
Ice::Double inArray[5];
- for(int i = 0; i < 5; ++i)
+ for(size_t i = 0; i < 5; ++i)
{
inArray[i] = in[i];
}
@@ -1288,7 +1288,7 @@ allTests(Test::TestHelper* helper)
in[3] = false;
in[4] = true;
bool inArray[5];
- for(int i = 0; i < 5; ++i)
+ for(size_t i = 0; i < 5; ++i)
{
inArray[i] = in[i];
}
@@ -2041,7 +2041,7 @@ allTests(Test::TestHelper* helper)
in[3] = 4 / 3;
in[4] = -5.725;
Ice::Double inArray[5];
- for(int i = 0; i < 5; ++i)
+ for(size_t i = 0; i < 5; ++i)
{
inArray[i] = in[i];
}
@@ -2082,7 +2082,7 @@ allTests(Test::TestHelper* helper)
in[3] = false;
in[4] = true;
bool inArray[5];
- for(int i = 0; i < 5; ++i)
+ for(size_t i = 0; i < 5; ++i)
{
inArray[i] = in[i];
}
diff --git a/cpp/test/Ice/custom/CustomBuffer.h b/cpp/test/Ice/custom/CustomBuffer.h
index c5e81565075..553a65cf7df 100644
--- a/cpp/test/Ice/custom/CustomBuffer.h
+++ b/cpp/test/Ice/custom/CustomBuffer.h
@@ -183,7 +183,7 @@ struct StreamHelper< ::Test::CustomBuffer<T>, StreamHelperCategorySequence>
std::pair<const T*, const T*> a;
stream->read(a, p);
T* b = p.release();
- size_t count = a.second - a.first;
+ size_t count = static_cast<size_t>(a.second - a.first);
if(b == 0 && count > 0)
{
b = new T[count];
diff --git a/cpp/test/Ice/custom/StringConverterI.cpp b/cpp/test/Ice/custom/StringConverterI.cpp
index ded10b7b228..a436bb6508b 100644
--- a/cpp/test/Ice/custom/StringConverterI.cpp
+++ b/cpp/test/Ice/custom/StringConverterI.cpp
@@ -30,7 +30,7 @@ Test::StringConverterI::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd,
target.resize(size);
for(size_t i = 0; i < size; ++i)
{
- target[i] = static_cast<Byte>(toupper(sourceStart[i]));
+ target[i] = static_cast<char>(toupper(sourceStart[i]));
}
}
diff --git a/cpp/test/Ice/gc/Client.cpp b/cpp/test/Ice/gc/Client.cpp
index 4bf38d8aa86..9bf572df30c 100644
--- a/cpp/test/Ice/gc/Client.cpp
+++ b/cpp/test/Ice/gc/Client.cpp
@@ -370,14 +370,16 @@ allTests()
{
nodes.push_back(new N());
}
+
for(int j = 0; j < i; ++j)
{
- nodes[j]->left = nodes[IceUtilInternal::random(i)];
- nodes[j]->right = nodes[IceUtilInternal::random(i)];
+ nodes[static_cast<size_t>(j)]->left = nodes[IceUtilInternal::random(i)];
+ nodes[static_cast<size_t>(j)]->right = nodes[IceUtilInternal::random(i)];
}
+
for(int j = 0; j < i; ++j)
{
- nodes[j]->ice_collectable(true);
+ nodes[static_cast<size_t>(j)]->ice_collectable(true);
}
test(getNum() == i);
}
diff --git a/cpp/test/Ice/hold/AllTests.cpp b/cpp/test/Ice/hold/AllTests.cpp
index ed2242f863c..047fdd01d49 100644
--- a/cpp/test/Ice/hold/AllTests.cpp
+++ b/cpp/test/Ice/hold/AllTests.cpp
@@ -173,7 +173,7 @@ allTests(Test::TestHelper* helper)
while(cond->value())
{
result = hold->begin_set(value + 1,
- IceUtilInternal::random(5),
+ static_cast<Ice::Int>(IceUtilInternal::random(5)),
newCallback_Hold_set(new SetCB(cond, value), &SetCB::response, &SetCB::exception));
++value;
if(value % 100 == 0)
@@ -236,7 +236,7 @@ allTests(Test::TestHelper* helper)
while(value < 3000 && cond->value())
{
result = holdSerialized->begin_set(value + 1,
- IceUtilInternal::random(1),
+ static_cast<Ice::Int>(IceUtilInternal::random(1)),
newCallback_Hold_set(new SetCB(cond, value),
&SetCB::response,
&SetCB::exception));
diff --git a/cpp/test/Ice/operations/Test.ice b/cpp/test/Ice/operations/Test.ice
index dbd6bccde34..e152939fbdd 100644
--- a/cpp/test/Ice/operations/Test.ice
+++ b/cpp/test/Ice/operations/Test.ice
@@ -437,8 +437,6 @@ interface MyDerivedClass extends Test::MyClass
}
-
-
//
// Test proxy inheritance for class with operations
// see: https://github.com/zeroc-ice/ice/issues/406
diff --git a/cpp/test/Ice/operations/Twoways.cpp b/cpp/test/Ice/operations/Twoways.cpp
index 41779343cd3..4c3bc092299 100644
--- a/cpp/test/Ice/operations/Twoways.cpp
+++ b/cpp/test/Ice/operations/Twoways.cpp
@@ -1699,7 +1699,7 @@ twoways(const Ice::CommunicatorPtr& communicator, Test::TestHelper* helper, cons
test(r.size() == static_cast<size_t>(lengths[l]));
for(int j = 0; j < static_cast<int>(r.size()); ++j)
{
- test(r[j] == -j);
+ test(r[static_cast<size_t>(j)] == -j);
}
}
}
diff --git a/cpp/test/Ice/operations/TwowaysAMI.cpp b/cpp/test/Ice/operations/TwowaysAMI.cpp
index f37ce43077a..e71852c300a 100644
--- a/cpp/test/Ice/operations/TwowaysAMI.cpp
+++ b/cpp/test/Ice/operations/TwowaysAMI.cpp
@@ -983,7 +983,7 @@ public:
{
for(int j = 0; j < static_cast<int>(r.size()); ++j)
{
- test(r[j] == -j);
+ test(r[static_cast<size_t>(j)] == -j);
}
called();
}
diff --git a/cpp/test/Ice/optional/AllTests.cpp b/cpp/test/Ice/optional/AllTests.cpp
index 80fa70cc3c3..7b00e0a421c 100644
--- a/cpp/test/Ice/optional/AllTests.cpp
+++ b/cpp/test/Ice/optional/AllTests.cpp
@@ -424,9 +424,9 @@ allTests(Test::TestHelper* helper, bool)
test(!oon->a);
MultiOptionalPtr mo1 = ICE_MAKE_SHARED(MultiOptional);
- mo1->a = 15;
+ mo1->a = static_cast<Ice::Byte>(15);
mo1->b = true;
- mo1->c = 19;
+ mo1->c = static_cast<Ice::Short>(19);
mo1->d = 78;
mo1->e = 99;
mo1->f = 5.5f;
@@ -1074,7 +1074,7 @@ allTests(Test::TestHelper* helper, bool)
in.read(1, p2);
in.read(3, p3);
- IceUtil::Optional<Ice::Byte> p4 = 0x08;
+ IceUtil::Optional<Ice::Byte> p4 = static_cast<Ice::Byte>(0x08);
in.read(89, p4);
in.endEncapsulation();
diff --git a/cpp/test/Ice/slicing/objects/AllTests.cpp b/cpp/test/Ice/slicing/objects/AllTests.cpp
index 04e376c7dc9..4a1a6838f79 100644
--- a/cpp/test/Ice/slicing/objects/AllTests.cpp
+++ b/cpp/test/Ice/slicing/objects/AllTests.cpp
@@ -571,7 +571,7 @@ public:
test(p3->pi == 3);
for(int i = 0; i < 300; ++i)
{
- PCDerived2Ptr p2 = ICE_DYNAMIC_CAST(PCDerived2, p3->pbs[i]);
+ PCDerived2Ptr p2 = ICE_DYNAMIC_CAST(PCDerived2, p3->pbs[static_cast<size_t>(i)]);
test(p2->pi == i);
test(p2->pbs.size() == 1);
test(!p2->pbs[0]);
@@ -2910,7 +2910,7 @@ allTests(Test::TestHelper* helper)
test(p3->pi == 3);
for(i = 0; i < 300; ++i)
{
- PCDerived2Ptr p2 = ICE_DYNAMIC_CAST(PCDerived2, p3->pbs[i]);
+ PCDerived2Ptr p2 = ICE_DYNAMIC_CAST(PCDerived2, p3->pbs[static_cast<size_t>(i)]);
test(p2->pi == i);
test(p2->pbs.size() == 1);
test(!p2->pbs[0]);
diff --git a/cpp/test/Ice/stream/Client.cpp b/cpp/test/Ice/stream/Client.cpp
index 6f23a511211..e1c2a282d4f 100644
--- a/cpp/test/Ice/stream/Client.cpp
+++ b/cpp/test/Ice/stream/Client.cpp
@@ -423,7 +423,7 @@ allTests(Test::TestHelper* helper)
OptionalClassPtr o = ICE_MAKE_SHARED(OptionalClass);
o->bo = false;
o->by = 5;
- o->sh = 4;
+ o->sh = static_cast<Ice::Short>(4);
o->i = 3;
out.write(o);
out.writePendingValues();
@@ -451,7 +451,7 @@ allTests(Test::TestHelper* helper)
OptionalClassPtr o = ICE_MAKE_SHARED(OptionalClass);
o->bo = false;
o->by = 5;
- o->sh = 4;
+ o->sh = static_cast<Ice::Short>(4);
o->i = 3;
out.write(o);
out.writePendingValues();
diff --git a/cpp/test/IceGrid/allocation/AllTests.cpp b/cpp/test/IceGrid/allocation/AllTests.cpp
index d0a9646372c..3543e07e67c 100644
--- a/cpp/test/IceGrid/allocation/AllTests.cpp
+++ b/cpp/test/IceGrid/allocation/AllTests.cpp
@@ -133,7 +133,7 @@ public:
else
{
session = _registry->createSession(os.str(), "");
- session->setAllocationTimeout(IceUtilInternal::random(200)); // 200ms timeout
+ session->setAllocationTimeout(static_cast<Ice::Int>(IceUtilInternal::random(200))); // 200ms timeout
}
}
diff --git a/cpp/test/IceGrid/session/AllTests.cpp b/cpp/test/IceGrid/session/AllTests.cpp
index 964c504d570..256236e8dd0 100644
--- a/cpp/test/IceGrid/session/AllTests.cpp
+++ b/cpp/test/IceGrid/session/AllTests.cpp
@@ -44,7 +44,8 @@ public:
vector<string>::const_iterator q = p->second->_stack.begin();
if(p->second->_stack.size() > 10)
{
- q = p->second->_stack.begin() + p->second->_stack.size() - 10;
+ q = p->second->_stack.begin() +
+ static_cast<vector<string>::difference_type>(p->second->_stack.size() - 10);
}
cerr << "Last 10 updates of observer `" << p->second->_name << "':" << endl;
for(; q != p->second->_stack.end(); ++q)
diff --git a/cpp/test/IceSSL/configuration/AllTests.cpp b/cpp/test/IceSSL/configuration/AllTests.cpp
index 367b7bc8df2..2fcba33ecb1 100644
--- a/cpp/test/IceSSL/configuration/AllTests.cpp
+++ b/cpp/test/IceSSL/configuration/AllTests.cpp
@@ -91,10 +91,10 @@ readFile(const string& file, vector<char>& buffer)
}
is.seekg(0, is.end);
- buffer.resize(static_cast<int>(is.tellg()));
+ buffer.resize(static_cast<size_t>(is.tellg()));
is.seekg(0, is.beg);
- is.read(&buffer[0], buffer.size());
+ is.read(&buffer[0], static_cast<streamsize>(buffer.size()));
if(!is.good())
{
diff --git a/cpp/test/IceStorm/rep1/Publisher.cpp b/cpp/test/IceStorm/rep1/Publisher.cpp
index 67746af7429..479d0806f2c 100644
--- a/cpp/test/IceStorm/rep1/Publisher.cpp
+++ b/cpp/test/IceStorm/rep1/Publisher.cpp
@@ -104,11 +104,11 @@ Publisher::run(int argc, char** argv)
os << argv[0] << ": Not enough endpoints in publisher proxy";
throw invalid_argument(os.str());
}
- int which = 0;
- for(int i = 0; i < 1000; ++i)
+ size_t which = 0;
+ for(size_t i = 0; i < 1000; ++i)
{
- single[which]->event(i);
- which = (which + 1) % static_cast<int>(single.size());
+ single[which]->event(static_cast<Ice::Int>(i));
+ which = (which + 1) % single.size();
}
}
else
diff --git a/cpp/test/IceUtil/sha1/Client.cpp b/cpp/test/IceUtil/sha1/Client.cpp
index 62bbb220aeb..1fd53bdd2d0 100644
--- a/cpp/test/IceUtil/sha1/Client.cpp
+++ b/cpp/test/IceUtil/sha1/Client.cpp
@@ -62,8 +62,7 @@ string toHex(const string& data)
{
os.width(2);
os.fill('0');
- unsigned char c = data[i];
- os << hex << (int)c;
+ os << hex << (int)static_cast<unsigned char>(data[i]);
}
return os.str();
}
diff --git a/cpp/test/IceUtil/uuid/Client.cpp b/cpp/test/IceUtil/uuid/Client.cpp
index 729d5e9e4fb..046c4eb8a01 100644
--- a/cpp/test/IceUtil/uuid/Client.cpp
+++ b/cpp/test/IceUtil/uuid/Client.cpp
@@ -122,7 +122,7 @@ public:
int
operator()()
{
- return IceUtilInternal::random();
+ return static_cast<int>(IceUtilInternal::random());
}
};