Skip to content

Commit fe25d7c

Browse files
committed
fix some warnings
1 parent 9269e4a commit fe25d7c

7 files changed

Lines changed: 23 additions & 32 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ repos:
4444
args: ['-fallback-style=none', '-i']
4545

4646
# C++ static analysis (installs clang-tidy automatically via pip)
47-
- repo: https://github.com/mxmlnrdr/clang_tidy_hook
48-
rev: v0.3.1
49-
hooks:
50-
- id: clang-tidy
51-
args:
52-
- --config-file=.clang-tidy
53-
- -p=build
47+
# - repo: https://github.com/mxmlnrdr/clang_tidy_hook
48+
# rev: v0.3.1
49+
# hooks:
50+
# - id: clang-tidy
51+
# args:
52+
# - --config-file=.clang-tidy
53+
# - -p=build
5454

5555
# Spell check
5656
- repo: https://github.com/codespell-project/codespell

‎src/action_node.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ NodeStatus SyncActionNode::executeTick()
6868
struct CoroActionNode::Pimpl
6969
{
7070
mco_coro* coro = nullptr;
71-
mco_desc desc;
71+
mco_desc desc = {};
7272
};
7373

7474
void CoroEntry(mco_coro* co)

‎src/decorator_node.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ DecoratorNode::DecoratorNode(const std::string& name, const NodeConfig& config)
2121

2222
void DecoratorNode::setChild(TreeNode* child)
2323
{
24-
if(child_node_)
24+
if(child_node_ != nullptr)
2525
{
2626
throw BehaviorTreeException("Decorator [", name(), "] has already a child assigned");
2727
}
@@ -52,7 +52,7 @@ void DecoratorNode::haltChild()
5252

5353
void DecoratorNode::resetChild()
5454
{
55-
if(!child_node_)
55+
if(child_node_ == nullptr)
5656
{
5757
return;
5858
}

‎src/decorators/delay_node.cpp‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
/* Contributed by Indraneel on 26/04/2020
2-
*/
2+
*/
33

44
#include "behaviortree_cpp/decorators/delay_node.h"
55

66
namespace BT
77
{
88
DelayNode::DelayNode(const std::string& name, unsigned milliseconds)
9-
: DecoratorNode(name, {})
10-
, delay_started_(false)
11-
, delay_aborted_(false)
12-
, msec_(milliseconds)
13-
, read_parameter_from_ports_(false)
9+
: DecoratorNode(name, {}), timer_id_(0), msec_(milliseconds)
1410
{
1511
setRegistrationID("Delay");
1612
}
1713

1814
DelayNode::DelayNode(const std::string& name, const NodeConfig& config)
19-
: DecoratorNode(name, config)
20-
, delay_started_(false)
21-
, delay_aborted_(false)
22-
, msec_(0)
23-
, read_parameter_from_ports_(true)
15+
: DecoratorNode(name, config), timer_id_(0), msec_(0)
2416
{}
2517

2618
void DelayNode::halt()

‎src/loggers/bt_cout_logger.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ namespace BT
55

66
StdCoutLogger::StdCoutLogger(const BT::Tree& tree) : StatusChangeLogger(tree.rootNode())
77
{}
8-
StdCoutLogger::~StdCoutLogger()
9-
{}
8+
StdCoutLogger::~StdCoutLogger() = default;
109

1110
void StdCoutLogger::callback(Duration timestamp, const TreeNode& node,
1211
NodeStatus prev_status, NodeStatus status)
@@ -17,6 +16,7 @@ void StdCoutLogger::callback(Duration timestamp, const TreeNode& node,
1716
constexpr const size_t ws_count = 25;
1817

1918
double since_epoch = duration<double>(timestamp).count();
19+
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)
2020
printf("[%.3f]: %s%s %s -> %s", since_epoch, node.name().c_str(),
2121
&whitespaces[std::min(ws_count, node.name().size())],
2222
toStr(prev_status, true).c_str(), toStr(status, true).c_str());

‎src/shared_library.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ BT::SharedLibrary::SharedLibrary(const std::string& path, int flags)
99
void* BT::SharedLibrary::getSymbol(const std::string& name)
1010
{
1111
void* result = findSymbol(name);
12-
if(result)
12+
if(result != nullptr)
1313
return result;
1414
else
1515
throw RuntimeError("[SharedLibrary::getSymbol]: can't find symbol ", name);

‎src/shared_library_UNIX.cpp‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@
77
namespace BT
88
{
99
SharedLibrary::SharedLibrary()
10-
{
11-
_handle = nullptr;
12-
}
10+
{}
1311

1412
void SharedLibrary::load(const std::string& path, int)
1513
{
1614
std::unique_lock<std::mutex> lock(_mutex);
1715

18-
if(_handle)
16+
if(_handle != nullptr)
1917
{
2018
throw RuntimeError("Library already loaded: " + path);
2119
}
2220

2321
_handle = dlopen(path.c_str(), RTLD_NOW | RTLD_GLOBAL);
24-
if(!_handle)
22+
if(_handle == nullptr)
2523
{
2624
const char* err = dlerror();
27-
throw RuntimeError("Could not load library: " + (err ? std::string(err) : path));
25+
throw RuntimeError("Could not load library: " +
26+
(err != nullptr ? std::string(err) : path));
2827
}
2928
_path = path;
3029
}
@@ -33,7 +32,7 @@ void SharedLibrary::unload()
3332
{
3433
std::unique_lock<std::mutex> lock(_mutex);
3534

36-
if(_handle)
35+
if(_handle != nullptr)
3736
{
3837
dlclose(_handle);
3938
_handle = nullptr;
@@ -50,7 +49,7 @@ void* SharedLibrary::findSymbol(const std::string& name)
5049
std::unique_lock<std::mutex> lock(_mutex);
5150

5251
void* result = nullptr;
53-
if(_handle)
52+
if(_handle != nullptr)
5453
{
5554
result = dlsym(_handle, name.c_str());
5655
}

0 commit comments

Comments
 (0)