#define _BSD_SOURCE
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "configfile.h"
#include "utils_dns.h"
-#include <pthread.h>
#include <poll.h>
#include <pcap.h>
{
counter_list_t *entry;
- entry = (counter_list_t *) malloc (sizeof (counter_list_t));
+ entry = calloc (1, sizeof (*entry));
if (entry == NULL)
return (NULL);
- memset (entry, 0, sizeof (counter_list_t));
entry->key = key;
entry->value = value;
{
pcap_t *pcap_obj;
char pcap_error[PCAP_ERRBUF_SIZE];
- struct bpf_program fp;
+ struct bpf_program fp = { 0 };
int status;
return (PCAP_ERROR);
}
- memset (&fp, 0, sizeof (fp));
status = pcap_compile (pcap_obj, &fp, "udp port 53", 1, 0);
if (status < 0)
{
unsigned int keys[T_MAX];
unsigned int values[T_MAX];
int len;
- int i;
counter_list_t *ptr;
}
pthread_mutex_unlock (&qtype_mutex);
- for (i = 0; i < len; i++)
+ for (int i = 0; i < len; i++)
{
DEBUG ("dns plugin: qtype = %u; counter = %u;", keys[i], values[i]);
submit_derive ("dns_qtype", qtype_str (keys[i]), values[i]);
}
pthread_mutex_unlock (&opcode_mutex);
- for (i = 0; i < len; i++)
+ for (int i = 0; i < len; i++)
{
DEBUG ("dns plugin: opcode = %u; counter = %u;", keys[i], values[i]);
submit_derive ("dns_opcode", opcode_str (keys[i]), values[i]);
}
pthread_mutex_unlock (&rcode_mutex);
- for (i = 0; i < len; i++)
+ for (int i = 0; i < len; i++)
{
DEBUG ("dns plugin: rcode = %u; counter = %u;", keys[i], values[i]);
submit_derive ("dns_rcode", rcode_str (keys[i]), values[i]);