Subject: bin/11465: ntpdc -c loopinfo doesn't show negative time_const correctly on alpha
To: None <gnats-bugs@gnats.netbsd.org>
From: None <tsutsui@ceres.dti.ne.jp>
List: netbsd-bugs
Date: 11/10/2000 10:45:20
>Number:         11465
>Category:       bin
>Synopsis:       ntpdc -c loopinfo doesn't show negative time_const correctly on alpha
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 10 10:45:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Izumi Tsutsui
>Release:        NetBSD 1.5_BETA
>Organization:
Izumi Tsutsui	Himeji City, JAPAN
>Environment:
NetBSD/alpha 1.5_BETA on 3000/300

>Description:
If "time_const" value is negative, ntpdc -c loopinfo does not print
it correctly on alpha.

>How-To-Repeat:
% ntpdc
ntpdc> loopinfo oneline
offset 0.007369, frequency 26.980, time_const 4294967284, watchdog 19

In this case, time_const should be -24.

>Fix:
Even though il->compliance is (u_int32), time_const is signed (I think).
So don't cast it to (u_long).

Index: ntpdc_ops.c
===================================================================
RCS file: /cvs/cvsroot/basesrc/dist/ntp/ntpdc/ntpdc_ops.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 ntpdc_ops.c
--- ntpdc_ops.c	2000/03/29 12:38:55	1.1.1.1
+++ ntpdc_ops.c	2000/11/10 18:29:29
@@ -723,10 +723,10 @@
 		NTOHL_FP(&il->drift_comp, &temp2ts);
 
 		(void) fprintf(fp,
-			       "offset %s, frequency %s, time_const %ld, watchdog %ld\n",
+			       "offset %s, frequency %s, time_const %d, watchdog %ld\n",
 			       lfptoa(&tempts, 6),
 			       lfptoa(&temp2ts, 3),
-			       (u_long)ntohl(il->compliance),
+			       (int)ntohl(il->compliance),
 			       (u_long)ntohl(il->watchdog_timer));
 	} else {
 		NTOHL_FP(&il->last_offset, &tempts);
@@ -735,8 +735,8 @@
 		NTOHL_FP(&il->drift_comp, &tempts);
 		(void) fprintf(fp, "frequency:            %s ppm\n",
 			       lfptoa(&tempts, 3));
-		(void) fprintf(fp, "poll adjust:          %ld\n",
-			       (u_long)ntohl(il->compliance));
+		(void) fprintf(fp, "poll adjust:          %d\n",
+			       (int)ntohl(il->compliance));
 		(void) fprintf(fp, "watchdog timer:       %ld s\n",
 			       (u_long)ntohl(il->watchdog_timer));
 	}
>Release-Note:
>Audit-Trail:
>Unformatted: