Skip to content

Commit

Permalink
Fixed some warnings
Browse files Browse the repository at this point in the history
Also improved configure script's use of warning settings on VC++.
This avoids "warning D9025: overriding '/W3' with '/W4'"
  • Loading branch information
mitza-oci committed Dec 9, 2024
1 parent a5c8849 commit 75dc659
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 124 deletions.
14 changes: 11 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -869,9 +869,17 @@ if ($compile_warnings eq 'WARNING' or $compile_warnings eq 'ERROR') {
}
my $warning_flags = $sections->{$section}{'warning'};
my $error_flags = $sections->{$section}{'error'};
push(@mpcopts, '-value_template', "compile_flags+=${warning_flags}");
if ($compile_warnings eq 'ERROR') {
push(@mpcopts, '-value_template', "compile_flags+=${error_flags}");
if ($section eq 'MSVC') {
$warning_flags =~ s/^\/W//;
push(@mpcopts, '-value_template', "warning_level+=${warning_flags}");
if ($compile_warnings eq 'ERROR') {
push(@mpcopts, '-value_template', 'WarnAsError=1');
}
} else {
push(@mpcopts, '-value_template', "compile_flags+=${warning_flags}");
if ($compile_warnings eq 'ERROR') {
push(@mpcopts, '-value_template', "compile_flags+=${error_flags}");
}
}
}

