fixed coveriry 379136 379135 379134 379133 (#13123)
Costa Tsaousis committed
Jun 14, 2022 at 15:54 UTC
72184b533c506e9d74a39f7b349aa712c3773ac3
3 files changed
+13
-6
database/metric_correlations.c
+7
-2
@@ -87,6 +87,8 @@ static void register_result_destroy(DICTIONARY *results) {
87
}
88
89
static void register_result(DICTIONARY *results, RRDSET *st, RRDDIM *d, calculated_number value) {
90
+ if(!calculated_number_isnumber(value)) return;
91
+
92
struct register_result t = {
93
.st = st,
94
.chart_id = st->id,
@@ -553,8 +555,7 @@ static int rrdset_metric_correlations_volume(RRDSET *st, DICTIONARY *results,
555
else if(isgreater(highlight_average, 0.0) || isless(highlight_average, 0.0))
556
pcent = highlight_average;
557
556
- if(!isnan(pcent))
557
- register_result(results, st, d, pcent);
558
+ register_result(results, st, d, pcent);
559
}
560
561
return correlated_dimensions;
@@ -616,6 +617,10 @@ static size_t spread_results_evenly(DICTIONARY *results) {
617
slots[unique_values++] = last_value = slots[i];
618
}
619
620
+ // this cannot happen, but coverity thinks otherwise...
621
+ if(!unique_values)
622
+ unique_values = dimensions;
623
+
624
// calculate the weight of each slot, using the number of unique values
625
calculated_number slot_weight = 1.0 / (calculated_number)unique_values;
626
database/rrdlabels.c
+5
-3
@@ -831,8 +831,10 @@ static int rrdlabels_log_label_to_buffer_callback(const char *name, void *value,
831
buffer_sprintf(wb, "Label: %s: \"%s\" (", name, lb->value);
832
833
size_t sources = 0;
834
- if(lb->label_source & RRDLABEL_SRC_AUTO)
835
- buffer_sprintf(wb, "%sauto", sources++?",":"");
834
+ if(lb->label_source & RRDLABEL_SRC_AUTO) {
835
+ buffer_sprintf(wb, "auto");
836
+ sources++;
837
+ }
838
839
if(lb->label_source & RRDLABEL_SRC_CONFIG)
840
buffer_sprintf(wb, "%snetdata.conf", sources++?",":"");
@@ -968,7 +970,7 @@ int rrdlabels_unittest_add_a_pair_callback(const char *name, const char *value,
970
t->errors++;
971
}
972
else if(strcmp(value, t->expected_value) != 0) {
971
- fprintf(stderr, "values don't match, found \"%s\", expected \"%s\"", value?value:"(null)", t->expected_value?t->expected_value:"(null)");
973
+ fprintf(stderr, "values don't match, found \"%s\", expected \"%s\"", value, t->expected_value);
974
t->errors++;
975
}
976
web/api/formatters/rrd2json.c
+1
-1
@@ -255,7 +255,7 @@ int rrdset2anything_api_v1(
255
return HTTP_RESP_BACKEND_FETCH_FAILED;
256
}
257
258
- if (st && st->state && st->state->is_ar_chart)
258
+ if (st->state && st->state->is_ar_chart)
259
ml_process_rrdr(r, query_params->max_anomaly_rates);
260
261
RRDDIM *temp_rd = query_params->context_param_list ? query_params->context_param_list->rd : NULL;