X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Fcommon.c;h=9da47755034038ebc0025343b9e3b55a6b2f1796;hb=3fae5596643f1e361eb18c3d65448f8bc02fdd80;hp=f82efe3347d0cf292a8177120d6d2c3ea1d88242;hpb=cd5602386cf810ade2750bf026e5fe340765ce05;p=collectd.git diff --git a/src/daemon/common.c b/src/daemon/common.c index f82efe33..9da47755 100644 --- a/src/daemon/common.c +++ b/src/daemon/common.c @@ -36,8 +36,6 @@ #include "plugin.h" #include "utils_cache.h" -#include - #ifdef HAVE_MATH_H # include #endif @@ -273,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; @@ -1517,7 +1518,7 @@ int service_name_to_port_number (const char *service_name) { struct addrinfo *ai_list; struct addrinfo *ai_ptr; - struct addrinfo ai_hints; + struct addrinfo ai_hints = { 0 }; int status; int service_number; @@ -1525,7 +1526,6 @@ int service_name_to_port_number (const char *service_name) return (-1); ai_list = NULL; - memset (&ai_hints, 0, sizeof (ai_hints)); ai_hints.ai_family = AF_UNSPEC; status = getaddrinfo (/* node = */ NULL, service_name,