X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fdaemon%2Fcommon.c;h=7bbace76e0a817b1f351f99c9099b2f3668787ba;hb=5afde1077e3c8fc119b79caa2572cbf84dbfe5ca;hp=546da3b3f240e94d019e15d20036fca20755fa16;hpb=b81104a423234c04f0eb4ace0ec5e93a363c917a;p=collectd.git diff --git a/src/daemon/common.c b/src/daemon/common.c index 546da3b3..7bbace76 100644 --- a/src/daemon/common.c +++ b/src/daemon/common.c @@ -36,10 +36,6 @@ #include "plugin.h" #include "utils_cache.h" -#if HAVE_PTHREAD_H -# include -#endif - #ifdef HAVE_MATH_H # include #endif @@ -275,6 +271,9 @@ ssize_t swrite (int fd, const void *buf, size_t count) ptr = (const char *) buf; nleft = count; + if (fd < 0) + return (-1); + /* checking for closed peer connection */ pfd.fd = fd; pfd.events = POLLIN | POLLHUP; @@ -1519,16 +1518,15 @@ int service_name_to_port_number (const char *service_name) { struct addrinfo *ai_list; struct addrinfo *ai_ptr; - struct addrinfo ai_hints; int status; int service_number; if (service_name == NULL) return (-1); - ai_list = NULL; - memset (&ai_hints, 0, sizeof (ai_hints)); - ai_hints.ai_family = AF_UNSPEC; + struct addrinfo ai_hints = { + .ai_family = AF_UNSPEC + }; status = getaddrinfo (/* node = */ NULL, service_name, &ai_hints, &ai_list);