X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibcollectdclient%2Fclient.c;fp=src%2Flibcollectdclient%2Fclient.c;h=f5eda6d2222957400258ada8e353422997ddd2b0;hb=69b8a9a1af204685dfdfaf1279a0f2928e0bbb32;hp=77fd576ee5d5703c304c22da4ce28928849554fb;hpb=b599cc64d3ba270fb9fb7116631a01b7404f1a9b;p=collectd.git diff --git a/src/libcollectdclient/client.c b/src/libcollectdclient/client.c index 77fd576e..f5eda6d2 100644 --- a/src/libcollectdclient/client.c +++ b/src/libcollectdclient/client.c @@ -266,13 +266,11 @@ static int lcc_send (lcc_connection_t *c, const char *command) /* {{{ */ static int lcc_receive (lcc_connection_t *c, /* {{{ */ lcc_response_t *ret_res) { - lcc_response_t res; + lcc_response_t res = { 0 }; char *ptr; char buffer[4096]; size_t i; - memset (&res, 0, sizeof (res)); - /* Read the first line, containing the status and a message */ ptr = fgets (buffer, sizeof (buffer), c->fh); if (ptr == NULL) @@ -358,7 +356,7 @@ static int lcc_receive (lcc_connection_t *c, /* {{{ */ static int lcc_sendreceive (lcc_connection_t *c, /* {{{ */ const char *command, lcc_response_t *ret_res) { - lcc_response_t res; + lcc_response_t res = { 0 }; int status; if (c->fh == NULL) @@ -371,7 +369,6 @@ static int lcc_sendreceive (lcc_connection_t *c, /* {{{ */ if (status != 0) return (status); - memset (&res, 0, sizeof (res)); status = lcc_receive (c, &res); if (status == 0) memcpy (ret_res, &res, sizeof (*ret_res)); @@ -381,7 +378,7 @@ static int lcc_sendreceive (lcc_connection_t *c, /* {{{ */ static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */ { - struct sockaddr_un sa; + struct sockaddr_un sa = { 0 }; int fd; int status; @@ -398,7 +395,6 @@ static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */ return (-1); } - memset (&sa, 0, sizeof (sa)); sa.sun_family = AF_UNIX; strncpy (sa.sun_path, path, sizeof (sa.sun_path) - 1); @@ -424,7 +420,7 @@ static int lcc_open_unixsocket (lcc_connection_t *c, const char *path) /* {{{ */ static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */ const char *addr_orig) { - struct addrinfo ai_hints; + struct addrinfo ai_hints = { 0 }; struct addrinfo *ai_res; struct addrinfo *ai_ptr; char addr_copy[NI_MAXHOST]; @@ -441,8 +437,6 @@ static int lcc_open_netsocket (lcc_connection_t *c, /* {{{ */ addr_copy[sizeof(addr_copy) - 1] = '\0'; addr = addr_copy; - memset (&ai_hints, 0, sizeof (ai_hints)); - ai_hints.ai_flags = 0; #ifdef AI_ADDRCONFIG ai_hints.ai_flags |= AI_ADDRCONFIG; #endif