0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-22 12:32:32 +00:00

Coverity fixes ()

* Ignore return code, we are exiting (suppress coverity)

* cloud base url is now url

* Suppress coverity warning

* Fix coverity time_t
This commit is contained in:
Stelios Fragkakis 2024-10-30 15:52:49 +02:00 committed by GitHub
parent d544c2266e
commit b4dfc78ec2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 16 additions and 10 deletions

View file

@ -171,7 +171,6 @@ biofailed:
*/ */
static int wait_till_agent_claimed(void) static int wait_till_agent_claimed(void)
{ {
//TODO prevent malloc and freez
ND_UUID uuid = claim_id_get_uuid(); ND_UUID uuid = claim_id_get_uuid();
while (likely(UUIDiszero(uuid))) { while (likely(UUIDiszero(uuid))) {
sleep_usec(USEC_PER_SEC * 1); 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. // 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(); const char *cloud_base_url = cloud_config_url_get();
if (cloud_base_url == NULL) { 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; return 1;
} }
@ -210,7 +209,7 @@ static int wait_till_agent_claim_ready()
// TODO make it without malloc/free // TODO make it without malloc/free
memset(&url, 0, sizeof(url_t)); memset(&url, 0, sizeof(url_t));
if (url_parse(cloud_base_url, &url)) { 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); url_t_destroy(&url);
sleep(5); sleep(5);
continue; continue;
@ -560,7 +559,7 @@ static int aclk_attempt_to_connect(mqtt_wss_client client)
while (service_running(SERVICE_ACLK)) { while (service_running(SERVICE_ACLK)) {
aclk_cloud_base_url = cloud_config_url_get(); aclk_cloud_base_url = cloud_config_url_get();
if (aclk_cloud_base_url == NULL) { 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; aclk_status = ACLK_STATUS_NO_CLOUD_URL;
return -1; return -1;
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -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.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.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; host->health_log.next_alarm_id = 0;
rw_spinlock_init(&host->health_log.spinlock); rw_spinlock_init(&host->health_log.spinlock);

View file

@ -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); alarm_id = sql_get_alarm_id(host, chart, name, next_event_id);
if (!alarm_id) { if (!alarm_id) {
if (unlikely(!host->health_log.next_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++; alarm_id = host->health_log.next_alarm_id++;
} }
} }