Skip to content

Commit 5387e67

Browse files
committed
fix warnings
1 parent 5ef79b5 commit 5387e67

6 files changed

Lines changed: 37 additions & 16 deletions

File tree

‎include/behaviortree_cpp/utils/locked_reference.hpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ class LockedPtr
3434
LockedPtr(LockedPtr const&) = delete;
3535
LockedPtr& operator=(LockedPtr const&) = delete;
3636

37-
LockedPtr(LockedPtr&& other)
37+
LockedPtr(LockedPtr&& other) noexcept
3838
{
3939
std::swap(ref_, other.ref_);
4040
std::swap(mutex_, other.mutex_);
4141
}
4242

43-
LockedPtr& operator=(LockedPtr&& other)
43+
LockedPtr& operator=(LockedPtr&& other) noexcept
4444
{
4545
std::swap(ref_, other.ref_);
4646
std::swap(mutex_, other.mutex_);
47+
return *this;
4748
}
4849

4950
operator bool() const

‎include/behaviortree_cpp/utils/safe_any.hpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ class Any
7070
Any(const Any& other) : _any(other._any), _original_type(other._original_type)
7171
{}
7272

73-
Any(Any&& other) : _any(std::move(other._any)), _original_type(other._original_type)
73+
Any(Any&& other) noexcept
74+
: _any(std::move(other._any)), _original_type(other._original_type)
7475
{}
7576

7677
explicit Any(const double& value) : _any(value), _original_type(typeid(double))

‎include/behaviortree_cpp/utils/simple_string.hpp‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace SafeAny
1818
class SimpleString
1919
{
2020
public:
21+
SimpleString() = default;
22+
2123
SimpleString(const std::string& str) : SimpleString(str.data(), str.size())
2224
{}
2325

@@ -34,12 +36,12 @@ class SimpleString
3436
return *this;
3537
}
3638

37-
SimpleString(SimpleString&& other) : SimpleString(nullptr, 0)
39+
SimpleString(SimpleString&& other) noexcept
3840
{
3941
std::swap(_storage, other._storage);
4042
}
4143

42-
SimpleString& operator=(SimpleString&& other)
44+
SimpleString& operator=(SimpleString&& other) noexcept
4345
{
4446
this->~SimpleString();
4547

@@ -137,8 +139,8 @@ class SimpleString
137139
private:
138140
struct String
139141
{
140-
char* data;
141-
std::size_t size;
142+
char* data = nullptr;
143+
std::size_t size = 0;
142144
};
143145

144146
constexpr static std::size_t CAPACITY = 15; // sizeof(String) - 1);
@@ -153,9 +155,9 @@ class SimpleString
153155
struct SOO
154156
{
155157
char data[CAPACITY];
156-
uint8_t capacity_left;
158+
uint8_t capacity_left = CAPACITY;
157159
} soo;
158-
} _storage;
160+
} _storage = {};
159161

160162
private:
161163
void createImpl(const char* input_data, std::size_t size)

‎src/action_node.cpp‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#define MINICORO_IMPL
1515
#include "minicoro.h"
1616
#include "behaviortree_cpp/action_node.h"
17+
#include <iostream>
1718

1819
using namespace BT;
1920

@@ -85,7 +86,14 @@ CoroActionNode::CoroActionNode(const std::string& name, const NodeConfig& config
8586

8687
CoroActionNode::~CoroActionNode()
8788
{
88-
destroyCoroutine();
89+
try
90+
{
91+
destroyCoroutine();
92+
}
93+
catch(const std::exception& ex)
94+
{
95+
std::cerr << "Exception in ~CoroActionNode(): " << ex.what() << std::endl;
96+
}
8997
}
9098

9199
void CoroActionNode::setStatusRunningAndYield()

‎src/loggers/bt_sqlite_logger.cpp‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <sqlite3.h>
44
#include <stdexcept>
55
#include <sstream>
6+
#include <iostream>
67

78
namespace BT
89
{
@@ -129,11 +130,18 @@ SqliteLogger::SqliteLogger(const Tree& tree, std::filesystem::path const& filepa
129130

130131
SqliteLogger::~SqliteLogger()
131132
{
132-
loop_ = false;
133-
queue_cv_.notify_one();
134-
writer_thread_.join();
135-
flush();
136-
execSQL(db_, "PRAGMA optimize;");
133+
try
134+
{
135+
loop_ = false;
136+
queue_cv_.notify_one();
137+
writer_thread_.join();
138+
flush();
139+
execSQL(db_, "PRAGMA optimize;");
140+
}
141+
catch(const std::exception& ex)
142+
{
143+
std::cerr << "Exception in ~SqliteLogger(): " << ex.what() << std::endl;
144+
}
137145
sqlite3_close(db_);
138146
}
139147

‎src/loggers/groot2_publisher.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ namespace
3434
{
3535
std::array<char, 16> CreateRandomUUID()
3636
{
37-
std::mt19937 gen;
37+
std::random_device rd;
38+
std::mt19937 gen(rd());
3839
std::uniform_int_distribution<uint32_t> dist;
3940
std::array<char, 16> out;
4041
char* bytes = out.data();

0 commit comments

Comments
 (0)