Fix coverity issues (#18892)
* Get lock before check Ignore return code * In case timeout is not given assume 1000ms
Stelios Fragkakis committed
Oct 30, 2024 at 00:42 UTC
93ff15f18257f81a096cb46c43fdcc9b04f81729
4 files changed
+8
-8
src/database/sqlite/sqlite_metadata.c
+1
-1
@@ -2367,7 +2367,7 @@ done:
2367
2368
void cleanup_agent_event_log(void)
2369
{
2370
- db_execute(db_meta, "DELETE FROM agent_event_log WHERE date_created < UNIXEPOCH() - 30 * 86400");
2370
+ (void) db_execute(db_meta, "DELETE FROM agent_event_log WHERE date_created < UNIXEPOCH() - 30 * 86400");
2371
}
2372
2373
#define SQL_GET_AGENT_EVENT_TYPE_MEDIAN \
src/exporting/prometheus/prometheus.c
+2
-3
@@ -88,9 +88,8 @@ static netdata_mutex_t prometheus_server_root_mutex = NETDATA_MUTEX_INITIALIZER;
88
*/
89
void prometheus_clean_server_root()
90
{
91
+ netdata_mutex_lock(&prometheus_server_root_mutex);
92
if (prometheus_server_root) {
92
- netdata_mutex_lock(&prometheus_server_root_mutex);
93
-
93
struct prometheus_server *ps;
94
for (ps = prometheus_server_root; ps; ) {
95
struct prometheus_server *current = ps;
@@ -101,8 +100,8 @@ void prometheus_clean_server_root()
100
freez(current);
101
}
102
prometheus_server_root = NULL;
104
- netdata_mutex_unlock(&prometheus_server_root_mutex);
103
}
104
+ netdata_mutex_unlock(&prometheus_server_root_mutex);
105
}
106
107
/**
src/libnetdata/dictionary/dictionary.c
+4
-3
@@ -318,10 +318,11 @@ static void dictionary_queue_for_destruction(DICTIONARY *dict) {
318
}
319
320
void cleanup_destroyed_dictionaries(void) {
321
- if(!dictionaries_waiting_to_be_destroyed)
322
- return;
323
-
321
netdata_mutex_lock(&dictionaries_waiting_to_be_destroyed_mutex);
322
+ if (!dictionaries_waiting_to_be_destroyed) {
323
+ netdata_mutex_unlock(&dictionaries_waiting_to_be_destroyed_mutex);
324
+ return;
325
+ }
326
327
DICTIONARY *dict, *last = NULL, *next = NULL;
328
for(dict = dictionaries_waiting_to_be_destroyed; dict ; dict = next) {
src/libnetdata/socket/socket.c
+1
-1
@@ -953,7 +953,7 @@ int connect_to_this_ip46(
953
hostBfr, servBfr);
954
955
// Convert 'struct timeval' to milliseconds for poll():
956
- int timeout_ms = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
956
+ int timeout_ms = timeout ? (timeout->tv_sec * 1000 + timeout->tv_usec / 1000) : 1000;
957
958
switch(wait_on_socket_or_cancel_with_timeout(
959
NULL,