Module Name: src
Committed By: christos
Date: Sat Aug 20 14:38:09 UTC 2011
Modified Files:
src/sbin/ping: ping.c
Log Message:
we need difftime to return a signed result, so clamp the timeval's to
uint32_t but then, return a signed result of their difference.
To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sbin/ping/ping.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/ping/ping.c
diff -u src/sbin/ping/ping.c:1.95 src/sbin/ping/ping.c:1.96
--- src/sbin/ping/ping.c:1.95 Fri Aug 19 04:35:40 2011
+++ src/sbin/ping/ping.c Sat Aug 20 10:38:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: ping.c,v 1.95 2011/08/19 08:35:40 christos Exp $ */
+/* $NetBSD: ping.c,v 1.96 2011/08/20 14:38:09 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -58,7 +58,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: ping.c,v 1.95 2011/08/19 08:35:40 christos Exp $");
+__RCSID("$NetBSD: ping.c,v 1.96 2011/08/20 14:38:09 christos Exp $");
#endif
#include <stdio.h>
@@ -1242,8 +1242,8 @@
diffsec(struct timeval *timenow,
struct timeval *then)
{
- return ((uint32_t)(timenow->tv_sec - then->tv_sec) * 1.0
- + (timenow->tv_usec - then->tv_usec)/1000000.0);
+ return ((int32_t)((uint32_t)timenow->tv_sec - (uint32_t)then->tv_sec)
+ * 1.0 + (timenow->tv_usec - then->tv_usec)/1000000.0);
}