Skip to content

Commit

Permalink
Code Quality: Address shadowing
Browse files Browse the repository at this point in the history
  • Loading branch information
kheaactua committed Jan 28, 2025
1 parent 683e145 commit 2f77dcd
Show file tree
Hide file tree
Showing 16 changed files with 150 additions and 151 deletions.
133 changes: 66 additions & 67 deletions implementation/configuration/src/configuration_impl.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions implementation/endpoints/src/endpoint_manager_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,9 +1104,9 @@ endpoint_manager_impl::find_remote_client(
service_instances_[_service][its_endpoint.get()] = _instance;

// add endpoint to serviceinfo object
auto found_service_info = rm_->find_service(_service,_instance);
if (found_service_info) {
found_service_info->set_endpoint(its_endpoint, _reliable);
auto found_service_info_inner = rm_->find_service(_service,_instance);
if (found_service_info_inner) {
found_service_info_inner->set_endpoint(its_endpoint, _reliable);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions implementation/endpoints/src/local_tcp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void local_tcp_server_endpoint_impl::start() {
io_);

{
std::unique_lock<std::mutex> its_lock(new_connection->get_socket_lock());
std::unique_lock<std::mutex> its_lock_inner(new_connection->get_socket_lock());
acceptor_.async_accept(
new_connection->get_socket(),
std::bind(
Expand Down Expand Up @@ -150,7 +150,7 @@ bool local_tcp_server_endpoint_impl::send(const uint8_t *_data, uint32_t _size)

connection::ptr its_connection;
{
std::lock_guard<std::mutex> its_lock(connections_mutex_);
std::lock_guard<std::mutex> its_lock_inner(connections_mutex_);
const auto its_iterator = connections_.find(its_client);
if (its_iterator == connections_.end()) {
return false;
Expand Down Expand Up @@ -275,8 +275,8 @@ void local_tcp_server_endpoint_impl::accept_cbk(
auto its_ep = std::dynamic_pointer_cast<local_tcp_server_endpoint_impl>(
shared_from_this());
its_timer->async_wait([its_timer, its_ep]
(const boost::system::error_code& _error) {
if (!_error) {
(const boost::system::error_code& _error_inner) {
if (!_error_inner) {
its_ep->start();
}
});
Expand Down Expand Up @@ -848,7 +848,7 @@ void local_tcp_server_endpoint_impl::print_status() {
std::lock_guard<std::mutex> its_lock(mutex_);
connections_t its_connections;
{
std::lock_guard<std::mutex> its_lock(connections_mutex_);
std::lock_guard<std::mutex> its_lock_inner(connections_mutex_);
its_connections = connections_;
}
std::string its_local_path("TCP");
Expand Down
10 changes: 5 additions & 5 deletions implementation/endpoints/src/local_uds_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ void local_uds_server_endpoint_impl::start() {
io_);

{
std::unique_lock<std::mutex> its_lock(new_connection->get_socket_lock());
std::unique_lock<std::mutex> its_lock_inner(new_connection->get_socket_lock());
acceptor_.async_accept(
new_connection->get_socket(),
std::bind(
Expand Down Expand Up @@ -163,7 +163,7 @@ bool local_uds_server_endpoint_impl::send(const uint8_t *_data, uint32_t _size)

connection::ptr its_connection;
{
std::lock_guard<std::mutex> its_lock(connections_mutex_);
std::lock_guard<std::mutex> its_lock_inner(connections_mutex_);
const auto its_iterator = connections_.find(its_client);
if (its_iterator == connections_.end()) {
return false;
Expand Down Expand Up @@ -257,8 +257,8 @@ void local_uds_server_endpoint_impl::accept_cbk(
auto its_ep = std::dynamic_pointer_cast<local_uds_server_endpoint_impl>(
shared_from_this());
its_timer->async_wait([its_timer, its_ep]
(const boost::system::error_code& _error) {
if (!_error) {
(const boost::system::error_code& _error_inner) {
if (!_error_inner) {
its_ep->start();
}
});
Expand Down Expand Up @@ -950,7 +950,7 @@ void local_uds_server_endpoint_impl::print_status() {
std::lock_guard<std::mutex> its_lock(mutex_);
connections_t its_connections;
{
std::lock_guard<std::mutex> its_lock(connections_mutex_);
std::lock_guard<std::mutex> its_lock_inner(connections_mutex_);
its_connections = connections_;
}

Expand Down
2 changes: 1 addition & 1 deletion implementation/endpoints/src/netlink_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include <boost/asio/write.hpp>
#include <boost/asio/read.hpp>
#include<sstream>
#include <sstream>

#include <vsomeip/internal/logger.hpp>

Expand Down
6 changes: 3 additions & 3 deletions implementation/endpoints/src/tcp_client_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void tcp_client_endpoint_impl::connect() {
}
std::size_t operations_cancelled;
{
std::lock_guard<std::mutex> its_lock(connecting_timer_mutex_);
std::lock_guard<std::mutex> its_lock_inner(connecting_timer_mutex_);
operations_cancelled = connecting_timer_.cancel();
}
if (operations_cancelled != 0) {
Expand Down Expand Up @@ -249,7 +249,7 @@ void tcp_client_endpoint_impl::connect() {
<< "(" << its_error.value() << "): " << its_error.message();
std::size_t operations_cancelled;
{
std::lock_guard<std::mutex> its_lock(connecting_timer_mutex_);
std::lock_guard<std::mutex> its_lock_inner(connecting_timer_mutex_);
operations_cancelled = connecting_timer_.cancel();
}
if (operations_cancelled != 0) {
Expand Down Expand Up @@ -577,7 +577,7 @@ void tcp_client_endpoint_impl::receive_cbk(
} else {
if (has_enabled_magic_cookies_) {
uint32_t its_offset = find_magic_cookie(&(*_recv_buffer)[its_iteration_gap],
(uint32_t) _recv_buffer_size);
uint32_t(_recv_buffer_size));
if (its_offset < current_message_size) {
VSOMEIP_ERROR << "Message includes Magic Cookie. Ignoring it.";
current_message_size = its_offset;
Expand Down
8 changes: 4 additions & 4 deletions implementation/endpoints/src/tcp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ void tcp_server_endpoint_impl::get_configured_times_from_endpoint(
bool tcp_server_endpoint_impl::is_established_to(
const std::shared_ptr<endpoint_definition>& _endpoint) {
bool is_connected = false;
endpoint_type endpoint(_endpoint->get_address(), _endpoint->get_port());
endpoint_type my_endpoint(_endpoint->get_address(), _endpoint->get_port());
{
std::lock_guard<std::mutex> its_lock(connections_mutex_);
auto connection_iterator = connections_.find(endpoint);
auto connection_iterator = connections_.find(my_endpoint);
if (connection_iterator != connections_.end()) {
is_connected = true;
} else {
VSOMEIP_INFO << "Didn't find TCP connection: Subscription "
<< "rejected for: " << endpoint.address().to_string() << ":" << std::dec
<< static_cast<std::uint16_t>(endpoint.port());
<< "rejected for: " << my_endpoint.address().to_string() << ":" << std::dec
<< static_cast<std::uint16_t>(my_endpoint.port());
}
}
return is_connected;
Expand Down
10 changes: 5 additions & 5 deletions implementation/endpoints/src/udp_server_endpoint_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,22 +352,22 @@ void udp_server_endpoint_impl::join_unlocked(const std::string& _address) {
//
// join_func must be called with multicast_mutex_ being hold!
//
auto join_func = [this](const std::string& _address) {
auto join_func = [this](const std::string& __address) {
try {
VSOMEIP_DEBUG << "Joining to multicast group " << _address << " from "
VSOMEIP_DEBUG << "Joining to multicast group " << __address << " from "
<< local_.address().to_string();

auto its_endpoint_host = endpoint_host_.lock();
if (its_endpoint_host) {
multicast_option_t its_join_option {shared_from_this(), true,
boost::asio::ip::make_address(_address)};
boost::asio::ip::make_address(__address)};
its_endpoint_host->add_multicast_option(its_join_option);
}

joined_[_address] = false;
joined_[__address] = false;
} catch (const std::exception& e) {
VSOMEIP_ERROR << "udp_server_endpoint_impl::join" << ":" << e.what()
<< " address: " << _address;
<< " address: " << __address;
}
};

Expand Down
2 changes: 1 addition & 1 deletion implementation/logger/src/message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ message::~message() try {
std::streambuf::int_type
message::buffer::overflow(std::streambuf::int_type c) {
if (c != EOF) {
data_ << (char)c;
data_ << static_cast<char>(c);
}

return c;
Expand Down
2 changes: 1 addition & 1 deletion implementation/protocol/src/register_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void
register_event::set_eventgroups(const std::set<eventgroup_t> &_eventgroups) {

eventgroups_ = _eventgroups;
num_eventg_ = (uint16_t)eventgroups_.size();
num_eventg_ = static_cast<uint16_t>(eventgroups_.size());
}

} // namespace protocol
Expand Down
2 changes: 1 addition & 1 deletion implementation/routing/src/eventgroupinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ eventgroupinfo::is_remote_subscription_limit_reached(
if (find_address != remote_subscribers_count_.end()) {
if (find_address->second >= max_remote_subscribers_) {
VSOMEIP_WARNING << ": remote subscriber limit [" << std::dec
<< (uint32_t)max_remote_subscribers_ << "] to ["
<< static_cast<uint32_t>(max_remote_subscribers_) << "] to ["
<< std::hex << std::setfill('0')
<< std::setw(4) << service_ << "."
<< std::setw(4) << instance_ << "."
Expand Down
12 changes: 6 additions & 6 deletions implementation/routing/src/routing_manager_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2385,7 +2385,7 @@ void routing_manager_client::send_pending_event_registrations(client_t _client)
for(; it!=pending_event_registrations_.end(); it++) {
protocol::register_event reg(it->service_, it->instance_, it->notifier_, it->type_,
it->is_provided_, it->reliability_, it->is_cyclic_
, (uint16_t)it->eventgroups_.size(), it->eventgroups_);
, uint16_t(it->eventgroups_.size()), it->eventgroups_);
if(!its_command.add_registration(reg)) {break;}
}

Expand Down Expand Up @@ -2419,7 +2419,7 @@ void routing_manager_client::send_register_event(client_t _client,

protocol::register_event reg(_service, _instance, _notifier, _type,
_is_provided, _reliability, _is_cyclic,
(uint16_t)_eventgroups.size(), _eventgroups);
uint16_t(_eventgroups.size()), _eventgroups);

if(!its_command.add_registration(reg)) {
VSOMEIP_ERROR << __func__ << ": register event command is too long.";
Expand Down Expand Up @@ -2514,10 +2514,10 @@ void routing_manager_client::cache_event_payload(
std::chrono::milliseconds::zero(), false, true,
nullptr,
false, false, true);
std::shared_ptr<event> its_event = find_event(its_service, its_instance, its_method);
if (its_event) {
its_event->prepare_update_payload(_message->get_payload(), true);
its_event->update_payload();
std::shared_ptr<event> its_event_inner = find_event(its_service, its_instance, its_method);
if (its_event_inner) {
its_event_inner->prepare_update_payload(_message->get_payload(), true);
its_event_inner->update_payload();
}
}
}
Expand Down
Loading

0 comments on commit 2f77dcd

Please sign in to comment.