X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fzookeeper.c;h=84174853d24c62bd8ba22aaa17bc28e5f68aaa3d;hb=1326af38b3ef25c41c994cd76c043202636b3d70;hp=a236c8ae66404bd5173c0be7e2537246e34511f4;hpb=69b8a9a1af204685dfdfaf1279a0f2928e0bbb32;p=collectd.git diff --git a/src/zookeeper.c b/src/zookeeper.c index a236c8ae..84174853 100644 --- a/src/zookeeper.c +++ b/src/zookeeper.c @@ -25,6 +25,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -105,17 +106,18 @@ static int zookeeper_connect (void) { int sk = -1; int status; - struct addrinfo ai_hints = { 0 }; - struct addrinfo *ai; struct addrinfo *ai_list; const char *host; const char *port; - ai_hints.ai_family = AF_UNSPEC; - ai_hints.ai_socktype = SOCK_STREAM; - host = (zk_host != NULL) ? zk_host : ZOOKEEPER_DEF_HOST; port = (zk_port != NULL) ? zk_port : ZOOKEEPER_DEF_PORT; + + struct addrinfo ai_hints = { + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_STREAM + }; + status = getaddrinfo (host, port, &ai_hints, &ai_list); if (status != 0) { @@ -127,7 +129,7 @@ static int zookeeper_connect (void) return (-1); } - for (ai = ai_list; ai != NULL; ai = ai->ai_next) + for (struct addrinfo *ai = ai_list; ai != NULL; ai = ai->ai_next) { sk = socket (ai->ai_family, SOCK_STREAM, 0); if (sk < 0)