**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
{
int sk = -1;
int status;
- struct addrinfo ai_hints;
- struct addrinfo *ai;
struct addrinfo *ai_list;
const char *host;
const char *port;
- memset ((void *) &ai_hints, '\0', sizeof (ai_hints));
- 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)
{
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)