X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_fbhash.c;h=893bfbd49bded329e7b320cadd28c3da8c42bd5f;hb=5523a080010dcb7a61dc0dccc3969a2a048e52f9;hp=cbd150610205255a8a20478a324175a7feebd35a;hpb=b286b677bb54a3192a4121c2aa0857a133fd0603;p=collectd.git diff --git a/src/utils_fbhash.c b/src/utils_fbhash.c index cbd15061..893bfbd4 100644 --- a/src/utils_fbhash.c +++ b/src/utils_fbhash.c @@ -25,9 +25,8 @@ **/ #include "collectd.h" -#include "plugin.h" -#include +#include "plugin.h" #include "utils_fbhash.h" #include "utils_avltree.h" @@ -71,7 +70,7 @@ static int fbh_read_file (fbhash_t *h) /* {{{ */ { FILE *fh; char buffer[4096]; - struct flock fl; + struct flock fl = { 0 }; c_avl_tree_t *tree; int status; @@ -79,11 +78,8 @@ static int fbh_read_file (fbhash_t *h) /* {{{ */ if (fh == NULL) return (-1); - memset (&fl, 0, sizeof (fl)); fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 0; /* == entire file */ /* TODO: Lock file? -> fcntl */ status = fcntl (fileno (fh), F_SETLK, &fl); @@ -93,7 +89,7 @@ static int fbh_read_file (fbhash_t *h) /* {{{ */ return (-1); } - tree = c_avl_create ((void *) strcmp); + tree = c_avl_create ((int (*) (const void *, const void *)) strcmp); if (tree == NULL) { fclose (fh); @@ -179,11 +175,9 @@ static int fbh_read_file (fbhash_t *h) /* {{{ */ static int fbh_check_file (fbhash_t *h) /* {{{ */ { - struct stat statbuf; + struct stat statbuf = { 0 }; int status; - memset (&statbuf, 0, sizeof (statbuf)); - status = stat (h->filename, &statbuf); if (status != 0) return (-1); @@ -209,10 +203,9 @@ fbhash_t *fbh_create (const char *file) /* {{{ */ if (file == NULL) return (NULL); - h = malloc (sizeof (*h)); + h = calloc (1, sizeof (*h)); if (h == NULL) return (NULL); - memset (h, 0, sizeof (*h)); h->filename = strdup (file); if (h->filename == NULL)