diff options
author | Guy Harris <guy@alum.mit.edu> | 2014-05-23 16:40:56 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2014-05-23 23:41:37 +0000 |
commit | d5d0f51909047f0b38a867792232e72cf1553d88 (patch) | |
tree | 18d3deb570f478162d3953939b580466e49d0a12 /wsutil | |
parent | b056e18108196f3b78532863bc50d1920fd1d1cb (diff) | |
download | wireshark-d5d0f51909047f0b38a867792232e72cf1553d88.tar.gz |
More handling of missing time stamps.
Make nstime_cmp() handle "unset" time stamps (they're equal to other
"unset" time stamps, and less than all other time stamps), use it in
reordercap, and "unset" the time stamp if it's absent.
Also, nstime_cmp() does not modify its argument, so make it const.
Change-Id: I016dab5fefaf4696e78cbd8c6dd3395808e54369
Reviewed-on: https://code.wireshark.org/review/1769
Reviewed-by: Guy Harris <guy@alum.mit.edu>
(cherry picked from commit d470a468a63a081688ddc2c6d125e4e2edafecfc)
Reviewed-on: https://code.wireshark.org/review/1770
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/nstime.c | 13 | ||||
-rw-r--r-- | wsutil/nstime.h | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/wsutil/nstime.c b/wsutil/nstime.c index c53e67fffd..bb4ba5e6f6 100644 --- a/wsutil/nstime.c +++ b/wsutil/nstime.c @@ -59,7 +59,7 @@ void nstime_set_unset(nstime_t *nstime) } /* is the given nstime_t currently (0,maxint)? */ -gboolean nstime_is_unset(nstime_t *nstime) +gboolean nstime_is_unset(const nstime_t *nstime) { if(nstime->secs == 0 && nstime->nsecs == G_MAXINT) { return TRUE; @@ -148,6 +148,17 @@ void nstime_sum(nstime_t *sum, const nstime_t *a, const nstime_t *b) int nstime_cmp (const nstime_t *a, const nstime_t *b ) { + if (G_UNLIKELY(nstime_is_unset(a))) { + if (G_UNLIKELY(nstime_is_unset(b))) { + return 0; /* "no time stamp" is "equal" to "no time stamp" */ + } else { + return -1; /* and is less than all time stamps */ + } + } else { + if (G_UNLIKELY(nstime_is_unset(b))) { + return 1; + } + } if (a->secs == b->secs) { return a->nsecs - b->nsecs; } else { diff --git a/wsutil/nstime.h b/wsutil/nstime.h index 3222ed18ba..a74457c8b6 100644 --- a/wsutil/nstime.h +++ b/wsutil/nstime.h @@ -56,7 +56,7 @@ WS_DLL_PUBLIC gboolean nstime_is_zero(nstime_t *nstime); WS_DLL_PUBLIC void nstime_set_unset(nstime_t *nstime); /* is the given nstime_t currently (0,maxint)? */ -WS_DLL_PUBLIC gboolean nstime_is_unset(nstime_t *nstime); +WS_DLL_PUBLIC gboolean nstime_is_unset(const nstime_t *nstime); /** duplicate the current time * |