diff options
author | Brent Cook <bcook@cvs.openbsd.org> | 2015-01-04 01:19:47 +0000 |
---|---|---|
committer | Brent Cook <bcook@cvs.openbsd.org> | 2015-01-04 01:19:47 +0000 |
commit | 5516b38d65c744b087257e6d998e12c311f42026 (patch) | |
tree | 740dd8e94ff9a7af5d051351f03a3fc08b1f0bd4 /usr.sbin/ntpd | |
parent | 62033321d3b41891c8d37cf599f335a317b1015b (diff) |
don't rely on sys/param.h having a MAX macro.
Switch to local definitions where MAX is needed.
discussed with deraadt@
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r-- | usr.sbin/ntpd/client.c | 8 | ||||
-rw-r--r-- | usr.sbin/ntpd/ntp.c | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c index 65eae36dd3a..cca9cbcc54e 100644 --- a/usr.sbin/ntpd/client.c +++ b/usr.sbin/ntpd/client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: client.c,v 1.93 2014/05/12 20:50:46 miod Exp $ */ +/* $OpenBSD: client.c,v 1.94 2015/01/04 01:19:46 bcook Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -121,13 +121,15 @@ client_nextaddr(struct ntp_peer *p) return (0); } +#define SCALE_MAX(a, b) ((a) > (b) ? (a) : (b)) + int client_query(struct ntp_peer *p) { int val; if (p->addr == NULL && client_nextaddr(p) == -1) { - set_next(p, MAX(SETTIME_TIMEOUT, + set_next(p, SCALE_MAX(SETTIME_TIMEOUT, scale_interval(INTERVAL_QUERY_AGGRESSIVE))); return (0); } @@ -150,7 +152,7 @@ client_query(struct ntp_peer *p) if (errno == ECONNREFUSED || errno == ENETUNREACH || errno == EHOSTUNREACH || errno == EADDRNOTAVAIL) { client_nextaddr(p); - set_next(p, MAX(SETTIME_TIMEOUT, + set_next(p, SCALE_MAX(SETTIME_TIMEOUT, scale_interval(INTERVAL_QUERY_AGGRESSIVE))); return (-1); } else diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 8b9ff63ee40..25eabe83ea3 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.122 2015/01/04 01:16:10 bcook Exp $ */ +/* $OpenBSD: ntp.c,v 1.123 2015/01/04 01:19:46 bcook Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -734,13 +734,15 @@ update_scale(double offset) conf->scale = QSCALE_OFF_MAX / offset; } +#define SCALE_MAX(a, b) ((a) > (b) ? (a) : (b)) + time_t scale_interval(time_t requested) { time_t interval, r; interval = requested * conf->scale; - r = arc4random_uniform(MAX(5, interval / 10)); + r = arc4random_uniform(SCALE_MAX(5, interval / 10)); return (interval + r); } |