X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_dns.c;h=a1e4222f3cb2180fd1c692b86de0aaafccb82f17;hb=dc6f54ccc87c5ae63d29f05eca91714ade689691;hp=71a14d87ddc7fe75f2326165e11b86cdaf4ce139;hpb=7531a36086295c02ccb2d78c41d355a424426607;p=collectd.git diff --git a/src/utils_dns.c b/src/utils_dns.c index 71a14d87..a1e4222f 100644 --- a/src/utils_dns.c +++ b/src/utils_dns.c @@ -156,9 +156,6 @@ typedef int (printer)(const char *, ...); /* * Global variables */ -int qtype_counts[T_MAX]; -int opcode_counts[OP_MAX]; -int qclass_counts[C_MAX]; #if HAVE_PCAP_H static pcap_t *pcap_obj = NULL; @@ -212,7 +209,7 @@ static void ignore_list_add (const struct in6_addr *addr) if (ignore_list_match (addr) != 0) return; - new = malloc (sizeof (ip_list_t)); + new = malloc (sizeof (*new)); if (new == NULL) { perror ("malloc"); @@ -286,8 +283,7 @@ void dnstop_set_callback (void (*cb) (const rfc1035_header_t *)) #define RFC1035_MAXLABELSZ 63 static int -rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns -) +rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns) { off_t no = 0; unsigned char c; @@ -295,7 +291,7 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns static int loop_detect = 0; if (loop_detect > 2) return 4; /* compression loop */ - if (ns <= 0) + if (ns == 0) return 4; /* probably compression loop */ do { if ((*off) >= ((off_t) sz)) @@ -327,7 +323,6 @@ rfc1035NameUnpack(const char *buf, size_t sz, off_t * off, char *name, size_t ns * "(The 10 and 01 combinations are reserved for future use.)" */ return 3; /* reserved label/compression flags */ - break; } else { (*off)++; len = (size_t) c; @@ -418,11 +413,6 @@ handle_dns(const char *buf, int len) qh.length = (uint16_t) len; - /* gather stats */ - qtype_counts[qh.qtype]++; - qclass_counts[qh.qclass]++; - opcode_counts[qh.opcode]++; - if (Callback != NULL) Callback (&qh); @@ -838,9 +828,7 @@ const char *qtype_str(int t) default: ssnprintf (buf, sizeof (buf), "#%i", t); return (buf); - }; /* switch (t) */ - /* NOTREACHED */ - return (NULL); + } /* switch (t) */ } const char *opcode_str (int o) @@ -849,24 +837,18 @@ const char *opcode_str (int o) switch (o) { case 0: return "Query"; - break; case 1: return "Iquery"; - break; case 2: return "Status"; - break; case 4: return "Notify"; - break; case 5: return "Update"; - break; default: ssnprintf(buf, sizeof (buf), "Opcode%d", o); return buf; } - /* NOTREACHED */ } const char *rcode_str (int rcode) @@ -910,8 +892,6 @@ const char *rcode_str (int rcode) ssnprintf (buf, sizeof (buf), "RCode%i", rcode); return (buf); } - /* Never reached */ - return (NULL); } /* const char *rcode_str (int rcode) */ #if 0