X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fchrony.c;h=77ba8cc460564d42ed6b8794080a36234e3c0199;hb=c5ffa797883f238776e6294054f260df3cd0aea6;hp=4a09753ffc3ee2b3ee151b5841ad670dc6b86e5a;hpb=362a519e00d50fc3657d485135075f753ec71bab;p=collectd.git diff --git a/src/chrony.c b/src/chrony.c index 4a09753f..77ba8cc4 100644 --- a/src/chrony.c +++ b/src/chrony.c @@ -26,6 +26,7 @@ */ #include "collectd.h" + #include "common.h" /* auxiliary functions */ #include "plugin.h" /* plugin_register_*, plugin_dispatch_values */ @@ -306,14 +307,15 @@ static int connect_client(const char *p_hostname, const char *p_service, int p_family, int p_socktype) { - struct addrinfo hints = { 0 }; - struct addrinfo *res = NULL, *ressave = NULL; + struct addrinfo *res, *ressave; int n, sockfd; - hints.ai_family = p_family; - hints.ai_socktype = p_socktype; + struct addrinfo ai_hints = { + .ai_family = p_family, + .ai_socktype = p_socktype + }; - n = getaddrinfo(p_hostname, p_service, &hints, &res); + n = getaddrinfo(p_hostname, p_service, &ai_hints, &res); if (n < 0) { @@ -450,8 +452,8 @@ chrony_connect(void) if (chrony_set_timeout()) { - ERROR(PLUGIN_NAME ": Error setting timeout to %lds. Errno = %d", - g_chrony_timeout, errno); + ERROR(PLUGIN_NAME ": Error setting timeout to %llds. Errno = %d", + (long long)g_chrony_timeout, errno); return CHRONY_RC_FAIL; } return CHRONY_RC_OK; @@ -675,18 +677,12 @@ ntohf(tFloat p_float) static void chrony_push_data(const char *p_type, const char *p_type_inst, double p_value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = p_value; /* TODO: Check type??? (counter, gauge, derive, absolute) */ - - vl.values = values; + vl.values = &(value_t) { .gauge = p_value }; vl.values_len = 1; /* XXX: Shall g_chrony_host/g_chrony_port be reflected in the plugin's output? */ - /* hostname_g is set in daemon/collectd.c (from config, via gethostname or by resolving localhost) */ - /* defined as: char hostname_g[DATA_MAX_NAME_LEN]; (never NULL) */ - sstrncpy(vl.host, hostname_g, sizeof(vl.host)); sstrncpy(vl.plugin, PLUGIN_NAME_SHORT, sizeof(vl.plugin)); if (g_chrony_plugin_instance != NULL) { @@ -1051,7 +1047,7 @@ chrony_read(void) { /* collectd read callback: Perform data acquisition */ int rc; - unsigned int now_src, n_sources; + unsigned int n_sources; if (g_chrony_seq_is_initialized == 0) { @@ -1073,7 +1069,7 @@ chrony_read(void) if (rc != CHRONY_RC_OK) return rc; - for (now_src = 0; now_src < n_sources; ++now_src) + for (unsigned int now_src = 0; now_src < n_sources; ++now_src) { int is_reachable; rc = chrony_request_source_data(now_src, &is_reachable);