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
/
powerdns.c
diff --git
a/src/powerdns.c
b/src/powerdns.c
index
ab62dcf
..
e215a8c
100644
(file)
--- a/
src/powerdns.c
+++ b/
src/powerdns.c
@@
-25,6
+25,7
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "configfile.h"
#include "common.h"
#include "plugin.h"
#include "configfile.h"
@@
-375,7
+376,7
@@
static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */
char *buffer = NULL;
size_t buffer_size = 0;
char *buffer = NULL;
size_t buffer_size = 0;
- struct sockaddr_un sa_unix;
+ struct sockaddr_un sa_unix
= { 0 }
;
struct timeval stv_timeout;
cdtime_t cdt_timeout;
struct timeval stv_timeout;
cdtime_t cdt_timeout;
@@
-387,7
+388,6
@@
static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */
return (-1);
}
return (-1);
}
- memset (&sa_unix, 0, sizeof (sa_unix));
sa_unix.sun_family = AF_UNIX;
sstrncpy (sa_unix.sun_path,
(local_sockpath != NULL) ? local_sockpath : PDNS_LOCAL_SOCKPATH,
sa_unix.sun_family = AF_UNIX;
sstrncpy (sa_unix.sun_path,
(local_sockpath != NULL) ? local_sockpath : PDNS_LOCAL_SOCKPATH,
@@
-465,7
+465,7
@@
static int powerdns_get_data_dgram (list_item_t *item, /* {{{ */
return (-1);
assert (buffer_size > 0);
return (-1);
assert (buffer_size > 0);
- buffer =
(char *)
malloc (buffer_size);
+ buffer = malloc (buffer_size);
if (buffer == NULL)
{
FUNC_ERROR ("malloc");
if (buffer == NULL)
{
FUNC_ERROR ("malloc");
@@
-542,7
+542,7
@@
static int powerdns_get_data_stream (list_item_t *item, /* {{{ */
else if (status == 0)
break;
else if (status == 0)
break;
- buffer_new =
(char *)
realloc (buffer, buffer_size + status + 1);
+ buffer_new = realloc (buffer, buffer_size + status + 1);
if (buffer_new == NULL)
{
FUNC_ERROR ("realloc");
if (buffer_new == NULL)
{
FUNC_ERROR ("realloc");
@@
-631,8
+631,6
@@
static int powerdns_read_server (list_item_t *item) /* {{{ */
saveptr = NULL;
while ((key = strtok_r (dummy, ",", &saveptr)) != NULL)
{
saveptr = NULL;
while ((key = strtok_r (dummy, ",", &saveptr)) != NULL)
{
- int i;
-
dummy = NULL;
value = strchr (key, '=');
dummy = NULL;
value = strchr (key, '=');
@@
-646,6
+644,7
@@
static int powerdns_read_server (list_item_t *item) /* {{{ */
continue;
/* Check if this item was requested. */
continue;
/* Check if this item was requested. */
+ int i;
for (i = 0; i < fields_num; i++)
if (strcasecmp (key, fields[i]) == 0)
break;
for (i = 0; i < fields_num; i++)
if (strcasecmp (key, fields[i]) == 0)
break;
@@
-781,7
+780,6
@@
static int powerdns_read_recursor (list_item_t *item) /* {{{ */
static int powerdns_config_add_collect (list_item_t *li, /* {{{ */
oconfig_item_t *ci)
{
static int powerdns_config_add_collect (list_item_t *li, /* {{{ */
oconfig_item_t *ci)
{
- int i;
char **temp;
if (ci->values_num < 1)
char **temp;
if (ci->values_num < 1)
@@
-791,7
+789,7
@@
static int powerdns_config_add_collect (list_item_t *li, /* {{{ */
return (-1);
}
return (-1);
}
- 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)
{
WARNING ("powerdns plugin: Only string arguments are allowed to "
if (ci->values[i].type != OCONFIG_TYPE_STRING)
{
WARNING ("powerdns plugin: Only string arguments are allowed to "
@@
-799,7
+797,7
@@
static int powerdns_config_add_collect (list_item_t *li, /* {{{ */
return (-1);
}
return (-1);
}
- temp =
(char **)
realloc (li->fields,
+ temp = realloc (li->fields,
sizeof (char *) * (li->fields_num + ci->values_num));
if (temp == NULL)
{
sizeof (char *) * (li->fields_num + ci->values_num));
if (temp == NULL)
{
@@
-808,7
+806,7
@@
static int powerdns_config_add_collect (list_item_t *li, /* {{{ */
}
li->fields = temp;
}
li->fields = temp;
- for (i = 0; i < ci->values_num; i++)
+ for (i
nt i
= 0; i < ci->values_num; i++)
{
li->fields[li->fields_num] = strdup (ci->values[i].value.string);
if (li->fields[li->fields_num] == NULL)
{
li->fields[li->fields_num] = strdup (ci->values[i].value.string);
if (li->fields[li->fields_num] == NULL)
@@
-831,7
+829,6
@@
static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */
list_item_t *item;
int status;
list_item_t *item;
int status;
- int i;
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
{
if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING))
{
@@
-840,13
+837,12
@@
static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */
return (-1);
}
return (-1);
}
- item =
(list_item_t *) malloc (sizeof (list_item_t
));
+ item =
calloc (1, sizeof (*item
));
if (item == NULL)
{
if (item == NULL)
{
- ERROR ("powerdns plugin:
m
alloc failed.");
+ ERROR ("powerdns plugin:
c
alloc failed.");
return (-1);
}
return (-1);
}
- memset (item, '\0', sizeof (list_item_t));
item->instance = strdup (ci->values[0].value.string);
if (item->instance == NULL)
item->instance = strdup (ci->values[0].value.string);
if (item->instance == NULL)
@@
-881,7
+877,7
@@
static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */
}
status = 0;
}
status = 0;
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *option = ci->children + i;
{
oconfig_item_t *option = ci->children + i;
@@
-941,8
+937,6
@@
static int powerdns_config_add_server (oconfig_item_t *ci) /* {{{ */
static int powerdns_config (oconfig_item_t *ci) /* {{{ */
{
static int powerdns_config (oconfig_item_t *ci) /* {{{ */
{
- int i;
-
DEBUG ("powerdns plugin: powerdns_config (ci = %p);", (void *) ci);
if (list == NULL)
DEBUG ("powerdns plugin: powerdns_config (ci = %p);", (void *) ci);
if (list == NULL)
@@
-956,7
+950,7
@@
static int powerdns_config (oconfig_item_t *ci) /* {{{ */
}
}
}
}
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *option = ci->children + i;
{
oconfig_item_t *option = ci->children + i;
@@
-989,9
+983,7
@@
static int powerdns_config (oconfig_item_t *ci) /* {{{ */
static int powerdns_read (void)
{
static int powerdns_read (void)
{
- llentry_t *e;
-
- for (e = llist_head (list); e != NULL; e = e->next)
+ for (llentry_t *e = llist_head (list); e != NULL; e = e->next)
{
list_item_t *item = e->value;
item->func (item);
{
list_item_t *item = e->value;
item->func (item);
@@
-1002,12
+994,10
@@
static int powerdns_read (void)
static int powerdns_shutdown (void)
{
static int powerdns_shutdown (void)
{
- llentry_t *e;
-
if (list == NULL)
return (0);
if (list == NULL)
return (0);
- for (e = llist_head (list); e != NULL; e = e->next)
+ for (
llentry_t *
e = llist_head (list); e != NULL; e = e->next)
{
list_item_t *item = (list_item_t *) e->value;
e->value = NULL;
{
list_item_t *item = (list_item_t *) e->value;
e->value = NULL;