@cryptotaxi247 / netdata-1 / commits / c086b6611

Fix coverity issues (#12598)

* Clamp LagN to non-zero values. * Free static threads even on test failure. * Initialize rusage. * s/free/freez/

vkalintiris committed Apr 4, 2022 at 15:01 UTC c086b6611207dd6599d4375eee51e46f2e5894a5
3 files changed +5 -3
daemon/unit_test.c
+3 -1
@@ -420,6 +420,7 @@ int unit_test_static_threads() {
420
421 if (n < 2) {
422 fprintf(stderr, "only %d static threads registered", n);
423 + freez(static_threads);
424 return 1;
425 }
426
@@ -432,11 +433,12 @@ int unit_test_static_threads() {
433 continue;
434
435 fprintf(stderr, "Found duplicate threads with name: %s\n", static_threads[i].name);
436 + freez(static_threads);
437 return 1;
438 }
439 }
440
439 - free(static_threads);
441 + freez(static_threads);
442 return 0;
443 }
444
ml/Config.cc
+1 -1
@@ -66,7 +66,7 @@ void Config::readMLConfig(void) {
66
67 DiffN = clamp(DiffN, 0u, 1u);
68 SmoothN = clamp(SmoothN, 0u, 5u);
69 - LagN = clamp(LagN, 0u, 5u);
69 + LagN = clamp(LagN, 1u, 5u);
70
71 RandomSamplingRatio = clamp(RandomSamplingRatio, 0.2, 1.0);
72 MaxKMeansIters = clamp(MaxKMeansIters, 500u, 1000u);
ml/Host.h
+1 -1
@@ -84,8 +84,8 @@ private:
84 std::pair<Dimension *, Duration<double>> findDimensionToTrain(const TimePoint &NowTP);
85 void trainDimension(Dimension *D, const TimePoint &NowTP);
86
87 + struct rusage ResourceUsage{};
88 std::mutex ResourceUsageMutex;
88 - struct rusage ResourceUsage;
89 };
90
91 class DetectableHost : public TrainableHost {