X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fntpd.c;h=1071d0b34544aa773017f483381f69333f239234;hb=edd9af8a874ebc9f2a7f02846807229a648917db;hp=ce54e029e7124c673cddcc9a6293ded9e71e9bf7;hpb=c346dc6b18ee4215ccab911c1732c5c39a961baf;p=collectd.git diff --git a/src/ntpd.c b/src/ntpd.c index ce54e029..1071d0b3 100644 --- a/src/ntpd.c +++ b/src/ntpd.c @@ -38,9 +38,6 @@ #if HAVE_NETDB_H # include #endif -#if HAVE_SYS_SOCKET_H -# include -#endif #if HAVE_NETINET_IN_H # include #endif @@ -250,7 +247,7 @@ struct info_kernel }; /* List of reference clock names */ -static char *refclock_names[] = +static const char *refclock_names[] = { "UNKNOWN", "LOCAL", "GPS_TRAK", "WWV_PST", /* 0- 3 */ "SPECTRACOM", "TRUETIME", "IRIG_AUDIO", "CHU_AUDIO", /* 4- 7 */ @@ -265,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.. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ @@ -310,7 +307,7 @@ static int ntpd_config (const char *key, const char *value) return (0); } -static void ntpd_submit (char *type, char *type_inst, gauge_t 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; @@ -331,8 +328,8 @@ static void ntpd_submit (char *type, char *type_inst, gauge_t value) /* Each time a peer is polled, ntpd shifts the reach register to the left and * sets the LSB based on whether the peer was reachable. If the LSB is zero, * the values are out of date. */ -static void ntpd_submit_reach (char *type, char *type_inst, uint8_t reach, - gauge_t value) +static void ntpd_submit_reach (const char *type, const char *type_inst, + uint8_t reach, gauge_t value) { if (!(reach & 1)) value = NAN; @@ -342,8 +339,8 @@ static void ntpd_submit_reach (char *type, char *type_inst, uint8_t reach, static int ntpd_connect (void) { - char *host; - char *port; + const char *host; + const char *port; struct addrinfo ai_hints; struct addrinfo *ai_list; @@ -666,7 +663,7 @@ static int ntpd_receive_response (int *res_items, int *res_size, */ DEBUG ("realloc (%p, %zu)", (void *) *res_data, (items_num + pkt_item_num) * res_item_size); - items = realloc ((void *) *res_data, + items = realloc (*res_data, (items_num + pkt_item_num) * res_item_size); if (items == NULL) { @@ -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));