projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1856 from rubenk/snmp-dont-dispatch-values-with-empty-type-instance
[collectd.git]
/
src
/
target_set.c
diff --git
a/src/target_set.c
b/src/target_set.c
index
da2d307
..
fee5ffd
100644
(file)
--- a/
src/target_set.c
+++ b/
src/target_set.c
@@
-25,6
+25,7
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "filter_chain.h"
#include "common.h"
#include "filter_chain.h"
@@
-39,7
+40,7
@@
struct ts_data_s
};
typedef struct ts_data_s ts_data_t;
};
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)
{
if ((ci->values_num != 2)
|| (ci->values[0].type != OCONFIG_TYPE_STRING)
@@
-103,15
+104,17
@@
static int ts_config_add_meta (meta_data_t **dest, /* {{{ */
return (-1);
}
return (-1);
}
- if(NULL == (*dest)) {
+ if ((*dest) == NULL)
+ {
// Create a new meta_data_t
// 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);
}
}
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) /* {{{ */
} /* }}} int ts_config_add_meta */
static int ts_destroy (void **user_data) /* {{{ */
@@
-140,15
+143,13
@@
static int ts_create (const oconfig_item_t *ci, void **user_data) /* {{{ */
{
ts_data_t *data;
int status;
{
ts_data_t *data;
int status;
- int i;
- data =
(ts_data_t *) malloc (
sizeof (*data));
+ data =
calloc (1,
sizeof (*data));
if (data == NULL)
{
if (data == NULL)
{
- ERROR ("ts_create:
m
alloc failed.");
+ ERROR ("ts_create:
c
alloc failed.");
return (-ENOMEM);
}
return (-ENOMEM);
}
- memset (data, 0, sizeof (*data));
data->host = NULL;
data->plugin = NULL;
data->host = NULL;
data->plugin = NULL;
@@
-158,7
+159,7
@@
static int ts_create (const oconfig_item_t *ci, void **user_data) /* {{{ */
data->meta = NULL;
status = 0;
data->meta = NULL;
status = 0;
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-238,7
+239,8
@@
static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */
return (-EINVAL);
}
return (-EINVAL);
}
- if(NULL != data->meta) {
+ if (data->meta != NULL)
+ {
meta_data_clone_merge(&(vl->meta), data->meta);
}
meta_data_clone_merge(&(vl->meta), data->meta);
}
@@
-254,9
+256,8
@@
static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */
void module_register (void)
{
void module_register (void)
{
- target_proc_t tproc;
+ target_proc_t tproc
= { 0 }
;
- memset (&tproc, 0, sizeof (tproc));
tproc.create = ts_create;
tproc.destroy = ts_destroy;
tproc.invoke = ts_invoke;
tproc.create = ts_create;
tproc.destroy = ts_destroy;
tproc.invoke = ts_invoke;