X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Fdaemon%2Fconfigfile.c;h=5cf8ac1fbe83e6cf85803ced862f89182f9202fd;hp=8750bef87b84a45313e82004319945815f2b74ad;hb=b15665fc2c279cf02dc16d3169c770f2c677e982;hpb=62e9fd1e6b8e29d187f771f82820a3070bec0156 diff --git a/src/daemon/configfile.c b/src/daemon/configfile.c index 8750bef8..5cf8ac1f 100644 --- a/src/daemon/configfile.c +++ b/src/daemon/configfile.c @@ -29,11 +29,11 @@ #include "liboconfig/oconfig.h" -#include "common.h" #include "configfile.h" #include "filter_chain.h" #include "plugin.h" #include "types_list.h" +#include "utils/common/common.h" #if HAVE_WORDEXP_H #include @@ -267,7 +267,8 @@ static int dispatch_loadplugin(oconfig_item_t *ci) { /* default to the global interval set before loading this plugin */ plugin_ctx_t ctx = { - .interval = cf_get_default_interval(), .name = strdup(name), + .interval = cf_get_default_interval(), + .name = strdup(name), }; if (ctx.name == NULL) return ENOMEM; @@ -411,10 +412,16 @@ static int dispatch_block_plugin(oconfig_item_t *ci) { } /* Hm, no complex plugin found. Dispatch the values one by one */ - for (int i = 0; i < ci->children_num; i++) { - if (ci->children[i].children == NULL) - dispatch_value_plugin(name, ci->children + i); - else { + for (int i = 0, ret = 0; i < ci->children_num; i++) { + if (ci->children[i].children == NULL) { + oconfig_item_t *child = ci->children + i; + ret = dispatch_value_plugin(name, child); + if (ret != 0) { + ERROR("Plugin %s failed to handle option %s, return code: %i", name, + child->key, ret); + return ret; + } + } else { WARNING("There is a `%s' block within the " "configuration for the %s plugin. " "The plugin either only expects " @@ -473,9 +480,9 @@ static int cf_ci_replace_child(oconfig_item_t *dst, oconfig_item_t *src, return 0; } - temp = realloc(dst->children, - sizeof(oconfig_item_t) * - (dst->children_num + src->children_num - 1)); + temp = + realloc(dst->children, sizeof(oconfig_item_t) * + (dst->children_num + src->children_num - 1)); if (temp == NULL) { ERROR("configfile: realloc failed."); return -1; @@ -514,9 +521,8 @@ static int cf_ci_append_children(oconfig_item_t *dst, oconfig_item_t *src) { if ((src == NULL) || (src->children_num == 0)) return 0; - temp = - realloc(dst->children, - sizeof(oconfig_item_t) * (dst->children_num + src->children_num)); + temp = realloc(dst->children, sizeof(oconfig_item_t) * + (dst->children_num + src->children_num)); if (temp == NULL) { ERROR("configfile: realloc failed."); return -1; @@ -804,7 +810,7 @@ static oconfig_item_t *cf_read_generic(const char *path, const char *pattern, return root; } /* oconfig_item_t *cf_read_generic */ -/* #endif HAVE_WORDEXP_H */ + /* #endif HAVE_WORDEXP_H */ #else /* if !HAVE_WORDEXP_H */ static oconfig_item_t *cf_read_generic(const char *path, const char *pattern, @@ -1064,7 +1070,7 @@ int cf_util_get_string(const oconfig_item_t *ci, char **ret_string) /* {{{ */ } /* }}} int cf_util_get_string */ /* Assures the config option is a string and copies it to the provided buffer. - * Assures null-termination. */ + * Assures NUL-termination. */ int cf_util_get_string_buffer(const oconfig_item_t *ci, char *buffer, /* {{{ */ size_t buffer_size) { if ((ci == NULL) || (buffer == NULL) || (buffer_size < 1)) @@ -1076,7 +1082,7 @@ int cf_util_get_string_buffer(const oconfig_item_t *ci, char *buffer, /* {{{ */ } strncpy(buffer, ci->values[0].value.string, buffer_size); - buffer[buffer_size - 1] = 0; + buffer[buffer_size - 1] = '\0'; return 0; } /* }}} int cf_util_get_string_buffer */