Browse Source

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 4 months ago
parent
commit
b4dfc78ec2

+ 3 - 4
src/aclk/aclk.c

@@ -171,7 +171,6 @@ biofailed:
  */
 static int wait_till_agent_claimed(void)
 {
-    //TODO prevent malloc and freez
     ND_UUID uuid = claim_id_get_uuid();
     while (likely(UUIDiszero(uuid))) {
         sleep_usec(USEC_PER_SEC * 1);
@@ -202,7 +201,7 @@ static int wait_till_agent_claim_ready()
         // We trap the impossible NULL here to keep the linter happy without using a fatal() in the code.
         const char *cloud_base_url = cloud_config_url_get();
         if (cloud_base_url == NULL) {
-            netdata_log_error("Do not move the cloud base url out of post_conf_load!!");
+            netdata_log_error("Do not move the \"url\" out of post_conf_load!!");
             return 1;
         }
 
@@ -210,7 +209,7 @@ static int wait_till_agent_claim_ready()
         // TODO make it without malloc/free
         memset(&url, 0, sizeof(url_t));
         if (url_parse(cloud_base_url, &url)) {
-            netdata_log_error("Agent is claimed but the URL in configuration key \"cloud base url\" is invalid, please fix");
+            netdata_log_error("Agent is claimed but the URL in configuration key \"url\" is invalid, please fix");
             url_t_destroy(&url);
             sleep(5);
             continue;
@@ -560,7 +559,7 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
     while (service_running(SERVICE_ACLK)) {
         aclk_cloud_base_url = cloud_config_url_get();
         if (aclk_cloud_base_url == NULL) {
-            error_report("Do not move the cloud base url out of post_conf_load!!");
+            error_report("Do not move the \"url\" out of post_conf_load!!");
             aclk_status = ACLK_STATUS_NO_CLOUD_URL;
             return -1;
         }

+ 1 - 1
src/daemon/main.c

@@ -1201,7 +1201,7 @@ static void get_netdata_configured_variables()
     // get the hostname
 
     netdata_configured_host_prefix = config_get(CONFIG_SECTION_GLOBAL, "host access prefix", "");
-    verify_netdata_host_prefix(true);
+    (void) verify_netdata_host_prefix(true);
 
     char buf[HOSTNAME_MAX + 1];
     if (get_hostname(buf, HOSTNAME_MAX))

+ 1 - 1
src/database/engine/rrdengine.c

@@ -2075,6 +2075,6 @@ void dbengine_event_loop(void* arg) {
     }
 
     nd_log(NDLS_DAEMON, NDLP_DEBUG, "Shutting down dbengine thread");
-    uv_loop_close(&main->loop);
+    (void) uv_loop_close(&main->loop);
     worker_unregister();
 }

+ 5 - 0
src/database/rrd.h

@@ -1637,6 +1637,11 @@ static inline double rrddim_get_last_stored_value(RRDDIM *rd_dim, double *max_va
     return value;
 }
 
+static inline uint32_t get_uint32_id()
+{
+    return now_realtime_sec() & UINT32_MAX;
+}
+
 //
 // RRD DB engine declarations
 

+ 4 - 2
src/database/sqlite/sqlite_health.c

@@ -727,8 +727,10 @@ void sql_health_alarm_log_load(RRDHOST *host)
     dictionary_destroy(all_rrdcalcs);
     all_rrdcalcs = NULL;
 
-    if(!host->health_max_unique_id) host->health_max_unique_id = (uint32_t)now_realtime_sec();
-    if(!host->health_max_alarm_id)  host->health_max_alarm_id  = (uint32_t)now_realtime_sec();
+    if (!host->health_max_unique_id)
+        host->health_max_unique_id = get_uint32_id();
+    if (!host->health_max_alarm_id)
+        host->health_max_alarm_id = get_uint32_id();
 
     host->health_log.next_log_id = host->health_max_unique_id + 1;
     if (unlikely(!host->health_log.next_alarm_id || host->health_log.next_alarm_id <= host->health_max_alarm_id))

+ 1 - 1
src/health/health_event_loop.c

@@ -138,7 +138,7 @@ static void health_initialize_rrdhost(RRDHOST *host) {
     host->health.health_default_recipient = string_dup(health_globals.config.default_recipient);
     host->health.use_summary_for_notifications = health_globals.config.use_summary_for_notifications;
 
-    host->health_log.next_log_id = (uint32_t)now_realtime_sec();
+    host->health_log.next_log_id = get_uint32_id();
     host->health_log.next_alarm_id = 0;
 
     rw_spinlock_init(&host->health_log.spinlock);

+ 1 - 1
src/health/rrdcalc.c

@@ -80,7 +80,7 @@ uint32_t rrdcalc_get_unique_id(RRDHOST *host, STRING *chart, STRING *name, uint3
         alarm_id = sql_get_alarm_id(host, chart, name, next_event_id);
         if (!alarm_id) {
             if (unlikely(!host->health_log.next_alarm_id))
-                host->health_log.next_alarm_id = (uint32_t)now_realtime_sec();
+                host->health_log.next_alarm_id = get_uint32_id();
             alarm_id = host->health_log.next_alarm_id++;
         }
     }