X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fhddtemp.c;h=2b481f51cf3cfebf0a215cebe300c57120c01f61;hb=df5d1022f12e9a4620da763bb510095c8ee0777e;hp=82c158cab17180dc18a4d5e878d1704b60e081ce;hpb=213eb227d7737bfbd899474033f94342c61dcb8c;p=collectd.git diff --git a/src/hddtemp.c b/src/hddtemp.c index 82c158ca..2b481f51 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -30,12 +30,12 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "configfile.h" # include -# include # include # include # include /* for basename */ @@ -89,19 +89,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 +100,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];