X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Ftarget_set.c;h=6115639b5bcd73679b41f4a5623b0f38b43cbd69;hb=82e59ce7eb02c78d911dac7663383ce372b79c90;hp=da2d3075928a5e43032b17f003061127f2b49af8;hpb=a89fc9296186de14cc308e18adae56c7777bae0e;p=collectd.git diff --git a/src/target_set.c b/src/target_set.c index da2d3075..6115639b 100644 --- a/src/target_set.c +++ b/src/target_set.c @@ -39,7 +39,7 @@ struct ts_data_s }; typedef struct ts_data_s ts_data_t; -int ts_util_get_key_and_string_wo_strdup (const oconfig_item_t *ci, char **ret_key, char **ret_string) /* {{{ */ +static int ts_util_get_key_and_string_wo_strdup (const oconfig_item_t *ci, char **ret_key, char **ret_string) /* {{{ */ { if ((ci->values_num != 2) || (ci->values[0].type != OCONFIG_TYPE_STRING) @@ -103,15 +103,17 @@ static int ts_config_add_meta (meta_data_t **dest, /* {{{ */ return (-1); } - if(NULL == (*dest)) { + if ((*dest) == NULL) + { // Create a new meta_data_t - if( NULL == (*dest = meta_data_create())) { + if ((*dest = meta_data_create()) == NULL) + { ERROR ("Target `set': failed to create a meta data for `%s'.", ci->key); return (-1); } } - return(meta_data_add_string (*dest, key, string)); + return (meta_data_add_string (*dest, key, string)); } /* }}} int ts_config_add_meta */ static int ts_destroy (void **user_data) /* {{{ */ @@ -142,13 +144,12 @@ static int ts_create (const oconfig_item_t *ci, void **user_data) /* {{{ */ int status; int i; - data = (ts_data_t *) malloc (sizeof (*data)); + data = calloc (1, sizeof (*data)); if (data == NULL) { - ERROR ("ts_create: malloc failed."); + ERROR ("ts_create: calloc failed."); return (-ENOMEM); } - memset (data, 0, sizeof (*data)); data->host = NULL; data->plugin = NULL; @@ -238,7 +239,8 @@ static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */ return (-EINVAL); } - if(NULL != data->meta) { + if (data->meta != NULL) + { meta_data_clone_merge(&(vl->meta), data->meta); }