projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
write_kafka: ensure key is properly hashed to select partition
[collectd.git]
/
src
/
snmp.c
diff --git
a/src/snmp.c
b/src/snmp.c
index
e1f1f75
..
6a5bb8b
100644
(file)
--- a/
src/snmp.c
+++ b/
src/snmp.c
@@
-29,8
+29,6
@@
#include "plugin.h"
#include "utils_complain.h"
#include "plugin.h"
#include "utils_complain.h"
-#include <pthread.h>
-
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
@@
-384,10
+382,9
@@
static int csnmp_config_add_data (oconfig_item_t *ci)
int status = 0;
int i;
int status = 0;
int i;
- dd =
malloc (
sizeof (*dd));
+ dd =
calloc (1,
sizeof (*dd));
if (dd == NULL)
return (-1);
if (dd == NULL)
return (-1);
- memset (dd, '\0', sizeof (data_definition_t));
status = cf_util_get_string(ci, &dd->name);
if (status != 0)
status = cf_util_get_string(ci, &dd->name);
if (status != 0)
@@
-521,7
+518,7
@@
static int csnmp_config_add_host_collect (host_definition_t *host,
}
data_list_len = host->data_list_len + ci->values_num;
}
data_list_len = host->data_list_len + ci->values_num;
- data_list =
(data_definition_t **)
realloc (host->data_list,
+ data_list = realloc (host->data_list,
sizeof (data_definition_t *) * data_list_len);
if (data_list == NULL)
return (-1);
sizeof (data_definition_t *) * data_list_len);
if (data_list == NULL)
return (-1);
@@
-646,10
+643,9
@@
static int csnmp_config_add_host (oconfig_item_t *ci)
char cb_name[DATA_MAX_NAME_LEN];
user_data_t cb_data;
char cb_name[DATA_MAX_NAME_LEN];
user_data_t cb_data;
- hd =
malloc (
sizeof (*hd));
+ hd =
calloc (1,
sizeof (*hd));
if (hd == NULL)
return (-1);
if (hd == NULL)
return (-1);
- memset (hd, '\0', sizeof (host_definition_t));
hd->version = 2;
C_COMPLAIN_INIT (&hd->complaint);
hd->version = 2;
C_COMPLAIN_INIT (&hd->complaint);
@@
-1162,13
+1158,12
@@
static int csnmp_instance_list_add (csnmp_list_instances_t **head,
csnmp_oid_init (&vb_name, vb->name, vb->name_length);
csnmp_oid_init (&vb_name, vb->name, vb->name_length);
- il =
malloc (
sizeof (*il));
+ il =
calloc (1,
sizeof (*il));
if (il == NULL)
{
if (il == NULL)
{
- ERROR ("snmp plugin:
m
alloc failed.");
+ ERROR ("snmp plugin:
c
alloc failed.");
return (-1);
}
return (-1);
}
- memset (il, 0, sizeof (*il));
il->next = NULL;
status = csnmp_oid_suffix (&il->suffix, &vb_name, &dd->instance.oid);
il->next = NULL;
status = csnmp_oid_suffix (&il->suffix, &vb_name, &dd->instance.oid);
@@
-1607,14
+1602,13
@@
static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
continue;
}
continue;
}
- vt =
malloc (
sizeof (*vt));
+ vt =
calloc (1,
sizeof (*vt));
if (vt == NULL)
{
if (vt == NULL)
{
- ERROR ("snmp plugin:
m
alloc failed.");
+ ERROR ("snmp plugin:
c
alloc failed.");
status = -1;
break;
}
status = -1;
break;
}
- memset (vt, 0, sizeof (*vt));
vt->value = csnmp_value_list_to_value (vb, ds->ds[i].type,
data->scale, data->shift, host->name, data->name);
vt->value = csnmp_value_list_to_value (vb, ds->ds[i].type,
data->scale, data->shift, host->name, data->name);
@@
-1677,7
+1671,7
@@
static int csnmp_read_table (host_definition_t *host, data_definition_t *data)
static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
{
struct snmp_pdu *req;
static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
{
struct snmp_pdu *req;
- struct snmp_pdu *res;
+ struct snmp_pdu *res
= NULL
;
struct variable_list *vb;
const data_set_t *ds;
struct variable_list *vb;
const data_set_t *ds;
@@
-1739,7
+1733,6
@@
static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
for (i = 0; i < data->values_len; i++)
snmp_add_null_var (req, data->values[i].oid, data->values[i].oid_len);
for (i = 0; i < data->values_len; i++)
snmp_add_null_var (req, data->values[i].oid, data->values[i].oid_len);
- res = NULL;
status = snmp_sess_synch_response (host->sess_handle, req, &res);
if ((status != STAT_SUCCESS) || (res == NULL))
status = snmp_sess_synch_response (host->sess_handle, req, &res);
if ((status != STAT_SUCCESS) || (res == NULL))
@@
-1752,7
+1745,6
@@
static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
if (res != NULL)
snmp_free_pdu (res);
if (res != NULL)
snmp_free_pdu (res);
- res = NULL;
sfree (errstr);
sfree (vl.values);
sfree (errstr);
sfree (vl.values);
@@
-1778,9
+1770,7
@@
static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
data->scale, data->shift, host->name, data->name);
} /* for (res->variables) */
data->scale, data->shift, host->name, data->name);
} /* for (res->variables) */
- if (res != NULL)
- snmp_free_pdu (res);
- res = NULL;
+ snmp_free_pdu (res);
DEBUG ("snmp plugin: -> plugin_dispatch_values (&vl);");
plugin_dispatch_values (&vl);
DEBUG ("snmp plugin: -> plugin_dispatch_values (&vl);");
plugin_dispatch_values (&vl);