Implement clang-tidy fixes
clang-tidy allows the CI robot to check many things via static analysis.
All changes here were made by the clang-tidy robot, and include a number
of modernization fixes. updating the tidy file will be done at a later
date.
Signed-off-by: Ed Tanous <etanous@nvidia.com>
Change-Id: I98cc4d600a3c589675507958f6d2350b2141216b
diff --git a/pid/ec/logging.hpp b/pid/ec/logging.hpp
index 3cef589..049d2ed 100644
--- a/pid/ec/logging.hpp
+++ b/pid/ec/logging.hpp
@@ -53,24 +53,24 @@
std::ofstream fileCoeffs;
std::chrono::milliseconds lastLog;
PidCoreContext lastContext;
- bool moved;
+ bool moved = false;
PidCoreLog() :
nameOriginal(), nameClean(), fileContext(), fileCoeffs(), lastLog(),
- lastContext(), moved(false)
+ lastContext()
{}
PidCoreLog(const PidCoreLog& copy) = delete;
PidCoreLog& operator=(const PidCoreLog& copy) = delete;
- PidCoreLog(PidCoreLog&& move)
+ PidCoreLog(PidCoreLog&& move) noexcept
{
// Reuse assignment operator below
*this = std::move(move);
}
- PidCoreLog& operator=(PidCoreLog&& move)
+ PidCoreLog& operator=(PidCoreLog&& move) noexcept
{
if (this != &move)
{
@@ -79,8 +79,8 @@
nameClean = std::move(move.nameClean);
fileContext = std::move(move.fileContext);
fileCoeffs = std::move(move.fileCoeffs);
- lastLog = std::move(move.lastLog);
- lastContext = std::move(move.lastContext);
+ lastLog = move.lastLog;
+ lastContext = move.lastContext;
// Mark the moved object, so destructor knows it was moved
move.moved = true;
diff --git a/pid/ec/pid.cpp b/pid/ec/pid.cpp
index 762513a..ad547d9 100644
--- a/pid/ec/pid.cpp
+++ b/pid/ec/pid.cpp
@@ -34,7 +34,7 @@
{
return min;
}
- else if (x > max)
+ if (x > max)
{
return max;
}
diff --git a/pid/ec/pid.hpp b/pid/ec/pid.hpp
index ac77f05..02138cd 100644
--- a/pid/ec/pid.hpp
+++ b/pid/ec/pid.hpp
@@ -8,16 +8,16 @@
namespace ec
{
-typedef struct limits_t
+struct limits_t
{
double min = 0.0;
double max = 0.0;
-} limits_t;
+};
/* Note: If you update these structs you need to update the copy code in
* pid/util.cpp and the initialization code in pid/buildjson.hpp files.
*/
-typedef struct pid_info_t
+struct pid_info_t
{
bool initialized = false; // has pid been initialized
bool checkHysterWithSetpt = false; // compare current input and setpoint to
@@ -40,7 +40,7 @@
double slewPos = 0.0;
double positiveHysteresis = 0.0;
double negativeHysteresis = 0.0;
-} pid_info_t;
+};
double pid(pid_info_t* pidinfoptr, double input, double setpoint,
const std::string* nameptr = nullptr);