cleanup: reduce scope of variables
Various things caught by cppcheck that are non-critical.
Change-Id: I495453c84bc15788b85036a163ee36b0ac601fa1
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/pid/ec/pid.cpp b/pid/ec/pid.cpp
index ef0df14..c2236c2 100644
--- a/pid/ec/pid.cpp
+++ b/pid/ec/pid.cpp
@@ -44,7 +44,7 @@
{
float error;
- float p_term = 0.0f;
+ float p_term;
float i_term = 0.0f;
float ff_term = 0.0f;
diff --git a/pid/fancontroller.cpp b/pid/fancontroller.cpp
index 4a94458..b1c923f 100644
--- a/pid/fancontroller.cpp
+++ b/pid/fancontroller.cpp
@@ -41,7 +41,6 @@
float FanController::input_proc(void)
{
- float sum = 0;
double value = 0;
std::vector<int64_t> values;
std::vector<int64_t>::iterator result;
@@ -62,7 +61,6 @@
if (value > 0)
{
values.push_back(value);
- sum += value;
}
}
}
@@ -76,14 +74,9 @@
value = 0;
if (values.size() > 0)
{
- /* When this is a configuration option in a later update, this code
- * will be updated.
- */
- // value = sum / _inputs.size();
-
/* the fan PID algorithm was unstable with average, and seemed to work
* better with minimum. I had considered making this choice a variable
- * in the configuration, and I will.
+ * in the configuration, and it's a nice-to-have..
*/
result = std::min_element(values.begin(), values.end());
value = *result;
diff --git a/pid/zone.cpp b/pid/zone.cpp
index 92a332e..d5e2646 100644
--- a/pid/zone.cpp
+++ b/pid/zone.cpp
@@ -132,13 +132,15 @@
static constexpr auto setpointpath = "/etc/thermal.d/set-point";
try
{
- int value;
std::ifstream ifs;
ifs.open(setpointpath);
if (ifs.good())
{
+ int value;
ifs >> value;
- max = value; // expecting RPM set-point, not pwm%
+
+ /* expecting RPM set-point, not pwm% */
+ max = static_cast<float>(value);
}
}
catch (const std::exception& e)