Skip to content

Commit 0c232f4

Browse files
committed
Fix a few clang-analyzer warnings
1 parent 054f5ed commit 0c232f4

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

src/netinterfaces.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#include <cstring>
33
#include <loguru.hpp>
44

5-
using asio::ip::address_v4;
6-
75
asio::ip::address_v6 sinaddr_to_asio(sockaddr_in6 *addr) {
86
asio::ip::address_v6::bytes_type buf;
97
memcpy(buf.data(), addr->sin6_addr.s6_addr, sizeof(addr->sin6_addr));

src/tcp_server.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ void client_session::handle_read_query_outcome(err_t err) {
336336
if (serv_->info_->matches_query(query)) {
337337
// matches: reply (otherwise just close the stream)
338338
async_write(*sock_, asio::buffer(serv_->shortinfo_msg_),
339-
[shared_this = shared_from_this() /*unused*/](err_t, std::size_t /*unused*/) {
339+
[shared_this = shared_from_this()](err_t /*unused*/, std::size_t /*unused*/) {
340340
/* keep the client_session alive until the shortinfo is sent completely*/
341341
});
342342
} else {
@@ -347,10 +347,10 @@ void client_session::handle_read_query_outcome(err_t err) {
347347
}
348348
}
349349

350-
void client_session::send_status_message(const std::string &str) {
351-
auto msg(std::make_shared<std::string>(str));
352-
async_write(*sock_, asio::buffer(*msg),
353-
[msg, shared_this = shared_from_this()](err_t /*unused*/,
350+
void client_session::send_status_message(const std::string &msg) {
351+
auto buf(std::make_shared<std::string>(msg));
352+
async_write(*sock_, asio::buffer(*buf),
353+
[buf, shared_this = shared_from_this()](err_t /*unused*/,
354354
std::size_t /*unused*/) { /* keep objects alive until the message is sent */ });
355355
}
356356

@@ -478,7 +478,7 @@ void client_session::handle_read_feedparams(
478478
// --- validation ---
479479
if (data_protocol_version_ == 100) {
480480
// create a portable output archive to write to
481-
outarch_.reset(new eos::portable_oarchive(feedbuf_));
481+
outarch_ = std::make_unique<eos::portable_oarchive>(feedbuf_);
482482
// serialize the shortinfo message into an archive
483483
*outarch_ << serv_->shortinfo_msg_;
484484
} else {

src/udp_server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,10 @@ void udp_server::end_serving() {
8989
// gracefully close the socket; this will eventually lead to the cancellation of the IO
9090
// operation(s) tied to its socket
9191
auto sock(socket_); // socket shared ptr to be kept alive
92-
post(io_, [sock]() {
92+
post(io_, [sock, fn = __func__]() {
9393
try {
9494
if (sock->is_open()) sock->close();
95-
} catch (std::exception &e) { LOG_F(ERROR, "Error during %s: %s", __func__, e.what()); }
95+
} catch (std::exception &e) { LOG_F(ERROR, "Error during %s: %s", fn, e.what()); }
9696
});
9797
}
9898

@@ -125,7 +125,7 @@ void udp_server::process_shortinfo_request(std::istream& request_stream)
125125
string_p replymsg(
126126
std::make_shared<std::string>((query_id += "\r\n") += shortinfo_msg_));
127127
socket_->async_send_to(asio::buffer(*replymsg), return_endpoint,
128-
[shared_this = shared_from_this(), replymsg](err_t err_, std::size_t) {
128+
[shared_this = shared_from_this(), replymsg](err_t err_, std::size_t /*unused*/) {
129129
if (err_ != asio::error::operation_aborted && err_ != asio::error::shut_down)
130130
shared_this->request_next_packet();
131131
});
@@ -147,7 +147,7 @@ void udp_server::process_timedata_request(std::istream &request_stream, double t
147147
reply << ' ' << wave_id << ' ' << t0 << ' ' << t1 << ' ' << lsl_clock();
148148
string_p replymsg(std::make_shared<std::string>(reply.str()));
149149
socket_->async_send_to(asio::buffer(*replymsg), remote_endpoint_,
150-
[shared_this = shared_from_this(), replymsg](err_t err_, std::size_t) {
150+
[shared_this = shared_from_this(), replymsg](err_t err_, std::size_t /*unused*/) {
151151
if (err_ != asio::error::operation_aborted && err_ != asio::error::shut_down)
152152
shared_this->request_next_packet();
153153
});

0 commit comments

Comments
 (0)