@cryptotaxi247 / netdata-1 / commits / b4dfc78ec

Coverity fixes (#18896)

* Ignore return code, we are exiting (suppress coverity) * cloud base url is now url * Suppress coverity warning * Fix coverity time_t

Stelios Fragkakis committed Oct 30, 2024 at 15:52 UTC b4dfc78ec2bea6b8ac7033bdadfdbdd7c120c56e
7 files changed +16 -10
src/aclk/aclk.c
+3 -4
@@ -171,7 +171,6 @@ biofailed:
171 */
172 static int wait_till_agent_claimed(void)
173 {
174 - //TODO prevent malloc and freez
174 ND_UUID uuid = claim_id_get_uuid();
175 while (likely(UUIDiszero(uuid))) {
176 sleep_usec(USEC_PER_SEC * 1);
@@ -202,7 +201,7 @@ static int wait_till_agent_claim_ready()
201 // We trap the impossible NULL here to keep the linter happy without using a fatal() in the code.
202 const char *cloud_base_url = cloud_config_url_get();
203 if (cloud_base_url == NULL) {
205 - netdata_log_error("Do not move the cloud base url out of post_conf_load!!");
204 + netdata_log_error("Do not move the \"url\" out of post_conf_load!!");
205 return 1;
206 }
207
@@ -210,7 +209,7 @@ static int wait_till_agent_claim_ready()
209 // TODO make it without malloc/free
210 memset(&url, 0, sizeof(url_t));
211 if (url_parse(cloud_base_url, &url)) {
213 - netdata_log_error("Agent is claimed but the URL in configuration key \"cloud base url\" is invalid, please fix");
212 + netdata_log_error("Agent is claimed but the URL in configuration key \"url\" is invalid, please fix");
213 url_t_destroy(&url);
214 sleep(5);
215 continue;
@@ -560,7 +559,7 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
559 while (service_running(SERVICE_ACLK)) {
560 aclk_cloud_base_url = cloud_config_url_get();
561 if (aclk_cloud_base_url == NULL) {
563 - error_report("Do not move the cloud base url out of post_conf_load!!");
562 + error_report("Do not move the \"url\" out of post_conf_load!!");
563 aclk_status = ACLK_STATUS_NO_CLOUD_URL;
564 return -1;
565 }
src/daemon/main.c
+1 -1
@@ -1201,7 +1201,7 @@ static void get_netdata_configured_variables()
1201 // get the hostname
1202
1203 netdata_configured_host_prefix = config_get(CONFIG_SECTION_GLOBAL, "host access prefix", "");
1204 - verify_netdata_host_prefix(true);
1204 + (void) verify_netdata_host_prefix(true);
1205
1206 char buf[HOSTNAME_MAX + 1];
1207 if (get_hostname(buf, HOSTNAME_MAX))
src/database/engine/rrdengine.c
+1 -1
@@ -2075,6 +2075,6 @@ void dbengine_event_loop(void* arg) {
2075 }
2076
2077 nd_log(NDLS_DAEMON, NDLP_DEBUG, "Shutting down dbengine thread");
2078 - uv_loop_close(&main->loop);
2078 + (void) uv_loop_close(&main->loop);
2079 worker_unregister();
2080 }
src/database/rrd.h
+5
@@ -1637,6 +1637,11 @@ static inline double rrddim_get_last_stored_value(RRDDIM *rd_dim, double *max_va
1637 return value;
1638 }
1639
1640 +static inline uint32_t get_uint32_id()
1641 +{
1642 + return now_realtime_sec() & UINT32_MAX;
1643 +}
1644 +
1645 //
1646 // RRD DB engine declarations
1647
src/database/sqlite/sqlite_health.c
+4 -2
@@ -727,8 +727,10 @@ void sql_health_alarm_log_load(RRDHOST *host)
727 dictionary_destroy(all_rrdcalcs);
728 all_rrdcalcs = NULL;
729
730 - if(!host->health_max_unique_id) host->health_max_unique_id = (uint32_t)now_realtime_sec();
731 - if(!host->health_max_alarm_id) host->health_max_alarm_id = (uint32_t)now_realtime_sec();
730 + if (!host->health_max_unique_id)
731 + host->health_max_unique_id = get_uint32_id();
732 + if (!host->health_max_alarm_id)
733 + host->health_max_alarm_id = get_uint32_id();
734
735 host->health_log.next_log_id = host->health_max_unique_id + 1;
736 if (unlikely(!host->health_log.next_alarm_id || host->health_log.next_alarm_id <= host->health_max_alarm_id))
src/health/health_event_loop.c
+1 -1
@@ -138,7 +138,7 @@ static void health_initialize_rrdhost(RRDHOST *host) {
138 host->health.health_default_recipient = string_dup(health_globals.config.default_recipient);
139 host->health.use_summary_for_notifications = health_globals.config.use_summary_for_notifications;
140
141 - host->health_log.next_log_id = (uint32_t)now_realtime_sec();
141 + host->health_log.next_log_id = get_uint32_id();
142 host->health_log.next_alarm_id = 0;
143
144 rw_spinlock_init(&host->health_log.spinlock);
src/health/rrdcalc.c
+1 -1
@@ -80,7 +80,7 @@ uint32_t rrdcalc_get_unique_id(RRDHOST *host, STRING *chart, STRING *name, uint3
80 alarm_id = sql_get_alarm_id(host, chart, name, next_event_id);
81 if (!alarm_id) {
82 if (unlikely(!host->health_log.next_alarm_id))
83 - host->health_log.next_alarm_id = (uint32_t)now_realtime_sec();
83 + host->health_log.next_alarm_id = get_uint32_id();
84 alarm_id = host->health_log.next_alarm_id++;
85 }
86 }