X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Futils_fbhash.c;h=7c342e53c3715295078f58a36a8a9a6d1d067251;hp=f94e2e5b7a08a3e6b437a797b78876e1e53f1292;hb=48efd3deb4c9139fd060ff3d289896e9031bcc7c;hpb=295947714f23935be771c98f1071564d5567d33a diff --git a/src/utils_fbhash.c b/src/utils_fbhash.c index f94e2e5b..7c342e53 100644 --- a/src/utils_fbhash.c +++ b/src/utils_fbhash.c @@ -28,7 +28,7 @@ #include "plugin.h" -#include "utils_avltree.h" +#include "utils/avltree/avltree.h" #include "utils_fbhash.h" struct fbhash_s { @@ -74,7 +74,7 @@ static int fbh_read_file(fbhash_t *h) /* {{{ */ fh = fopen(h->filename, "r"); if (fh == NULL) - return (-1); + return -1; fl.l_type = F_RDLCK; fl.l_whence = SEEK_SET; @@ -83,13 +83,13 @@ static int fbh_read_file(fbhash_t *h) /* {{{ */ status = fcntl(fileno(fh), F_SETLK, &fl); if (status != 0) { fclose(fh); - return (-1); + return -1; } tree = c_avl_create((int (*)(const void *, const void *))strcmp); if (tree == NULL) { fclose(fh); - return (-1); + return -1; } /* Read `fh' into `tree' */ @@ -102,7 +102,7 @@ static int fbh_read_file(fbhash_t *h) /* {{{ */ char *key_copy; char *value_copy; - buffer[sizeof(buffer) - 1] = 0; + buffer[sizeof(buffer) - 1] = '\0'; len = strlen(buffer); /* Remove trailing newline characters. */ @@ -162,7 +162,7 @@ static int fbh_read_file(fbhash_t *h) /* {{{ */ fbh_free_tree(h->tree); h->tree = tree; - return (0); + return 0; } /* }}} int fbh_read_file */ static int fbh_check_file(fbhash_t *h) /* {{{ */ @@ -172,16 +172,16 @@ static int fbh_check_file(fbhash_t *h) /* {{{ */ status = stat(h->filename, &statbuf); if (status != 0) - return (-1); + return -1; if (h->mtime >= statbuf.st_mtime) - return (0); + return 0; status = fbh_read_file(h); if (status == 0) h->mtime = statbuf.st_mtime; - return (status); + return status; } /* }}} int fbh_check_file */ /* @@ -193,16 +193,16 @@ fbhash_t *fbh_create(const char *file) /* {{{ */ int status; if (file == NULL) - return (NULL); + return NULL; h = calloc(1, sizeof(*h)); if (h == NULL) - return (NULL); + return NULL; h->filename = strdup(file); if (h->filename == NULL) { free(h); - return (NULL); + return NULL; } h->mtime = 0; @@ -212,10 +212,10 @@ fbhash_t *fbh_create(const char *file) /* {{{ */ if (status != 0) { fbh_destroy(h); free(h); - return (NULL); + return NULL; } - return (h); + return h; } /* }}} fbhash_t *fbh_create */ void fbh_destroy(fbhash_t *h) /* {{{ */ @@ -235,7 +235,7 @@ char *fbh_get(fbhash_t *h, const char *key) /* {{{ */ int status; if ((h == NULL) || (key == NULL)) - return (NULL); + return NULL; value = NULL; value_copy = NULL; @@ -253,5 +253,5 @@ char *fbh_get(fbhash_t *h, const char *key) /* {{{ */ pthread_mutex_unlock(&h->lock); - return (value_copy); + return value_copy; } /* }}} char *fbh_get */