Use int32_t for temporary variables (instead of long), that is the same

type as we get the data passed from the kernel. This avoids (missing)
sign extension bugs on LP64 systems and partly takes care of PR 15677.

We now print this values as negative seconds - still wrong, but that
probably is due to the simple way this values are acumulated in the
scheduler, causing negative times when ntpd steps time backwards.
This commit is contained in:
martin 2002-02-21 19:31:03 +00:00
parent b6ad50f62e
commit f95cd5a968

View File

@ -1,4 +1,4 @@
/* $NetBSD: print.c,v 1.70 2002/01/21 23:01:55 jdolecek Exp $ */ /* $NetBSD: print.c,v 1.71 2002/02/21 19:31:03 martin Exp $ */
/* /*
* Copyright (c) 2000 The NetBSD Foundation, Inc. * Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -74,7 +74,7 @@
#if 0 #if 0
static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94";
#else #else
__RCSID("$NetBSD: print.c,v 1.70 2002/01/21 23:01:55 jdolecek Exp $"); __RCSID("$NetBSD: print.c,v 1.71 2002/02/21 19:31:03 martin Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -728,8 +728,8 @@ cputime(k, ve, mode)
int mode; int mode;
{ {
VAR *v; VAR *v;
long secs; int32_t secs;
long psecs; /* "parts" of a second. first micro, then centi */ int32_t psecs; /* "parts" of a second. first micro, then centi */
int fmtlen; int fmtlen;
v = ve->var; v = ve->var;
@ -772,8 +772,8 @@ cputime(k, ve, mode)
v->width = fmtlen; v->width = fmtlen;
} }
} else { } else {
printf("%*ld:%02ld.%02ld", v->width - 6, secs / SECSPERMIN, printf("%*ld:%02ld.%02ld", v->width - 6, (long)(secs / SECSPERMIN),
secs % SECSPERMIN, psecs); (long)(secs % SECSPERMIN), (long)psecs);
} }
} }