X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fntpd.c;h=dbde6609f64527ff8d58c91a4e9fda5f53e226e6;hb=6bf2e82bf5049af097beae4a8b7f086466520839;hp=6bed82c22c670a62dca5614345771e51d4678d6b;hpb=103f05e098865196fc5f28df51e99b64fd6b5202;p=collectd.git diff --git a/src/ntpd.c b/src/ntpd.c index 6bed82c2..dbde6609 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -24,6 +24,7 @@ * Florian octo Forster **/ +#define _DEFAULT_SOURCE #define _BSD_SOURCE /* For NI_MAXHOST */ #include "collectd.h" @@ -37,9 +38,6 @@ #if HAVE_NETDB_H # include #endif -#if HAVE_SYS_SOCKET_H -# include -#endif #if HAVE_NETINET_IN_H # include #endif @@ -264,7 +262,7 @@ static char *refclock_names[] = "JJY", "TT_IRIG", "GPS_ZYFER", "GPS_RIPENCC", /* 40-43 */ "NEOCLK4X" /* 44 */ }; -static int refclock_names_num = STATIC_ARRAY_SIZE (refclock_names); +static size_t refclock_names_num = STATIC_ARRAY_SIZE (refclock_names); /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * End of the copied stuff.. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -486,7 +484,7 @@ static int ntpd_receive_response (int *res_items, int *res_size, poll_s.fd = sd; poll_s.events = POLLIN | POLLPRI; poll_s.revents = 0; - + DEBUG ("Polling for %ims", timeout); status = poll (&poll_s, 1, timeout); @@ -526,7 +524,7 @@ static int ntpd_receive_response (int *res_items, int *res_size, DEBUG ("recv'd %i bytes", status); - /* + /* * Do some sanity checks first */ if (status < RESP_HEADER_SIZE) @@ -669,7 +667,6 @@ static int ntpd_receive_response (int *res_items, int *res_size, (items_num + pkt_item_num) * res_item_size); if (items == NULL) { - items = *res_data; ERROR ("ntpd plugin: realloc failed."); continue; } @@ -736,7 +733,7 @@ static int ntpd_send_request (int req_code, int req_items, int req_size, char *r req.err_nitems = ERR_NITEMS (0, req_items); req.mbz_itemsize = MBZ_ITEMSIZE (req_size); - + if (req_data != NULL) memcpy ((void *) req.data, (const void *) req_data, req_data_len); @@ -868,7 +865,7 @@ static int ntpd_get_name_refclock (char *buffer, size_t buffer_size, uint32_t refclock_id = ntpd_get_refclock_id (peer_info); uint32_t unit_id = ntohl (peer_info->srcadr) & 0x00FF; - if (refclock_id >= refclock_names_num) + if (((size_t) refclock_id) >= refclock_names_num) return (ntpd_get_name_from_address (buffer, buffer_size, peer_info, /* do_reverse_lookup = */ 0));