Skip to content
14 changes: 7 additions & 7 deletions hazelcast/include/hazelcast/client/protocol/ClientMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -1192,8 +1192,8 @@ class HAZELCAST_API ClientMessage
{
auto h = reinterpret_cast<frame_header_type*>(
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;
}
Expand All @@ -1212,7 +1212,7 @@ class HAZELCAST_API ClientMessage

auto f = reinterpret_cast<frame_header_type*>(
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<int32_t>(a.get_port()));

Expand All @@ -1231,7 +1231,7 @@ class HAZELCAST_API ClientMessage

auto f = reinterpret_cast<frame_header_type*>(
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<int32_t>(c.type));

Expand All @@ -1249,7 +1249,7 @@ class HAZELCAST_API ClientMessage

auto f = reinterpret_cast<frame_header_type*>(
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<int32_t>(o.transformation));

Expand Down Expand Up @@ -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<frame_header_type*>(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());
Expand Down Expand Up @@ -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<frame_header_type*>(memory);
h->frame_len = len;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1296,4 +1296,4 @@ class HAZELCAST_API generic_record
} // namespace generic_record
} // namespace serialization
} // namespace client
} // namespace hazelcast
} // namespace hazelcast
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit - change of line ending

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ T inline compact_reader::read_primitive(
const pimpl::field_descriptor& field_descriptor)
{
return object_data_input.read<T>(
read_fixed_size_position(field_descriptor));
(int)read_fixed_size_position(field_descriptor));
}

template<>
Expand Down Expand Up @@ -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<int32_t>(item_count);
size_t offset = object_data_output_.position();
std::vector<int32_t> offsets(item_count);
Expand Down Expand Up @@ -544,7 +544,7 @@ typename std::enable_if<std::is_same<std::vector<bool>, T>::value, void>::type
default_compact_writer::write(const T& value)
{
auto len = value.size();
object_data_output_.write<int32_t>(len);
object_data_output_.write<int32_t>((int32_t)len);
size_t position = object_data_output_.position();
if (len > 0) {
int index = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ 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<int8_t>& bytes)
{
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)
Expand All @@ -93,7 +93,7 @@ class data_input
std::is_same<char, typename std::remove_cv<T>::type>::value,
T>::type inline read()
{
return read<char16_t>();
return (char)read<char16_t>();
}

template<typename T>
Expand Down Expand Up @@ -282,7 +282,7 @@ class data_input
check_available(byte_count);
std::string value(reinterpret_cast<const char*>(&buffer_[pos_]),
byte_count);
pos_ += byte_count;
pos_ += (int)byte_count;
return value;
}

Expand Down
2 changes: 1 addition & 1 deletion hazelcast/src/hazelcast/client/client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ twos_complement(std::vector<int8_t>& 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;
Expand Down
5 changes: 3 additions & 2 deletions hazelcast/src/hazelcast/client/compact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<uint64_t>(-1) * (fp & 1L)));
}
FP_TABLE[i] = fp;
}
Expand Down
2 changes: 1 addition & 1 deletion hazelcast/src/hazelcast/client/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("");
Expand Down
10 changes: 6 additions & 4 deletions hazelcast/src/hazelcast/client/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ zlib_compress(const std::vector<byte>& input)
output.push_back(
static_cast<byte>(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<byte>(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<byte>((~block_size) >> 8)); // NLEN - most significant

// copy uncompressed bytes and accumulate checksum
for (std::size_t i = block_start; i < block_end; i++) {
Expand All @@ -126,9 +128,9 @@ zlib_compress(const std::vector<byte>& input)
}

// Adler32 checksum
output.push_back(a2 >> 8);
output.push_back(static_cast<byte>(a2 >> 8));
output.push_back(a2 & 0xff);
output.push_back(a1 >> 8);
output.push_back(static_cast<byte>(a1 >> 8));
output.push_back(a1 & 0xff);

return output;
Expand Down
9 changes: 5 additions & 4 deletions hazelcast/src/hazelcast/client/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ClientMessage::ClientMessage(size_t initial_frame_size, bool is_fingle_frame)
{
auto* initial_frame =
reinterpret_cast<frame_header_type*>(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<int16_t>(ClientMessage::UNFRAGMENTED_MESSAGE) |
Expand Down Expand Up @@ -114,8 +114,8 @@ ClientMessage::set(
{
auto* f = reinterpret_cast<frame_header_type*>(
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);
Expand All @@ -129,7 +129,8 @@ ClientMessage::set(const std::vector<boost::uuids::uuid>& values, bool is_final)
{
auto* h = reinterpret_cast<frame_header_type*>(
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);
Expand Down
4 changes: 2 additions & 2 deletions hazelcast/src/hazelcast/client/serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ ClassDefinition::write_data(pimpl::data_output& data_output)
data_output.write<int32_t>(factory_id_);
data_output.write<int32_t>(class_id_);
data_output.write<int32_t>(version_);
data_output.write<int16_t>(field_definitions_map_.size());
data_output.write<int16_t>((int16_t)field_definitions_map_.size());
for (auto& entry : field_definitions_map_) {
entry.second.write_data(data_output);
}
Expand Down Expand Up @@ -783,7 +783,7 @@ data_output::write(const std::string& str)
return;
}

write<int32_t>(str.size());
write<int32_t>((int32_t)str.size());
output_stream_.insert(output_stream_.end(), str.begin(), str.end());
}

Expand Down
2 changes: 1 addition & 1 deletion hazelcast/src/hazelcast/client/spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions hazelcast/src/hazelcast/client/sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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<int> distribution(0, count - 1);
std::uniform_int_distribution<int> 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) {
Expand Down
2 changes: 1 addition & 1 deletion hazelcast/src/hazelcast/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions hazelcast/test/src/logger_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);

Expand Down
Loading
Loading