X-Git-Url: https://git.octo.it/?p=collectd.git;a=blobdiff_plain;f=src%2Ftable.c;h=f181de94624b2be7201819592d120c43d61b5455;hp=ae26c7890f3860379443f9c3257278a071060577;hb=54619dc85fd308b21ed09a0271e5c7383c7921b9;hpb=4cf5858f09f55f06b891c67b7bb5ddcb5de4608f diff --git a/src/table.c b/src/table.c index ae26c789..f181de94 100644 --- a/src/table.c +++ b/src/table.c @@ -30,7 +30,7 @@ #include "collectd.h" -#include "common.h" +#include "utils/common/common.h" #include "plugin.h" @@ -132,18 +132,6 @@ static size_t tables_num; /* * configuration handling */ - -static int tbl_config_set_s(char *name, char **var, oconfig_item_t *ci) { - if (ci->values_num != 1 || ci->values[0].type != OCONFIG_TYPE_STRING) { - log_err("\"%s\" expects a single string argument.", name); - return 1; - } - - sfree(*var); - *var = sstrdup(ci->values[0].value.string); - return 0; -} /* tbl_config_set_separator */ - static int tbl_config_append_array_i(char *name, size_t **var, size_t *len, oconfig_item_t *ci) { if (ci->values_num < 1) { @@ -196,9 +184,9 @@ static int tbl_config_result(tbl_t *tbl, oconfig_item_t *ci) { oconfig_item_t *c = ci->children + i; if (strcasecmp(c->key, "Type") == 0) - tbl_config_set_s(c->key, &res->type, c); + cf_util_get_string(c, &res->type); else if (strcasecmp(c->key, "InstancePrefix") == 0) - tbl_config_set_s(c->key, &res->instance_prefix, c); + cf_util_get_string(c, &res->instance_prefix); else if (strcasecmp(c->key, "InstancesFrom") == 0) tbl_config_append_array_i(c->key, &res->instances, &res->instances_num, c); @@ -253,11 +241,11 @@ static int tbl_config_table(oconfig_item_t *ci) { oconfig_item_t *c = ci->children + i; if (strcasecmp(c->key, "Separator") == 0) - tbl_config_set_s(c->key, &tbl->sep, c); + cf_util_get_string(c, &tbl->sep); else if (strcasecmp(c->key, "Plugin") == 0) - tbl_config_set_s(c->key, &tbl->plugin_name, c); + cf_util_get_string(c, &tbl->plugin_name); else if (strcasecmp(c->key, "Instance") == 0) - tbl_config_set_s(c->key, &tbl->instance, c); + cf_util_get_string(c, &tbl->instance); else if (strcasecmp(c->key, "Result") == 0) tbl_config_result(tbl, c); else @@ -396,7 +384,7 @@ static int tbl_result_dispatch(tbl_t *tbl, tbl_result_t *res, char **fields, else r = snprintf(vl.type_instance, sizeof(vl.type_instance), "%s-%s", res->instance_prefix, instances_str); - if (r >= sizeof(vl.type_instance)) + if ((size_t)r >= sizeof(vl.type_instance)) log_warn("Truncated type instance: %s.", vl.type_instance); }