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_scale.c
diff --git
a/src/target_scale.c
b/src/target_scale.c
index
b667ed1
..
22af4e3
100644
(file)
--- a/
src/target_scale.c
+++ b/
src/target_scale.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"
@@
-302,7
+303,6
@@
static int ts_config_add_data_source(ts_data_t *data, /* {{{ */
{
size_t new_data_sources_num;
char **temp;
{
size_t new_data_sources_num;
char **temp;
- int i;
/* Check number of arbuments. */
if (ci->values_num < 1)
/* Check number of arbuments. */
if (ci->values_num < 1)
@@
-313,7
+313,7
@@
static int ts_config_add_data_source(ts_data_t *data, /* {{{ */
}
/* Check type of arguments */
}
/* Check type of arguments */
- for (i = 0; i < ci->values_num; i++)
+ for (i
nt i
= 0; i < ci->values_num; i++)
{
if (ci->values[i].type == OCONFIG_TYPE_STRING)
continue;
{
if (ci->values[i].type == OCONFIG_TYPE_STRING)
continue;
@@
-328,7
+328,7
@@
static int ts_config_add_data_source(ts_data_t *data, /* {{{ */
/* Allocate space for the char pointers */
new_data_sources_num = data->data_sources_num + ((size_t) ci->values_num);
/* Allocate space for the char pointers */
new_data_sources_num = data->data_sources_num + ((size_t) ci->values_num);
- temp =
(char **)
realloc (data->data_sources,
+ temp = realloc (data->data_sources,
new_data_sources_num * sizeof (char *));
if (temp == NULL)
{
new_data_sources_num * sizeof (char *));
if (temp == NULL)
{
@@
-338,7
+338,7
@@
static int ts_config_add_data_source(ts_data_t *data, /* {{{ */
data->data_sources = temp;
/* Copy the strings, allocating memory as needed. */
data->data_sources = temp;
/* Copy the strings, allocating memory as needed. */
- for (i = 0; i < ci->values_num; i++)
+ for (i
nt i
= 0; i < ci->values_num; i++)
{
size_t j;
{
size_t j;
@@
-369,8
+369,7
@@
static int ts_destroy (void **user_data) /* {{{ */
if ((data != NULL) && (data->data_sources != NULL))
{
if ((data != NULL) && (data->data_sources != NULL))
{
- size_t i;
- for (i = 0; i < data->data_sources_num; i++)
+ for (size_t i = 0; i < data->data_sources_num; i++)
sfree (data->data_sources[i]);
sfree (data->data_sources);
}
sfree (data->data_sources[i]);
sfree (data->data_sources);
}
@@
-385,21
+384,19
@@
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 =
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->factor = NAN;
data->offset = NAN;
status = 0;
data->factor = NAN;
data->offset = NAN;
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;
@@
-447,7
+444,6
@@
static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */
notification_meta_t __attribute__((unused)) **meta, void **user_data)
{
ts_data_t *data;
notification_meta_t __attribute__((unused)) **meta, void **user_data)
{
ts_data_t *data;
- size_t i;
if ((ds == NULL) || (vl == NULL) || (user_data == NULL))
return (-EINVAL);
if ((ds == NULL) || (vl == NULL) || (user_data == NULL))
return (-EINVAL);
@@
-459,7
+455,7
@@
static int ts_invoke (const data_set_t *ds, value_list_t *vl, /* {{{ */
return (-EINVAL);
}
return (-EINVAL);
}
- for (i = 0; i < ds->ds_num; i++)
+ for (
size_t
i = 0; i < ds->ds_num; i++)
{
/* If we've got a list of data sources, is it in the list? */
if (data->data_sources) {
{
/* If we've got a list of data sources, is it in the list? */
if (data->data_sources) {
@@
-491,9
+487,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;