summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2013-07-05 20:30:57 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2013-07-05 20:30:57 +0000
commit14f6e60349818c5de1fa4174240d8c5e86f3a3c1 (patch)
treed7ef4c302a485382ceffcdb979fed5d47ed764d6 /sys
parentc7db72065086f0d31f99f199a9c3807aafe684ab (diff)
Avoid truncation when calculating clock gain/loss
ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc/sparc/clock.c9
-rw-r--r--sys/arch/sparc64/sparc64/clock.c9
2 files changed, 10 insertions, 8 deletions
diff --git a/sys/arch/sparc/sparc/clock.c b/sys/arch/sparc/sparc/clock.c
index 56eee62e412..bf596958c5a 100644
--- a/sys/arch/sparc/sparc/clock.c
+++ b/sys/arch/sparc/sparc/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.27 2012/11/05 13:20:16 miod Exp $ */
+/* $OpenBSD: clock.c,v 1.28 2013/07/05 20:30:56 guenther Exp $ */
/* $NetBSD: clock.c,v 1.52 1997/05/24 20:16:05 pk Exp $ */
/*
@@ -919,7 +919,7 @@ forward:
if (!badbase)
resettodr();
} else {
- int deltat = ts.tv_sec - base;
+ time_t deltat = ts.tv_sec - base;
tc_setclock(&ts);
if (deltat < 0)
@@ -928,8 +928,9 @@ forward:
return;
#ifndef SMALL_KERNEL
- printf("WARNING: clock %s %d days",
- ts.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
+ printf("WARNING: clock %s %lld days",
+ ts.tv_sec < base ? "lost" : "gained",
+ (long long)(deltat / SECDAY));
bad = "";
#endif
}
diff --git a/sys/arch/sparc64/sparc64/clock.c b/sys/arch/sparc64/sparc64/clock.c
index a7bac04c4d2..5b28c377d6d 100644
--- a/sys/arch/sparc64/sparc64/clock.c
+++ b/sys/arch/sparc64/sparc64/clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clock.c,v 1.48 2010/07/07 15:37:22 kettenis Exp $ */
+/* $OpenBSD: clock.c,v 1.49 2013/07/05 20:30:56 guenther Exp $ */
/* $NetBSD: clock.c,v 1.41 2001/07/24 19:29:25 eeh Exp $ */
/*
@@ -931,7 +931,7 @@ inittodr(base)
if (!badbase)
resettodr();
} else {
- int deltat = tv.tv_sec - base;
+ time_t deltat = tv.tv_sec - base;
sparc_clock_time_is_ok = 1;
@@ -939,8 +939,9 @@ inittodr(base)
deltat = -deltat;
if (!(waszero || deltat < 2 * SECDAY)) {
#ifndef SMALL_KERNEL
- printf("WARNING: clock %s %ld days",
- tv.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
+ printf("WARNING: clock %s %lld days",
+ tv.tv_sec < base ? "lost" : "gained",
+ (long long)(deltat / SECDAY));
bad = "";
#endif
}