On Tue, Jan 07, 2020 at 10:21:33PM +0200, Artturi Alm wrote:
> Hi,
>
> been there unused since import, and counting accepts+rejects has been enough,
> so here's a diff for cleaning it away.
Assuming that `attempts = accepts + rejects` was intended, i.e.,
while (accepts < MAX_QUERIES && ++attempts < 2 * MAX_QUERIES) {
the second condition is redundant, as `attempts >= 2 * MAX_QUERIES`
means that one of `accepts` or `rejects` must have reached MAX_QUERIES
as well and one of the other termination conditions would have been hit.
ok tb
I'll commit this tomorrow if no-one beats me to it.
>
> -Artturi
>
>
> diff --git a/usr.sbin/rdate/ntp.c b/usr.sbin/rdate/ntp.c
> index d48b6cae19e..92cb4c70fcb 100644
> --- a/usr.sbin/rdate/ntp.c
> +++ b/usr.sbin/rdate/ntp.c
> @@ -177,7 +177,7 @@ ntp_client(const char *hostname, int family, struct
> timeval *new,
> int
> sync_ntp(int fd, const struct sockaddr *peer, double *offset, double *error)
> {
> - int attempts = 0, accepts = 0, rejects = 0;
> + int accepts = 0, rejects = 0;
> int delay = MAX_DELAY, ret;
> double deadline;
> double a, b, x, y;
> @@ -193,7 +193,7 @@ sync_ntp(int fd, const struct sockaddr *peer, double
> *offset, double *error)
> return (-1);
> }
>
> - while (accepts < MAX_QUERIES && attempts < 2 * MAX_QUERIES) {
> + while (accepts < MAX_QUERIES) {
> memset(&data, 0, sizeof(data));
>
> if (current_time(JAN_1970) > deadline) {
>