Skip to content

Commit

Permalink
Suppress conversion warnings when compiling with old gcc versions (#183)
Browse files Browse the repository at this point in the history
* Suppress conversion warnings when compiling with old gcc versions

Signed-off-by: Raul Sanchez-Mateos <raul@eprosima.com>

* Uncrustify

Signed-off-by: Raul Sanchez-Mateos <raul@eprosima.com>

---------

Signed-off-by: Raul Sanchez-Mateos <raul@eprosima.com>
  • Loading branch information
rsanchez15 authored Dec 19, 2023
1 parent 0425a69 commit 439b9e1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/cpp/Cdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,8 @@ void Cdr::xcdr1_serialize_short_member_header(

make_alignment(alignment(4));

uint16_t flags_and_member_id = (member_id.must_understand ? 0x4000 : 0x0) | static_cast<uint16_t>(member_id.id);
uint16_t flags_and_member_id = static_cast<uint16_t>(member_id.must_understand ? 0x4000 : 0x0) |
static_cast<uint16_t>(member_id.id);
serialize(flags_and_member_id);
uint16_t size = 0;
serialize(size);
Expand All @@ -2399,7 +2400,8 @@ void Cdr::xcdr1_serialize_long_member_header(
{
make_alignment(alignment(4));

uint16_t flags_and_extended_pid = (member_id.must_understand ? 0x4000 : 0x0) | static_cast<uint16_t>(PID_EXTENDED);
uint16_t flags_and_extended_pid = static_cast<uint16_t>(member_id.must_understand ? 0x4000 : 0x0) |
static_cast<uint16_t>(PID_EXTENDED);
serialize(flags_and_extended_pid);
uint16_t size = PID_EXTENDED_LENGTH;
serialize(size);
Expand All @@ -2426,7 +2428,7 @@ void Cdr::xcdr1_change_to_short_member_header(
assert(0x3F00 >= member_id.id);
assert(std::numeric_limits<uint16_t>::max() >= member_serialized_size );

uint16_t flags_and_member_id = (member_id.must_understand ? 0x4000 : 0x0) |
uint16_t flags_and_member_id = static_cast<uint16_t>(member_id.must_understand ? 0x4000 : 0x0) |
static_cast<uint16_t>(member_id.id);
serialize(flags_and_member_id);
uint16_t size = static_cast<uint16_t>(member_serialized_size);
Expand All @@ -2446,7 +2448,8 @@ void Cdr::xcdr1_change_to_long_member_header(
{
throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
}
uint16_t flags_and_extended_pid = (member_id.must_understand ? 0x4000 : 0x0) | static_cast<uint16_t>(PID_EXTENDED);
uint16_t flags_and_extended_pid = static_cast<uint16_t>(member_id.must_understand ? 0x4000 : 0x0) |
static_cast<uint16_t>(PID_EXTENDED);
serialize(flags_and_extended_pid);
uint16_t size = PID_EXTENDED_LENGTH;
serialize(size);
Expand Down

0 comments on commit 439b9e1

Please sign in to comment.