**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
static void cr_submit_io (cr_data_t *rd, const char *type, /* {{{ */
const char *type_instance, derive_t rx, derive_t tx)
{
- value_t values[2];
value_list_t vl = VALUE_LIST_INIT;
-
- values[0].derive = rx;
- values[1].derive = tx;
+ value_t values[] = {
+ { .derive = rx },
+ { .derive = tx },
+ };
vl.values = values;
vl.values_len = STATIC_ARRAY_SIZE (values);
{
cr_data_t *router_data;
char read_name[128];
- user_data_t user_data;
int status;
- int i;
- router_data = malloc (sizeof (*router_data));
+ router_data = calloc (1, sizeof (*router_data));
if (router_data == NULL)
return (-1);
- memset (router_data, 0, sizeof (router_data));
router_data->connection = NULL;
router_data->node = NULL;
router_data->service = NULL;
router_data->password = NULL;
status = 0;
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
}
ssnprintf (read_name, sizeof (read_name), "routeros/%s", router_data->node);
- user_data.data = router_data;
- user_data.free_func = (void *) cr_free_data;
if (status == 0)
status = plugin_register_complex_read (/* group = */ NULL, read_name,
- cr_read, /* interval = */ 0, &user_data);
+ cr_read, /* interval = */ 0, &(user_data_t) {
+ .data = router_data,
+ .free_func = (void *) cr_free_data,
+ });
if (status != 0)
cr_free_data (router_data);
static int cr_config (oconfig_item_t *ci)
{
- int i;
-
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;