X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fhddtemp.c;h=e7b4d8a10d63aefcc153bb9757ca770ec2e1504d;hb=71bbf854d3e6f8c6d6c3582527263bb01a3a7e04;hp=82c158cab17180dc18a4d5e878d1704b60e081ce;hpb=6258e772d808f4e76ea8e23d9e2750cfc7e6c60d;p=collectd.git diff --git a/src/hddtemp.c b/src/hddtemp.c index 82c158ca..e7b4d8a1 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -35,7 +35,6 @@ #include "configfile.h" # include -# include # include # include # include /* for basename */ @@ -89,19 +88,9 @@ static int hddtemp_query_daemon (char *buffer, int buffer_size) const char *host; const char *port; - struct addrinfo ai_hints; struct addrinfo *ai_list, *ai_ptr; int ai_return; - memset (&ai_hints, '\0', sizeof (ai_hints)); - ai_hints.ai_flags = 0; -#ifdef AI_ADDRCONFIG - ai_hints.ai_flags |= AI_ADDRCONFIG; -#endif - ai_hints.ai_family = PF_UNSPEC; - ai_hints.ai_socktype = SOCK_STREAM; - ai_hints.ai_protocol = IPPROTO_TCP; - host = hddtemp_host; if (host == NULL) host = HDDTEMP_DEF_HOST; @@ -110,6 +99,13 @@ static int hddtemp_query_daemon (char *buffer, int buffer_size) if (strlen (port) == 0) port = HDDTEMP_DEF_PORT; + struct addrinfo ai_hints = { + .ai_flags = AI_ADDRCONFIG, + .ai_family = AF_UNSPEC, + .ai_protocol = IPPROTO_TCP, + .ai_socktype = SOCK_STREAM + }; + if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0) { char errbuf[1024];