mirror of
https://github.com/netdata/netdata.git
synced 2025-04-16 18:37:50 +00:00
Fix coverity issues (#14543)
* Fix coverity 383236: Resource leak * Fix coverity 382915 : Logically dead code * Fix coverity 379133 : Division or modulo by float zero * Fix coverity 382783 : Copy into fixed size buffer * Fix coverity 381151 : Missing unlock * Fix coverity 381903 : Dereference after null check
This commit is contained in:
parent
f1f6f4e197
commit
bde40023ed
6 changed files with 10 additions and 8 deletions
aclk
collectors/apps.plugin
database
libnetdata/buffer
web/api/queries
|
@ -272,13 +272,12 @@ int create_node_instance_result(const char *msg, size_t msg_len)
|
|||
.live = 0,
|
||||
.queryable = 1,
|
||||
.session_id = aclk_session_newarch,
|
||||
.node_id = res.node_id
|
||||
.node_id = res.node_id,
|
||||
.capabilities = NULL
|
||||
};
|
||||
|
||||
RRDHOST *host = rrdhost_find_by_guid(res.machine_guid);
|
||||
if (host) {
|
||||
// not all host must have RRDHOST struct created for them
|
||||
// if they never connected during runtime of agent
|
||||
if (likely(host)) {
|
||||
if (host == localhost) {
|
||||
node_state_update.live = 1;
|
||||
node_state_update.hops = 0;
|
||||
|
@ -286,10 +285,9 @@ int create_node_instance_result(const char *msg, size_t msg_len)
|
|||
node_state_update.live = (!rrdhost_flag_check(host, RRDHOST_FLAG_ORPHAN));
|
||||
node_state_update.hops = host->system_info->hops;
|
||||
}
|
||||
node_state_update.capabilities = aclk_get_node_instance_capas(host);
|
||||
}
|
||||
|
||||
node_state_update.capabilities = aclk_get_node_instance_capas(host);
|
||||
|
||||
rrdhost_aclk_state_lock(localhost);
|
||||
node_state_update.claim_id = localhost->aclk_state.claimed_id;
|
||||
query->data.bin_payload.payload = generate_node_instance_connection(&query->data.bin_payload.size, &node_state_update);
|
||||
|
|
|
@ -5165,4 +5165,5 @@ int main(int argc, char **argv) {
|
|||
|
||||
debug_log("done Loop No %zu", global_iterations_counter);
|
||||
}
|
||||
netdata_mutex_unlock(&mutex);
|
||||
}
|
||||
|
|
|
@ -1764,7 +1764,7 @@ PGC *pgc_create(const char *name,
|
|||
cache->config.max_dirty_pages_per_call = max_dirty_pages_per_flush;
|
||||
cache->config.pgc_save_init_cb = pgc_save_init_cb;
|
||||
cache->config.pgc_save_dirty_cb = pgc_save_dirty_cb;
|
||||
cache->config.max_pages_per_inline_eviction = (max_pages_per_inline_eviction < 2) ? 2 : max_pages_per_inline_eviction;
|
||||
cache->config.max_pages_per_inline_eviction = max_pages_per_inline_eviction;
|
||||
cache->config.max_skip_pages_per_inline_eviction = (max_skip_pages_per_inline_eviction < 2) ? 2 : max_skip_pages_per_inline_eviction;
|
||||
cache->config.max_flushes_inline = (max_flushes_inline < 1) ? 1 : max_flushes_inline;
|
||||
cache->config.partitions = partitions < 1 ? (size_t)get_netdata_cpus() : partitions;
|
||||
|
|
|
@ -95,7 +95,7 @@ static STRING *rrdcalc_replace_variables_with_rrdset_labels(const char *line, RR
|
|||
temp = buf;
|
||||
}
|
||||
else if (!strncmp(var, RRDCALC_VAR_LABEL, RRDCALC_VAR_LABEL_LEN)) {
|
||||
char label_val[RRDCALC_VAR_MAX + 1] = { 0 };
|
||||
char label_val[RRDCALC_VAR_MAX + RRDCALC_VAR_LABEL_LEN + 1] = { 0 };
|
||||
strcpy(label_val, var+RRDCALC_VAR_LABEL_LEN);
|
||||
label_val[i - RRDCALC_VAR_LABEL_LEN - 1] = '\0';
|
||||
|
||||
|
|
|
@ -495,6 +495,7 @@ int buffer_unittest(void) {
|
|||
buffer_json_finalize(wb);
|
||||
errors += buffer_expect(wb, "{\n \"hello\":\"world\",\n \"alpha\":\"this: \\\" is a double quote\",\n \"object1\":{\n \"hello\":\"world\"\n }\n}\n");
|
||||
|
||||
buffer_free(wb);
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
|
|
@ -741,6 +741,8 @@ static size_t spread_results_evenly(DICTIONARY *results, WEIGHTS_STATS *stats) {
|
|||
}
|
||||
dfe_done(t);
|
||||
|
||||
if(!dimensions) return 0; // Coverity fix
|
||||
|
||||
// sort the array with the values of all dimensions
|
||||
qsort(slots, dimensions, sizeof(NETDATA_DOUBLE), compare_netdata_doubles);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue