X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fntpd.c;h=ccdecd98302e26362e2c3de949d52f513249c689;hb=e1bfa71aca1f37c2f293dc9adb44065c6e7a9ad9;hp=c3dee22c2d0b656e3ad9e2cb9a8c723acdbb8bbf;hpb=71bbf854d3e6f8c6d6c3582527263bb01a3a7e04;p=collectd.git diff --git a/src/ntpd.c b/src/ntpd.c index c3dee22c..ccdecd98 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -28,9 +28,9 @@ #define _BSD_SOURCE /* For NI_MAXHOST */ #include "collectd.h" + #include "common.h" #include "plugin.h" -#include "configfile.h" #if HAVE_STDINT_H # include @@ -313,12 +313,9 @@ static int ntpd_config (const char *key, const char *value) static void ntpd_submit (const char *type, const char *type_inst, gauge_t value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = value; - - vl.values = values; + vl.values = &(value_t) { .gauge = value }; vl.values_len = 1; sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "ntpd", sizeof (vl.plugin)); @@ -347,7 +344,6 @@ static int ntpd_connect (void) const char *port; struct addrinfo *ai_list; - struct addrinfo *ai_ptr; int status; if (sock_descr >= 0) @@ -381,7 +377,7 @@ static int ntpd_connect (void) return (-1); } - for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) + for (struct addrinfo *ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) { /* create our socket descriptor */ if ((sock_descr = socket (ai_ptr->ai_family, @@ -419,7 +415,6 @@ static int ntpd_receive_response (int *res_items, int *res_size, struct resp_pkt res; int status; int done; - int i; char *items; size_t items_num; @@ -673,7 +668,7 @@ static int ntpd_receive_response (int *res_items, int *res_size, items_num += pkt_item_num; *res_data = items; - for (i = 0; i < pkt_item_num; i++) + for (int i = 0; i < pkt_item_num; i++) { /* dst: There are already `*res_items' items with * res_item_size bytes each in in `*res_data'. Set @@ -902,7 +897,6 @@ static int ntpd_read (void) gauge_t offset_error; int status; - int i; /* On Linux, if the STA_NANO bit is set in ik->status, then ik->offset * is is nanoseconds, otherwise it's microseconds. */ @@ -970,7 +964,7 @@ static int ntpd_read (void) return (-1); } - for (i = 0; i < ps_num; i++) + for (int i = 0; i < ps_num; i++) { struct info_peer_summary *ptr; double offset;