projects
/
icmpmonitor
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
d283bb6
)
Updated timeval_diff() to calculate a full difference.
author
Aaron Taylor
<ataylor@subgeniuskitty.com>
Mon, 7 Oct 2019 11:19:28 +0000
(
04:19
-0700)
committer
Aaron Taylor
<ataylor@subgeniuskitty.com>
Mon, 7 Oct 2019 11:19:28 +0000
(
04:19
-0700)
icmpmonitor.c
patch
|
blob
|
blame
|
history
diff --git
a/icmpmonitor.c
b/icmpmonitor.c
index
efa6d71
..
6bc2006
100644
(file)
--- a/
icmpmonitor.c
+++ b/
icmpmonitor.c
@@
-100,12
+100,16
@@
checksum(const uint16_t * data)
}
/*
}
/*
- * Calculate difference
between two timeval structs to within one second
.
+ * Calculate difference
(a-b) between two timeval structs
.
*/
void
timeval_diff(struct timeval * a, const struct timeval * b)
{
*/
void
timeval_diff(struct timeval * a, const struct timeval * b)
{
- assert(a->tv_sec >= b->tv_sec);
+ if (a->tv_usec < b->tv_usec) {
+ a->tv_sec--;
+ a->tv_usec += 1000000;
+ }
+ a->tv_usec -= b->tv_usec;
a->tv_sec -= b->tv_sec;
}
a->tv_sec -= b->tv_sec;
}