Module Name:    src
Committed By:   christos
Date:           Sun Aug 21 06:39:09 UTC 2011

Modified Files:
        src/sbin/ping: ping.c

Log Message:
handle the first loop where time == 0.


To generate a diff of this commit:
cvs rdiff -u -r1.96 -r1.97 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.96 src/sbin/ping/ping.c:1.97
--- src/sbin/ping/ping.c:1.96	Sat Aug 20 10:38:09 2011
+++ src/sbin/ping/ping.c	Sun Aug 21 02:39:09 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: ping.c,v 1.96 2011/08/20 14:38:09 christos Exp $	*/
+/*	$NetBSD: ping.c,v 1.97 2011/08/21 06:39:09 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -58,7 +58,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: ping.c,v 1.96 2011/08/20 14:38:09 christos Exp $");
+__RCSID("$NetBSD: ping.c,v 1.97 2011/08/21 06:39:09 christos Exp $");
 #endif
 
 #include <stdio.h>
@@ -1242,6 +1242,8 @@
 diffsec(struct timeval *timenow,
 	struct timeval *then)
 {
+	if (timenow->tv_sec == 0)
+		return -1;
 	return ((int32_t)((uint32_t)timenow->tv_sec - (uint32_t)then->tv_sec)
 	    * 1.0 + (timenow->tv_usec - then->tv_usec)/1000000.0);
 }

Reply via email to