Skip to content

Commit f62b3bd

Browse files
committed
Fix several compiler and clang-tidy warnings
1 parent a0fc2fd commit f62b3bd

24 files changed

+102
-87
lines changed

src/api_config.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ void api_config::load_from_file(const std::string &filename) {
208208
outlet_buffer_reserve_samples_ = pt.get("tuning.OutletBufferReserveSamples", 128);
209209
inlet_buffer_reserve_ms_ = pt.get("tuning.InletBufferReserveMs", 5000);
210210
inlet_buffer_reserve_samples_ = pt.get("tuning.InletBufferReserveSamples", 128);
211-
smoothing_halftime_ = pt.get("tuning.SmoothingHalftime", 90.0f);
211+
smoothing_halftime_ = pt.get("tuning.SmoothingHalftime", 90.0F);
212212
force_default_timestamps_ = pt.get("tuning.ForceDefaultTimestamps", false);
213213

214214
// read the [log] settings

src/cancellation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "cancellation.h"
22
#include <loguru.hpp>
33

4-
lsl::cancellable_registry::~cancellable_registry() {}
4+
lsl::cancellable_registry::~cancellable_registry() = default;
55

66
lsl::cancellable_obj::~cancellable_obj() { unregister_from_all(); }
77

88
void lsl::cancellable_obj::unregister_from_all() {
99
try {
10-
for (auto obj : registered_at_) obj->unregister_cancellable(this);
10+
for (auto *obj : registered_at_) obj->unregister_cancellable(this);
1111
registered_at_.clear();
1212
} catch (std::exception &e) {
1313
LOG_F(ERROR,

src/cast.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
namespace lsl {
77

8-
template <> std::string to_string(double str) {
8+
template <> std::string to_string(double val) {
99
std::ostringstream os;
1010
os.imbue(std::locale::classic());
11-
os << std::setprecision(16) << std::showpoint << str;
11+
os << std::setprecision(16) << std::showpoint << val;
1212
return os.str();
1313
}
1414

15-
template <> std::string to_string(float str) {
15+
template <> std::string to_string(float val) {
1616
std::ostringstream os;
1717
os.imbue(std::locale::classic());
18-
os << std::setprecision(8) << std::showpoint << str;
18+
os << std::setprecision(8) << std::showpoint << val;
1919
return os.str();
2020
}
2121

src/cast.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
namespace lsl {
55
template <typename T> std::string to_string(T val) { return std::to_string(val); }
6+
template <> std::string to_string(double val);
7+
template <> std::string to_string(float val);
68

79
template <typename T> T from_string(const std::string &str);
8-
9-
template <> std::string to_string(double str);
10-
template <> std::string to_string(float str);
11-
1210
template <> inline bool from_string(const std::string &str) { return str == "1"; }
1311

1412
} // namespace lsl

src/consumer_queue.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
#include "send_buffer.h"
44
#include <chrono>
55
#include <loguru.hpp>
6+
#include <utility>
67

78
using namespace lsl;
89

910
consumer_queue::consumer_queue(std::size_t max_capacity, send_buffer_p registry)
10-
: registry_(registry), buffer_(max_capacity) {
11+
: registry_(std::move(registry)), buffer_(max_capacity) {
1112
if (registry_) registry_->register_consumer(this);
1213
}
1314

src/inireader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class INI {
1111
}
1212

1313
public:
14-
void load(std::istream &ini);
14+
void load(std::istream &infile);
1515

1616
template <typename T> inline T get(const char *key, T defaultval = T()) {
1717
auto it = values.find(key);

src/lsl_inlet_c.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ LIBLSL_C_API void lsl_destroy_inlet(lsl_inlet in) {
2222
}
2323

2424
LIBLSL_C_API lsl_streaminfo lsl_get_fullinfo(lsl_inlet in, double timeout, int32_t *ec) {
25-
return create_object_noexcept<stream_info_impl>(in->info(timeout));
25+
try {
26+
return new stream_info_impl(in->info(timeout));
27+
}
28+
LSL_STORE_EXCEPTION_IN(ec)
29+
return nullptr;
2630
}
2731

2832
LIBLSL_C_API void lsl_open_stream(lsl_inlet in, double timeout, int32_t *ec) {

src/lsl_outlet_c.cpp

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

5-
#pragma warning(disable : 4800)
6-
75
extern "C" {
86
#include "api_types.hpp"
97
// include api_types before public API header
@@ -14,8 +12,10 @@ using namespace lsl;
1412
// boilerplate wrapper code
1513
LIBLSL_C_API lsl_outlet lsl_create_outlet(
1614
lsl_streaminfo info, int32_t chunk_size, int32_t max_buffered) {
17-
return create_object_noexcept<stream_outlet_impl>(*info, chunk_size,
18-
info->nominal_srate() ? (int)(info->nominal_srate() * max_buffered) : max_buffered * 100);
15+
double buftime = info->nominal_srate();
16+
if (buftime <= 0) buftime = 100;
17+
return create_object_noexcept<stream_outlet_impl>(
18+
*info, chunk_size, static_cast<int>(buftime * max_buffered));
1919
}
2020

2121
LIBLSL_C_API void lsl_destroy_outlet(lsl_outlet out) {

src/lsl_streaminfo_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ LIBLSL_C_API int32_t lsl_stream_info_matches_query(lsl_streaminfo info, const ch
7878

7979
LIBLSL_C_API lsl_streaminfo lsl_streaminfo_from_xml(const char *xml) {
8080
try {
81-
stream_info_impl *impl = new stream_info_impl();
81+
auto *impl = new stream_info_impl();
8282
impl->from_fullinfo_message(xml);
8383
return impl;
8484
} catch (std::exception &e) {

src/netinterfaces.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ std::vector<lsl::netif> lsl::get_local_interfaces() {
8484
LOG_F(ERROR, "Couldn't enumerate network interfaces: %d", errno);
8585
return res;
8686
}
87-
for (auto addr = ifs; addr != nullptr; addr = addr->ifa_next) {
87+
for (auto *addr = ifs; addr != nullptr; addr = addr->ifa_next) {
8888
// No address? Skip.
8989
if (addr->ifa_addr == nullptr) continue;
9090
LOG_F(INFO, "netif '%s' (status: %d, multicast: %d, broadcast: %d)", addr->ifa_name,

0 commit comments

Comments
 (0)