From: Miroslav Lichvar Date: Wed, 2 Dec 2015 17:21:07 +0000 (+0100) Subject: client: print invalid intervals as dash X-Git-Tag: 2.3-pre1~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=302abf848071c5c0af8b0702ebbacaee6eaaa8e8;p=thirdparty%2Fchrony.git client: print invalid intervals as dash Instead of printing some large arbitrary values use dash in the LastRx column of the sources output and the Last/Int columns in the clients output when no sample or hit is recorded. --- diff --git a/client.c b/client.c index f8f2ecfd..25d7c7ad 100644 --- a/client.c +++ b/client.c @@ -1544,7 +1544,10 @@ static void print_seconds(unsigned long s) { unsigned long d; - if (s <= 1024) { + + if (s == (uint32_t)-1) { + printf(" -"); + } else if (s <= 1024) { printf("%4ld", s); } else if (s < 36000) { printf("%3ldm", s / 60); @@ -1644,6 +1647,18 @@ print_signed_freq_ppm(double f) /* ================================================== */ +static void +print_clientlog_interval(int rate) +{ + if (rate >= 127) { + printf(" -"); + } else { + printf("%2d", rate); + } +} + +/* ================================================== */ + static int check_for_verbose_flag(char *line) { @@ -2084,13 +2099,17 @@ process_cmd_clients(char *line) DNS_IPAddress2Name(&ip, hostname, sizeof (hostname)); printf("%-25s", hostname); - printf(" %6"PRIu32" %5"PRIu16" %2d %2d ", - ntohl(client->ntp_hits), ntohs(client->ntp_drops), - client->ntp_interval, client->ntp_timeout_interval); + printf(" %6"PRIu32" %5"PRIu16" ", + ntohl(client->ntp_hits), ntohs(client->ntp_drops)); + print_clientlog_interval(client->ntp_interval); + printf(" "); + print_clientlog_interval(client->ntp_timeout_interval); + printf(" "); print_seconds(ntohl(client->last_ntp_hit_ago)); - printf(" %6"PRIu32" %5"PRIu16" %2d ", - ntohl(client->cmd_hits), ntohs(client->cmd_drops), - client->cmd_interval); + printf(" %6"PRIu32" %5"PRIu16" ", + ntohl(client->cmd_hits), ntohs(client->cmd_drops)); + print_clientlog_interval(client->cmd_interval); + printf(" "); print_seconds(ntohl(client->last_cmd_hit_ago)); printf("\n"); }