Skip to content

Commit aab2078

Browse files
committed
fixup! squash! squash! fixup! squash! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Code Quality: Address shadowing
1 parent 60cc04a commit aab2078

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

implementation/endpoints/src/local_uds_server_endpoint_impl.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ local_uds_server_endpoint_impl::local_uds_server_endpoint_impl(
4646

4747
void local_uds_server_endpoint_impl::init(const endpoint_type& _local,
4848
boost::system::error_code& _error) {
49-
std::lock_guard<std::mutex> its_lock(acceptor_mutex_);
49+
std::scoped_lock its_lock{acceptor_mutex_};
5050
acceptor_.open(_local.protocol(), _error);
5151
if (_error)
5252
return;
@@ -56,7 +56,7 @@ void local_uds_server_endpoint_impl::init(const endpoint_type& _local,
5656

5757
void local_uds_server_endpoint_impl::init(const endpoint_type& _local, const int _socket,
5858
boost::system::error_code& _error) {
59-
std::lock_guard<std::mutex> its_lock(acceptor_mutex_);
59+
std::scoped_lock its_lock{acceptor_mutex_};
6060
acceptor_.assign(_local.protocol(), _socket, _error);
6161
if (_error)
6262
return;
@@ -91,13 +91,13 @@ void local_uds_server_endpoint_impl::init_helper(const endpoint_type& _local,
9191
}
9292

9393
void local_uds_server_endpoint_impl::deinit() {
94-
std::lock_guard<std::mutex> its_lock(acceptor_mutex_);
94+
std::scoped_lock its_lock{acceptor_mutex_};
9595
boost::system::error_code its_error;
9696
acceptor_.close(its_error);
9797
}
9898

9999
void local_uds_server_endpoint_impl::start() {
100-
std::lock_guard<std::mutex> its_lock(acceptor_mutex_);
100+
std::scoped_lock its_lock{acceptor_mutex_};
101101
if (acceptor_.is_open()) {
102102
connection::ptr new_connection = connection::create(
103103
std::dynamic_pointer_cast<local_uds_server_endpoint_impl>(
@@ -126,14 +126,14 @@ void local_uds_server_endpoint_impl::stop() {
126126

127127
server_endpoint_impl::stop();
128128
{
129-
std::lock_guard<std::mutex> its_lock(acceptor_mutex_);
129+
std::scoped_lock its_lock{acceptor_mutex_};
130130
if (acceptor_.is_open()) {
131131
boost::system::error_code its_error;
132132
acceptor_.close(its_error);
133133
}
134134
}
135135
{
136-
std::lock_guard<std::mutex> its_lock(connections_mutex_);
136+
std::scoped_lock its_lock{connections_mutex_};
137137
for (const auto &c : connections_) {
138138
c.second->stop();
139139
}
@@ -153,7 +153,7 @@ bool local_uds_server_endpoint_impl::send(const uint8_t *_data, uint32_t _size)
153153
msg << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(_data[i] << " ";
154154
VSOMEIP_INFO << msg.str();
155155
#endif
156-
std::lock_guard<std::mutex> its_lock(mutex_);
156+
std::scoped_lock its_lock{mutex_};
157157
if (endpoint_impl::sending_blocked_) {
158158
return false;
159159
}
@@ -163,7 +163,7 @@ bool local_uds_server_endpoint_impl::send(const uint8_t *_data, uint32_t _size)
163163

164164
connection::ptr its_connection;
165165
{
166-
std::lock_guard<std::mutex> its_lock_inner(connections_mutex_);
166+
std::scoped_lock its_lock_inner{connections_mutex_};
167167
const auto its_iterator = connections_.find(its_client);
168168
if (its_iterator == connections_.end()) {
169169
return false;
@@ -222,7 +222,7 @@ bool local_uds_server_endpoint_impl::add_connection(const client_t &_client,
222222
const std::shared_ptr<connection> &_connection) {
223223

224224
bool ret = false;
225-
std::lock_guard<std::mutex> its_lock(connections_mutex_);
225+
std::scoped_lock its_lock{connections_mutex_};
226226
auto find_connection = connections_.find(_client);
227227
if (find_connection == connections_.end()) {
228228
connections_[_client] = _connection;
@@ -237,7 +237,7 @@ bool local_uds_server_endpoint_impl::add_connection(const client_t &_client,
237237
void local_uds_server_endpoint_impl::remove_connection(
238238
const client_t &_client) {
239239

240-
std::lock_guard<std::mutex> its_lock(connections_mutex_);
240+
std::scoped_lock its_lock{connections_mutex_};
241241
connections_.erase(_client);
242242
}
243243

@@ -312,7 +312,7 @@ void local_uds_server_endpoint_impl::accept_cbk(
312312
_connection->set_bound_client_host(its_client_host);
313313
} else {
314314
{
315-
std::lock_guard<std::mutex> its_connection_lock(connections_mutex_);
315+
std::scoped_lock its_connection_lock{connections_mutex_};
316316
// rm_impl receives VSOMEIP_CLIENT_UNSET initially -> check later
317317
const auto found_client = connections_.find(its_client);
318318
if (found_client != connections_.end()) {
@@ -421,7 +421,7 @@ local_uds_server_endpoint_impl::connection::get_socket_lock() {
421421
}
422422

423423
void local_uds_server_endpoint_impl::connection::start() {
424-
std::lock_guard<std::mutex> its_lock(socket_mutex_);
424+
std::scoped_lock its_lock{socket_mutex_};
425425
if (socket_.is_open()) {
426426
const std::size_t its_capacity(recv_buffer_.capacity());
427427
if (recv_buffer_size_ > its_capacity) {
@@ -484,7 +484,7 @@ void local_uds_server_endpoint_impl::connection::start() {
484484
}
485485

486486
void local_uds_server_endpoint_impl::connection::stop() {
487-
std::lock_guard<std::mutex> its_lock(socket_mutex_);
487+
std::scoped_lock its_lock{socket_mutex_};
488488
is_stopped_ = true;
489489
if (socket_.is_open()) {
490490
if (-1 == fcntl(socket_.native_handle(), F_GETFD)) {
@@ -524,7 +524,7 @@ void local_uds_server_endpoint_impl::connection::send_queued(
524524
bufs.push_back(boost::asio::buffer(its_end_tag));
525525

526526
{
527-
std::lock_guard<std::mutex> its_lock(socket_mutex_);
527+
std::scoped_lock its_lock{socket_mutex_};
528528
boost::asio::async_write(
529529
socket_,
530530
bufs,
@@ -662,7 +662,7 @@ void local_uds_server_endpoint_impl::connection::receive_cbk(
662662
}
663663
if (its_command_size && max_message_size_ != MESSAGE_SIZE_UNLIMITED
664664
&& its_command_size > max_message_size_) {
665-
std::lock_guard<std::mutex> its_lock(socket_mutex_);
665+
std::scoped_lock its_lock{socket_mutex_};
666666
VSOMEIP_ERROR << "Received a local message which exceeds "
667667
<< "maximum message size (" << std::dec << its_command_size
668668
<< ") aborting! local: " << get_path_local() << " remote: "
@@ -935,7 +935,7 @@ local_uds_server_endpoint_impl::connection::get_recv_buffer_capacity() const {
935935

936936
void
937937
local_uds_server_endpoint_impl::connection::shutdown_and_close() {
938-
std::lock_guard<std::mutex> its_lock(socket_mutex_);
938+
std::scoped_lock its_lock{socket_mutex_};
939939
shutdown_and_close_unlocked();
940940
}
941941

@@ -947,10 +947,10 @@ local_uds_server_endpoint_impl::connection::shutdown_and_close_unlocked() {
947947
}
948948

949949
void local_uds_server_endpoint_impl::print_status() {
950-
std::lock_guard<std::mutex> its_lock(mutex_);
950+
std::scoped_lock its_lock{mutex_};
951951
connections_t its_connections;
952952
{
953-
std::lock_guard<std::mutex> its_lock_inner(connections_mutex_);
953+
std::scoped_lock its_lock_inner{connections_mutex_};
954954
its_connections = connections_;
955955
}
956956

implementation/endpoints/src/tcp_server_endpoint_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ bool tcp_server_endpoint_impl::is_established_to(
217217
} else {
218218
VSOMEIP_INFO << "Didn't find TCP connection: Subscription "
219219
<< "rejected for: " << its_endpoint.address().to_string() << ":" << std::dec
220-
<< static_cast<std::uint16_t>(its_endpoint.port());
220+
<< its_endpoint.port();
221221
}
222222
}
223223
return is_connected;

0 commit comments

Comments
 (0)