X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Flibcollectdclient%2Fclient.c;h=f5eda6d2222957400258ada8e353422997ddd2b0;hb=3fae5596643f1e361eb18c3d65448f8bc02fdd80;hp=8b5ac0bd490b711ae975f467665079f84837d211;hpb=5841d1fb13436af787c748a965084cb06e66d326;p=collectd.git diff --git a/src/libcollectdclient/client.c b/src/libcollectdclient/client.c index 8b5ac0bd..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 @@ -693,7 +687,7 @@ int lcc_getval (lcc_connection_t *c, lcc_identifier_t *ident, /* {{{ */ if (ret_values_names != NULL) { - values_names = (char **) calloc (values_num, sizeof (*values_names)); + values_names = calloc (values_num, sizeof (*values_names)); if (values_names == NULL) BAIL_OUT (ENOMEM); } @@ -1062,9 +1056,11 @@ int lcc_string_to_identifier (lcc_connection_t *c, /* {{{ */ return (0); } /* }}} int lcc_string_to_identifier */ -int lcc_identifier_compare (const lcc_identifier_t *i0, /* {{{ */ - const lcc_identifier_t *i1) +int lcc_identifier_compare (const void *a, /* {{{ */ + const void *b) { + const lcc_identifier_t *i0 = a; + const lcc_identifier_t *i1 = b; int status; if ((i0 == NULL) && (i1 == NULL)) @@ -1101,7 +1097,7 @@ int lcc_sort_identifiers (lcc_connection_t *c, /* {{{ */ } qsort (idents, idents_num, sizeof (*idents), - (void *) lcc_identifier_compare); + lcc_identifier_compare); return (0); } /* }}} int lcc_sort_identifiers */