Skip to content

Commit 6d0bb72

Browse files
committed
fix warnings
1 parent 5387e67 commit 6d0bb72

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

.clang-tidy

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ Checks: [
1313
"-bugprone-branch-clone",
1414
"-bugprone-easily-swappable-parameters",
1515
"-bugprone-narrowing-conversions",
16-
"-cert-err33-c",
17-
"-cert-err58-cpp",
18-
"-cert-oop54-cpp",
1916
"-clang-analyzer-optin.cplusplus.VirtualCall",
2017
"-cppcoreguidelines-avoid-c-arrays",
2118
"-cppcoreguidelines-avoid-const-or-ref-data-members",
2219
"-cppcoreguidelines-avoid-magic-numbers",
2320
"-cppcoreguidelines-avoid-non-const-global-variables",
2421
"-cppcoreguidelines-init-variables",
25-
"-cppcoreguidelines-macro-usage",
2622
"-cppcoreguidelines-narrowing-conversions",
27-
"-cppcoreguidelines-noexcept-move-operations",
2823
"-cppcoreguidelines-owning-memory",
2924
"-cppcoreguidelines-prefer-member-initializer",
3025
"-cppcoreguidelines-pro-bounds-array-to-pointer-decay",
@@ -34,7 +29,6 @@ Checks: [
3429
"-cppcoreguidelines-pro-type-member-init",
3530
"-cppcoreguidelines-pro-type-union-access",
3631
"-cppcoreguidelines-pro-type-vararg",
37-
"-cppcoreguidelines-special-member-functions",
3832
"-cppcoreguidelines-use-default-member-init",
3933
"-misc-no-recursion",
4034
"-modernize-avoid-c-arrays",

include/behaviortree_cpp/utils/safe_any.hpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class Any
118118

119119
Any& operator=(const Any& other);
120120

121+
Any& operator=(Any&& other) noexcept;
122+
121123
[[nodiscard]] bool isNumber() const;
122124

123125
[[nodiscard]] bool isIntegral() const;
@@ -306,7 +308,17 @@ inline bool isCastingSafe(const std::type_index& type, const T& val)
306308

307309
inline Any& Any::operator=(const Any& other)
308310
{
309-
this->_any = other._any;
311+
if(this != &other)
312+
{
313+
this->_any = other._any;
314+
this->_original_type = other._original_type;
315+
}
316+
return *this;
317+
}
318+
319+
inline Any& Any::operator=(Any&& other) noexcept
320+
{
321+
this->_any = std::move(other._any);
310322
this->_original_type = other._original_type;
311323
return *this;
312324
}

include/behaviortree_cpp/utils/simple_string.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ class SimpleString
3131

3232
SimpleString& operator=(const SimpleString& other)
3333
{
34-
this->~SimpleString();
35-
createImpl(other.data(), other.size());
34+
if(this != &other)
35+
{
36+
this->~SimpleString();
37+
createImpl(other.data(), other.size());
38+
}
3639
return *this;
3740
}
3841

src/blackboard.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,11 +308,14 @@ void ImportBlackboardFromJSON(const nlohmann::json& json, Blackboard& blackboard
308308

309309
Blackboard::Entry& Blackboard::Entry::operator=(const Entry& other)
310310
{
311-
value = other.value;
312-
info = other.info;
313-
string_converter = other.string_converter;
314-
sequence_id = other.sequence_id;
315-
stamp = other.stamp;
311+
if(this != &other)
312+
{
313+
value = other.value;
314+
info = other.info;
315+
string_converter = other.string_converter;
316+
sequence_id = other.sequence_id;
317+
stamp = other.stamp;
318+
}
316319
return *this;
317320
}
318321

src/xml_parsing.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ void XMLParser::PImpl::loadDocImpl(XMLDocument* doc, bool add_includes)
243243
if(doc->Error())
244244
{
245245
char buffer[512];
246-
snprintf(buffer, sizeof buffer, "Error parsing the XML: %s", doc->ErrorStr());
246+
std::ignore =
247+
snprintf(buffer, sizeof buffer, "Error parsing the XML: %s", doc->ErrorStr());
247248
throw RuntimeError(buffer);
248249
}
249250

@@ -368,14 +369,16 @@ void VerifyXML(const std::string& xml_text,
368369
if(xml_error != tinyxml2::XML_SUCCESS)
369370
{
370371
char buffer[512];
371-
snprintf(buffer, sizeof buffer, "Error parsing the XML: %s", doc.ErrorName());
372+
std::ignore =
373+
snprintf(buffer, sizeof buffer, "Error parsing the XML: %s", doc.ErrorName());
372374
throw RuntimeError(buffer);
373375
}
374376

375377
//-------- Helper functions (lambdas) -----------------
376378
auto ThrowError = [&](int line_num, const std::string& text) {
377379
char buffer[512];
378-
snprintf(buffer, sizeof buffer, "Error at line %d: -> %s", line_num, text.c_str());
380+
std::ignore = snprintf(buffer, sizeof buffer, "Error at line %d: -> %s", line_num,
381+
text.c_str());
379382
throw RuntimeError(buffer);
380383
};
381384

0 commit comments

Comments
 (0)