From 466841625f98160f5f1b472f7c782b416de5ad4a Mon Sep 17 00:00:00 2001 From: Jason Lokerson Date: Tue, 26 Apr 2016 08:39:34 -0700 Subject: [PATCH] Fix 32/64 cast warning These were revealed recently by trying to build with VS2015, correct by adding casts or changing types as appropriate. --- contrib/autoboost/libs/filesystem/unique_path.cpp | 3 +-- contrib/autoboost/libs/filesystem/windows_file_codecvt.cpp | 4 ++-- contrib/websocketpp/websocketpp/common/md5.hpp | 2 +- contrib/websocketpp/websocketpp/frame.hpp | 2 +- contrib/websocketpp/websocketpp/sha1/sha1.hpp | 2 +- src/benchmark/Benchmark.cpp | 4 ++-- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/contrib/autoboost/libs/filesystem/unique_path.cpp b/contrib/autoboost/libs/filesystem/unique_path.cpp index 9497f0651..d50981208 100644 --- a/contrib/autoboost/libs/filesystem/unique_path.cpp +++ b/contrib/autoboost/libs/filesystem/unique_path.cpp @@ -109,8 +109,7 @@ void system_crypt_random(void* buf, std::size_t len, autoboost::system::error_co if (!errval) { - BOOL gen_ok = ::CryptGenRandom(handle, len, static_cast(buf)); - if (!gen_ok) + if (!::CryptGenRandom(handle, (DWORD)len, static_cast(buf))) errval = ::GetLastError(); ::CryptReleaseContext(handle, 0); } diff --git a/contrib/autoboost/libs/filesystem/windows_file_codecvt.cpp b/contrib/autoboost/libs/filesystem/windows_file_codecvt.cpp index acd4d734a..675667b85 100644 --- a/contrib/autoboost/libs/filesystem/windows_file_codecvt.cpp +++ b/contrib/autoboost/libs/filesystem/windows_file_codecvt.cpp @@ -40,7 +40,7 @@ int count; if ((count = ::MultiByteToWideChar(codepage, MB_PRECOMPOSED, from, - from_end - from, to, to_end - to)) == 0) + (int)(from_end - from), to, (int)(to_end - to))) == 0) { return error; // conversion failed } @@ -60,7 +60,7 @@ int count; if ((count = ::WideCharToMultiByte(codepage, WC_NO_BEST_FIT_CHARS, from, - from_end - from, to, to_end - to, 0, 0)) == 0) + (int)(from_end - from), to, (int)(to_end - to), 0, 0)) == 0) { return error; // conversion failed } diff --git a/contrib/websocketpp/websocketpp/common/md5.hpp b/contrib/websocketpp/websocketpp/common/md5.hpp index 279725f45..81a676813 100644 --- a/contrib/websocketpp/websocketpp/common/md5.hpp +++ b/contrib/websocketpp/websocketpp/common/md5.hpp @@ -364,7 +364,7 @@ void md5_append(md5_state_t *pms, md5_byte_t const * data, size_t nbytes) { return; /* Update the message length. */ - pms->count[1] += nbytes >> 29; + pms->count[1] += static_cast(nbytes >> 29); pms->count[0] += nbits; if (pms->count[0] < nbits) pms->count[1]++; diff --git a/contrib/websocketpp/websocketpp/frame.hpp b/contrib/websocketpp/websocketpp/frame.hpp index af850391f..2690df060 100644 --- a/contrib/websocketpp/websocketpp/frame.hpp +++ b/contrib/websocketpp/websocketpp/frame.hpp @@ -826,7 +826,7 @@ inline size_t byte_mask_circ(uint8_t * input, uint8_t * output, size_t length, size_t prepared_key) { uint32_converter key; - key.i = prepared_key; + key.i = static_cast(prepared_key); for (size_t i = 0; i < length; ++i) { output[i] = input[i] ^ key.c[i % 4]; diff --git a/contrib/websocketpp/websocketpp/sha1/sha1.hpp b/contrib/websocketpp/websocketpp/sha1/sha1.hpp index 43a843382..33eb9c057 100755 --- a/contrib/websocketpp/websocketpp/sha1/sha1.hpp +++ b/contrib/websocketpp/websocketpp/sha1/sha1.hpp @@ -173,7 +173,7 @@ inline void calc(void const * src, size_t bytelength, unsigned char * hash) { innerHash(result, w); clearWBuffert(w); } - w[15] = bytelength << 3; + w[15] = static_cast(bytelength << 3); innerHash(result, w); // Store hash in result pointer, and make sure we get in in the correct diff --git a/src/benchmark/Benchmark.cpp b/src/benchmark/Benchmark.cpp index 05400243b..3c5ab9ade 100644 --- a/src/benchmark/Benchmark.cpp +++ b/src/benchmark/Benchmark.cpp @@ -3,7 +3,7 @@ #include "Benchmark.h" #include "PrintableDuration.h" -static const size_t sc_ncbOuterLoop = +static const int sc_ncbOuterLoop = #ifdef _DEBUG 100; #else @@ -15,7 +15,7 @@ BenchmarkEntry::BenchmarkEntry(const char* name, void(*pfnBM)(Stopwatch&)) : { // Benchmark the whole function call Stopwatch sw; - for (size_t i = sc_ncbOuterLoop; i--;) + for (int i = sc_ncbOuterLoop; i--;) pfnBM(sw); // Difference over scale