X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fhddtemp.c;h=1b7ed329a9a088360730abc44fd59eee356da2d5;hb=5afde1077e3c8fc119b79caa2572cbf84dbfe5ca;hp=3de18fd91354d166a58beff919d4b38e65e0fe33;hpb=12f249b209d7fa31e3a9d53315e47a2342463e0f;p=collectd.git diff --git a/src/hddtemp.c b/src/hddtemp.c index 3de18fd9..1b7ed329 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -88,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; @@ -109,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 = PF_UNSPEC, + .ai_protocol = IPPROTO_TCP, + .ai_socktype = SOCK_STREAM + }; + if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0) { char errbuf[1024];