X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=34c23cdfad3b24c408269ae60f834aa90e18f8f4;hb=354f9991530248e45207d236eb74c1cc3d5238ef;hp=1d81a6528c027e46c71de7fdc8c52c4ccf9ba9fc;hpb=36ee20dc97d0e0a5483892667f5d032618e18f10;p=collectd.git diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 1d81a652..34c23cdf 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -358,7 +358,7 @@ static int dispatch_value_plugin (const char *plugin, oconfig_item_t *ci) static int dispatch_value (oconfig_item_t *ci) { - int ret = -2; + int ret = 0; int i; for (i = 0; i < cf_value_map_num; i++) @@ -514,7 +514,7 @@ static int cf_ci_replace_child (oconfig_item_t *dst, oconfig_item_t *src, return (0); } - temp = (oconfig_item_t *) realloc (dst->children, + temp = realloc (dst->children, sizeof (oconfig_item_t) * (dst->children_num + src->children_num - 1)); if (temp == NULL) @@ -562,7 +562,7 @@ static int cf_ci_append_children (oconfig_item_t *dst, oconfig_item_t *src) if ((src == NULL) || (src->children_num == 0)) return (0); - temp = (oconfig_item_t *) realloc (dst->children, + temp = realloc (dst->children, sizeof (oconfig_item_t) * (dst->children_num + src->children_num)); if (temp == NULL) @@ -749,7 +749,7 @@ static oconfig_item_t *cf_read_dir (const char *dir, } ++filenames_num; - tmp = (char **) realloc (filenames, + tmp = realloc (filenames, filenames_num * sizeof (*filenames)); if (tmp == NULL) { ERROR ("configfile: realloc failed."); @@ -1117,6 +1117,7 @@ int cf_read (const char *filename) { oconfig_item_t *conf; int i; + int ret = 0; conf = cf_read_generic (filename, /* pattern = */ NULL, /* depth = */ 0); if (conf == NULL) @@ -1134,18 +1135,27 @@ int cf_read (const char *filename) for (i = 0; i < conf->children_num; i++) { if (conf->children[i].children == NULL) - dispatch_value (conf->children + i); + { + if (dispatch_value (conf->children + i) != 0) + ret = -1; + } else - dispatch_block (conf->children + i); + { + if (dispatch_block (conf->children + i) != 0) + ret = -1; + } } oconfig_free (conf); /* Read the default types.db if no `TypesDB' option was given. */ if (cf_default_typesdb) - read_types_list (PKGDATADIR"/types.db"); + { + if (read_types_list (PKGDATADIR"/types.db") != 0) + ret = -1; + } - return (0); + return ret; } /* int cf_read */ /* Assures the config option is a string, duplicates it and returns the copy in