Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed warnings [8886] #1290

Merged
merged 2 commits into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions include/fastdds/dds/core/policy/ParameterTypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,9 +900,9 @@ class ParameterProperty_t
uint32_t old_size = size();

uint32_t first_size = (uint32_t)new_value.first.size() + 1;
uint32_t first_alignment = ((first_size + 3) & ~3) - first_size;
uint32_t first_alignment = ((first_size + 3u) & ~3u) - first_size;
uint32_t second_size = (uint32_t)new_value.second.size() + 1;
uint32_t second_alignment = ((second_size + 3) & ~3) - second_size;
uint32_t second_alignment = ((second_size + 3u) & ~3u) - second_size;
uint32_t new_size = first_size + first_alignment + second_size + second_alignment + 8;

if (old_size != new_size)
Expand Down Expand Up @@ -971,7 +971,7 @@ class ParameterProperty_t
{
//Size of the element (with alignment)
uint32_t size = *(uint32_t*)ptr;
return (4 + ((size + 3) & ~3));
return (4u + ((size + 3u) & ~3u));
}

};
Expand Down Expand Up @@ -1278,10 +1278,10 @@ class ParameterPropertyList_t : public Parameter_t
{
//Realloc if needed;
uint32_t size1 = (uint32_t) p.first.length() + 1;
uint32_t alignment1 = ((size1 + 3) & ~3) - size1;
uint32_t alignment1 = ((size1 + 3u) & ~3u) - size1;

uint32_t size2 = (uint32_t) p.second.length() + 1;
uint32_t alignment2 = ((size2 + 3) & ~3) - size2;
uint32_t alignment2 = ((size2 + 3u) & ~3u) - size2;

if (limit_size_ && (properties_.max_size < properties_.length +
size1 + alignment1 + 4 +
Expand Down Expand Up @@ -1314,8 +1314,8 @@ class ParameterPropertyList_t : public Parameter_t
uint32_t str2_size)
{
//Realloc if needed;
uint32_t alignment1 = ((str1_size + 3) & ~3) - str1_size;
uint32_t alignment2 = ((str2_size + 3) & ~3) - str2_size;
uint32_t alignment1 = ((str1_size + 3u) & ~3u) - str1_size;
uint32_t alignment2 = ((str2_size + 3u) & ~3u) - str2_size;

if (limit_size_ && (properties_.max_size < properties_.length +
str1_size + alignment1 + 4 +
Expand Down
10 changes: 5 additions & 5 deletions include/fastdds/dds/core/policy/QosPolicies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ class GenericDataQosPolicy : public Parameter_t, public QosPolicy,
, ResourceLimitedOctetVector()
{
assign(data.begin(), data.end());
length = (size() + 7) & ~3;
length = static_cast<uint16_t>((size() + 7u) & ~3u);
}

virtual RTPS_DllAPI ~GenericDataQosPolicy() = default;
Expand All @@ -760,7 +760,7 @@ class GenericDataQosPolicy : public Parameter_t, public QosPolicy,
//If the object is size limited, already has max_size() allocated
//assign() will always stop copying when reaching max_size()
assign(b.begin(), b.end());
length = (size() + 7) & ~3;
length = static_cast<uint16_t>((size() + 7u) & ~3u);
hasChanged = true;
}
return *this;
Expand Down Expand Up @@ -866,7 +866,7 @@ class GenericDataQosPolicy : public Parameter_t, public QosPolicy,
if (collection_ != vec)
{
assign(vec.begin(), vec.end());
length = (size() + 7) & ~3;
length = static_cast<uint16_t>((size() + 7u) & ~3u);
hasChanged = true;
}
}
Expand Down Expand Up @@ -1282,7 +1282,7 @@ class PartitionQosPolicy : public Parameter_t, public QosPolicy
{
//Size of the element (with alignment)
uint32_t size = *(uint32_t*)ptr_;
ptr_ += (4 + ((size + 3) & ~3));
ptr_ += (4u + ((size + 3u) & ~3u));
value_ = Partition_t(ptr_);
}

Expand Down Expand Up @@ -1434,7 +1434,7 @@ class PartitionQosPolicy : public Parameter_t, public QosPolicy
{
//Realloc if needed;
uint32_t size = (uint32_t)strlen(name) + 1;
uint32_t alignment = ((size + 3) & ~3) - size;
uint32_t alignment = ((size + 3u) & ~3u) - size;

if (max_size_ != 0 && (partitions_.max_size < partitions_.length +
size + alignment + 4))
Expand Down
2 changes: 1 addition & 1 deletion include/fastdds/rtps/common/CacheChange.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ struct RTPS_DllAPI CacheChange_t
{
size_t offset = fragment_size_;
offset *= fragment_index;
offset = (offset + 3) & ~3;
offset = (offset + 3u) & ~3u;
return reinterpret_cast<uint32_t*>(&serializedPayload.data[offset]);
}

Expand Down
3 changes: 2 additions & 1 deletion include/fastdds/rtps/common/SequenceNumber.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ struct RTPS_DllAPI SequenceNumber_t
SequenceNumber_t& operator +=(
int inc) noexcept
{
assert(inc >= 0);
uint32_t aux_low = low;
ahcorde marked this conversation as resolved.
Show resolved Hide resolved
low += inc;
low += static_cast<uint32_t>(inc);

if (low < aux_low)
{
Expand Down
16 changes: 7 additions & 9 deletions include/fastdds/rtps/messages/CDRMessage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ inline bool CDRMessage::read_array_with_max_size(
return false;
}
valid &= CDRMessage::readData(msg, arr, datasize);
msg->pos = (msg->pos + 3) & ~3;
msg->pos = (msg->pos + 3u) & ~3u;
return valid;
}

Expand Down Expand Up @@ -235,7 +235,7 @@ inline SequenceNumberSet_t CDRMessage::readSequenceNumberSet(
SequenceNumberSet_t sns(seqNum);
uint32_t numBits = 0;
valid &= CDRMessage::readUInt32(msg, &numBits);
uint32_t n_longs = (numBits + 31ul) / 32ul;
uint32_t n_longs = (numBits + 31u) / 32u;
uint32_t bitmap[8];
for (uint32_t i = 0; i < n_longs; ++i)
{
Expand All @@ -259,7 +259,7 @@ inline bool CDRMessage::readFragmentNumberSet(
fns->base(base);
uint32_t numBits = 0;
valid &= CDRMessage::readUInt32(msg, &numBits);
uint32_t n_longs = (numBits + 31ul) / 32ul;
uint32_t n_longs = (numBits + 31u) / 32u;
uint32_t bitmap[8];
for (uint32_t i = 0; i < n_longs; ++i)
{
Expand Down Expand Up @@ -371,7 +371,7 @@ inline bool CDRMessage::readOctetVector(
bool valid = CDRMessage::readUInt32(msg, &vecsize);
ocvec->resize(vecsize);
valid &= CDRMessage::readData(msg, ocvec->data(), vecsize);
msg->pos = (msg->pos + 3) & ~3;
msg->pos = (msg->pos + 3u) & ~3u;
return valid;
}

Expand All @@ -393,11 +393,11 @@ inline bool CDRMessage::readString(
stri->resize(str_size - 1);
for (uint32_t i = 0; i < str_size - 1; i++)
{
stri->at(i) = msg->buffer[msg->pos + i];
stri->at(i) = static_cast<char>(msg->buffer[msg->pos + i]);
}
}
msg->pos += str_size;
msg->pos = (msg->pos + 3) & ~3;
msg->pos = (msg->pos + 3u) & ~3u;

return valid;
}
Expand All @@ -420,9 +420,7 @@ inline bool CDRMessage::readString(
*stri = (const char*) &(msg->buffer[msg->pos]);
}
msg->pos += str_size;
int rest = (str_size) % 4;
rest = rest == 0 ? 0 : 4 - rest;
msg->pos += rest;
msg->pos = (msg->pos + 3u) & ~3u;

return valid;
}
Expand Down
4 changes: 2 additions & 2 deletions include/fastrtps/types/AnnotationParameterValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ class AnnotationParameterValue
case TK_BOOLEAN:
{
std::string val_ = value;
std::transform(val_.begin(), val_.end(), val_.begin(),
std::transform(val_.begin(), val_.end(), val_.begin(),
[](unsigned char c){ return static_cast<char>(std::tolower(c));});
boolean_value(val_.compare("0") != 0 || val_.compare(CONST_TRUE) == 0);
}
Expand Down Expand Up @@ -717,7 +717,7 @@ class AnnotationParameterValue
case TK_ENUM:
{
// TODO Translate from enum value name to integer value
enumerated_value(static_cast<uint32_t>(std::stoul(value)));
enumerated_value(static_cast<int32_t>(std::stoul(value)));
}
break;
default:
Expand Down
6 changes: 4 additions & 2 deletions include/fastrtps/utils/collections/ResourceLimitedVector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,11 @@ class ResourceLimitedVector
InputIterator first,
InputIterator last)
{
size_type n = std::distance(first, last);
size_type n = static_cast<size_type>(std::distance(first, last));
n = std::min(n, configuration_.maximum);
collection_.assign(first, first + n);
InputIterator value = first;
std::advance(value, n);
collection_.assign(first, value);
}

/**
Expand Down
Loading