Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/rtadvd KNF, fix time printing formats.
details: https://anonhg.NetBSD.org/src/rev/cb802b85b654
branches: trunk
changeset: 356240:cb802b85b654
user: christos <christos%NetBSD.org@localhost>
date: Mon Sep 11 14:12:07 2017 +0000
description:
KNF, fix time printing formats.
diffstat:
usr.sbin/rtadvd/rtadvd.c | 112 +++++++++++++++++++++-------------------------
1 files changed, 51 insertions(+), 61 deletions(-)
diffs (truncated from 401 to 300 lines):
diff -r 821fd207c249 -r cb802b85b654 usr.sbin/rtadvd/rtadvd.c
--- a/usr.sbin/rtadvd/rtadvd.c Mon Sep 11 10:11:05 2017 +0000
+++ b/usr.sbin/rtadvd/rtadvd.c Mon Sep 11 14:12:07 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtadvd.c,v 1.53 2017/04/11 14:29:23 roy Exp $ */
+/* $NetBSD: rtadvd.c,v 1.54 2017/09/11 14:12:07 christos Exp $ */
/* $KAME: rtadvd.c,v 1.92 2005/10/17 14:40:02 suz Exp $ */
/*
@@ -219,14 +219,13 @@
argc -= optind;
argv += optind;
if (argc == 0) {
- fprintf(stderr,
- "usage: rtadvd [-DdfRs] [-c conffile]"
- " [-M ifname] [-p pidfile] interface ...\n");
- exit(1);
+ fprintf(stderr, "Ysage: %s [-DdfRs] [-c conffile]"
+ " [-M ifname] [-p pidfile] interface ...\n", getprogname());
+ return EXIT_FAILURE;
}
if (prog_init && prog_init() == -1) {
- err(1, "init failed");
+ err(EXIT_FAILURE, "init failed");
}
logopt = LOG_NDELAY | LOG_PID;
@@ -248,7 +247,7 @@
RTADVD_USER);
else
syslog(LOG_ERR, "getpwnam: %s: %m", RTADVD_USER);
- exit(1);
+ return EXIT_FAILURE;
}
/* timer initialization */
@@ -285,18 +284,18 @@
syslog(LOG_INFO, "dropping privileges to %s", RTADVD_USER);
if (prog_chroot(pw->pw_dir) == -1) {
syslog(LOG_ERR, "chroot: %s: %m", pw->pw_dir);
- exit(1);
+ return EXIT_FAILURE;
}
if (prog_chdir("/") == -1) {
syslog(LOG_ERR, "chdir: /: %m");
- exit(1);
+ return EXIT_FAILURE;
}
if (prog_setgroups(1, &pw->pw_gid) == -1 ||
prog_setgid(pw->pw_gid) == -1 ||
prog_setuid(pw->pw_uid) == -1)
{
syslog(LOG_ERR, "failed to drop privileges: %m");
- exit(1);
+ return EXIT_FAILURE;
}
signal(SIGINT, set_die);
@@ -330,10 +329,10 @@
if (timeout != NULL) {
syslog(LOG_DEBUG,
- "<%s> set timer to %ld:%ld. waiting for "
+ "<%s> set timer to %jd:%jd. waiting for "
"inputs or timeout", __func__,
- (long int)timeout->tv_sec,
- (long int)timeout->tv_nsec);
+ (intmax_t)timeout->tv_sec,
+ (intmax_t)timeout->tv_nsec);
} else {
syslog(LOG_DEBUG,
"<%s> there's no timer. waiting for inputs",
@@ -355,7 +354,7 @@
if (set[0].revents & POLLIN)
rtadvd_input();
}
- exit(0); /* NOTREACHED */
+ return EXIT_SUCCESS; /* NOTREACHED */
}
static void
@@ -397,13 +396,13 @@
syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
free(rcvcmsgbuf);
free(sndcmsgbuf);
- exit(0);
+ exit(EXIT_SUCCESS);
/* NOT REACHED */
}
if (TAILQ_FIRST(&ralist) == NULL) {
syslog(LOG_NOTICE, "<%s> gracefully terminated", __func__);
- exit(0);
+ exit(EXIT_SUCCESS);
/* NOT REACHED */
}
@@ -432,7 +431,7 @@
rai->maxinterval = MIN_DELAY_BETWEEN_RAS;
rai->leaving_adv = MAX_FINAL_RTR_ADVERTISEMENTS;
ra_output(rai);
- ra_timer_update((void *)rai, &rai->timer->tm);
+ ra_timer_update(rai, &rai->timer->tm);
rtadvd_set_timer(&rai->timer->tm, rai->timer);
}
}
@@ -688,7 +687,7 @@
rtadvd_remove_timer(&rai->timer);
rai->timer = rtadvd_add_timer(ra_timeout,
ra_timer_update, rai, rai);
- ra_timer_update((void *)rai, &rai->timer->tm);
+ ra_timer_update(rai, &rai->timer->tm);
rtadvd_set_timer(&rai->timer->tm, rai->timer);
} else if (prefixchange && rai->ifflags & IFF_UP) {
/*
@@ -901,8 +900,6 @@
__func__, icp->icmp6_type);
return;
}
-
- return;
}
static void
@@ -993,7 +990,6 @@
done:
free_ndopts(&ndopts);
- return;
}
void
@@ -1196,7 +1192,6 @@
done:
free_ndopts(&ndopts);
- return;
}
/* return a non-zero value if the received prefix is inconsitent with ours */
@@ -1212,7 +1207,7 @@
#if 0 /* impossible */
if (pinfo->nd_opt_pi_type != ND_OPT_PREFIX_INFORMATION)
- return(0);
+ return 0;
#endif
/*
@@ -1242,7 +1237,7 @@
inet_ntop(AF_INET6, &from->sin6_addr,
ntopbuf, INET6_ADDRSTRLEN),
rai->ifname);
- return(0);
+ return 0;
}
preferred_time = ntohl(pinfo->nd_opt_pi_preferred_time);
@@ -1325,7 +1320,7 @@
inconsistent++;
}
- return(inconsistent);
+ return inconsistent;
}
struct prefix *
@@ -1341,16 +1336,16 @@
bytelen = plen / 8;
bitlen = plen % 8;
bitmask = 0xff << (8 - bitlen);
- if (memcmp((void *)prefix, (void *)&pp->prefix, bytelen))
+ if (memcmp(prefix, &pp->prefix, bytelen))
continue;
if (bitlen == 0 ||
((prefix->s6_addr[bytelen] & bitmask) ==
(pp->prefix.s6_addr[bytelen] & bitmask))) {
- return(pp);
+ return pp;
}
}
- return(NULL);
+ return NULL;
}
/* check if p0/plen0 matches p1/plen1; return 1 if matches, otherwise 0. */
@@ -1362,19 +1357,19 @@
unsigned char bitmask;
if (plen0 < plen1)
- return(0);
+ return 0;
bytelen = plen1 / 8;
bitlen = plen1 % 8;
bitmask = 0xff << (8 - bitlen);
- if (memcmp((void *)p0, (void *)p1, bytelen))
- return(0);
+ if (memcmp(p0, p1, bytelen))
+ return 0;
if (bitlen == 0 ||
((p0->s6_addr[bytelen] & bitmask) ==
(p1->s6_addr[bytelen] & bitmask))) {
- return(1);
+ return 1;
}
- return(0);
+ return 0;
}
static int
@@ -1475,12 +1470,11 @@
}
}
- return(0);
+ return 0;
bad:
free_ndopts(ndopts);
-
- return(-1);
+ return -1;
}
static void
@@ -1509,19 +1503,19 @@
rcvcmsgbuf = malloc(rcvcmsgbuflen);
if (rcvcmsgbuf == NULL) {
syslog(LOG_ERR, "<%s> malloc: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
sndcmsgbuflen = CMSG_SPACE(sizeof(struct in6_pktinfo));
sndcmsgbuf = malloc(sndcmsgbuflen);
if (sndcmsgbuf == NULL) {
syslog(LOG_ERR, "<%s> malloc: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
if ((sock = prog_socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
syslog(LOG_ERR, "<%s> socket: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
/* RFC 4861 Section 4.2 */
@@ -1529,7 +1523,7 @@
if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &on,
sizeof(on)) == -1) {
syslog(LOG_ERR, "<%s> IPV6_MULTICAST_HOPS: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
/* specify to tell receiving interface */
@@ -1538,13 +1532,13 @@
if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on,
sizeof(on)) < 0) {
syslog(LOG_ERR, "<%s> IPV6_RECVPKTINFO: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
#else /* old adv. API */
if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_PKTINFO, &on,
sizeof(on)) < 0) {
syslog(LOG_ERR, "<%s> IPV6_PKTINFO: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
#endif
@@ -1554,13 +1548,13 @@
if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &on,
sizeof(on)) < 0) {
syslog(LOG_ERR, "<%s> IPV6_RECVHOPLIMIT: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
#else /* old adv. API */
if (prog_setsockopt(sock, IPPROTO_IPV6, IPV6_HOPLIMIT, &on,
sizeof(on)) < 0) {
syslog(LOG_ERR, "<%s> IPV6_HOPLIMIT: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
#endif
@@ -1572,7 +1566,7 @@
if (prog_setsockopt(sock, IPPROTO_ICMPV6, ICMP6_FILTER, &filt,
sizeof(filt)) < 0) {
syslog(LOG_ERR, "<%s> IICMP6_FILTER: %m", __func__);
- exit(1);
+ exit(EXIT_FAILURE);
}
Home |
Main Index |
Thread Index |
Old Index