Expand Down
14 changes: 7 additions & 7 deletions dds/DCPS/JsonValueReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ template <typename InputStream>
bool JsonValueReader<InputStream>::read_byte(ACE_CDR::Octet& value)
{
if (peek() == kUint) {
value = uint_value_;
value = static_cast<ACE_CDR::Octet>(uint_value_);
return consume(kUint);
}
return false;
Expand All @@ -378,10 +378,10 @@ bool JsonValueReader<InputStream>::read_int8(ACE_CDR::Int8& value)
{
switch (peek()) {
case kInt:
value = int_value_;
value = static_cast<ACE_CDR::Int8>(int_value_);
return consume(kInt);
case kUint:
value = uint_value_;
value = static_cast<ACE_CDR::Int8>(uint_value_);
return consume(kUint);
default:
return false;
Expand All @@ -392,7 +392,7 @@ template <typename InputStream>
bool JsonValueReader<InputStream>::read_uint8(ACE_CDR::UInt8& value)
{
if (peek() == kUint) {
value = uint_value_;
value = static_cast<ACE_CDR::UInt8>(uint_value_);
return consume(kUint);
}
return false;
Expand All @@ -405,10 +405,10 @@ bool JsonValueReader<InputStream>::read_int16(ACE_CDR::Short& value)
peek();
switch (peek()) {
case kInt:
value = int_value_;
value = static_cast<ACE_CDR::Short>(int_value_);
return consume(kInt);
case kUint:
value = uint_value_;
value = static_cast<ACE_CDR::Short>(uint_value_);
return consume(kUint);
default:
return false;
Expand All @@ -419,7 +419,7 @@ template <typename InputStream>
bool JsonValueReader<InputStream>::read_uint16(ACE_CDR::UShort& value)
{
if (peek() == kUint) {
value = uint_value_;
value = static_cast<ACE_CDR::UShort>(uint_value_);
return consume(kUint);
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion dds/DCPS/JsonValueWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ template <typename Writer>
bool JsonValueWriter<Writer>::write_float128(ACE_CDR::LongDouble value)
{
// TODO
return writer_.Double(value);
return writer_.Double(static_cast<double>(value));
}

template <typename Writer>
Expand Down
50 changes: 20 additions & 30 deletions dds/DCPS/RTPS/ICE/Checklist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ ConnectivityCheck::ConnectivityCheck(const CandidatePair& a_candidate_pair,

if (a_candidate_pair.local_is_controlling) {
request_.append_attribute(STUN::make_ice_controlling(a_ice_tie_breaker));
}

else {
} else {
request_.append_attribute(STUN::make_ice_controlled(a_ice_tie_breaker));
}

Expand Down Expand Up @@ -139,9 +137,7 @@ void Checklist::generate_candidate_pairs()
while (test_pos != limit) {
if (pos->local.base == test_pos->local.base && pos->remote == test_pos->remote) {
frozen_.erase(test_pos++);
}

else {
} else {
++test_pos;
}
}
Expand Down Expand Up @@ -355,8 +351,7 @@ void Checklist::generate_triggered_check(const ACE_INET_Addr& local_address,

// 7.3.1.4
Candidate local;
bool flag = get_local_candidate(local_address, local);
if (!flag) {
if (!get_local_candidate(local_address, local)) {
// Network addresses may have changed so that local_address is not valid.
ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::generate_triggered_check: WARNING local_address %C is no longer a local candidate\n"),
DCPS::LogAddr(local_address).c_str()));
Expand Down Expand Up @@ -398,9 +393,7 @@ void Checklist::succeeded(const ConnectivityCheck& cc)
nominating_ = valid_list_.end();
OPENDDS_ASSERT(frozen_.empty());
OPENDDS_ASSERT(waiting_.empty());
}

else {
} else {
nominated_ = std::find(valid_list_.begin(), valid_list_.end(), cp);

// This is the case where the use_candidate check succeeded before the normal check.
Expand All @@ -410,16 +403,16 @@ void Checklist::succeeded(const ConnectivityCheck& cc)
}

while (!frozen_.empty()) {
CandidatePair cp = frozen_.front();
const CandidatePair pair = frozen_.front();
frozen_.pop_front();
failed_.push_back(cp);
failed_.push_back(pair);
}

while (!waiting_.empty()) {
CandidatePair cp = waiting_.front();
const CandidatePair pair = waiting_.front();
waiting_.pop_front();
endpoint_manager_->agent_impl->remove(cp.foundation);
failed_.push_back(cp);
endpoint_manager_->agent_impl->remove(pair.foundation);
failed_.push_back(pair);
}

triggered_check_queue_.clear();
Expand All @@ -430,18 +423,16 @@ void Checklist::succeeded(const ConnectivityCheck& cc)
last_indication_.set_to_now();

while (!connectivity_checks_.empty()) {
ConnectivityCheck cc = connectivity_checks_.front();
const ConnectivityCheck check = connectivity_checks_.front();
connectivity_checks_.pop_front();

if (!cc.cancelled()) {
failed(cc);
}

else {
remove_from_in_progress(cc.candidate_pair());
if (!check.cancelled()) {
failed(check);
} else {
remove_from_in_progress(check.candidate_pair());
}

endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
endpoint_manager_->unset_responsible_checklist(check.request().transaction_id, rchandle_from(this));
}

OPENDDS_ASSERT(frozen_.empty());
Expand Down Expand Up @@ -605,11 +596,11 @@ void Checklist::error_response(const ACE_INET_Addr& /*local_address*/,
a_message.get_error_reason().c_str()));

if (a_message.get_error_code() == STUN::UNKNOWN_ATTRIBUTE && a_message.has_unknown_attributes()) {
std::vector<STUN::AttributeType> unknown_attributes = a_message.get_unknown_attributes();
std::vector<STUN::AttributeType> unknown = a_message.get_unknown_attributes();

for (std::vector<STUN::AttributeType>::const_iterator pos = unknown_attributes.begin(),
limit = unknown_attributes.end(); pos != limit; ++pos) {
ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING Unknown STUN attribute %d\n"), *pos));
for (std::vector<STUN::AttributeType>::const_iterator attrib = unknown.begin(),
limit = unknown.end(); attrib != limit; ++attrib) {
ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING Unknown STUN attribute %d\n"), *attrib));
}
}

Expand All @@ -619,9 +610,8 @@ void Checklist::error_response(const ACE_INET_Addr& /*local_address*/,
connectivity_checks_.erase(pos);
endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
}
}

else {
} else {
ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING STUN error response (no code)\n")));
}
}
Expand Down
46 changes: 23 additions & 23 deletions dds/DCPS/RTPS/ICE/Stun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bool operator>>(DCPS::Serializer& serializer, AttributeHolder& holder)
return false;
}

ACE_UINT16 code = class_ * 100 + num;
ACE_UINT16 code = static_cast<ACE_UINT16>(class_ * 100 + num);

const ACE_CDR::ULong reason_length = attribute_length - 4;

Expand Down Expand Up @@ -463,7 +463,7 @@ bool operator>>(DCPS::Serializer& serializer, AttributeHolder& holder)

bool operator<<(DCPS::Serializer& serializer, ConstAttributeHolder& holder)
{
ACE_UINT16 attribute_type = holder.attribute.type;
ACE_UINT16 attribute_type = static_cast<ACE_UINT16>(holder.attribute.type);
ACE_UINT16 attribute_length = holder.attribute.length();
serializer << attribute_type;
serializer << attribute_length;
Expand Down Expand Up @@ -497,8 +497,8 @@ bool operator<<(DCPS::Serializer& serializer, ConstAttributeHolder& holder)
break;

case ERROR_CODE: {
ACE_UINT8 class_ = holder.attribute.error.code / 100;
ACE_UINT8 num = holder.attribute.error.code % 100;
const ACE_UINT8 class_ = static_cast<ACE_UINT8>(holder.attribute.error.code / 100);
const ACE_UINT8 num = holder.attribute.error.code % 100;
serializer << static_cast<ACE_CDR::Char>(0);
serializer << static_cast<ACE_CDR::Char>(0);
serializer << static_cast<ACE_CDR::Char>(class_);
Expand Down Expand Up @@ -702,14 +702,14 @@ bool Message::has_message_integrity() const
return false;
}

bool Message::verify_message_integrity(const std::string& password) const
bool Message::verify_message_integrity(const std::string& pass) const
{
bool verified = false;

for (STUN::Message::const_iterator pos = begin(), limit = end(); pos != limit; ++pos) {
if (pos->type == STUN::MESSAGE_INTEGRITY) {
unsigned char computed_message_integrity[20];
compute_message_integrity(password, computed_message_integrity);
compute_message_integrity(pass, computed_message_integrity);
verified = memcmp(computed_message_integrity, pos->message_integrity, 20) == 0;
// Use the last.
}
Expand All @@ -718,27 +718,27 @@ bool Message::verify_message_integrity(const std::string& password) const
return verified;
}

void Message::compute_message_integrity(const std::string& password, unsigned char message_integrity[20]) const
void Message::compute_message_integrity(const std::string& pass, unsigned char message_integrity[20]) const
{
ACE_Message_Block* block = this->block->duplicate();
block->rd_ptr(block->base());
DCPS::Serializer serializer(block, encoding);
ACE_Message_Block* amb = this->block->duplicate();
amb->rd_ptr(amb->base());
DCPS::Serializer serializer(amb, encoding);

// Write the length and resize for hashing.
block->wr_ptr(block->base() + 2);
amb->wr_ptr(amb->base() + 2);
ACE_UINT16 message_length = length_for_message_integrity();
serializer << message_length;
block->wr_ptr(block->base() + HEADER_SIZE + length_for_message_integrity() - 24);
amb->wr_ptr(amb->base() + HEADER_SIZE + length_for_message_integrity() - 24);

// Compute the SHA1.
TheSecurityRegistry->builtin_config()->get_utility()->hmac(message_integrity, block->rd_ptr(), block->length(), password);
TheSecurityRegistry->builtin_config()->get_utility()->hmac(message_integrity, amb->rd_ptr(), amb->length(), pass);

// Write the correct length.
block->wr_ptr(block->base() + 2);
amb->wr_ptr(amb->base() + 2);
message_length = length();
serializer << message_length;

block->release();
amb->release();
}

bool Message::has_error_code() const
Expand Down Expand Up @@ -809,17 +809,17 @@ bool Message::has_fingerprint() const

ACE_UINT32 Message::compute_fingerprint() const
{
ACE_Message_Block* block = this->block->duplicate();
block->rd_ptr(block->base());
DCPS::Serializer serializer(block, encoding);
ACE_Message_Block* amb = this->block->duplicate();
amb->rd_ptr(amb->base());
DCPS::Serializer serializer(amb, encoding);

// Resize for hashing.
block->wr_ptr(block->base() + HEADER_SIZE + length() - 8);
amb->wr_ptr(amb->base() + HEADER_SIZE + length() - 8);

// Compute the CRC-32
ACE_UINT32 crc = ACE::crc32(block->rd_ptr(), block->length());
ACE_UINT32 crc = ACE::crc32(amb->rd_ptr(), amb->length());

block->release();
amb->release();

return crc ^ 0x5354554E;
}
Expand Down Expand Up @@ -945,8 +945,8 @@ bool operator>>(DCPS::Serializer& serializer, Message& message)

bool operator<<(DCPS::Serializer& serializer, const Message& message)
{
ACE_UINT16 message_class = message.class_;
ACE_UINT16 message_method = message.method;
const ACE_UINT16 message_class = static_cast<ACE_UINT16>(message.class_);
const ACE_UINT16 message_method = static_cast<ACE_UINT16>(message.method);
ACE_UINT16 message_type =
((message_method & 0xF80) << 2) |
((message_class & 0x2) << 7) |
Expand Down
2 changes: 1 addition & 1 deletion dds/DCPS/RTPS/ParameterListConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1613,7 +1613,7 @@ bool to_param_list(const ICE::AgentInfoMap& ai_map,
DCPS::push_back(param_list, param_general);

for (ICE::AgentInfo::CandidatesType::const_iterator pos = agent_info.candidates.begin(),
limit = agent_info.candidates.end(); pos != limit; ++pos) {
ai_limit = agent_info.candidates.end(); pos != ai_limit; ++pos) {
IceCandidate_t ice_candidate;
ice_candidate.key = map_pos->first.c_str();
address_to_locator(ice_candidate.locator, pos->address);
Expand Down
8 changes: 4 additions & 4 deletions dds/DCPS/RTPS/RtpsDiscoveryConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,14 @@ RtpsDiscoveryConfig::dy(DDS::UInt16 sedp_unicast_offset)
bool RtpsDiscoveryConfig::set_spdp_multicast_port(DCPS::NetworkAddress& addr,
DDS::DomainId_t domain) const
{
return set_rtps_multicast_port(addr, "SPDP multicast", pb(), d0(), domain, dg());
return set_rtps_multicast_port(addr, "SPDP multicast", pb(), d0(), static_cast<DDS::UInt16>(domain), dg());
}

bool RtpsDiscoveryConfig::set_spdp_unicast_port(DCPS::NetworkAddress& addr, bool& fixed_port,
DDS::DomainId_t domain, DDS::UInt16 part_id) const
{
return set_rtps_unicast_port(addr, fixed_port, "SPDP unicast", spdp_port_mode(),
pb(), d1(), domain, dg(), part_id, pg());
pb(), d1(), static_cast<DDS::UInt16>(domain), dg(), part_id, pg());
}

unsigned char
Expand Down Expand Up @@ -715,8 +715,8 @@ RtpsDiscoveryConfig::auth_resend_period(const DCPS::TimeDuration& x)
u_short
RtpsDiscoveryConfig::max_spdp_sequence_msg_reset_checks() const
{
return TheServiceParticipant->config_store()->get_uint32(config_key("MAX_SPDP_SEQUENCE_MSG_RESET_CHECKS").c_str(),
3);
const DDS::UInt32 val = TheServiceParticipant->config_store()->get_uint32(config_key("MAX_SPDP_SEQUENCE_MSG_RESET_CHECKS").c_str(), 3);
return static_cast<u_short>(val);
}

void
Expand Down
5 changes: 2 additions & 3 deletions dds/DCPS/RTPS/Sedp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3642,7 +3642,7 @@ Sedp::Writer::set_header_fields(DCPS::DataSampleHeader& dsh,
bool historic_sample,
DCPS::MessageId id)
{
dsh.message_id_ = id;
dsh.message_id_ = static_cast<char>(id);
dsh.byte_order_ = ACE_CDR_BYTE_ORDER;
dsh.message_length_ = static_cast<ACE_UINT32>(size);
dsh.publication_id_ = repo_id_;
Expand Down Expand Up @@ -7102,8 +7102,7 @@ void Sedp::match(const GUID_t& writer, const GUID_t& reader)
// request only the remote complete TypeObject (if it's not already in the cache).
// The following code assumes when the "minimal" part is not included in the discovered
// endpoint's TypeInformation, then the "complete" part also is not included.
bool request = false;
bool need_minimal, need_complete;
bool request = false, need_minimal = false, need_complete = false;
if ((writer_type_info->minimal.typeid_with_size.type_id.kind() != XTypes::TK_NONE) &&
(reader_type_info->minimal.typeid_with_size.type_id.kind() != XTypes::TK_NONE)) {
if (!writer_local && reader_local) {
Expand Down
4 changes: 2 additions & 2 deletions dds/DCPS/security/AccessControlBuiltInImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ ::CORBA::Boolean AccessControlBuiltInImpl::check_create_topic(
return false;
}

Permissions::PublishSubscribe_t denied_type;
Permissions::PublishSubscribe_t denied_type = Permissions::PUBLISH;
bool found_deny = false;
// Iterate over allow / deny rules
for (perm_topic_rules_iter ptr_iter = grant->rules.begin(); ptr_iter != grant->rules.end(); ++ptr_iter) {
Expand Down Expand Up @@ -906,7 +906,7 @@ ::CORBA::Boolean AccessControlBuiltInImpl::check_remote_topic(
return false;
}

Permissions::PublishSubscribe_t denied_type;
Permissions::PublishSubscribe_t denied_type = Permissions::PUBLISH;
bool found_deny = false;
for (perm_topic_rules_iter ptr_iter = grant->rules.begin(); ptr_iter != grant->rules.end(); ++ptr_iter) {

Expand Down
Loading

0 comments on commit 75dc659

Please sign in to comment.