X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmbmon.c;h=2e26aa1fc0083a004e7fe47e65461fd1b5d5cf0a;hb=f3610533206238bf4fcb72c76e9a07517d8bc64b;hp=d23062db2d54734551789c76cac837c9915c43f2;hpb=56536633afb68ded68ac7bd012060cb9337fbcc5;p=collectd.git diff --git a/src/mbmon.c b/src/mbmon.c index d23062db..2e26aa1f 100644 --- a/src/mbmon.c +++ b/src/mbmon.c @@ -24,12 +24,12 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "configfile.h" #include -#include #include #include @@ -85,19 +85,9 @@ static int mbmon_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 = mbmon_host; if (host == NULL) host = MBMON_DEF_HOST; @@ -106,6 +96,13 @@ static int mbmon_query_daemon (char *buffer, int buffer_size) if (port == NULL) port = MBMON_DEF_PORT; + struct addrinfo ai_hints = { + .ai_family = AF_UNSPEC, + .ai_flags = AI_ADDRCONFIG, + .ai_protocol = IPPROTO_TCP, + .ai_socktype = SOCK_STREAM + }; + if ((ai_return = getaddrinfo (host, port, &ai_hints, &ai_list)) != 0) { char errbuf[1024]; @@ -261,8 +258,8 @@ static int mbmon_read (void) double value; char *nextc; - char *type; - char *inst; + const char *type; + const char *inst; *t++ = '\0'; trim_spaces (s);