X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fwrite_sensu.c;h=ce9efb9f3766aaab4cfae8874d39234ae5a09935;hb=cd2238b8b4f4ecd80c45862b5aeed3d3d73eddfe;hp=475354c83bb0110c89b81dde3e85cb33a3203953;hpb=01e2d29ebc5dec07daab935da3fcee5bb9c7d620;p=collectd.git diff --git a/src/write_sensu.c b/src/write_sensu.c index 475354c8..ce9efb9f 100644 --- a/src/write_sensu.c +++ b/src/write_sensu.c @@ -27,6 +27,7 @@ #define _GNU_SOURCE #include "collectd.h" + #include "plugin.h" #include "common.h" #include "configfile.h" @@ -35,7 +36,6 @@ #include #include #include -#include #include #include @@ -105,25 +105,25 @@ static void free_str_list(struct str_list *strs) /* {{{ */ static int sensu_connect(struct sensu_host *host) /* {{{ */ { int e; - struct addrinfo *ai, hints; + struct addrinfo *ai; char const *node; char const *service; // Resolve the target if we haven't done already if (!(host->flags & F_READY)) { - memset(&hints, 0, sizeof(hints)); memset(&service, 0, sizeof(service)); host->res = NULL; - hints.ai_family = AF_INET; - hints.ai_socktype = SOCK_STREAM; -#ifdef AI_ADDRCONFIG - hints.ai_flags |= AI_ADDRCONFIG; -#endif node = (host->node != NULL) ? host->node : SENSU_HOST; service = (host->service != NULL) ? host->service : SENSU_PORT; - if ((e = getaddrinfo(node, service, &hints, &(host->res))) != 0) { + struct addrinfo ai_hints = { + .ai_family = AF_INET, + .ai_flags = AI_ADDRCONFIG, + .ai_socktype = SOCK_STREAM + }; + + if ((e = getaddrinfo(node, service, &ai_hints, &(host->res))) != 0) { ERROR("write_sensu plugin: Unable to resolve host \"%s\": %s", node, gai_strerror(e)); return -1;