summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbcook <bcook@openbsd.org>2015-01-04 01:48:49 +0000
committerbcook <bcook@openbsd.org>2015-01-04 01:48:49 +0000
commite3770ba3af6c509ba74b5fdc7da89c9c3f5b75f9 (patch)
tree49506300b4c37dd47232aac1b883f52c90fbec15
parentrename sockaddr_un variables from 'sun' to the more common 'sa'. (diff)
downloadwireguard-openbsd-e3770ba3af6c509ba74b5fdc7da89c9c3f5b75f9.tar.xz
wireguard-openbsd-e3770ba3af6c509ba74b5fdc7da89c9c3f5b75f9.zip
use MAXIMUM as the canonical local MAX macro.
suggested by deraadt@ re: more general MIN/MAX cleanups
-rw-r--r--usr.sbin/ntpd/client.c8
-rw-r--r--usr.sbin/ntpd/ntp.c6
-rw-r--r--usr.sbin/ntpd/ntpd.h4
3 files changed, 8 insertions, 10 deletions
diff --git a/usr.sbin/ntpd/client.c b/usr.sbin/ntpd/client.c
index cca9cbcc54e..02f0e2f2576 100644
--- a/usr.sbin/ntpd/client.c
+++ b/usr.sbin/ntpd/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.94 2015/01/04 01:19:46 bcook Exp $ */
+/* $OpenBSD: client.c,v 1.95 2015/01/04 01:48:49 bcook Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -121,15 +121,13 @@ 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, SCALE_MAX(SETTIME_TIMEOUT,
+ set_next(p, MAXIMUM(SETTIME_TIMEOUT,
scale_interval(INTERVAL_QUERY_AGGRESSIVE)));
return (0);
}
@@ -152,7 +150,7 @@ client_query(struct ntp_peer *p)
if (errno == ECONNREFUSED || errno == ENETUNREACH ||
errno == EHOSTUNREACH || errno == EADDRNOTAVAIL) {
client_nextaddr(p);
- set_next(p, SCALE_MAX(SETTIME_TIMEOUT,
+ set_next(p, MAXIMUM(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 25eabe83ea3..f0cafb37d7e 100644
--- a/usr.sbin/ntpd/ntp.c
+++ b/usr.sbin/ntpd/ntp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntp.c,v 1.123 2015/01/04 01:19:46 bcook Exp $ */
+/* $OpenBSD: ntp.c,v 1.124 2015/01/04 01:48:49 bcook Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -734,15 +734,13 @@ 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(SCALE_MAX(5, interval / 10));
+ r = arc4random_uniform(MAXIMUM(5, interval / 10));
return (interval + r);
}
diff --git a/usr.sbin/ntpd/ntpd.h b/usr.sbin/ntpd/ntpd.h
index 6978ea6fb72..5db89282bce 100644
--- a/usr.sbin/ntpd/ntpd.h
+++ b/usr.sbin/ntpd/ntpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ntpd.h,v 1.112 2015/01/04 01:13:10 bcook Exp $ */
+/* $OpenBSD: ntpd.h,v 1.113 2015/01/04 01:48:49 bcook Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -33,6 +33,8 @@
#include "ntp.h"
#include <imsg.h>
+#define MAXIMUM(a, b) ((a) > (b) ? (a) : (b))
+
#define NTPD_USER "_ntp"
#define CONFFILE "/etc/ntpd.conf"
#define DRIFTFILE "/var/db/ntpd.drift"