diff options
author | Jose <jose@zeroc.com> | 2019-06-22 00:29:53 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-06-22 00:29:53 +0200 |
commit | c5959fd09de61604bedd75354401df6a57395d65 (patch) | |
tree | 3b0227f631c8b20fb1a1a274b92f63f52f34af2c /cpp/src/IceUtil | |
parent | Small fix (diff) | |
parent | Enable -Wconversion with clang - Close #363 (diff) | |
download | ice-c5959fd09de61604bedd75354401df6a57395d65.tar.bz2 ice-c5959fd09de61604bedd75354401df6a57395d65.tar.xz ice-c5959fd09de61604bedd75354401df6a57395d65.zip |
Merge remote-tracking branch 'origin/3.7' into swift
Diffstat (limited to 'cpp/src/IceUtil')
-rw-r--r-- | cpp/src/IceUtil/FileUtil.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceUtil/Options.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceUtil/Random.cpp | 4 | ||||
-rw-r--r-- | cpp/src/IceUtil/StringConverter.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IceUtil/StringUtil.cpp | 6 | ||||
-rw-r--r-- | cpp/src/IceUtil/Time.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IceUtil/UUID.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IceUtil/UtilException.cpp | 6 |
8 files changed, 21 insertions, 21 deletions
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 |