diff --git a/hazelcast/include/hazelcast/client/protocol/ClientMessage.h b/hazelcast/include/hazelcast/client/protocol/ClientMessage.h index 911f641e4..fdd2c542e 100644 --- a/hazelcast/include/hazelcast/client/protocol/ClientMessage.h +++ b/hazelcast/include/hazelcast/client/protocol/ClientMessage.h @@ -1192,8 +1192,8 @@ class HAZELCAST_API ClientMessage { auto h = reinterpret_cast( wr_ptr(SIZE_OF_FRAME_LENGTH_AND_FLAGS)); - auto len = value.length(); - h->frame_len = SIZE_OF_FRAME_LENGTH_AND_FLAGS + len; + int32_t len = (int32_t)value.length(); + h->frame_len = (int32_t)SIZE_OF_FRAME_LENGTH_AND_FLAGS + len; if (is_final) { h->flags |= IS_FINAL_FLAG; } @@ -1212,7 +1212,7 @@ class HAZELCAST_API ClientMessage auto f = reinterpret_cast( wr_ptr(SIZE_OF_FRAME_LENGTH_AND_FLAGS)); - f->frame_len = SIZE_OF_FRAME_LENGTH_AND_FLAGS + INT32_SIZE; + f->frame_len = (int32_t)SIZE_OF_FRAME_LENGTH_AND_FLAGS + INT32_SIZE; f->flags = DEFAULT_FLAGS; set(static_cast(a.get_port())); @@ -1231,7 +1231,7 @@ class HAZELCAST_API ClientMessage auto f = reinterpret_cast( wr_ptr(SIZE_OF_FRAME_LENGTH_AND_FLAGS)); - f->frame_len = SIZE_OF_FRAME_LENGTH_AND_FLAGS + INT32_SIZE; + f->frame_len = (int32_t)SIZE_OF_FRAME_LENGTH_AND_FLAGS + INT32_SIZE; f->flags = DEFAULT_FLAGS; set(static_cast(c.type)); @@ -1249,7 +1249,7 @@ class HAZELCAST_API ClientMessage auto f = reinterpret_cast( wr_ptr(SIZE_OF_FRAME_LENGTH_AND_FLAGS)); - f->frame_len = SIZE_OF_FRAME_LENGTH_AND_FLAGS + INT32_SIZE; + f->frame_len = (int32_t)SIZE_OF_FRAME_LENGTH_AND_FLAGS + INT32_SIZE; f->flags = DEFAULT_FLAGS; set(static_cast(o.transformation)); @@ -1292,7 +1292,7 @@ class HAZELCAST_API ClientMessage auto frame_length = SIZE_OF_FRAME_LENGTH_AND_FLAGS + bytes.size(); auto fp = wr_ptr(frame_length); auto* header = reinterpret_cast(fp); - header->frame_len = frame_length; + header->frame_len = (int32_t)frame_length; header->flags = is_final ? IS_FINAL_FLAG : DEFAULT_FLAGS; std::memcpy( fp + SIZE_OF_FRAME_LENGTH_AND_FLAGS, &bytes[0], bytes.size()); @@ -1515,7 +1515,7 @@ class HAZELCAST_API ClientMessage bool is_final = false) { int32_t len = - SIZE_OF_FRAME_LENGTH_AND_FLAGS + values.size() * sizeof(T); + (int32_t)(SIZE_OF_FRAME_LENGTH_AND_FLAGS + values.size() * sizeof(T)); auto memory = wr_ptr(len); auto* h = reinterpret_cast(memory); h->frame_len = len; diff --git a/hazelcast/include/hazelcast/client/serialization/generic_record.h b/hazelcast/include/hazelcast/client/serialization/generic_record.h index 197e50af8..fce192134 100644 --- a/hazelcast/include/hazelcast/client/serialization/generic_record.h +++ b/hazelcast/include/hazelcast/client/serialization/generic_record.h @@ -1296,4 +1296,4 @@ class HAZELCAST_API generic_record } // namespace generic_record } // namespace serialization } // namespace client -} // namespace hazelcast \ No newline at end of file +} // namespace hazelcast diff --git a/hazelcast/include/hazelcast/client/serialization/pimpl/compact/compact_impl.h b/hazelcast/include/hazelcast/client/serialization/pimpl/compact/compact_impl.h index dea99c03a..0d5cf8ec3 100644 --- a/hazelcast/include/hazelcast/client/serialization/pimpl/compact/compact_impl.h +++ b/hazelcast/include/hazelcast/client/serialization/pimpl/compact/compact_impl.h @@ -82,7 +82,7 @@ T inline compact_reader::read_primitive( const pimpl::field_descriptor& field_descriptor) { return object_data_input.read( - read_fixed_size_position(field_descriptor)); + (int)read_fixed_size_position(field_descriptor)); } template<> @@ -481,7 +481,7 @@ default_compact_writer::write_array_of_variable_size( size_t data_length_offset = object_data_output_.position(); object_data_output_.write_zero_bytes(util::Bits::INT_SIZE_IN_BYTES); const auto& v = value.value(); - int item_count = v.size(); + int item_count = (int)v.size(); object_data_output_.write(item_count); size_t offset = object_data_output_.position(); std::vector offsets(item_count); @@ -544,7 +544,7 @@ typename std::enable_if, T>::value, void>::type default_compact_writer::write(const T& value) { auto len = value.size(); - object_data_output_.write(len); + object_data_output_.write((int32_t)len); size_t position = object_data_output_.position(); if (len > 0) { int index = 0; diff --git a/hazelcast/include/hazelcast/client/serialization/pimpl/data_input.h b/hazelcast/include/hazelcast/client/serialization/pimpl/data_input.h index dadad2134..786b5d33b 100644 --- a/hazelcast/include/hazelcast/client/serialization/pimpl/data_input.h +++ b/hazelcast/include/hazelcast/client/serialization/pimpl/data_input.h @@ -61,7 +61,7 @@ class data_input size_t length = bytes.size(); check_available(length); memcpy(&(bytes[0]), &(buffer_[pos_]), length); - pos_ += length; + pos_ += (int)length; } inline void read_fully(std::vector& bytes) @@ -69,7 +69,7 @@ class data_input size_t length = bytes.size(); check_available(length); memcpy(&(bytes[0]), &(buffer_[pos_]), length); - pos_ += length; + pos_ += (int32_t)length; } inline int skip_bytes(int i) @@ -93,7 +93,7 @@ class data_input std::is_same::type>::value, T>::type inline read() { - return read(); + return (char)read(); } template @@ -282,7 +282,7 @@ class data_input check_available(byte_count); std::string value(reinterpret_cast(&buffer_[pos_]), byte_count); - pos_ += byte_count; + pos_ += (int)byte_count; return value; } diff --git a/hazelcast/src/hazelcast/client/client_impl.cpp b/hazelcast/src/hazelcast/client/client_impl.cpp index ce1ac0765..efbef5c57 100644 --- a/hazelcast/src/hazelcast/client/client_impl.cpp +++ b/hazelcast/src/hazelcast/client/client_impl.cpp @@ -757,7 +757,7 @@ twos_complement(std::vector& a) } // add 1 int8_t carry = 1; - for (int i = a.size() - 1; i >= 0; i--) { + for (auto i = a.size() - 1; i >= 0; i--) { a[i] = a[i] + carry; if (a[i] == 0) { carry = 1; diff --git a/hazelcast/src/hazelcast/client/compact.cpp b/hazelcast/src/hazelcast/client/compact.cpp index 0f893cef4..d28c79f23 100644 --- a/hazelcast/src/hazelcast/client/compact.cpp +++ b/hazelcast/src/hazelcast/client/compact.cpp @@ -2548,7 +2548,7 @@ compact_reader::read_var_size_position( { int32_t index = field_descriptor.index; int32_t offset = - get_offset(object_data_input, variable_offsets_position, index); + get_offset(object_data_input, (uint32_t)variable_offsets_position, index); return offset == pimpl::offset_reader::NULL_OFFSET ? pimpl::offset_reader::NULL_OFFSET : offset + data_start_position; @@ -3346,7 +3346,8 @@ init_fp_table() for (int i = 0; i < 256; ++i) { uint64_t fp = i; for (int j = 0; j < 8; ++j) { - fp = (fp >> 1) ^ (rabin_finger_print::INIT & -(fp & 1L)); + fp = (fp >> 1) ^ (rabin_finger_print::INIT & + (static_cast(-1) * (fp & 1L))); } FP_TABLE[i] = fp; } diff --git a/hazelcast/src/hazelcast/client/discovery.cpp b/hazelcast/src/hazelcast/client/discovery.cpp index e2b6e4ec9..0e65eb13d 100644 --- a/hazelcast/src/hazelcast/client/discovery.cpp +++ b/hazelcast/src/hazelcast/client/discovery.cpp @@ -351,7 +351,7 @@ void Filter::add_filter(const std::string& name, const std::string& value) { std::stringstream out; - unsigned long index = filters_.size() + 1; + auto index = filters_.size() + 1; out << "Filter." << index << ".Name"; filters_[out.str()] = name; out.str(""); diff --git a/hazelcast/src/hazelcast/client/metrics.cpp b/hazelcast/src/hazelcast/client/metrics.cpp index e495b7507..f2a379d9b 100644 --- a/hazelcast/src/hazelcast/client/metrics.cpp +++ b/hazelcast/src/hazelcast/client/metrics.cpp @@ -103,9 +103,11 @@ zlib_compress(const std::vector& input) output.push_back( static_cast(is_final)); // BFINAL = is_final, BTYPE = 00 output.push_back(block_size & 0xff); // LEN - least significant - output.push_back(block_size >> 8); // LEN - most significant + output.push_back( + static_cast(block_size >> 8)); // LEN - most significant output.push_back((~block_size) & 0xff); // NLEN - least significant - output.push_back((~block_size) >> 8); // NLEN - most significant + output.push_back( + static_cast((~block_size) >> 8)); // NLEN - most significant // copy uncompressed bytes and accumulate checksum for (std::size_t i = block_start; i < block_end; i++) { @@ -126,9 +128,9 @@ zlib_compress(const std::vector& input) } // Adler32 checksum - output.push_back(a2 >> 8); + output.push_back(static_cast(a2 >> 8)); output.push_back(a2 & 0xff); - output.push_back(a1 >> 8); + output.push_back(static_cast(a1 >> 8)); output.push_back(a1 & 0xff); return output; diff --git a/hazelcast/src/hazelcast/client/protocol.cpp b/hazelcast/src/hazelcast/client/protocol.cpp index c0e45928a..a845746bc 100644 --- a/hazelcast/src/hazelcast/client/protocol.cpp +++ b/hazelcast/src/hazelcast/client/protocol.cpp @@ -66,7 +66,7 @@ ClientMessage::ClientMessage(size_t initial_frame_size, bool is_fingle_frame) { auto* initial_frame = reinterpret_cast(wr_ptr(REQUEST_HEADER_LEN)); - initial_frame->frame_len = initial_frame_size; + initial_frame->frame_len = (int32_t)initial_frame_size; initial_frame->flags = is_fingle_frame ? static_cast(ClientMessage::UNFRAGMENTED_MESSAGE) | @@ -114,8 +114,8 @@ ClientMessage::set( { auto* f = reinterpret_cast( wr_ptr(SIZE_OF_FRAME_LENGTH_AND_FLAGS)); - f->frame_len = - values.size() * (UUID_SIZE + INT64_SIZE) + SIZE_OF_FRAME_LENGTH_AND_FLAGS; + f->frame_len = (int32_t)(values.size() * (UUID_SIZE + INT64_SIZE) + + SIZE_OF_FRAME_LENGTH_AND_FLAGS); f->flags = is_final ? IS_FINAL_FLAG : DEFAULT_FLAGS; for (auto& p : values) { set(p.first); @@ -129,7 +129,8 @@ ClientMessage::set(const std::vector& values, bool is_final) { auto* h = reinterpret_cast( wr_ptr(SIZE_OF_FRAME_LENGTH_AND_FLAGS)); - h->frame_len = SIZE_OF_FRAME_LENGTH_AND_FLAGS + values.size() * UUID_SIZE; + h->frame_len = + (int32_t)(SIZE_OF_FRAME_LENGTH_AND_FLAGS + values.size() * UUID_SIZE); h->flags = is_final ? IS_FINAL_FLAG : DEFAULT_FLAGS; for (auto& v : values) { set(v); diff --git a/hazelcast/src/hazelcast/client/serialization.cpp b/hazelcast/src/hazelcast/client/serialization.cpp index 1397c2c49..ed8f2eefc 100644 --- a/hazelcast/src/hazelcast/client/serialization.cpp +++ b/hazelcast/src/hazelcast/client/serialization.cpp @@ -534,7 +534,7 @@ ClassDefinition::write_data(pimpl::data_output& data_output) data_output.write(factory_id_); data_output.write(class_id_); data_output.write(version_); - data_output.write(field_definitions_map_.size()); + data_output.write((int16_t)field_definitions_map_.size()); for (auto& entry : field_definitions_map_) { entry.second.write_data(data_output); } @@ -783,7 +783,7 @@ data_output::write(const std::string& str) return; } - write(str.size()); + write((int32_t)str.size()); output_stream_.insert(output_stream_.end(), str.begin(), str.end()); } diff --git a/hazelcast/src/hazelcast/client/spi.cpp b/hazelcast/src/hazelcast/client/spi.cpp index 2e5c70d7e..570a7dcf4 100644 --- a/hazelcast/src/hazelcast/client/spi.cpp +++ b/hazelcast/src/hazelcast/client/spi.cpp @@ -3041,7 +3041,7 @@ cluster_view_listener::try_register( try { f.get(); - } catch (exception::hazelcast_client_not_active& e) { + } catch (exception::hazelcast_client_not_active&) { /** * If client is shutdown, we should not retry for another * connection diff --git a/hazelcast/src/hazelcast/client/sql.cpp b/hazelcast/src/hazelcast/client/sql.cpp index f4cacdfca..22fa3f670 100644 --- a/hazelcast/src/hazelcast/client/sql.cpp +++ b/hazelcast/src/hazelcast/client/sql.cpp @@ -642,7 +642,7 @@ query_utils::throw_public_exception(std::exception_ptr exc, { try { std::rethrow_exception(exc); - } catch (hazelcast_sql_exception& e) { + } catch (hazelcast_sql_exception&) { throw; } catch (exception::query& e) { auto originating_member_id = e.originating_member_uuid(); @@ -720,7 +720,7 @@ query_utils::member_of_same_larger_version_group( // otherwise return a random member from the larger group static thread_local std::mt19937 generator; - std::uniform_int_distribution distribution(0, count - 1); + std::uniform_int_distribution distribution(0, (int)(count - 1)); auto random_member_index = distribution(generator); for (const auto& m : members) { if (!m.is_lite_member() && m.get_version() == version) { diff --git a/hazelcast/src/hazelcast/util/util.cpp b/hazelcast/src/hazelcast/util/util.cpp index 07944fc29..1017103b9 100644 --- a/hazelcast/src/hazelcast/util/util.cpp +++ b/hazelcast/src/hazelcast/util/util.cpp @@ -426,7 +426,7 @@ hz_snprintf(char* str, size_t len, const char* format, ...) #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) int result = vsnprintf_s(str, len, _TRUNCATE, format, args); if (result < 0) { - return len > 0 ? len - 1 : 0; + return len > 0 ? (int)(len - 1) : 0; } va_end(args); return result; diff --git a/hazelcast/test/src/logger_test.cpp b/hazelcast/test/src/logger_test.cpp index 286081bf5..8b70f326a 100644 --- a/hazelcast/test/src/logger_test.cpp +++ b/hazelcast/test/src/logger_test.cpp @@ -118,6 +118,11 @@ TEST_F(default_log_handler_test, test_format) int day, mon, year, hr, mn, sec, ms; char lev[64], tid[64], msg[64], ins_grp[64], ver[64]; +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#pragma warning(push) +#pragma warning(disable : 4996) // suppress unsecure std::sscanf warning. + // Not a problem for our test. +#endif int read = std::sscanf(sstrm_.str().c_str(), "%02d/%02d/%04d %02d:%02d:%02d.%03d %s %s %s %s %s\n", @@ -133,6 +138,9 @@ TEST_F(default_log_handler_test, test_format) ins_grp, ver, msg); +#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64) +#pragma warning(pop) +#endif ASSERT_EQ(12, read); diff --git a/hazelcast/test/src/sql_test.cpp b/hazelcast/test/src/sql_test.cpp index 1168e884f..36585c616 100644 --- a/hazelcast/test/src/sql_test.cpp +++ b/hazelcast/test/src/sql_test.cpp @@ -491,11 +491,11 @@ class SqlTest std::vector instance_mapping(members.size()); for (size_t i = 0; i < members.size(); i++) { - std::string curr_uuid = get_uuid_of_instance(i); + std::string curr_uuid = get_uuid_of_instance((int32_t)i); for (size_t j = 0; j < members.size(); j++) { if (curr_uuid == to_string(members[j].get_uuid())) { - instance_mapping[j] = i; + instance_mapping[j] = (int32_t)i; } } } @@ -775,7 +775,7 @@ class SqlTest for (size_t i = 0; i < members.size(); i++) { if (members[i].get_uuid() == owner) { - return i; + return (int32_t)i; } } @@ -788,7 +788,8 @@ class SqlTest std::vector member_2_instance_mapping = prepare_member_to_instance_mapping(); - int32_t members_size = client.get_cluster().get_members().size(); + int32_t members_size = + (int32_t)client.get_cluster().get_members().size(); // warm up cache client.get_sql().execute(sql, 0).get(); @@ -1723,7 +1724,8 @@ TEST_F(SqlTest, find_with_page_sync_iterator) create_mapping(); auto numbers = populate_map(map, 500); - auto searchee = numbers[numbers.size() / 2]; + int index = (int)(numbers.size() / 2); + auto searchee = numbers[index]; auto result = select_all(); auto found_page_itr = std::find_if( @@ -1753,7 +1755,8 @@ TEST_F(SqlTest, find_with_row_sync_iterator) create_mapping(); auto numbers = populate_map(map, 500); - auto searchee = numbers[numbers.size() / 2]; + int index = (int)(numbers.size() / 2); + auto searchee = numbers[index]; auto result = select_all(); auto found_row_itr = @@ -2167,7 +2170,7 @@ TEST_F(SqlTest, test_partition_based_routing_complex_type_test) .str(), boost::none, "value-1", - student{ 2, 1.72 }); + student{ 2, 1.72f }); } catch (exception::iexception& ie) { auto msg = ie.get_message(); ASSERT_NE( @@ -2186,19 +2189,19 @@ TEST_F(SqlTest, test_partition_based_routing_complex_key) check_partition_argument_index( (boost::format("SELECT * FROM %1% WHERE __key = ?") % map_name).str(), boost::make_optional(0), - student{ 2, 1.72 }); + student{ 2, 1.72f }); check_partition_argument_index( (boost::format("UPDATE %1% SET this = ? WHERE __key = ?") % map_name) .str(), boost::make_optional(1), "testVal", - student{ 2, 1.72 }); + student{ 2, 1.72f }); check_partition_argument_index( (boost::format("DELETE FROM %1% WHERE __key = ?") % map_name).str(), boost::make_optional(0), - student{ 2, 1.72 }); + student{ 2, 1.72f }); } TEST_F(SqlTest, test_routing_for_select) @@ -2408,7 +2411,7 @@ class read_optimized_lru_cache_for_testing { } - int32_t get_cache_size() { return this->cache_.size(); } + int32_t get_cache_size() { return (int32_t)this->cache_.size(); } V get_cache_value(K k) { return this->cache_.get(k)->value_; } }; @@ -2429,13 +2432,13 @@ TEST_F(read_optimized_lru_cache_test, construction_test) using cache_type = sql::impl::read_optimized_lru_cache; std::shared_ptr lru_cache; - EXPECT_THROW(std::make_shared(0, 0), + EXPECT_THROW(lru_cache = std::make_shared(0, 0), exception::illegal_argument); - EXPECT_THROW(std::make_shared(10, 5), + EXPECT_THROW(lru_cache = std::make_shared(10, 5), exception::illegal_argument); - EXPECT_NO_THROW(std::make_shared(10, 15)); + EXPECT_NO_THROW(lru_cache = std::make_shared(10, 15)); } TEST_F(read_optimized_lru_cache_test, put_test)