summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSami Kerola <kerolasa@iki.fi>2019-07-14 17:09:53 +0100
committerSami Kerola <kerolasa@iki.fi>2019-07-14 17:34:58 +0100
commitb572ac3b41715446714d6e2a8c5b77a160bc470b (patch)
tree777e90ab305f7e581d49cccc6130b2e56ff4d2c0
parent9e08707d743b29e853df81bd7def1729e3afe55d (diff)
downloadiputils-b572ac3b41715446714d6e2a8c5b77a160bc470b.tar.gz
misc: various clean ups
Addresses: https://github.com/iputils/iputils/issues/205 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
-rw-r--r--ninfod/ninfod.h3
-rw-r--r--ninfod/ninfod_addrs.c10
-rw-r--r--ninfod/ninfod_core.c11
-rw-r--r--ping6_common.c3
-rw-r--r--ping_common.c4
-rw-r--r--rdisc.c3
6 files changed, 9 insertions, 25 deletions
diff --git a/ninfod/ninfod.h b/ninfod/ninfod.h
index 64bbd8a..d4e7d67 100644
--- a/ninfod/ninfod.h
+++ b/ninfod/ninfod.h
@@ -110,9 +110,8 @@ int pr_nodeinfo_refused(CHECKANDFILL_ARGS);
int pr_nodeinfo_noop(CHECKANDFILL_ARGS);
/* ninfod_addrs.c */
-void init_nodeinfo_ipv6addr(INIT_ARGS __attribute__((__unused__)));
int pr_nodeinfo_ipv6addr(CHECKANDFILL_ARGS);
-void init_nodeinfo_ipv4addr(INIT_ARGS __attribute__((__unused__)));
+void init_nodeinfo(INIT_ARGS __attribute__((__unused__)));
int pr_nodeinfo_ipv4addr(CHECKANDFILL_ARGS);
/* ninfod_name.c */
diff --git a/ninfod/ninfod_addrs.c b/ninfod/ninfod_addrs.c
index 59ddb63..799466f 100644
--- a/ninfod/ninfod_addrs.c
+++ b/ninfod/ninfod_addrs.c
@@ -114,14 +114,6 @@
#include "ninfod.h"
#include "ni_ifaddrs.h"
-/* ---------- */
-/* ipv6 address */
-void init_nodeinfo_ipv6addr(INIT_ARGS __attribute__((__unused__)))
-{
- DEBUG(LOG_DEBUG, "%s()\n", __func__);
- return;
-}
-
int filter_ipv6addr(const struct in6_addr *ifaddr, unsigned int flags)
{
if (IN6_IS_ADDR_UNSPECIFIED(ifaddr) ||
@@ -285,7 +277,7 @@ int pr_nodeinfo_ipv6addr(CHECKANDFILL_ARGS)
}
/* ipv4 address */
-void init_nodeinfo_ipv4addr(INIT_ARGS __attribute__((__unused__)))
+void init_nodeinfo(INIT_ARGS __attribute__((__unused__)))
{
DEBUG(LOG_DEBUG, "%s()\n", __func__);
return;
diff --git a/ninfod/ninfod_core.c b/ninfod/ninfod_core.c
index 2be60de..1948721 100644
--- a/ninfod/ninfod_core.c
+++ b/ninfod/ninfod_core.c
@@ -184,13 +184,13 @@ static struct qtypeinfo qtypeinfo_table[] = {
.qtype = IPUTILS_NI_QTYPE_IPV6ADDR,
.name = "NodeAddr",
.getreply = pr_nodeinfo_ipv6addr,
- .init = init_nodeinfo_ipv6addr,
+ .init = init_nodeinfo,
},
[IPUTILS_NI_QTYPE_IPV4ADDR] = {
.qtype = IPUTILS_NI_QTYPE_IPV4ADDR,
.name = "IPv4Addr",
.getreply = pr_nodeinfo_ipv4addr,
- .init = init_nodeinfo_ipv4addr,
+ .init = init_nodeinfo,
},
};
@@ -523,15 +523,10 @@ int pr_nodeinfo(struct packetcontext *p)
/* XXX: Step 5: Check the policy */
rc = ni_policy(p);
- if (rc <= 0) {
+ if (rc == 0) {
free(p->replydata);
p->replydata = NULL;
p->replydatalen = 0;
- if (rc < 0) {
- DEBUG(LOG_WARNING, "Ignored by policy.\n");
- free(p);
- return -1;
- }
DEBUG(LOG_WARNING, "Refused by policy.\n");
replyonsubjcheck = 0;
qtypeinfo = &qtypeinfo_refused;
diff --git a/ping6_common.c b/ping6_common.c
index 6cc5404..330b87a 100644
--- a/ping6_common.c
+++ b/ping6_common.c
@@ -203,7 +203,7 @@ static int niquery_nonce(uint8_t *nonce, int fill)
static uint8_t digest[MD5_DIGEST_LENGTH];
static int seq = -1;
- if (fill || seq != *(uint16_t *)nonce || seq < 0) {
+ if (fill || seq != *(uint16_t *)nonce || seq == -1) {
MD5_CTX ctxt;
MD5_Init(&ctxt);
@@ -476,7 +476,6 @@ static int niquery_option_subject_name_handler(int index, const char *name)
ni_group = nigroup_buf;
ni_subject = buf;
ni_subject_len = n + (fqdn < 0);
- ni_group = nigroup_buf;
free(canonname);
free(idn);
diff --git a/ping_common.c b/ping_common.c
index 9fbaf9d..73b76fa 100644
--- a/ping_common.c
+++ b/ping_common.c
@@ -310,7 +310,7 @@ int __schedule_exit(int next)
if (nreceived) {
waittime = 2 * tmax;
- if (waittime < (unsigned long)(1000 * interval))
+ if (waittime < 1000 * (unsigned long)interval)
waittime = 1000 * interval;
} else
waittime = lingertime * 1000;
@@ -809,7 +809,7 @@ restamp:
}
if (!csfailed) {
tsum += triptime;
- tsum2 += (long long)triptime *(long long)triptime;
+ tsum2 += (double)((long long)triptime * (long long)triptime);
if (triptime < tmin)
tmin = triptime;
if (triptime > tmax)
diff --git a/rdisc.c b/rdisc.c
index 4254fad..2d2e816 100644
--- a/rdisc.c
+++ b/rdisc.c
@@ -1141,8 +1141,7 @@ initifs()
ifr = ifc.ifc_req;
for (i = 0, n = ifc.ifc_len/sizeof (struct ifreq); n > 0; n--, ifr++) {
ifreq = *ifr;
- if (strlen(ifreq.ifr_name) >= IFNAMSIZ)
- continue;
+
if (ioctl(sock, SIOCGIFFLAGS, (char *)&ifreq) < 0) {
logperror("initifs: ioctl (get interface flags)");
continue;