From owner-svn-src-head@freebsd.org Thu Sep 10 06:40:30 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id ACD48A0074A; Thu, 10 Sep 2015 06:40:30 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 90FD2133D; Thu, 10 Sep 2015 06:40:30 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8A6eULY032871; Thu, 10 Sep 2015 06:40:30 GMT (envelope-from hrs@FreeBSD.org) Received: (from hrs@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8A6eTUV032669; Thu, 10 Sep 2015 06:40:29 GMT (envelope-from hrs@FreeBSD.org) Message-Id: <201509100640.t8A6eTUV032669@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hrs set sender to hrs@FreeBSD.org using -f From: Hiroki Sato Date: Thu, 10 Sep 2015 06:40:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287612 - in head: sbin/rtsol usr.sbin/rtsold X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Sep 2015 06:40:30 -0000 Author: hrs Date: Thu Sep 10 06:40:28 2015 New Revision: 287612 URL: https://svnweb.freebsd.org/changeset/base/287612 Log: - Remove #ifdef HAVE_POLL_H. - Use nitems(). MFC after: 3 days Modified: head/sbin/rtsol/Makefile head/usr.sbin/rtsold/Makefile head/usr.sbin/rtsold/if.c head/usr.sbin/rtsold/rtsold.c Modified: head/sbin/rtsol/Makefile ============================================================================== --- head/sbin/rtsol/Makefile Thu Sep 10 06:31:24 2015 (r287611) +++ head/sbin/rtsol/Makefile Thu Sep 10 06:40:28 2015 (r287612) @@ -14,15 +14,13 @@ # # $FreeBSD$ -SRCDIR= ${.CURDIR}/../../usr.sbin/rtsold - -.PATH: ${SRCDIR} +.PATH: ${.CURDIR}/../../usr.sbin/rtsold PROG= rtsol SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c MAN= WARNS?= 3 -CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H -DSMALL +CFLAGS+= -DHAVE_ARC4RANDOM -DSMALL .include Modified: head/usr.sbin/rtsold/Makefile ============================================================================== --- head/usr.sbin/rtsold/Makefile Thu Sep 10 06:31:24 2015 (r287611) +++ head/usr.sbin/rtsold/Makefile Thu Sep 10 06:40:28 2015 (r287612) @@ -20,6 +20,6 @@ MLINKS= rtsold.8 rtsol.8 SRCS= rtsold.c rtsol.c if.c probe.c dump.c rtsock.c WARNS?= 3 -CFLAGS+= -DHAVE_ARC4RANDOM -DHAVE_POLL_H +CFLAGS+= -DHAVE_ARC4RANDOM .include Modified: head/usr.sbin/rtsold/if.c ============================================================================== --- head/usr.sbin/rtsold/if.c Thu Sep 10 06:31:24 2015 (r287611) +++ head/usr.sbin/rtsold/if.c Thu Sep 10 06:40:28 2015 (r287612) @@ -280,18 +280,18 @@ lladdropt_fill(struct sockaddr_dl *sdl, struct sockaddr_dl * if_nametosdl(char *name) { - int mib[6] = {CTL_NET, AF_ROUTE, 0, 0, NET_RT_IFLIST, 0}; + int mib[] = {CTL_NET, AF_ROUTE, 0, 0, NET_RT_IFLIST, 0}; char *buf, *next, *lim; size_t len; struct if_msghdr *ifm; struct sockaddr *sa, *rti_info[RTAX_MAX]; struct sockaddr_dl *sdl = NULL, *ret_sdl; - if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) + if (sysctl(mib, nitems(mib), NULL, &len, NULL, 0) < 0) return(NULL); if ((buf = malloc(len)) == NULL) return(NULL); - if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { + if (sysctl(mib, nitems(mib), buf, &len, NULL, 0) < 0) { free(buf); return (NULL); } @@ -341,7 +341,7 @@ getinet6sysctl(int code) mib[3] = code; size = sizeof(value); - if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, NULL, 0) < 0) + if (sysctl(mib, nitems(mib), &value, &size, NULL, 0) < 0) return (-1); else return (value); @@ -356,7 +356,7 @@ setinet6sysctl(int code, int newval) mib[3] = code; size = sizeof(value); - if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &value, &size, + if (sysctl(mib, nitems(mib), &value, &size, &newval, sizeof(newval)) < 0) return (-1); else Modified: head/usr.sbin/rtsold/rtsold.c ============================================================================== --- head/usr.sbin/rtsold/rtsold.c Thu Sep 10 06:31:24 2015 (r287611) +++ head/usr.sbin/rtsold/rtsold.c Thu Sep 10 06:40:28 2015 (r287612) @@ -57,9 +57,7 @@ #include #include #include -#ifdef HAVE_POLL_H #include -#endif #include "rtsold.h" @@ -116,13 +114,7 @@ main(int argc, char **argv) int s, ch, once = 0; struct timespec *timeout; const char *opts; -#ifdef HAVE_POLL_H struct pollfd set[2]; -#else - fd_set *fdsetp, *selectfdp; - int fdmasks; - int maxfd; -#endif int rtsock; char *argv0; @@ -254,40 +246,16 @@ main(int argc, char **argv) warnmsg(LOG_ERR, __func__, "failed to open a socket"); exit(1); } -#ifdef HAVE_POLL_H set[0].fd = s; set[0].events = POLLIN; -#else - maxfd = s; -#endif - -#ifdef HAVE_POLL_H set[1].fd = -1; -#endif if ((rtsock = rtsock_open()) < 0) { warnmsg(LOG_ERR, __func__, "failed to open a socket"); exit(1); } -#ifdef HAVE_POLL_H set[1].fd = rtsock; set[1].events = POLLIN; -#else - if (rtsock > maxfd) - maxfd = rtsock; -#endif - -#ifndef HAVE_POLL_H - fdmasks = howmany(maxfd + 1, NFDBITS) * sizeof(fd_mask); - if ((fdsetp = malloc(fdmasks)) == NULL) { - warnmsg(LOG_ERR, __func__, "malloc"); - exit(1); - } - if ((selectfdp = malloc(fdmasks)) == NULL) { - warnmsg(LOG_ERR, __func__, "malloc"); - exit(1); - } -#endif /* configuration per interface */ if (ifinit()) { @@ -328,18 +296,8 @@ main(int argc, char **argv) fclose(fp); } } -#ifndef HAVE_POLL_H - memset(fdsetp, 0, fdmasks); - FD_SET(s, fdsetp); - FD_SET(rtsock, fdsetp); -#endif while (1) { /* main loop */ int e; - -#ifndef HAVE_POLL_H - memcpy(selectfdp, fdsetp, fdmasks); -#endif - #ifndef SMALL if (do_dump) { /* SIGUSR1 */ do_dump = 0; @@ -364,11 +322,7 @@ main(int argc, char **argv) if (ifi == NULL) break; } -#ifdef HAVE_POLL_H e = poll(set, 2, timeout ? (timeout->tv_sec * 1000 + timeout->tv_nsec / 1000 / 1000) : INFTIM); -#else - e = select(maxfd + 1, selectfdp, NULL, NULL, timeout); -#endif if (e < 1) { if (e < 0 && errno != EINTR) { warnmsg(LOG_ERR, __func__, "select: %s", @@ -378,17 +332,9 @@ main(int argc, char **argv) } /* packet reception */ -#ifdef HAVE_POLL_H if (set[1].revents & POLLIN) -#else - if (FD_ISSET(rtsock, selectfdp)) -#endif rtsock_input(rtsock); -#ifdef HAVE_POLL_H if (set[0].revents & POLLIN) -#else - if (FD_ISSET(s, selectfdp)) -#endif rtsol_input(s); } /* NOTREACHED */