Browse Source

KNF

OPENBSD_3_6
henning 20 years ago
parent
commit
bc7ac3d288
2 changed files with 12 additions and 21 deletions
  1. +6
    -12
      src/usr.sbin/ntpd/server.c
  2. +6
    -9
      src/usr.sbin/ntpd/util.c

+ 6
- 12
src/usr.sbin/ntpd/server.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: server.c,v 1.3 2004/06/29 18:34:00 alexander Exp $ */
/* $OpenBSD: server.c,v 1.4 2004/07/04 18:07:15 henning Exp $ */
/* /*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -30,7 +30,7 @@
int int
setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt) setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt)
{ {
char ntopbuf[INET6_ADDRSTRLEN];
char ntopbuf[INET6_ADDRSTRLEN];
struct listen_addr *la; struct listen_addr *la;
struct ifaddrs *ifap; struct ifaddrs *ifap;
struct sockaddr *sap; struct sockaddr *sap;
@ -64,29 +64,23 @@ setup_listeners(struct servent *se, struct ntpd_conf *conf, u_int *cnt)
switch (la->sa.ss_family) { switch (la->sa.ss_family) {
case AF_INET: case AF_INET:
if (((struct sockaddr_in *)sap)->sin_port == 0) if (((struct sockaddr_in *)sap)->sin_port == 0)
((struct sockaddr_in *)sap)->sin_port = ((struct sockaddr_in *)sap)->sin_port =
se->s_port; se->s_port;
inet_ntop(AF_INET, inet_ntop(AF_INET,
&((struct sockaddr_in *)sap)->sin_addr,
ntopbuf, sizeof(ntopbuf));
&((struct sockaddr_in *)sap)->sin_addr,
ntopbuf, sizeof(ntopbuf));
break; break;
case AF_INET6: case AF_INET6:
if (((struct sockaddr_in6 *)sap)->sin6_port == 0) if (((struct sockaddr_in6 *)sap)->sin6_port == 0)
((struct sockaddr_in6 *)sap)->sin6_port = ((struct sockaddr_in6 *)sap)->sin6_port =
se->s_port; se->s_port;
inet_ntop(AF_INET6, inet_ntop(AF_INET6,
&((struct sockaddr_in6 *)sap)->sin6_addr,
ntopbuf, sizeof(ntopbuf));
&((struct sockaddr_in6 *)sap)->sin6_addr,
ntopbuf, sizeof(ntopbuf));
break; break;
default: default:
fatalx("king bula sez: af borked"); fatalx("king bula sez: af borked");
} }
log_debug("adding listener on %s", ntopbuf); log_debug("adding listener on %s", ntopbuf);


+ 6
- 9
src/usr.sbin/ntpd/util.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: util.c,v 1.1 2004/07/04 11:01:49 alexander Exp $ */
/* $OpenBSD: util.c,v 1.2 2004/07/04 18:07:15 henning Exp $ */
/* /*
* Copyright (c) 2004 Alexander Guy <alexander.guy@andern.org> * Copyright (c) 2004 Alexander Guy <alexander.guy@andern.org>
@ -23,21 +23,18 @@
double double
gettime(void) gettime(void)
{ {
struct timeval tv;
double ret;
struct timeval tv;
if (gettimeofday(&tv, NULL) == -1) if (gettimeofday(&tv, NULL) == -1)
fatal("gettimeofday"); fatal("gettimeofday");
ret = tv.tv_sec + JAN_1970 + 1.0e-6 * tv.tv_usec;
return (ret);
return (tv.tv_sec + JAN_1970 + 1.0e-6 * tv.tv_usec);
} }
double double
lfp_to_d(struct l_fixedpt lfp) lfp_to_d(struct l_fixedpt lfp)
{ {
double ret;
double ret;
lfp.int_part = ntohl(lfp.int_part); lfp.int_part = ntohl(lfp.int_part);
lfp.fraction = ntohl(lfp.fraction); lfp.fraction = ntohl(lfp.fraction);
@ -50,8 +47,8 @@ lfp_to_d(struct l_fixedpt lfp)
struct l_fixedpt struct l_fixedpt
d_to_lfp(double d) d_to_lfp(double d)
{ {
struct l_fixedpt lfp;
struct l_fixedpt lfp;
lfp.int_part = htonl(d); lfp.int_part = htonl(d);
lfp.fraction = htonl((d - lfp.int_part) * UINT_MAX); lfp.fraction = htonl((d - lfp.int_part) * UINT_MAX);


Loading…
Cancel
Save