} eDaemonReplies;
-#if defined(__GNUC__)
-# /* GNU gcc extension to enforce struct packing. */
+#if defined(__GNUC__) || defined (__SUNPRO_C) || defined(lint)
+# /* extension to enforce struct packing. */
# define ATTRIB_PACKED __attribute__((packed))
#else
# error Not defining packed attribute (unknown compiler)
connect_client(const char *p_hostname,
const char *p_service, int p_family, int p_socktype)
{
- struct addrinfo hints, *res = NULL, *ressave = NULL;
+ struct addrinfo *res, *ressave;
int n, sockfd;
- memset(&hints, 0, sizeof(struct addrinfo));
+ struct addrinfo ai_hints = {
+ .ai_family = p_family,
+ .ai_socktype = p_socktype
+ };
- hints.ai_family = p_family;
- hints.ai_socktype = p_socktype;
-
- n = getaddrinfo(p_hostname, p_service, &hints, &res);
+ n = getaddrinfo(p_hostname, p_service, &ai_hints, &res);
if (n < 0)
{
static int
-chrony_set_timeout()
+chrony_set_timeout(void)
{
/* Set the socket's timeout to g_chrony_timeout; a value of 0 signals infinite timeout */
/* Returns 0 on success, !0 on error (check errno) */
static int
-chrony_connect()
+chrony_connect(void)
{
/* Connects to the chrony daemon */
/* Returns 0 on success, !0 on error (check errno) */
static void
-chrony_push_data(char *p_type, char *p_type_inst, double p_value)
+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;
static void
-chrony_push_data_valid(char *p_type, char *p_type_inst, const int p_is_valid,
+chrony_push_data_valid(const char *p_type, const char *p_type_inst, const int p_is_valid,
double p_value)
{
/* Push real value if p_is_valid is true, push NAN if p_is_valid is not true (idea from ntp plugin) */
static int
-chrony_init_seq()
+chrony_init_seq(void)
{
/* Initialize the sequence number generator from /dev/urandom */
/* Fallbacks: /dev/random and time(NULL) */
static int
-chrony_request_daemon_stats()
+chrony_request_daemon_stats(void)
{
/* Perform Tracking request */
int rc;
}
#if COLLECT_DEBUG
{
- char src_addr[IPV6_STR_MAX_SIZE];
- memset(src_addr, 0, sizeof(src_addr));
+ char src_addr[IPV6_STR_MAX_SIZE] = { 0 };
niptoha(&chrony_resp.body.tracking.addr, src_addr, sizeof(src_addr));
DEBUG(PLUGIN_NAME ": Daemon stat: .addr = %s, .ref_id= %u, .stratum = %u, .leap_status = %u, .ref_time = %u:%u:%u, .current_correction = %f, .last_offset = %f, .rms_offset = %f, .freq_ppm = %f, .skew_ppm = %f, .root_delay = %f, .root_dispersion = %f, .last_update_interval = %f", src_addr, ntohs(chrony_resp.body.tracking.f_ref_id),
ntohs(chrony_resp.body.tracking.f_stratum),
tChrony_Request chrony_req;
tChrony_Response chrony_resp;
- char src_addr[IPV6_STR_MAX_SIZE];
- memset(src_addr, 0, sizeof(src_addr));
+ char src_addr[IPV6_STR_MAX_SIZE] = { 0 };
chrony_init_req(&chrony_req);
chrony_req.body.source_data.f_index = htonl(p_src_idx);
tChrony_Response chrony_resp;
double skew_ppm, frequency_error, time_offset;
- char src_addr[IPV6_STR_MAX_SIZE];
- memset(src_addr, 0, sizeof(src_addr));
+ char src_addr[IPV6_STR_MAX_SIZE] = { 0 };
if (*p_is_reachable == 0)
{
static int
-chrony_read()
+chrony_read(void)
{
/* collectd read callback: Perform data acquisition */
int rc;
static int
-chrony_shutdown()
+chrony_shutdown(void)
{
/* Collectd shutdown callback: Free mem */
if (g_chrony_is_connected != 0)