diff options
164 files changed, 837 insertions, 517 deletions
diff --git a/config/Make.rules.Darwin b/config/Make.rules.Darwin index aa70226ee22..30a287e58f0 100644 --- a/config/Make.rules.Darwin +++ b/config/Make.rules.Darwin @@ -29,7 +29,7 @@ iphonesimulator_targetdir = $(if $(filter %/build,$5),/iphonesimulator) shared_cppflags = $(if $(filter-out program,$($1_target)),-fPIC) -fvisibility=hidden cppflags = -Wall -Wextra -Wshadow -Wshadow-all -Wredundant-decls \ - -Wdeprecated -Wstrict-prototypes -Werror -pthread \ + -Wdeprecated -Wstrict-prototypes -Werror -Wconversion -pthread \ $(if $(filter yes,$(OPTIMIZE)),-O2 -DNDEBUG,-g) ifeq ($(MAXWARN),yes) 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/Proxy.h b/cpp/include/Ice/Proxy.h index 4056f04a515..a5bf67c494c 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -1063,7 +1063,7 @@ public: } /** - * Flushes any pending batched requests for this communicator. The call blocks until the flush is complete. + * Flushes asynchronously any pending batched requests for this communicator. * @param ex The exception callback. * @param sent The sent callback. * @return A function that can be called to cancel the invocation locally. @@ -1079,7 +1079,7 @@ public: } /** - * Flushes any pending batched requests for this communicator. The call blocks until the flush is complete. + * Flushes asynchronously any pending batched requests for this communicator. * @return The future object for the invocation. */ template<template<typename> class P = std::promise> auto @@ -2741,7 +2741,7 @@ public: } /** - * Flushes any pending batched requests for this proxy. The call blocks until the flush is complete. + * Flushes asynchronously any pending batched requests for this proxy. * @return The asynchronous result object for the invocation. */ ::Ice::AsyncResultPtr begin_ice_flushBatchRequests() @@ -2750,7 +2750,7 @@ public: } /** - * Flushes any pending batched requests for this proxy. The call blocks until the flush is complete. + * Flushes asynchronously any pending batched requests for this proxy. * @param cb Asynchronous callback object. * @param cookie User-defined data to associate with the invocation. * @return The asynchronous result object for the invocation. @@ -2762,7 +2762,7 @@ public: } /** - * Flushes any pending batched requests for this proxy. The call blocks until the flush is complete. + * Flushes asynchronously any pending batched requests for this proxy. * @param cb Asynchronous callback object. * @param cookie User-defined data to associate with the invocation. * @return The asynchronous result object for the invocation. 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 ea2427df92b..488f59c39c6 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); @@ -158,16 +158,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); } } @@ -215,17 +215,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) @@ -241,17 +241,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 240fe7c867e..e0c06b52a9b 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -1037,7 +1037,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()); } @@ -1122,8 +1122,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 { @@ -1180,7 +1185,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/Object.cpp b/cpp/src/Ice/Object.cpp index d5509a24b5f..effce176db2 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -319,17 +319,12 @@ Ice::Object::_iceCheckMode(OperationMode expected, OperationMode received) { if(expected != received) { + assert(expected != ICE_ENUM(OperationMode, Nonmutating)); // We never expect Nonmutating if(expected == ICE_ENUM(OperationMode, Idempotent) && received == ICE_ENUM(OperationMode, Nonmutating)) { // // Fine: typically an old client still using the deprecated nonmutating keyword // - - // - // Note that expected == Nonmutating and received == Idempotent is not ok: - // the server may still use the deprecated nonmutating keyword to detect updates - // and the client should not break this (deprecated) feature. - // } else { 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/Selector.cpp b/cpp/src/Ice/Selector.cpp index e76b8ad93f5..0070f93fb3f 100644 --- a/cpp/src/Ice/Selector.cpp +++ b/cpp/src/Ice/Selector.cpp @@ -612,7 +612,7 @@ 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); @@ -822,11 +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(static_cast<int>(_changes[i].data)); + << 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 ad7f1e50aa7..611a940a3e0 100644 --- a/cpp/src/IceSSL/SecureTransportCertificateI.cpp +++ b/cpp/src/IceSSL/SecureTransportCertificateI.cpp @@ -459,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))); } } } @@ -498,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))); } } } @@ -589,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 } @@ -839,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 00d0ad0fce5..63f9b54af75 100644 --- a/cpp/src/IceSSL/SecureTransportTransceiverI.cpp +++ b/cpp/src/IceSSL/SecureTransportTransceiverI.cpp @@ -213,8 +213,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 { @@ -584,7 +586,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; } @@ -617,7 +619,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 5d20a56ee05..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); @@ -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(), static_cast<int>(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(), static_cast<int>(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)); @@ -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 = static_cast<int>(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 = static_cast<int>(label.size()); + attr.length = static_cast<UInt32>(label.size()); attributes.push_back(attr); } SecKeychainAttributeList attrs; attrs.attr = &attributes[0]; - attrs.count = static_cast<int>(attributes.size()); + attrs.count = static_cast<UInt32>(attributes.size()); SecKeychainItemModifyAttributesAndData(reinterpret_cast<SecKeychainItemRef>(key.get()), &attrs, 0, 0); UniqueRef<SecIdentityRef> identity; @@ -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; diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp index 29a265814fa..294640565a5 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 d68fff4a02e..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) 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/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp index 5120a15877a..853bbed5d49 100644 --- a/cpp/src/Slice/CPlusPlusUtil.cpp +++ b/cpp/src/Slice/CPlusPlusUtil.cpp @@ -1621,7 +1621,7 @@ Slice::writeStreamHelpers(Output& out, void Slice::writeIceTuple(::IceUtilInternal::Output& out, const string& scope, DataMemberList dataMembers, int typeCtx) { - out << sp << nl << "std::tuple<"; + out << nl << "std::tuple<"; for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { if(q != dataMembers.begin()) 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/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 0b3347f936e..37d0a42a8b8 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -6584,7 +6584,7 @@ Slice::Gen::Cpp11TypesVisitor::visitStructEnd(const StructPtr& p) { H << sp; H << nl << "/**"; - H << nl << " * Obtains a tuple containing all of the exception's data members."; + H << nl << " * Obtains a tuple containing all of the struct's data members."; H << nl << " * @return The data members in a tuple."; H << nl << " */"; writeIceTuple(H, fixKwd(p->scope()), p->dataMembers(), _useWstring); 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/Gen.h b/cpp/src/slice2js/Gen.h index e6ab5a23151..ccc8bfb167a 100644 --- a/cpp/src/slice2js/Gen.h +++ b/cpp/src/slice2js/Gen.h @@ -165,7 +165,6 @@ private: bool _icejs; int _nextImport; - std::map<std::string, std::string> _modulePrefix; }; class TypeScriptAliasVisitor : public JsVisitor 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/invoke/test.py b/cpp/test/Ice/invoke/test.py new file mode 100644 index 00000000000..176ed12558f --- /dev/null +++ b/cpp/test/Ice/invoke/test.py @@ -0,0 +1,8 @@ +# +# Copyright (c) ZeroC, Inc. All rights reserved. +# + +TestSuite(__file__, + [ClientServerTestCase(), + ClientServerTestCase(name = "client/server array", servers=[Server(args = ["--array"])]), + ClientServerTestCase(name = "client/server async", servers=[Server(args = ["--async"])])]) 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/proxy/AllTests.cpp b/cpp/test/Ice/proxy/AllTests.cpp index 147726defb0..a923bf398fb 100644 --- a/cpp/test/Ice/proxy/AllTests.cpp +++ b/cpp/test/Ice/proxy/AllTests.cpp @@ -1155,7 +1155,9 @@ allTests(Test::TestHelper* helper) Ice::ConnectionPtr connection = cl->ice_getConnection(); if(connection) { + test(!cl->ice_isFixed()); Test::MyClassPrxPtr prx = cl->ice_fixed(connection); // Test factory method return type + test(prx->ice_isFixed()); prx->ice_ping(); test(cl->ice_secure(true)->ice_fixed(connection)->ice_isSecure()); test(cl->ice_facet("facet")->ice_fixed(connection)->ice_getFacet() == "facet"); 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/deployer/AllTests.cpp b/cpp/test/IceGrid/deployer/AllTests.cpp index b8003d3ef83..b4ba1780519 100644 --- a/cpp/test/IceGrid/deployer/AllTests.cpp +++ b/cpp/test/IceGrid/deployer/AllTests.cpp @@ -437,19 +437,15 @@ allTests(Test::TestHelper* helper) { Ice::ObjectPrx obj = query->findObjectByType("::Test"); string id = comm->identityToString(obj->ice_getIdentity()); - test(id == "Server1" || id == "Server2" || id == "SimpleServer" || - id == "IceBox1-Service1" || id == "IceBox1-Service2" || - id == "IceBox2-Service1" || id == "IceBox2-Service2" || - id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); + test(id.find("Server") == 0 || id.find("IceBox") == 0 || + id == "SimpleServer" || id == "SimpleIceBox-SimpleService" || id == "ReplicatedObject"); } { Ice::ObjectPrx obj = query->findObjectByTypeOnLeastLoadedNode("::Test", LoadSample5); string id = comm->identityToString(obj->ice_getIdentity()); - test(id == "Server1" || id == "Server2" || id == "SimpleServer" || - id == "IceBox1-Service1" || id == "IceBox1-Service2" || - id == "IceBox2-Service1" || id == "IceBox2-Service2" || - id == "SimpleIceBox-SimpleService" || "ReplicatedObject"); + test(id.find("Server") == 0 || id.find("IceBox") == 0 || + id == "SimpleServer" || id == "SimpleIceBox-SimpleService" || id == "ReplicatedObject"); } { diff --git a/cpp/test/IceGrid/deployer/application.xml b/cpp/test/IceGrid/deployer/application.xml index 403e51afdf5..ba46b25089c 100644 --- a/cpp/test/IceGrid/deployer/application.xml +++ b/cpp/test/IceGrid/deployer/application.xml @@ -25,8 +25,8 @@ <replica-group id="ReplicatedAdapter 2" proxy-options="-e 1.4"> <description>REPLICA GROUP ${AppVar}</description> - <object identity="ReplicatedObject15" type="::Test" proxy-options="-e 1.5"/> - <object identity="ReplicatedObject14" type="::Test"/> + <object identity="ReplicatedObject15" type="::Test14" proxy-options="-e 1.5"/> + <object identity="ReplicatedObject14" type="::Test15"/> </replica-group> <!-- Variables for variable test --> @@ -110,7 +110,7 @@ <adapter name="Server" endpoints="default"> <description>ADAPTER ${NodeVar}</description> <object identity="${server}" type="::Test"/> - <object identity="cat\/cat/name\/name" type="::Test"/> + <object identity="cat\/cat/name\/name" type="::TestCN"/> <object identity="${ObjectId}" type="::TestId1"/> <object identity="${ObjectCategory1}/${ObjectName1}" type="::TestId2"/> <object identity="${ObjectCategory1}${ObjectIdSlash}${ObjectName1}-bis" type="::TestId3"/> @@ -175,7 +175,7 @@ <server id="LogServer" exe="${server.dir}/server" activation="on-demand" pwd="."> <adapter name="Server" endpoints="default"> - <object identity="${server}" type="::Test"/> + <object identity="${server}" type="::TestLog"/> </adapter> <log path="${server.dir}/log1.txt"/> 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/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp index 56bb9477dc0..9b4b5ce1eea 100644 --- a/cpp/test/IceGrid/update/AllTests.cpp +++ b/cpp/test/IceGrid/update/AllTests.cpp @@ -450,7 +450,6 @@ allTests(Test::TestHelper* helper) try { admin->updateApplication(update); - test(true); } catch(const Ice::Exception& ex) { @@ -490,7 +489,6 @@ allTests(Test::TestHelper* helper) try { admin->updateApplication(update); - test(true); } catch(const Ice::Exception& ex) { 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()); } }; diff --git a/csharp/msbuild/ice.common.props b/csharp/msbuild/ice.common.props index b7ac7a80ad3..c7431b30dab 100644 --- a/csharp/msbuild/ice.common.props +++ b/csharp/msbuild/ice.common.props @@ -16,7 +16,6 @@ <FileAlignment>512</FileAlignment> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <DefineConstants>TRACE</DefineConstants> <SignAssembly>true</SignAssembly> <DefineConstants Condition="'$(TargetFrameworkVersion)' == 'v4.5.1'">NET45;$(DefineConstants)</DefineConstants> diff --git a/csharp/msbuild/ice.test.props b/csharp/msbuild/ice.test.props index 2b5c78e0331..9f61f2d897b 100644 --- a/csharp/msbuild/ice.test.props +++ b/csharp/msbuild/ice.test.props @@ -10,7 +10,6 @@ <PlatformTarget>AnyCPU</PlatformTarget> <Prefer32Bit>false</Prefer32Bit> <WarningLevel>4</WarningLevel> - <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <ErrorReport>prompt</ErrorReport> <DefineConstants Condition="'$(TargetFrameworkVersion)' == 'v4.5.1'">NET45</DefineConstants> </PropertyGroup> diff --git a/csharp/src/Ice/Network.cs b/csharp/src/Ice/Network.cs index 6f32f4c4ef3..bcd2200ab4b 100644 --- a/csharp/src/Ice/Network.cs +++ b/csharp/src/Ice/Network.cs @@ -526,7 +526,7 @@ namespace IceInternal #if NETSTANDARD2_0 [DllImport("libc", SetLastError = true)] - private static extern int setsockopt(int socket, int level, int name, IntPtr value, uint len); + private static extern int setsockopt(int socket, int level, int name, ref int value, uint len); private const int SOL_SOCKET_MACOS= 0xffff; private const int SO_REUSEADDR_MACOS = 0x0004; @@ -534,7 +534,7 @@ namespace IceInternal private const int SO_REUSEADDR_LINUX = 0x0002; #endif - public static unsafe IPEndPoint doBind(Socket socket, EndPoint addr) + public static IPEndPoint doBind(Socket socket, EndPoint addr) { try { @@ -549,11 +549,11 @@ namespace IceInternal var fd = socket.Handle.ToInt32(); if(AssemblyUtil.isLinux) { - err = setsockopt(fd, SOL_SOCKET_LINUX, SO_REUSEADDR_LINUX, (IntPtr)(&value), sizeof(int)); + err = setsockopt(fd, SOL_SOCKET_LINUX, SO_REUSEADDR_LINUX, ref value, sizeof(int)); } else if(AssemblyUtil.isMacOS) { - err = setsockopt(fd, SOL_SOCKET_MACOS, SO_REUSEADDR_MACOS, (IntPtr)(&value), sizeof(int)); + err = setsockopt(fd, SOL_SOCKET_MACOS, SO_REUSEADDR_MACOS, ref value, sizeof(int)); } if(err != 0) { diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index ba7fed5fe1f..c687b8a58a2 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -706,6 +706,13 @@ namespace Ice ObjectPrx ice_fixed(Ice.Connection connection); /// <summary> + /// Returns whether this proxy is a fixed proxy. + /// </summary> + /// <returns>True if this is a fixed proxy, false otherwise. + /// </returns> + bool ice_isFixed(); + + /// <summary> /// Returns the Connection for this proxy. If the proxy does not yet have an established connection, /// it first attempts to create a connection. /// </summary> @@ -2186,6 +2193,16 @@ namespace Ice } } + /// <summary> + /// Returns whether this proxy is a fixed proxy. + /// </summary> + /// <returns>True if this is a fixed proxy, false otherwise. + /// </returns> + public bool ice_isFixed() + { + return _reference is IceInternal.FixedReference; + } + private class ProxyGetConnectionAsyncCallback : ProxyAsyncResultCompletionCallback<Callback_Object_ice_getConnection> { public ProxyGetConnectionAsyncCallback(ObjectPrxHelperBase proxy, string operation, object cookie, diff --git a/csharp/test/Ice/inheritance/msbuild/server/net45/server.csproj b/csharp/test/Ice/inheritance/msbuild/server/net45/server.csproj index 2d5aa01c190..795baecd7db 100644 --- a/csharp/test/Ice/inheritance/msbuild/server/net45/server.csproj +++ b/csharp/test/Ice/inheritance/msbuild/server/net45/server.csproj @@ -27,7 +27,6 @@ <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <AllowUnsafeBlocks>false</AllowUnsafeBlocks> <PlatformTarget>x64</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> @@ -38,7 +37,6 @@ <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> - <AllowUnsafeBlocks>false</AllowUnsafeBlocks> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|Win32'"> <OutputPath>$(MSBuildThisFileDirectory)</OutputPath> @@ -128,4 +126,4 @@ <Error Condition="!Exists('..\..\..\..\..\..\msbuild\packages\zeroc.icebuilder.msbuild.5.0.4\build\zeroc.icebuilder.msbuild.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\msbuild\packages\zeroc.icebuilder.msbuild.5.0.4\build\zeroc.icebuilder.msbuild.targets'))" /> </Target> <Import Project="..\..\..\..\..\..\msbuild\packages\zeroc.icebuilder.msbuild.5.0.4\build\zeroc.icebuilder.msbuild.targets" Condition="Exists('..\..\..\..\..\..\msbuild\packages\zeroc.icebuilder.msbuild.5.0.4\build\zeroc.icebuilder.msbuild.targets')" /> -</Project>
\ No newline at end of file +</Project> diff --git a/csharp/test/Ice/invoke/test.py b/csharp/test/Ice/invoke/test.py new file mode 100644 index 00000000000..3c563fa249c --- /dev/null +++ b/csharp/test/Ice/invoke/test.py @@ -0,0 +1,7 @@ +# +# Copyright (c) ZeroC, Inc. All rights reserved. +# + +TestSuite(__file__, + [ClientServerTestCase(), + ClientServerTestCase(name = "client/server async", servers=[Server(args = ["--async"])])]) diff --git a/csharp/test/Ice/operations/BatchOneways.cs b/csharp/test/Ice/operations/BatchOneways.cs index 893856795ab..b7e2e4c01ae 100644 --- a/csharp/test/Ice/operations/BatchOneways.cs +++ b/csharp/test/Ice/operations/BatchOneways.cs @@ -74,7 +74,6 @@ namespace Ice try { batch.opByteSOneway(bs1); - test(true); } catch (Ice.MemoryLimitException) { diff --git a/csharp/test/Ice/operations/TwowaysAMI.cs b/csharp/test/Ice/operations/TwowaysAMI.cs index 3dc20864b70..81a9430c0a2 100644 --- a/csharp/test/Ice/operations/TwowaysAMI.cs +++ b/csharp/test/Ice/operations/TwowaysAMI.cs @@ -489,7 +489,7 @@ namespace Ice di1[100] = false; test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); - // test(ro[10] == true); // Disabled since new dictionary mapping. + test(ro[10] == true); test(ro[11] == false); test(ro[100] == false); test(ro[101] == true); @@ -503,7 +503,7 @@ namespace Ice di1[1100] = 123123; test(Ice.CollectionComparer.Equals(_do, di1)); test(ro.Count == 4); - // test(ro[110] == -1); // Disabled since new dictionary mapping. + test(ro[110] == -1); test(ro[111] == -100); test(ro[1100] == 123123); test(ro[1101] == 0); diff --git a/csharp/test/Ice/proxy/AllTests.cs b/csharp/test/Ice/proxy/AllTests.cs index e8ccea04b44..c28e31cc7ff 100644 --- a/csharp/test/Ice/proxy/AllTests.cs +++ b/csharp/test/Ice/proxy/AllTests.cs @@ -808,7 +808,9 @@ namespace Ice Ice.Connection connection = cl.ice_getConnection(); if(connection != null) { + test(!cl.ice_isFixed()); Test.MyClassPrx prx =(Test.MyClassPrx)cl.ice_fixed(connection); + test(prx.ice_isFixed()); prx.ice_ping(); test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()); test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet().Equals("facet")); diff --git a/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java b/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java index 65d4a3e24bf..4c265c3abec 100644 --- a/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java +++ b/java-compat/src/Ice/src/main/java/Ice/ObjectPrx.java @@ -1112,6 +1112,13 @@ public interface ObjectPrx ObjectPrx ice_fixed(Ice.Connection connection); /** + * Returns whether this proxy is a fixed proxy. + * + * @return <code>true</code> if this is a fixed proxy, <code>false</code> otherwise. + **/ + boolean ice_isFixed(); + + /** * Returns the {@link Connection} for this proxy. If the proxy does not yet have an established connection, * it first attempts to create a connection. * diff --git a/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java b/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java index 28789a6158c..70ee6a66273 100644 --- a/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java +++ b/java-compat/src/Ice/src/main/java/Ice/ObjectPrxHelperBase.java @@ -2311,6 +2311,17 @@ public class ObjectPrxHelperBase implements ObjectPrx, java.io.Serializable } /** + * Returns whether this proxy is a fixed proxy. + * + * @return <code>true</code> if this is a fixed proxy, <code>false</code> otherwise. + **/ + @Override + public final boolean ice_isFixed() + { + return _reference instanceof IceInternal.FixedReference; + } + + /** * Returns the {@link Connection} for this proxy. If the proxy does not yet have an established connection, * it first attempts to create a connection. * diff --git a/java-compat/test/src/main/java/test/Ice/invoke/test.py b/java-compat/test/src/main/java/test/Ice/invoke/test.py new file mode 100644 index 00000000000..3c563fa249c --- /dev/null +++ b/java-compat/test/src/main/java/test/Ice/invoke/test.py @@ -0,0 +1,7 @@ +# +# Copyright (c) ZeroC, Inc. All rights reserved. +# + +TestSuite(__file__, + [ClientServerTestCase(), + ClientServerTestCase(name = "client/server async", servers=[Server(args = ["--async"])])]) diff --git a/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java b/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java index 57ebcd10180..a94cc224fa2 100644 --- a/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java +++ b/java-compat/test/src/main/java/test/Ice/proxy/AllTests.java @@ -901,7 +901,9 @@ public class AllTests Ice.Connection connection = cl.ice_getConnection(); if(connection != null) { + test(!cl.ice_isFixed()); MyClassPrx prx = (MyClassPrx)cl.ice_fixed(connection); // Test proxy return type. + test(prx.ice_isFixed()); prx.ice_ping(); test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()); test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet().equals("facet")); diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java index 23968550b11..f95213fa2d3 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/ObjectPrx.java @@ -330,6 +330,13 @@ public interface ObjectPrx } /** + * Returns whether this proxy is a fixed proxy. + * + * @return <code>true</code> if this is a fixed proxy, <code>false</code> otherwise. + **/ + boolean ice_isFixed(); + + /** * Returns a proxy that is identical to this proxy, except for the locator cache timeout. * * @param newTimeout The new locator cache timeout (in seconds). diff --git a/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java b/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java index 867193fced0..e2b70a29539 100644 --- a/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java +++ b/java/src/Ice/src/main/java/com/zeroc/Ice/_ObjectPrxI.java @@ -248,6 +248,11 @@ public class _ObjectPrxI implements ObjectPrx, java.io.Serializable return _reference.getEndpointSelection(); } + public boolean ice_isFixed() + { + return _reference instanceof com.zeroc.IceInternal.FixedReference; + } + public boolean ice_isSecure() { return _reference.getSecure(); diff --git a/java/test/src/main/java/test/Ice/invoke/test.py b/java/test/src/main/java/test/Ice/invoke/test.py new file mode 100644 index 00000000000..3c563fa249c --- /dev/null +++ b/java/test/src/main/java/test/Ice/invoke/test.py @@ -0,0 +1,7 @@ +# +# Copyright (c) ZeroC, Inc. All rights reserved. +# + +TestSuite(__file__, + [ClientServerTestCase(), + ClientServerTestCase(name = "client/server async", servers=[Server(args = ["--async"])])]) diff --git a/java/test/src/main/java/test/Ice/proxy/AllTests.java b/java/test/src/main/java/test/Ice/proxy/AllTests.java index 8272a56c105..c1fdd70b899 100644 --- a/java/test/src/main/java/test/Ice/proxy/AllTests.java +++ b/java/test/src/main/java/test/Ice/proxy/AllTests.java @@ -839,7 +839,9 @@ public class AllTests com.zeroc.Ice.Connection connection = cl.ice_getConnection(); if(connection != null) { + test(!cl.ice_isFixed()); MyClassPrx prx = cl.ice_fixed(connection); // Test proxy return type. + test(prx.ice_isFixed()); prx.ice_ping(); test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()); test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet().equals("facet")); diff --git a/js/src/Ice/ObjectPrx.d.ts b/js/src/Ice/ObjectPrx.d.ts index a377f92c4fb..6ea90a7022b 100644 --- a/js/src/Ice/ObjectPrx.d.ts +++ b/js/src/Ice/ObjectPrx.d.ts @@ -352,6 +352,13 @@ declare module "ice" ice_fixed(conn:Connection):this; /** + * Returns whether this proxy is a fixed proxy. + * + * @return True if this is a fixed proxy, false otherwise. + **/ + ice_isFixed():boolean; + + /** * Obtains the Connection for this proxy. If the proxy does not yet have an established connection, * it first attempts to create a connection. * @return The asynchronous result object for the invocation. @@ -380,7 +387,7 @@ declare module "ice" ice_isConnectionCached():boolean; /** - * Flushes any pending batched requests for this communicator. The call blocks until the flush is complete. + * Flushes any pending batched requests for this communicator. * @return The asynchronous result object for the invocation. */ ice_flushBatchRequests():AsyncResult<void>; diff --git a/js/src/Ice/ObjectPrx.js b/js/src/Ice/ObjectPrx.js index e51fe929a00..a29698fe192 100644 --- a/js/src/Ice/ObjectPrx.js +++ b/js/src/Ice/ObjectPrx.js @@ -447,6 +447,11 @@ class ObjectPrx } } + ice_isFixed() + { + return this._reference instanceof Ice.FixedReference; + } + ice_getConnectionId() { return this._reference.getConnectionId(); diff --git a/js/test/Ice/proxy/Client.js b/js/test/Ice/proxy/Client.js index 0ad59852ad5..e96681dc8e5 100644 --- a/js/test/Ice/proxy/Client.js +++ b/js/test/Ice/proxy/Client.js @@ -740,6 +740,8 @@ const connection = await cl.ice_getConnection(); if(connection !== null) { + test(!cl.ice_isFixed()); + test(cl.ice_fixed(connection).ice_isFixed()); await cl.ice_fixed(connection).getContext(); test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()); test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet"); diff --git a/js/test/typescript/Ice/proxy/Client.ts b/js/test/typescript/Ice/proxy/Client.ts index 90827760bc5..9dc59b49ce5 100644 --- a/js/test/typescript/Ice/proxy/Client.ts +++ b/js/test/typescript/Ice/proxy/Client.ts @@ -739,6 +739,8 @@ export class Client extends TestHelper const connection = await cl.ice_getConnection(); if(connection !== null) { + test(!cl.ice_isFixed()); + test(cl.ice_fixed(connection).ice_isFixed()); await cl.ice_fixed(connection).getContext(); test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()); test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet"); diff --git a/matlab/lib/+Ice/ObjectPrx.m b/matlab/lib/+Ice/ObjectPrx.m index 41d6c7e68bb..d5b85a74258 100644 --- a/matlab/lib/+Ice/ObjectPrx.m +++ b/matlab/lib/+Ice/ObjectPrx.m @@ -101,6 +101,7 @@ classdef ObjectPrx < IceInternal.WrapperObject % ice_getTimeout - Obtains the timeout override of this proxy. % ice_fixed - Obtains a proxy that is identical to this proxy, except it's % a fixed proxy bound to the given connection. + % ice_isFixed - Returns whether this proxy is a fixed proxy. % ice_getConnection - Returns the Connection for this proxy. % ice_getConnectionAsync - Returns the Connection for this proxy. % ice_getCachedConnection - Returns the cached Connection for this @@ -886,6 +887,14 @@ classdef ObjectPrx < IceInternal.WrapperObject r = obj.factory_('ice_fixed', true, connection.iceGetImpl()); end + function r = ice_isFixed(obj) + % ice_isFixed - Determines whether this proxy is a fixed proxy. + % + % Returns (logical) - True if this proxy is a fixed proxy, false otherwise. + + r = obj.iceCallWithResult('ice_isFixed'); + end + function r = ice_getConnection(obj) % ice_getConnection - Returns the Connection for this proxy. If the % proxy does not yet have an established connection, it first @@ -952,9 +961,8 @@ classdef ObjectPrx < IceInternal.WrapperObject end function r = ice_flushBatchRequestsAsync(obj) - % ice_flushBatchRequestsAsync - Flushes any pending batched - % requests for this communicator. The call blocks until the - % flush is complete. + % ice_flushBatchRequestsAsync - Flushes asynchronously any pending batched + % requests for this communicator. % % Returns (Ice.Future) - A future that will be completed when the % invocation completes. diff --git a/matlab/src/Init.cpp b/matlab/src/Init.cpp index 3f1b57f041a..fb90429390a 100644 --- a/matlab/src/Init.cpp +++ b/matlab/src/Init.cpp @@ -20,7 +20,6 @@ public: Init() { - Ice::registerIceWS(true); Ice::registerIceSSL(false); Ice::registerIceDiscovery(false); Ice::registerIceLocatorDiscovery(false); diff --git a/matlab/src/ObjectPrx.cpp b/matlab/src/ObjectPrx.cpp index e880f7471d8..7ce156f6c65 100644 --- a/matlab/src/ObjectPrx.cpp +++ b/matlab/src/ObjectPrx.cpp @@ -1019,6 +1019,12 @@ Ice_ObjectPrx_ice_fixed(void* self, void** r, void* connection) } mxArray* +Ice_ObjectPrx_ice_isFixed(void* self) +{ + return createResultValue(createBool(deref<Ice::ObjectPrx>(self)->ice_isFixed())); +} + +mxArray* Ice_ObjectPrx_ice_getConnection(void* self, void** r) { *r = 0; diff --git a/matlab/src/ice.h b/matlab/src/ice.h index ec70ee590b6..44ed95579eb 100644 --- a/matlab/src/ice.h +++ b/matlab/src/ice.h @@ -102,6 +102,7 @@ ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_getCompress(void*); ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_timeout(void*, void**, int); ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_getTimeout(void*); ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_fixed(void*, void**, void*); +ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_isFixed(void* self); ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_getConnection(void*, void**); ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_getConnectionAsync(void*, void**); ICE_MATLAB_API mxArray* Ice_ObjectPrx_ice_getCachedConnection(void*, void**); diff --git a/matlab/test/Ice/proxy/AllTests.m b/matlab/test/Ice/proxy/AllTests.m index 7abac3797b0..09923a53528 100644 --- a/matlab/test/Ice/proxy/AllTests.m +++ b/matlab/test/Ice/proxy/AllTests.m @@ -674,6 +674,8 @@ classdef AllTests fprintf('testing ice_fixed... '); connection = cl.ice_getConnection(); if ~isempty(connection) + assert(~(cl.ice_isFixed())); + assert(cl.ice_fixed(connection).ice_isFixed()); prx = cl.ice_fixed(connection); % Test factory method return type prx.ice_ping(); assert(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()); diff --git a/objective-c/include/objc/Ice/Proxy.h b/objective-c/include/objc/Ice/Proxy.h index 64ae023b3e1..24b5a0af9a7 100644 --- a/objective-c/include/objc/Ice/Proxy.h +++ b/objective-c/include/objc/Ice/Proxy.h @@ -145,6 +145,7 @@ ICE_API @protocol ICEObjectPrx <NSObject, NSCopying> -(id) ice_timeout:(int)timeout; -(id) ice_getTimeout; -(id) ice_fixed:(id<ICEConnection>)connection; +-(BOOL) ice_isFixed; -(id) ice_connectionId:(NSString*)connectionId; -(id<ICEConnection>) ice_getConnection; -(id<ICEAsyncResult>) begin_ice_getConnection; diff --git a/objective-c/src/Ice/Object.mm b/objective-c/src/Ice/Object.mm index 888c0dfb352..21c83688029 100644 --- a/objective-c/src/Ice/Object.mm +++ b/objective-c/src/Ice/Object.mm @@ -173,7 +173,7 @@ BlobjectI::ice_invoke_async(const Ice::AMD_Object_ice_invokePtr& cb, { ICECurrent* c = [[ICECurrent alloc] initWithCurrent:current]; NSData* inE = [NSData dataWithBytesNoCopy:const_cast<Ice::Byte*>(inEncaps.first) - length:(inEncaps.second - inEncaps.first) + length:static_cast<NSUInteger>(inEncaps.second - inEncaps.first) freeWhenDone:NO]; @try { @@ -216,7 +216,7 @@ int ICEInternalLookupString(NSString* const array[], size_t count, NSString* __unsafe_unretained str) { size_t low = 0; - size_t high = count - 1; + size_t high = static_cast<size_t>(count - 1); while(low <= high) { size_t mid = (low + high) / 2; @@ -233,7 +233,7 @@ ICEInternalLookupString(NSString* const array[], size_t count, NSString* __unsaf low = mid + 1; break; case NSOrderedSame: - return mid; + return static_cast<int>(mid); default: return -1; // Can't be reached } @@ -247,17 +247,12 @@ ICEInternalCheckModeAndSelector(id target, ICEOperationMode expected, SEL sel, I ICEOperationMode received = current.mode; if(expected != received) { + assert(expected != ICENonmutating); // We never expect Nonmutating if(expected == ICEIdempotent && received == ICENonmutating) { // // Fine: typically an old client still using the deprecated nonmutating keyword // - - // - // Note that expected == Nonmutating and received == Idempotent is not ok: - // the server may still use the deprecated nonmutating keyword to detect updates - // and the client should not break this (deprecated) feature. - // } else { @@ -432,9 +427,10 @@ static NSString* ICEObject_all[4] = -(BOOL) ice_isA:(NSString*)typeId current:(ICECurrent*)__unused current { - int count, index; + int count; + int index; NSString*const* staticIds = [[self class] iceStaticIds:&count idIndex:&index]; - return ICEInternalLookupString(staticIds, count, typeId) >= 0; + return ICEInternalLookupString(staticIds, static_cast<size_t>(count), typeId) >= 0; } -(void) ice_ping:(ICECurrent*)__unused current @@ -451,7 +447,7 @@ static NSString* ICEObject_all[4] = { int count, index; NSString*const* staticIds = [[self class] iceStaticIds:&count idIndex:&index]; - return [NSArray arrayWithObjects:staticIds count:count]; + return [NSArray arrayWithObjects:staticIds count:static_cast<NSUInteger>(count)]; } -(void) ice_dispatch:(id<ICERequest>)request diff --git a/objective-c/src/Ice/Proxy.mm b/objective-c/src/Ice/Proxy.mm index fab4ceb94c1..7f0107726fe 100644 --- a/objective-c/src/Ice/Proxy.mm +++ b/objective-c/src/Ice/Proxy.mm @@ -1340,7 +1340,7 @@ BOOL _returnsData; if(response) { NSMutableData* outEncaps = - [NSMutableData dataWithBytes:outP.first length:(outP.second - outP.first)]; + [NSMutableData dataWithBytes:outP.first length:static_cast<NSUInteger>(outP.second - outP.first)]; response(ret, outEncaps); } }, @@ -1371,7 +1371,7 @@ BOOL _returnsData; if(response) { NSMutableData* outEncaps = - [NSMutableData dataWithBytes:outP.first length:(outP.second - outP.first)]; + [NSMutableData dataWithBytes:outP.first length:static_cast<NSUInteger>(outP.second - outP.first)]; response(ret, outEncaps); } }, @@ -1385,7 +1385,7 @@ BOOL _returnsData; { std::pair<const ::Ice::Byte*, const ::Ice::Byte*> outP; ret = OBJECTPRX->_iceI_end_ice_invoke(outP, r); - *outEncaps = [NSMutableData dataWithBytes:outP.first length:(outP.second - outP.first)]; + *outEncaps = [NSMutableData dataWithBytes:outP.first length:static_cast<NSUInteger>(outP.second - outP.first)]; }, result); return ret; } @@ -1629,6 +1629,10 @@ BOOL _returnsData; @throw nsex; return nil; // Keep the compiler happy. } +-(BOOL) ice_isFixed +{ + return OBJECTPRX->ice_isFixed(); +} -(id) ice_connectionId:(NSString*)connectionId { return [[self class] iceObjectPrxWithObjectPrx:OBJECTPRX->ice_connectionId(fromNSString(connectionId))]; diff --git a/objective-c/src/Ice/Stream.mm b/objective-c/src/Ice/Stream.mm index ec323da9038..e49f494058e 100644 --- a/objective-c/src/Ice/Stream.mm +++ b/objective-c/src/Ice/Stream.mm @@ -190,7 +190,7 @@ public: { ICEObject* o = ValueWrapperPtr::dynamicCast(obj)->getValue(); checkType(o); - [_array replaceObjectAtIndex:_index withObject:o]; + [_array replaceObjectAtIndex:static_cast<NSUInteger>(_index) withObject:o]; } } @catch(id ex) @@ -481,7 +481,7 @@ private: std::pair<const bool*, const bool*> seq; IceUtil::ScopedArray<bool> result; is_->read(seq, result); - return [[NSMutableData alloc] initWithBytes:seq.first length:(seq.second - seq.first) * sizeof(BOOL)]; + return [[NSMutableData alloc] initWithBytes:seq.first length:static_cast<NSUInteger>(seq.second - seq.first) * sizeof(BOOL)]; } catch(const std::exception& ex) { @@ -520,7 +520,7 @@ private: { std::pair<const Ice::Byte*, const Ice::Byte*> seq; is_->read(seq); - return [[NSMutableData alloc] initWithBytes:seq.first length:(seq.second - seq.first)]; + return [[NSMutableData alloc] initWithBytes:seq.first length:static_cast<NSUInteger>(seq.second - seq.first)]; } catch(const std::exception& ex) { @@ -537,7 +537,7 @@ private: std::pair<const Ice::Byte*, const Ice::Byte*> seq; is_->read(seq); return [NSData dataWithBytesNoCopy:const_cast<Ice::Byte*>(seq.first) - length:(seq.second - seq.first) freeWhenDone:NO]; + length:static_cast<NSUInteger>(seq.second - seq.first) freeWhenDone:NO]; } catch(const std::exception& ex) { @@ -577,7 +577,7 @@ private: std::pair<const Ice::Short*, const Ice::Short*> seq; IceUtil::ScopedArray<Ice::Short> result; is_->read(seq, result); - return [[NSMutableData alloc] initWithBytes:seq.first length:(seq.second - seq.first) * sizeof(ICEShort)]; + return [[NSMutableData alloc] initWithBytes:seq.first length:static_cast<NSUInteger>(seq.second - seq.first) * sizeof(ICEShort)]; } catch(const std::exception& ex) { @@ -617,7 +617,7 @@ private: std::pair<const Ice::Int*, const Ice::Int*> seq; IceUtil::ScopedArray<Ice::Int> result; is_->read(seq, result); - return [[NSMutableData alloc] initWithBytes:seq.first length:(seq.second - seq.first) * sizeof(ICEInt)]; + return [[NSMutableData alloc] initWithBytes:seq.first length:static_cast<NSUInteger>(seq.second - seq.first) * sizeof(ICEInt)]; } catch(const std::exception& ex) { @@ -657,7 +657,7 @@ private: std::pair<const Ice::Long*, const Ice::Long*> seq; IceUtil::ScopedArray<Ice::Long> result; is_->read(seq, result); - return [[NSMutableData alloc] initWithBytes:seq.first length:(seq.second - seq.first) * sizeof(ICELong)]; + return [[NSMutableData alloc] initWithBytes:seq.first length:static_cast<NSUInteger>(seq.second - seq.first) * sizeof(ICELong)]; } catch(const std::exception& ex) { @@ -697,7 +697,7 @@ private: std::pair<const Ice::Float*, const Ice::Float*> seq; IceUtil::ScopedArray<Ice::Float> result; is_->read(seq, result); - return [[NSMutableData alloc] initWithBytes:seq.first length:(seq.second - seq.first) * sizeof(ICEFloat)]; + return [[NSMutableData alloc] initWithBytes:seq.first length:static_cast<NSUInteger>(seq.second - seq.first) * sizeof(ICEFloat)]; } catch(const std::exception& ex) { @@ -737,7 +737,7 @@ private: std::pair<const Ice::Double*, const Ice::Double*> seq; IceUtil::ScopedArray<Ice::Double> result; is_->read(seq, result); - return [[NSMutableData alloc] initWithBytes:seq.first length:(seq.second - seq.first) * sizeof(ICEDouble)]; + return [[NSMutableData alloc] initWithBytes:seq.first length:static_cast<NSUInteger>(seq.second - seq.first) * sizeof(ICEDouble)]; } catch(const std::exception& ex) { @@ -850,7 +850,7 @@ private: try { int count = is_->readSize(); - if((ret = [[NSMutableData alloc] initWithLength:(count * ENUM_SIZE)]) == 0) + if((ret = [[NSMutableData alloc] initWithLength:static_cast<NSUInteger>(count) * ENUM_SIZE]) == 0) { return ret; } @@ -984,7 +984,7 @@ private: -(NSMutableArray*) newValueSeq:(Class)type { ICEInt sz = [self readAndCheckSeqSize:1]; - NSMutableArray* arr = [[NSMutableArray alloc] initWithCapacity:sz]; + NSMutableArray* arr = [[NSMutableArray alloc] initWithCapacity:static_cast<NSUInteger>(sz)]; if(sz > 0) { NSException* nsex = nil; @@ -1025,7 +1025,7 @@ private: -(NSMutableDictionary*) newValueDict:(Class)keyHelper expectedType:(Class)type { ICEInt sz = [self readAndCheckSeqSize:[keyHelper minWireSize] + 1]; - NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] initWithCapacity:sz]; + NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] initWithCapacity:static_cast<NSUInteger>(sz)]; if(sz > 0) { if(!objectReaders_) @@ -1076,7 +1076,7 @@ private: -(NSMutableArray*) newSequence:(Class)helper { ICEInt sz = [self readAndCheckSeqSize:[helper minWireSize]]; - NSMutableArray* arr = [[NSMutableArray alloc] initWithCapacity:sz]; + NSMutableArray* arr = [[NSMutableArray alloc] initWithCapacity:static_cast<NSUInteger>(sz)]; id obj = nil; @try { @@ -1111,7 +1111,7 @@ private: -(NSMutableDictionary*) newDictionary:(ICEKeyValueTypeHelper)helper { ICEInt sz = [self readAndCheckSeqSize:[helper.key minWireSize] + [helper.value minWireSize]]; - NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] initWithCapacity:sz]; + NSMutableDictionary* dictionary = [[NSMutableDictionary alloc] initWithCapacity:static_cast<NSUInteger>(sz)]; id key = nil; id value = nil; @try @@ -1420,7 +1420,7 @@ private: NSException* nsex = nil; try { - is_->skip(sz); + is_->skip(static_cast<Ice::InputStream::size_type>(sz)); } catch(const std::exception& ex) { @@ -1804,7 +1804,7 @@ private: return; } - [self writeSize:[arr count]]; + [self writeSize:static_cast<Ice::Int>([arr count])]; for(id i in arr) { [helper write:(i == [NSNull null] ? nil : i) stream:self]; @@ -1819,7 +1819,7 @@ private: return; } - [self writeSize:[dictionary count]]; + [self writeSize:static_cast<Ice::Int>([dictionary count])]; NSEnumerator* e = [dictionary keyEnumerator]; id key; while((key = [e nextObject])) @@ -1903,7 +1903,7 @@ private: NSException* nsex = nil; try { - int count = v == nil ? 0 : [v length] / ENUM_SIZE; + int count = v == nil ? 0 : static_cast<int>([v length] / ENUM_SIZE); [self writeSize:count]; if(count == 0) { @@ -1992,7 +1992,7 @@ private: return; } - [self writeSize:[arr count]]; + [self writeSize:static_cast<Ice::Int>([arr count])]; for(id i in arr) { [self writeValue:(i == [NSNull null] ? nil : i)]; @@ -2007,7 +2007,7 @@ private: return; } - [self writeSize:[dictionary count]]; + [self writeSize:static_cast<Ice::Int>([dictionary count])]; NSEnumerator* e = [dictionary keyEnumerator]; id key; while((key = [e nextObject])) @@ -2240,7 +2240,7 @@ private: try { std::pair<const Ice::Byte*, const Ice::Byte*> b = os_->finished(); - return [NSData dataWithBytesNoCopy:const_cast<Ice::Byte*>(b.first) length:(b.second - b.first) freeWhenDone:NO]; + return [NSData dataWithBytesNoCopy:const_cast<Ice::Byte*>(b.first) length:static_cast<NSUInteger>(b.second - b.first) freeWhenDone:NO]; } catch(const std::exception& ex) { @@ -2917,7 +2917,7 @@ private: } +(ICEInt) count:(id)obj { - return [obj count]; + return static_cast<ICEInt>([obj count]); } @end @@ -2954,7 +2954,7 @@ private: } +(ICEInt) count:(id)obj { - return [obj length] / [[self getElementHelper] minWireSize]; + return static_cast<ICEInt>([obj length]) / [[self getElementHelper] minWireSize]; } +(Class) getElementHelper { @@ -3104,7 +3104,7 @@ private: @implementation ICEEnumSequenceHelper +(ICEInt) count:(id)obj { - return [obj length] / ENUM_SIZE; + return static_cast<ICEInt>([obj length] / ENUM_SIZE); } +(Class) getElementHelper { @@ -3206,7 +3206,7 @@ private: } +(ICEInt) count:(id)obj { - return [obj count]; + return static_cast<ICEInt>([obj count]); } @end diff --git a/objective-c/src/Ice/Util.h b/objective-c/src/Ice/Util.h index 7fce38929ac..2c31fb62c11 100644 --- a/objective-c/src/Ice/Util.h +++ b/objective-c/src/Ice/Util.h @@ -141,7 +141,7 @@ fromNSData(NSData* array, std::vector<T>& seq) { if(array != nil) { - int len = [array length] / sizeof(T); + size_t len = static_cast<size_t>([array length]) / sizeof(T); seq.reserve(len); T* src = (T*)[array bytes]; while(len-- > 0) diff --git a/objective-c/test/Ice/admin/AllTests.m b/objective-c/test/Ice/admin/AllTests.m index 01b223f8ccd..41e6c9a4c7b 100644 --- a/objective-c/test/Ice/admin/AllTests.m +++ b/objective-c/test/Ice/admin/AllTests.m @@ -392,7 +392,7 @@ adminAllTests(id<ICECommunicator> communicator) test([logMessages count] == 4); test([prefix isEqual:@"NullLogger"]); - int i = 0; + NSUInteger i = 0; test([((ICELogMessage*)[logMessages objectAtIndex:i]).traceCategory isEqual:@"testCat"] && [((ICELogMessage*)[logMessages objectAtIndex:i++]).message isEqual:@"trace"]); test([((ICELogMessage*)[logMessages objectAtIndex:i++]).message isEqual:@"warning"]); diff --git a/objective-c/test/Ice/binding/AllTests.m b/objective-c/test/Ice/binding/AllTests.m index e3df5180c1e..909ccb6132f 100644 --- a/objective-c/test/Ice/binding/AllTests.m +++ b/objective-c/test/Ice/binding/AllTests.m @@ -89,11 +89,11 @@ getEndpoints(id<TestBindingTestIntfPrx> proxy) { NSMutableArray* edpts = [NSMutableArray array]; bool escape = NO; - int beg = 0; - int length = 0; + NSUInteger beg = 0; + NSUInteger length = 0; NSString* s = [proxy ice_toString]; - int index; - for(index = 0; index < (int)[s length]; ++index) + NSUInteger index; + for(index = 0; index < [s length]; ++index) { unichar c = [s characterAtIndex:index]; if(c == '"') @@ -156,7 +156,7 @@ random_shuffle(NSMutableArray* array) NSUInteger count = [array count]; while(count--) { - [array exchangeObjectAtIndex:count withObjectAtIndex:(random() % (count + 1))]; + [array exchangeObjectAtIndex:count withObjectAtIndex:(NSUInteger)random() % (count + 1)]; } } diff --git a/objective-c/test/Ice/enums/AllTests.m b/objective-c/test/Ice/enums/AllTests.m index dd8c8477a64..b116c9ec60d 100644 --- a/objective-c/test/Ice/enums/AllTests.m +++ b/objective-c/test/Ice/enums/AllTests.m @@ -94,9 +94,9 @@ enumAllTests(id<ICECommunicator> communicator) TestEnumbenum6, TestEnumbenum7, TestEnumbenum8, TestEnumbenum9, TestEnumbenum10, TestEnumbenum11}; - int enumSize = sizeof(TestEnumByteEnum); - int length = sizeof(values); - int elements = length/enumSize; + NSUInteger enumSize = sizeof(TestEnumByteEnum); + NSUInteger length = sizeof(values); + NSUInteger elements = length / enumSize; TestEnumMutableByteEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableByteEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; @@ -106,7 +106,7 @@ enumAllTests(id<ICECommunicator> communicator) ICEByte* p2 = (ICEByte *)[enumSeq2 bytes]; ICEByte* p3 = (ICEByte *)[enumSeq3 bytes]; - for(int i = 0; i < elements; ++i) + for(NSUInteger i = 0; i < elements; ++i) { test(*p1 == *p2); test(*p1 == *p3); @@ -121,9 +121,9 @@ enumAllTests(id<ICECommunicator> communicator) TestEnumsenum6, TestEnumsenum7, TestEnumsenum8, TestEnumsenum9, TestEnumsenum10, TestEnumsenum11}; - int enumSize = sizeof(TestEnumShortEnum); - int length = sizeof(values); - int elements = length/enumSize; + NSUInteger enumSize = sizeof(TestEnumShortEnum); + NSUInteger length = sizeof(values); + NSUInteger elements = length / enumSize; TestEnumMutableShortEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableShortEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; @@ -133,7 +133,7 @@ enumAllTests(id<ICECommunicator> communicator) ICEByte* p2 = (ICEByte *)[enumSeq2 bytes]; ICEByte* p3 = (ICEByte *)[enumSeq3 bytes]; - for(int i = 0; i < elements; ++i) + for(NSUInteger i = 0; i < elements; ++i) { test(*p1 == *p2); test(*p1 == *p3); @@ -149,9 +149,9 @@ enumAllTests(id<ICECommunicator> communicator) TestEnumienum6, TestEnumienum7, TestEnumienum8, TestEnumienum9, TestEnumienum10, TestEnumienum11}; - int enumSize = sizeof(TestEnumShortEnum); - int length = sizeof(values); - int elements = length/enumSize; + NSUInteger enumSize = sizeof(TestEnumShortEnum); + NSUInteger length = sizeof(values); + NSUInteger elements = length / enumSize; TestEnumMutableShortEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableShortEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; @@ -161,7 +161,7 @@ enumAllTests(id<ICECommunicator> communicator) ICEByte* p2 = (ICEByte *)[enumSeq2 bytes]; ICEByte* p3 = (ICEByte *)[enumSeq3 bytes]; - for(int i = 0; i < elements; ++i) + for(NSUInteger i = 0; i < elements; ++i) { test(*p1 == *p2); test(*p1 == *p3); @@ -175,9 +175,9 @@ enumAllTests(id<ICECommunicator> communicator) TestEnumSimpleEnum values[] = {TestEnumred, TestEnumgreen, TestEnumblue}; - int enumSize = sizeof(TestEnumShortEnum); - int length = sizeof(values); - int elements = length/enumSize; + NSUInteger enumSize = sizeof(TestEnumShortEnum); + NSUInteger length = sizeof(values); + NSUInteger elements = length / enumSize; TestEnumMutableShortEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableShortEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; @@ -187,7 +187,7 @@ enumAllTests(id<ICECommunicator> communicator) ICEByte* p2 = (ICEByte *)[enumSeq2 bytes]; ICEByte* p3 = (ICEByte *)[enumSeq3 bytes]; - for(int i = 0; i < elements; ++i) + for(NSUInteger i = 0; i < elements; ++i) { test(*p1 == *p2); test(*p1 == *p3); @@ -260,11 +260,11 @@ enumAllTests(id<ICECommunicator> communicator) TestEnumbenum6, (TestEnumByteEnum)-1, TestEnumbenum8, TestEnumbenum9, TestEnumbenum10, TestEnumbenum11}; // Negative enumerators are not supported - int length = sizeof(values); + NSUInteger length = sizeof(values); TestEnumMutableByteEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableByteEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; - @try + @try { [proxy opByteSeq:enumSeq1 b2:&enumSeq2]; test(NO); @@ -279,11 +279,11 @@ enumAllTests(id<ICECommunicator> communicator) TestEnumbenum6, (TestEnumByteEnum)127, TestEnumbenum8, TestEnumbenum9, TestEnumbenum10, TestEnumbenum11}; // Invalid enumerator - int length = sizeof(values); + NSUInteger length = sizeof(values); TestEnumMutableByteEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableByteEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; - @try + @try { [proxy opByteSeq:enumSeq1 b2:&enumSeq2]; test(NO); @@ -299,7 +299,7 @@ enumAllTests(id<ICECommunicator> communicator) (TestEnumShortEnum)-1, TestEnumsenum7, TestEnumsenum8, TestEnumsenum9, TestEnumsenum10, TestEnumsenum11}; // Negative enumerators are not supported - int length = sizeof(values); + NSUInteger length = sizeof(values); TestEnumMutableShortEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableShortEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; @@ -319,7 +319,7 @@ enumAllTests(id<ICECommunicator> communicator) (TestEnumShortEnum)0, TestEnumsenum7, TestEnumsenum8, TestEnumsenum9, TestEnumsenum10, TestEnumsenum11}; // Invalid enumerator - int length = sizeof(values); + NSUInteger length = sizeof(values); TestEnumMutableShortEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableShortEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; @@ -339,7 +339,7 @@ enumAllTests(id<ICECommunicator> communicator) (TestEnumShortEnum)32767, TestEnumsenum7, TestEnumsenum8, TestEnumsenum9, TestEnumsenum10, TestEnumsenum11}; // Invalid enumerator - int length = sizeof(values); + NSUInteger length = sizeof(values); TestEnumMutableShortEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableShortEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; @@ -359,7 +359,7 @@ enumAllTests(id<ICECommunicator> communicator) (TestEnumIntEnum)-1, TestEnumienum7, TestEnumienum8, TestEnumienum9, TestEnumienum10, TestEnumienum11}; // Negative enumerators are not supported - int length = sizeof(values); + NSUInteger length = sizeof(values); TestEnumMutableShortEnumSeq* enumSeq1 = [NSMutableData dataWithBytes:values length:length]; TestEnumMutableShortEnumSeq* enumSeq2 = [NSMutableData dataWithLength:length]; diff --git a/objective-c/test/Ice/exceptions/TestI.m b/objective-c/test/Ice/exceptions/TestI.m index 17463a7d8d4..bcfceb948db 100644 --- a/objective-c/test/Ice/exceptions/TestI.m +++ b/objective-c/test/Ice/exceptions/TestI.m @@ -109,7 +109,7 @@ -(ICEByteSeq*) throwMemoryLimitException:(ICEMutableByteSeq*)__unused bs current:(ICECurrent*)__unused current { - int limit = 20 * 1024; + NSUInteger limit = 20 * 1024; ICEMutableByteSeq *r = [NSMutableData dataWithLength:limit]; ICEByte *p = (ICEByte *)[r bytes]; while(--limit > 0) diff --git a/objective-c/test/Ice/hash/AllTests.m b/objective-c/test/Ice/hash/AllTests.m index c5da614c8b4..8533410f39b 100644 --- a/objective-c/test/Ice/hash/AllTests.m +++ b/objective-c/test/Ice/hash/AllTests.m @@ -89,9 +89,9 @@ hashAllTests() NSMutableDictionary* seenObject = [[NSMutableDictionary alloc] init]; for(int i = 0; collisions < maxCollisions && i < maxIterations; ++i) { - TestHashPointF* obj = [TestHashPointF pointF:(arc4random() % 1000)/3.0 - y:(arc4random() % 1000)/5.0 - z:(arc4random() % 1000)/7.0]; + TestHashPointF* obj = [TestHashPointF pointF:(arc4random() % 1000) / 3.0f + y:(arc4random() % 1000) / 5.0f + z:(arc4random() % 1000) / 7.0f]; NSNumber* hash = [NSNumber numberWithUnsignedInteger:[obj hash]]; if([seenObject objectForKey:hash]) diff --git a/objective-c/test/Ice/hold/TestI.m b/objective-c/test/Ice/hold/TestI.m index 0213fb0d165..c1e5a4e5f1d 100644 --- a/objective-c/test/Ice/hold/TestI.m +++ b/objective-c/test/Ice/hold/TestI.m @@ -28,7 +28,7 @@ -(void) schedule:(void(^)(void))callback timeout:(ICEInt)t { dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); - dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, t * NSEC_PER_MSEC), DISPATCH_TIME_FOREVER, 0); + dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, t * (ICEInt)NSEC_PER_MSEC), DISPATCH_TIME_FOREVER, 0); dispatch_source_set_event_handler(timer, ^{ callback(); dispatch_source_cancel(timer); diff --git a/objective-c/test/Ice/operations/TestI.m b/objective-c/test/Ice/operations/TestI.m index a61bf84f388..c5e7a9b6e4d 100644 --- a/objective-c/test/Ice/operations/TestI.m +++ b/objective-c/test/Ice/operations/TestI.m @@ -145,8 +145,8 @@ *p5 = [TestOperationsMutableIntS dataWithLength:[p2 length]]; ICEInt *target = (ICEInt *)[*p5 bytes]; ICEInt *src = (ICEInt *)([p2 bytes] + [p2 length]); - int i; - for(i = 0; i != (int)[p2 length] / sizeof(ICEInt); ++i) + NSUInteger i; + for(i = 0; i != [p2 length] / sizeof(ICEInt); ++i) { *target++ = *--src; } @@ -855,8 +855,6 @@ } @end - - @implementation TestOperationsBI -(void) opB:(ICECurrent*)__unused current diff --git a/objective-c/test/Ice/operations/Twoways.m b/objective-c/test/Ice/operations/Twoways.m index 8cc9825a59a..40c74784603 100644 --- a/objective-c/test/Ice/operations/Twoways.m +++ b/objective-c/test/Ice/operations/Twoways.m @@ -1460,7 +1460,7 @@ twoways(id<ICECommunicator> communicator, id<TestOperationsMyClassPrx> p, id<Tes ICEFloat buf1[] = { -1.1f, 123123.2f, 100.0f }; ICEFloat buf2[] = { 42.24f, -1.61f }; - ICEFloat buf3[] = { -3.14, 3.14 }; + ICEFloat buf3[] = { -3.14f, 3.14f }; TestOperationsMutableFloatS *si1 = [TestOperationsMutableFloatS data]; TestOperationsMutableFloatS *si2 = [TestOperationsMutableFloatS data]; @@ -1629,17 +1629,17 @@ twoways(id<ICECommunicator> communicator, id<TestOperationsMyClassPrx> p, id<Tes } { - const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; + const NSUInteger lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; - int l; + NSUInteger l; for(l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l) { TestOperationsMutableIntS *s = [TestOperationsMutableIntS dataWithLength:(lengths[l] * sizeof(ICEInt))]; ICEInt *ip = (ICEInt *)[s bytes]; - int i; + NSUInteger i; for(i = 0; i < lengths[l]; ++i) { - *ip++ = i; + *ip++ = (ICEInt)i; } TestOperationsIntS *r = [p opIntS:s]; test([r length] == lengths[l] * sizeof(ICEInt)); diff --git a/objective-c/test/Ice/operations/TwowaysAMI.m b/objective-c/test/Ice/operations/TwowaysAMI.m index 1a111534990..a2b1b886129 100644 --- a/objective-c/test/Ice/operations/TwowaysAMI.m +++ b/objective-c/test/Ice/operations/TwowaysAMI.m @@ -1813,7 +1813,7 @@ twowaysAMI(id<ICECommunicator> communicator, id<TestOperationsMyClassPrx> p) ICEFloat buf1[] = { -1.1f, 123123.2f, 100.0f }; ICEFloat buf2[] = { 42.24f, -1.61f }; - ICEFloat buf3[] = { -3.14, 3.14 }; + ICEFloat buf3[] = { -3.14f, 3.14f }; TestOperationsMutableFloatS *si1 = [TestOperationsMutableFloatS data]; TestOperationsMutableFloatS *si2 = [TestOperationsMutableFloatS data]; @@ -1928,17 +1928,18 @@ twowaysAMI(id<ICECommunicator> communicator, id<TestOperationsMyClassPrx> p) } { - const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; + const NSUInteger lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; - int l; + NSUInteger l; for(l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l) { - TestOperationsMutableIntS *s = [TestOperationsMutableIntS dataWithLength:(lengths[l] * sizeof(ICEInt))]; + TestOperationsMutableIntS *s = + [TestOperationsMutableIntS dataWithLength:(lengths[l] * sizeof(ICEInt))]; ICEInt *ip = (ICEInt *)[s bytes]; - int i; + NSUInteger i; for(i = 0; i < lengths[l]; ++i) { - *ip++ = i; + *ip++ = (ICEInt)i; } TestAMIOperationsCallback* cb = [TestAMIOperationsCallback create]; diff --git a/objective-c/test/Ice/proxy/AllTests.m b/objective-c/test/Ice/proxy/AllTests.m index 50fc2cbb7bd..8519772a1b3 100644 --- a/objective-c/test/Ice/proxy/AllTests.m +++ b/objective-c/test/Ice/proxy/AllTests.m @@ -714,6 +714,8 @@ proxyAllTests(id<ICECommunicator> communicator) id<ICEConnection> connection = [cl ice_getConnection]; if(connection != nil) { + test(![cl ice_isFixed]); + test([[cl ice_fixed:connection] ice_isFixed]); [[cl ice_fixed:connection] getContext]; test([[[cl ice_secure:YES] ice_fixed:connection] ice_isSecure]); test([[[[cl ice_facet:@"facet"] ice_fixed:connection] ice_getFacet] isEqualToString:@"facet"]); diff --git a/objective-c/test/Ice/slicing/objects/AllTests.m b/objective-c/test/Ice/slicing/objects/AllTests.m index 0dc911dfbbe..f41db004813 100644 --- a/objective-c/test/Ice/slicing/objects/AllTests.m +++ b/objective-c/test/Ice/slicing/objects/AllTests.m @@ -680,13 +680,13 @@ static void breakCycles(id o) test([res isKindOfClass:[TestSlicingObjectsClientPCDerived3 class]]); TestSlicingObjectsClientPCDerived3* p3 = (TestSlicingObjectsClientPCDerived3*)res; test(p3.pi == 3); - for(int i = 0; i < 300; ++i) + for(NSUInteger i = 0; i < 300; ++i) { TestSlicingObjectsClientPCDerived2* p2 = (TestSlicingObjectsClientPCDerived2*)[p3.pbs objectAtIndex:i]; - test(p2.pi == i); + test(p2.pi == (ICEInt)i); test([p2.pbs count] == 1); test([[p2.pbs objectAtIndex:0] isEqual:[NSNull null]]); - test(p2.pcd2 == i); + test(p2.pcd2 == (ICEInt)i); } test(p3.pcd2 == p3.pi); test([p3.pcd3 isEqual:[p3.pbs objectAtIndex:10]]); @@ -2293,14 +2293,14 @@ slicingObjectsAllTests(id<ICECommunicator> communicator) // // Sending more than 254 objects exercises the encoding for object ids. // - int i; + NSUInteger i; pcd.pbs = [NSArray array]; for(i = 0; i < 300; ++i) { TestSlicingObjectsClientPCDerived2* p2 = [TestSlicingObjectsClientPCDerived2 pcDerived2]; - p2.pi = i; + p2.pi = (ICEInt)i; p2.pbs = [NSArray arrayWithObjects:[NSNull null], nil]; // Nil reference. This slice should not have an indirection table. - p2.pcd2 = i; + p2.pcd2 = (ICEInt)i; pcd.pbs = [pcd.pbs arrayByAddingObject:p2]; } pcd.pcd2 = pcd.pi; @@ -2321,10 +2321,10 @@ slicingObjectsAllTests(id<ICECommunicator> communicator) for(i = 0; i < 300; ++i) { TestSlicingObjectsClientPCDerived2* p2 = (TestSlicingObjectsClientPCDerived2*)[p3.pbs objectAtIndex:i]; - test(p2.pi == i); + test(p2.pi == (ICEInt)i); test([p2.pbs count] == 1); test([[p2.pbs objectAtIndex:0] isEqual:[NSNull null]]); - test(p2.pcd2 == i); + test(p2.pcd2 == (ICEInt)i); } test(p3.pcd2 == p3.pi); test(p3.pcd3 == [p3.pbs objectAtIndex:10]); diff --git a/objective-c/test/Ice/stream/Client.m b/objective-c/test/Ice/stream/Client.m index 0fd785433d8..b51a3b43f29 100644 --- a/objective-c/test/Ice/stream/Client.m +++ b/objective-c/test/Ice/stream/Client.m @@ -477,7 +477,7 @@ run(id<ICECommunicator> communicator) TestStreamSmallStructS* arr2 = [TestStreamSmallStructSHelper read:in]; [in readPendingValues]; test([arr2 count] == [arr count]); - for(int j = 0; j < (int)[arr2 count]; ++j) + for(NSUInteger j = 0; j < [arr2 count]; ++j) { test([[arr objectAtIndex:j] isEqual:[arr2 objectAtIndex:j]]); } @@ -548,7 +548,7 @@ run(id<ICECommunicator> communicator) [in readPendingValues]; test([arr2 count] > 0); test([arr2 count] == [arr count]); - for(int j = 0; j < (int)[arr2 count]; ++j) + for(NSUInteger j = 0; j < [arr2 count]; ++j) { TestStreamMyClass* e = [arr2 objectAtIndex:j]; TestStreamMyClass* f = [arr objectAtIndex:j]; diff --git a/php/src/php5/Proxy.cpp b/php/src/php5/Proxy.cpp index ccdd4a1873a..f398b8f3d20 100644 --- a/php/src/php5/Proxy.cpp +++ b/php/src/php5/Proxy.cpp @@ -1348,6 +1348,28 @@ ZEND_METHOD(Ice_ObjectPrx, ice_fixed) } } +ZEND_METHOD(Ice_ObjectPrx, ice_isFixed) +{ + if(ZEND_NUM_ARGS() != 0) + { + WRONG_PARAM_COUNT; + } + + ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis() TSRMLS_CC); + assert(_this); + + try + { + bool b = _this->proxy->ice_isFixed(); + RETURN_BOOL(b ? 1 : 0); + } + catch(const IceUtil::Exception& ex) + { + throwException(ex TSRMLS_CC); + RETURN_FALSE; + } +} + ZEND_METHOD(Ice_ObjectPrx, ice_getConnection) { if(ZEND_NUM_ARGS() != 0) @@ -1789,6 +1811,7 @@ static zend_function_entry _proxyMethods[] = ZEND_ME(Ice_ObjectPrx, ice_getInvocationTimeout, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_connectionId, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_fixed, ICE_NULLPTR, ZEND_ACC_PUBLIC) + ZEND_ME(Ice_ObjectPrx, ice_isFixed, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_getConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_getCachedConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_flushBatchRequests, ICE_NULLPTR, ZEND_ACC_PUBLIC) diff --git a/php/src/php7/Config.h b/php/src/php7/Config.h index fa43f45e803..48caba41981 100644 --- a/php/src/php7/Config.h +++ b/php/src/php7/Config.h @@ -33,6 +33,9 @@ extern "C" #ifdef _WIN32 # pragma warning( disable : 4018) // suppress signed/unsigned mismatch in zend_execute.h (PHP 5.3.x) +#elif defined(__clang__) +# pragma clang diagnostic ignored "-Wconversion" +# pragma clang diagnostic ignored "-Wsign-conversion" #elif defined(__GNUC__) # pragma GCC diagnostic warning "-Wsign-compare" #endif diff --git a/php/src/php7/Proxy.cpp b/php/src/php7/Proxy.cpp index 898ff63ae45..2e83a1d5378 100644 --- a/php/src/php7/Proxy.cpp +++ b/php/src/php7/Proxy.cpp @@ -1335,6 +1335,28 @@ ZEND_METHOD(Ice_ObjectPrx, ice_fixed) } } +ZEND_METHOD(Ice_ObjectPrx, ice_isFixed) +{ + if(ZEND_NUM_ARGS() != 0) + { + WRONG_PARAM_COUNT; + } + + ProxyPtr _this = Wrapper<ProxyPtr>::value(getThis()); + assert(_this); + + try + { + bool b = _this->proxy->ice_isFixed(); + RETURN_BOOL(b ? 1 : 0); + } + catch(const IceUtil::Exception& ex) + { + throwException(ex); + RETURN_FALSE; + } +} + ZEND_METHOD(Ice_ObjectPrx, ice_getConnection) { if(ZEND_NUM_ARGS() != 0) @@ -1742,6 +1764,7 @@ static zend_function_entry _proxyMethods[] = ZEND_ME(Ice_ObjectPrx, ice_getInvocationTimeout, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_connectionId, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_fixed, ICE_NULLPTR, ZEND_ACC_PUBLIC) + ZEND_ME(Ice_ObjectPrx, ice_isFixed, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_getConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_getCachedConnection, ICE_NULLPTR, ZEND_ACC_PUBLIC) ZEND_ME(Ice_ObjectPrx, ice_flushBatchRequests, ICE_NULLPTR, ZEND_ACC_PUBLIC) diff --git a/php/test/Ice/proxy/Client.php b/php/test/Ice/proxy/Client.php index 093177041c5..a4a7689376f 100644 --- a/php/test/Ice/proxy/Client.php +++ b/php/test/Ice/proxy/Client.php @@ -509,6 +509,8 @@ function allTests($helper) $connection = $cl->ice_getConnection(); if($connection != null) { + test(!$cl->ice_isFixed()); + test($cl->ice_fixed($connection)->ice_isFixed()); $cl->ice_fixed($connection)->getContext(); test($cl->ice_secure(true)->ice_fixed($connection)->ice_isSecure()); test($cl->ice_facet("facet")->ice_fixed($connection)->ice_getFacet() == "facet"); diff --git a/python/modules/IcePy/Operation.cpp b/python/modules/IcePy/Operation.cpp index ed0ef82e10e..f4bcd8256cc 100644 --- a/python/modules/IcePy/Operation.cpp +++ b/python/modules/IcePy/Operation.cpp @@ -3199,7 +3199,7 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) // // Create the output buffer and copy in the outParams. // - PyObjectHandle op = PyBuffer_New(out.size()); + PyObjectHandle op = PyBuffer_New(static_cast<Py_ssize_t>(out.size())); if(!op.get()) { throwPythonException(); @@ -3212,7 +3212,7 @@ IcePy::SyncBlobjectInvocation::invoke(PyObject* args, PyObject* /* kwds */) { throwPythonException(); } - memcpy(buf, &out[0], ssz); + memcpy(buf, &out[0], static_cast<size_t>(ssz)); } #endif @@ -3481,7 +3481,7 @@ IcePy::AsyncBlobjectInvocation::end(const Ice::ObjectPrx& proxy, const Ice::Asyn return 0; } assert(sz == results.second - results.first); - memcpy(buf, results.first, sz); + memcpy(buf, results.first, static_cast<size_t>(sz)); #endif PyTuple_SET_ITEM(args.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference. @@ -3563,7 +3563,7 @@ IcePy::AsyncBlobjectInvocation::response(bool ok, const pair<const Ice::Byte*, c return; } assert(sz == results.second - results.first); - memcpy(buf, results.first, sz); + memcpy(buf, results.first, static_cast<size_t>(sz)); #endif PyTuple_SET_ITEM(args.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference. @@ -3750,7 +3750,7 @@ IcePy::NewAsyncBlobjectInvocation::handleResponse(PyObject* future, bool ok, return; } assert(sz == results.second - results.first); - memcpy(buf, results.first, sz); + memcpy(buf, results.first, static_cast<size_t>(sz)); #endif PyTuple_SET_ITEM(args.get(), 1, op.release()); // PyTuple_SET_ITEM steals a reference. @@ -4082,7 +4082,7 @@ IcePy::BlobjectUpcall::dispatch(PyObject* servant, const pair<const Ice::Byte*, throwPythonException(); } assert(sz == inBytes.second - inBytes.first); - memcpy(buf, inBytes.first, sz); + memcpy(buf, inBytes.first, static_cast<size_t>(sz)); #endif PyTuple_SET_ITEM(args.get(), start, ip.release()); // PyTuple_SET_ITEM steals a reference. diff --git a/python/modules/IcePy/Proxy.cpp b/python/modules/IcePy/Proxy.cpp index d1733d6d993..c558dd315e8 100644 --- a/python/modules/IcePy/Proxy.cpp +++ b/python/modules/IcePy/Proxy.cpp @@ -1866,6 +1866,29 @@ proxyIceFixed(ProxyObject* self, PyObject* args) extern "C" #endif static PyObject* +proxyIceIsFixed(ProxyObject* self, PyObject* /*args*/) +{ + assert(self->proxy); + + PyObject* b; + try + { + b = (*self->proxy)->ice_isFixed() ? getTrue() : getFalse(); + } + catch(const Ice::Exception& ex) + { + setPythonException(ex); + return 0; + } + + Py_INCREF(b); + return b; +} + +#ifdef WIN32 +extern "C" +#endif +static PyObject* proxyIceGetConnection(ProxyObject* self, PyObject* /*args*/) { assert(self->proxy); @@ -2763,6 +2786,8 @@ static PyMethodDef ProxyMethods[] = PyDoc_STR(STRCAST("ice_connectionId(string) -> Ice.ObjectPrx")) }, { STRCAST("ice_fixed"), reinterpret_cast<PyCFunction>(proxyIceFixed), METH_VARARGS, PyDoc_STR(STRCAST("ice_fixed(Ice.Connection) -> Ice.ObjectPrx")) }, + { STRCAST("ice_isFixed"), reinterpret_cast<PyCFunction>(proxyIceIsFixed), METH_NOARGS, + PyDoc_STR(STRCAST("ice_isFixed() -> bool")) }, { STRCAST("ice_getConnection"), reinterpret_cast<PyCFunction>(proxyIceGetConnection), METH_NOARGS, PyDoc_STR(STRCAST("ice_getConnection() -> Ice.Connection")) }, { STRCAST("ice_getConnectionAsync"), reinterpret_cast<PyCFunction>(proxyIceGetConnectionAsync), diff --git a/python/modules/IcePy/Types.cpp b/python/modules/IcePy/Types.cpp index 2e33db2c632..7ecc7379af7 100644 --- a/python/modules/IcePy/Types.cpp +++ b/python/modules/IcePy/Types.cpp @@ -464,7 +464,7 @@ IcePy::StreamUtil::setSlicedDataMember(PyObject* obj, const Ice::SlicedDataPtr& throw AbortMarshaling(); } - PyObjectHandle slices = PyTuple_New(slicedData->slices.size()); + PyObjectHandle slices = PyTuple_New(static_cast<Py_ssize_t>(slicedData->slices.size())); if(!slices.get()) { assert(PyErr_Occurred()); @@ -520,9 +520,11 @@ IcePy::StreamUtil::setSlicedDataMember(PyObject* obj, const Ice::SlicedDataPtr& if((*p)->bytes.size() > 0) { #if PY_VERSION_HEX >= 0x03000000 - bytes = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size()); + bytes = PyBytes_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), + static_cast<Py_ssize_t>((*p)->bytes.size())); #else - bytes = PyString_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size()); + bytes = PyString_FromStringAndSize(reinterpret_cast<const char*>(&(*p)->bytes[0]), + static_cast<Py_ssize_t>((*p)->bytes.size())); #endif } else @@ -542,7 +544,7 @@ IcePy::StreamUtil::setSlicedDataMember(PyObject* obj, const Ice::SlicedDataPtr& // // instances // - PyObjectHandle instances = PyTuple_New((*p)->instances.size()); + PyObjectHandle instances = PyTuple_New(static_cast<Py_ssize_t>((*p)->instances.size())); if(!instances.get() || PyObject_SetAttrString(slice.get(), STRCAST("instances"), instances.get()) < 0) { assert(PyErr_Occurred()); @@ -2040,7 +2042,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje case PrimitiveInfo::KindBool: { sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::BoolSeq seq(sz); + Ice::BoolSeq seq(static_cast<size_t>(sz)); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); @@ -2056,7 +2058,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje static_cast<int>(i)); throw AbortMarshaling(); } - seq[i] = isTrue ? true : false; + seq[static_cast<size_t>(i)] = isTrue ? true : false; } os->write(seq); break; @@ -2080,7 +2082,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje else { sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::ByteSeq seq(sz); + Ice::ByteSeq seq(static_cast<size_t>(sz)); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); @@ -2098,7 +2100,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje static_cast<int>(i)); throw AbortMarshaling(); } - seq[i] = static_cast<Ice::Byte>(val); + seq[static_cast<size_t>(i)] = static_cast<Ice::Byte>(val); } os->write(seq); } @@ -2107,7 +2109,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje case PrimitiveInfo::KindShort: { sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::ShortSeq seq(sz); + Ice::ShortSeq seq(static_cast<size_t>(sz)); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); @@ -2125,7 +2127,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje static_cast<int>(i)); throw AbortMarshaling(); } - seq[i] = static_cast<Ice::Short>(val); + seq[static_cast<size_t>(i)] = static_cast<Ice::Short>(val); } os->write(seq); break; @@ -2133,7 +2135,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje case PrimitiveInfo::KindInt: { sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::IntSeq seq(sz); + Ice::IntSeq seq(static_cast<size_t>(sz)); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); @@ -2151,7 +2153,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje static_cast<int>(i)); throw AbortMarshaling(); } - seq[i] = static_cast<Ice::Int>(val); + seq[static_cast<size_t>(i)] = static_cast<Ice::Int>(val); } os->write(seq); break; @@ -2159,7 +2161,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje case PrimitiveInfo::KindLong: { sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::LongSeq seq(sz); + Ice::LongSeq seq(static_cast<size_t>(sz)); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); @@ -2177,7 +2179,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje static_cast<int>(i)); throw AbortMarshaling(); } - seq[i] = val; + seq[static_cast<size_t>(i)] = val; } os->write(seq); break; @@ -2185,7 +2187,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje case PrimitiveInfo::KindFloat: { sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::FloatSeq seq(sz); + Ice::FloatSeq seq(static_cast<size_t>(sz)); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); @@ -2203,7 +2205,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - seq[i] = val; + seq[static_cast<size_t>(i)] = val; } os->write(seq); break; @@ -2211,7 +2213,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje case PrimitiveInfo::KindDouble: { sz = PySequence_Fast_GET_SIZE(fs.get()); - Ice::DoubleSeq seq(sz); + Ice::DoubleSeq seq(static_cast<size_t>(sz)); for(Py_ssize_t i = 0; i < sz; ++i) { PyObject* item = PySequence_Fast_GET_ITEM(fs.get(), i); @@ -2229,7 +2231,7 @@ IcePy::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, PyObje throw AbortMarshaling(); } - seq[i] = val; + seq[static_cast<size_t>(i)] = val; } os->write(seq); break; @@ -2622,7 +2624,7 @@ IcePy::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, Ice: for(int i = 0; i < sz; ++i) { - PyObjectHandle item = createString(seq[i]); + PyObjectHandle item = createString(seq[static_cast<size_t>(i)]); if(!item.get()) { assert(PyErr_Occurred()); diff --git a/python/modules/IcePy/Util.cpp b/python/modules/IcePy/Util.cpp index 30c2a877223..6a17e0e4c1d 100644 --- a/python/modules/IcePy/Util.cpp +++ b/python/modules/IcePy/Util.cpp @@ -177,7 +177,7 @@ IcePy::getString(PyObject* p) str.assign(s, sz); } #else - str.assign(PyString_AS_STRING(p), PyString_GET_SIZE(p)); + str.assign(PyString_AS_STRING(p), static_cast<size_t>(PyString_GET_SIZE(p))); #endif } return str; diff --git a/python/test/Ice/proxy/AllTests.py b/python/test/Ice/proxy/AllTests.py index 7f4781b55d2..e5bc5b9339f 100644 --- a/python/test/Ice/proxy/AllTests.py +++ b/python/test/Ice/proxy/AllTests.py @@ -654,6 +654,8 @@ def allTests(helper, communicator, collocated): sys.stdout.flush() connection = cl.ice_getConnection() if connection != None: + test(cl.ice_isFixed() == False) + test(cl.ice_fixed(connection).ice_isFixed()) cl.ice_fixed(connection).getContext() test(cl.ice_secure(True).ice_fixed(connection).ice_isSecure()) test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet") diff --git a/ruby/src/IceRuby/Operation.cpp b/ruby/src/IceRuby/Operation.cpp index 24c4a3be763..e69b5059ae1 100644 --- a/ruby/src/IceRuby/Operation.cpp +++ b/ruby/src/IceRuby/Operation.cpp @@ -64,8 +64,8 @@ private: bool _returnsClasses; string _deprecateMessage; - void convertParams(VALUE, ParamInfoList&, int, bool&); - ParamInfoPtr convertParam(VALUE, int); + void convertParams(VALUE, ParamInfoList&, long, bool&); + ParamInfoPtr convertParam(VALUE, long); void prepareRequest(const Ice::ObjectPrx&, VALUE, Ice::OutputStream*, pair<const Ice::Byte*, const Ice::Byte*>&); VALUE unmarshalResults(const vector<Ice::Byte>&, const Ice::CommunicatorPtr&); VALUE unmarshalException(const vector<Ice::Byte>&, const Ice::CommunicatorPtr&); @@ -367,7 +367,7 @@ IceRuby::OperationI::deprecate(const string& msg) } void -IceRuby::OperationI::convertParams(VALUE v, ParamInfoList& params, int posOffset, bool& usesClasses) +IceRuby::OperationI::convertParams(VALUE v, ParamInfoList& params, long posOffset, bool& usesClasses) { assert(TYPE(v) == T_ARRAY); @@ -383,14 +383,14 @@ IceRuby::OperationI::convertParams(VALUE v, ParamInfoList& params, int posOffset } ParamInfoPtr -IceRuby::OperationI::convertParam(VALUE v, int pos) +IceRuby::OperationI::convertParam(VALUE v, long pos) { assert(TYPE(v) == T_ARRAY); ParamInfoPtr param = new ParamInfo; param->type = getType(RARRAY_AREF(v, 0)); param->optional = static_cast<bool>(RTEST(RARRAY_AREF(v, 1))); param->tag = static_cast<int>(getInteger(RARRAY_AREF(v, 2))); - param->pos = pos; + param->pos = static_cast<int>(pos); return param; } diff --git a/ruby/src/IceRuby/Properties.cpp b/ruby/src/IceRuby/Properties.cpp index 567c315b405..edd5f7fe059 100644 --- a/ruby/src/IceRuby/Properties.cpp +++ b/ruby/src/IceRuby/Properties.cpp @@ -136,7 +136,7 @@ IceRuby_Properties_getPropertyAsIntWithDefault(VALUE self, VALUE key, VALUE def) { Ice::PropertiesPtr p = getProperties(self); string k = getString(key); - Ice::Int d = getInteger(def); + Ice::Int d = static_cast<Ice::Int>(getInteger(def)); Ice::Int v = p->getPropertyAsIntWithDefault(k, d); return INT2FIX(v); } diff --git a/ruby/src/IceRuby/Proxy.cpp b/ruby/src/IceRuby/Proxy.cpp index d5b1c175baa..f51e5e03f46 100644 --- a/ruby/src/IceRuby/Proxy.cpp +++ b/ruby/src/IceRuby/Proxy.cpp @@ -153,7 +153,7 @@ IceRuby_ObjectPrx_ice_ids(int argc, VALUE* argv, VALUE self) checkArgs("ice_ids", 0, argc, argv, ctx); vector<string> ids = p->ice_ids(ctx); - volatile VALUE result = createArray(ids.size()); + volatile VALUE result = createArray(static_cast<long>(ids.size())); long i = 0; for(vector<string>::iterator q = ids.begin(); q != ids.end(); ++q, ++i) { @@ -307,7 +307,7 @@ IceRuby_ObjectPrx_ice_getEndpoints(VALUE self) Ice::ObjectPrx p = getProxy(self); Ice::EndpointSeq seq = p->ice_getEndpoints(); - volatile VALUE result = createArray(seq.size()); + volatile VALUE result = createArray(static_cast<long>(seq.size())); long i = 0; for(Ice::EndpointSeq::iterator q = seq.begin(); q != seq.end(); ++q, ++i) { @@ -921,6 +921,19 @@ IceRuby_ObjectPrx_ice_fixed(VALUE self, VALUE con) extern "C" VALUE +IceRuby_ObjectPrx_ice_isFixed(VALUE self) +{ + ICE_RUBY_TRY + { + Ice::ObjectPrx p = getProxy(self); + return p->ice_isFixed() ? Qtrue : Qfalse; + } + ICE_RUBY_CATCH + return Qnil; +} + +extern "C" +VALUE IceRuby_ObjectPrx_ice_getConnection(VALUE self) { ICE_RUBY_TRY @@ -1329,6 +1342,7 @@ IceRuby::initProxy(VALUE iceModule) rb_define_method(_proxyClass, "ice_getTimeout", CAST_METHOD(IceRuby_ObjectPrx_ice_getTimeout), 0); rb_define_method(_proxyClass, "ice_connectionId", CAST_METHOD(IceRuby_ObjectPrx_ice_connectionId), 1); rb_define_method(_proxyClass, "ice_fixed", CAST_METHOD(IceRuby_ObjectPrx_ice_fixed), 1); + rb_define_method(_proxyClass, "ice_isFixed", CAST_METHOD(IceRuby_ObjectPrx_ice_isFixed), 0); rb_define_method(_proxyClass, "ice_getConnection", CAST_METHOD(IceRuby_ObjectPrx_ice_getConnection), 0); rb_define_method(_proxyClass, "ice_getCachedConnection", CAST_METHOD(IceRuby_ObjectPrx_ice_getCachedConnection), 0); rb_define_method(_proxyClass, "ice_flushBatchRequests", CAST_METHOD(IceRuby_ObjectPrx_ice_flushBatchRequests), 0); diff --git a/ruby/src/IceRuby/Types.cpp b/ruby/src/IceRuby/Types.cpp index 5563b6fb57e..29f79f15ae5 100644 --- a/ruby/src/IceRuby/Types.cpp +++ b/ruby/src/IceRuby/Types.cpp @@ -75,9 +75,9 @@ escapeString(const string& str) { if(charSet.find(*c) == charSet.end()) { - unsigned char uc = *c; // char may be signed, so make it positive + unsigned char uc = static_cast<unsigned char>(*c); // char may be signed, so make it positive ostringstream s; - s << "\\"; // Print as octal if not in basic source character set + s << "\\"; // Print as octal if not in basic source character set s.width(3); s.fill('0'); s << oct; @@ -240,8 +240,7 @@ IceRuby::StreamUtil::setSlicedDataMember(VALUE obj, const Ice::SlicedDataPtr& sl volatile VALUE sd = callRuby(rb_class_new_instance, 0, static_cast<VALUE*>(0), _slicedDataType); - Ice::Int sz = slicedData->slices.size(); - volatile VALUE slices = createArray(sz); + volatile VALUE slices = createArray(static_cast<long>(slicedData->slices.size())); callRuby(rb_iv_set, sd, "@slices", slices); @@ -271,13 +270,14 @@ IceRuby::StreamUtil::setSlicedDataMember(VALUE obj, const Ice::SlicedDataPtr& sl // // bytes // - volatile VALUE bytes = callRuby(rb_str_new, reinterpret_cast<const char*>(&(*p)->bytes[0]), (*p)->bytes.size()); + volatile VALUE bytes = callRuby(rb_str_new, reinterpret_cast<const char*>(&(*p)->bytes[0]), + static_cast<long>((*p)->bytes.size())); callRuby(rb_iv_set, slice, "@bytes", bytes); // // instances // - volatile VALUE instances = createArray((*p)->instances.size()); + volatile VALUE instances = createArray(static_cast<long>((*p)->instances.size())); callRuby(rb_iv_set, slice, "@instances", instances); int j = 0; @@ -1012,7 +1012,7 @@ IceRuby::StructInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap* objectMa p = _nullMarshalValue; } - Ice::OutputStream::size_type sizePos = -1; + Ice::OutputStream::size_type sizePos; if(optional) { if(_variableLength) @@ -1187,7 +1187,7 @@ IceRuby::SequenceInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap* object volatile VALUE arr = Qnil; - Ice::OutputStream::size_type sizePos = -1; + Ice::OutputStream::size_type sizePos; if(optional) { if(elementType->variableLength()) @@ -1395,10 +1395,10 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU case PrimitiveInfo::KindBool: { long sz = RARRAY_LEN(arr); - Ice::BoolSeq seq(sz); + Ice::BoolSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { - seq[i] = RTEST(RARRAY_AREF(arr, i)); + seq[static_cast<size_t>(i)] = RTEST(RARRAY_AREF(arr, i)); } os->write(seq); break; @@ -1421,7 +1421,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU else { long sz = RARRAY_LEN(arr); - Ice::ByteSeq seq(sz); + Ice::ByteSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { long val = getInteger(RARRAY_AREF(arr, i)); @@ -1429,7 +1429,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU { throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<byte>", i); } - seq[i] = static_cast<Ice::Byte>(val); + seq[static_cast<size_t>(i)] = static_cast<Ice::Byte>(val); } os->write(&seq[0], &seq[0] + seq.size()); } @@ -1438,7 +1438,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU case PrimitiveInfo::KindShort: { long sz = RARRAY_LEN(arr); - Ice::ShortSeq seq(sz); + Ice::ShortSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { long val = getInteger(RARRAY_AREF(arr, i)); @@ -1446,7 +1446,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU { throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<short>", i); } - seq[i] = static_cast<Ice::Short>(val); + seq[static_cast<size_t>(i)] = static_cast<Ice::Short>(val); } os->write(&seq[0], &seq[0] + seq.size()); break; @@ -1454,7 +1454,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU case PrimitiveInfo::KindInt: { long sz = RARRAY_LEN(arr); - Ice::IntSeq seq(sz); + Ice::IntSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { long val = getInteger(RARRAY_AREF(arr, i)); @@ -1462,7 +1462,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU { throw RubyException(rb_eTypeError, "invalid value for element %ld of sequence<int>", i); } - seq[i] = static_cast<Ice::Int>(val); + seq[static_cast<size_t>(i)] = static_cast<Ice::Int>(val); } os->write(&seq[0], &seq[0] + seq.size()); break; @@ -1470,10 +1470,10 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU case PrimitiveInfo::KindLong: { long sz = RARRAY_LEN(arr); - Ice::LongSeq seq(sz); + Ice::LongSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { - seq[i] = getLong(RARRAY_AREF(arr, i)); + seq[static_cast<size_t>(i)] = getLong(RARRAY_AREF(arr, i)); } os->write(&seq[0], &seq[0] + seq.size()); break; @@ -1481,7 +1481,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU case PrimitiveInfo::KindFloat: { long sz = RARRAY_LEN(arr); - Ice::FloatSeq seq(sz); + Ice::FloatSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { volatile VALUE v = callRuby(rb_Float, RARRAY_AREF(arr, i)); @@ -1490,7 +1490,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU throw RubyException(rb_eTypeError, "unable to convert array element %ld to a float", i); } assert(TYPE(v) == T_FLOAT); - seq[i] = static_cast<Ice::Float>(RFLOAT_VALUE(v)); + seq[static_cast<size_t>(i)] = static_cast<Ice::Float>(RFLOAT_VALUE(v)); } os->write(&seq[0], &seq[0] + seq.size()); break; @@ -1498,7 +1498,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU case PrimitiveInfo::KindDouble: { long sz = RARRAY_LEN(arr); - Ice::DoubleSeq seq(sz); + Ice::DoubleSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { volatile VALUE v = callRuby(rb_Float, RARRAY_AREF(arr, i)); @@ -1507,7 +1507,7 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU throw RubyException(rb_eTypeError, "unable to convert array element %ld to a double", i); } assert(TYPE(v) == T_FLOAT); - seq[i] = RFLOAT_VALUE(v); + seq[static_cast<size_t>(i)] = RFLOAT_VALUE(v); } os->write(&seq[0], &seq[0] + seq.size()); break; @@ -1515,10 +1515,10 @@ IceRuby::SequenceInfo::marshalPrimitiveSequence(const PrimitiveInfoPtr& pi, VALU case PrimitiveInfo::KindString: { long sz = RARRAY_LEN(arr); - Ice::StringSeq seq(sz); + Ice::StringSeq seq(static_cast<size_t>(sz)); for(long i = 0; i < sz; ++i) { - seq[i] = getString(RARRAY_AREF(arr, i)); + seq[static_cast<size_t>(i)] = getString(RARRAY_AREF(arr, i)); } #ifdef HAVE_RUBY_ENCODING_H os->write(&seq[0], &seq[0] + seq.size(), false); // Bypass string conversion. @@ -1658,12 +1658,9 @@ IceRuby::SequenceInfo::unmarshalPrimitiveSequence(const PrimitiveInfoPtr& pi, Ic long sz = static_cast<long>(seq.size()); result = createArray(sz); - if(sz > 0) + for(long i = 0; i < sz; ++i) { - for(long i = 0; i < sz; ++i) - { - RARRAY_ASET(result, i, createString(seq[i])); - } + RARRAY_ASET(result, i, createString(seq[static_cast<size_t>(i)])); } break; } @@ -1762,13 +1759,13 @@ IceRuby::DictionaryInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap* obje } } - int sz = 0; + Ice::Int sz = 0; if(!NIL_P(hash)) { - sz = RHASH_SIZE(hash); + sz = static_cast<Ice::Int>(RHASH_SIZE(hash)); } - Ice::OutputStream::size_type sizePos = 0; + Ice::OutputStream::size_type sizePos; if(optional) { if(_variableLength) @@ -2356,7 +2353,7 @@ IceRuby::ProxyInfo::optionalFormat() const void IceRuby::ProxyInfo::marshal(VALUE p, Ice::OutputStream* os, ObjectMap*, bool optional) { - Ice::OutputStream::size_type sizePos = -1; + Ice::OutputStream::size_type sizePos; if(optional) { sizePos = os->startSize(); diff --git a/ruby/src/IceRuby/Util.cpp b/ruby/src/IceRuby/Util.cpp index 978a6bac56d..2c4a58233b4 100644 --- a/ruby/src/IceRuby/Util.cpp +++ b/ruby/src/IceRuby/Util.cpp @@ -762,7 +762,7 @@ setExceptionMembers(const Ice::LocalException& ex, VALUE p) } VALUE -IceRuby::createArrayHelper(long sz) +IceRuby::createArray(long sz) { volatile VALUE arr = callRuby(rb_ary_new2, sz); if(sz > 0) diff --git a/ruby/src/IceRuby/Util.h b/ruby/src/IceRuby/Util.h index 19fa928d392..765278b5555 100644 --- a/ruby/src/IceRuby/Util.h +++ b/ruby/src/IceRuby/Util.h @@ -8,6 +8,14 @@ #include <Config.h> #include <Ice/Ice.h> +// +// Avoid clang conversion warnings in "callRuby" calls +// +#if defined(__clang__) +# pragma clang diagnostic ignored "-Wconversion" +# pragma clang diagnostic ignored "-Wsign-conversion" +#endif + namespace IceRuby { @@ -228,7 +236,7 @@ class RF_2 public: RF_2(Fun f, T1 t1, T2 t2) : _f(f), _t1(t1), _t2(t2) {} - inline VALUE operator()() { return _f(_t1, _t2); } + inline VALUE operator()(){ return _f(_t1, _t2); } static inline VALUE call(VALUE f) { return (*reinterpret_cast<RF_2*>(f))(); @@ -468,8 +476,6 @@ inline void callRubyVoid(Fun fun, T1 t1, T2 t2, T3 t3, T4 t4) callProtected(RubyFunction(RF::call), reinterpret_cast<VALUE>(&f)); } -VALUE createArrayHelper(long); - // // Create an array with the given size. May raise RubyException. // @@ -485,11 +491,7 @@ VALUE createArrayHelper(long); // RARRAY_ASET(arr, i, val); // } // -template<typename T> -inline VALUE createArray(T sz) -{ - return createArrayHelper(static_cast<long>(sz)); -} +VALUE createArray(long); // // Create the Ruby equivalent of an Ice local exception. diff --git a/ruby/test/Ice/proxy/AllTests.rb b/ruby/test/Ice/proxy/AllTests.rb index cde9fef06b8..3a923e4d0d1 100644 --- a/ruby/test/Ice/proxy/AllTests.rb +++ b/ruby/test/Ice/proxy/AllTests.rb @@ -651,6 +651,8 @@ def allTests(helper, communicator) STDOUT.flush connection = cl.ice_getConnection() if connection != nil + test(!cl.ice_isFixed()) + test(cl.ice_fixed(connection).ice_isFixed()) cl.ice_fixed(connection).getContext() test(cl.ice_secure(true).ice_fixed(connection).ice_isSecure()) test(cl.ice_facet("facet").ice_fixed(connection).ice_getFacet() == "facet") diff --git a/scripts/LocalDriver.py b/scripts/LocalDriver.py index a04c03157a0..1dd6f858e34 100644 --- a/scripts/LocalDriver.py +++ b/scripts/LocalDriver.py @@ -577,6 +577,8 @@ class LocalDriver(Driver): self.runner.stopServerSide(server, current, success) except Exception as ex: failure.append(ex) + except KeyboardInterrupt: # Potentially raised by Except.py if Ctrl-C + pass sem.release() t=threading.Thread(target = stopServerSide) diff --git a/scripts/tests/Ice/retry.py b/scripts/tests/Ice/retry.py index ff589037696..b245f40f459 100644 --- a/scripts/tests/Ice/retry.py +++ b/scripts/tests/Ice/retry.py @@ -10,4 +10,9 @@ traceProps = { "Ice.Trace.Protocol" : 1 } -TestSuite(__name__, [ClientServerTestCase(traceProps=traceProps)]) +testcases = [ClientServerTestCase(traceProps=traceProps)] + +if Mapping.getByPath(__name__).hasSource("Ice/metrics", "collocated"): + testcases += [ CollocatedTestCase(traceProps=traceProps) ] + +TestSuite(__name__, testcases) |