aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/nstime.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-10-07 15:48:46 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-10-09 22:59:26 +0000
commitb07226775e920b6e2fc39e98d9f92faa5f35b017 (patch)
treebcb2c21e7c0a871fec6f746db7a4f3518316af72 /wsutil/nstime.c
parent5bdfb5c36be80511bf814fd6e999985edb75d81d (diff)
nstime: fix -Wshift-negative-value
Even if the result of the negative shift (in TIME_T_MIN) is not used because the signedness check happens before, it still causes a compile-time warning. Fix this by shifting on an unsigned value, then truncate by casting it. While at it, remove a "fix for broken SCO compiler", it might not apply to us (fingers crossed). Change-Id: Id9603149d8063e9eaaa65cf028323f10e60a6c42 Reviewed-on: https://code.wireshark.org/review/10862 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'wsutil/nstime.c')
-rw-r--r--wsutil/nstime.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/wsutil/nstime.c b/wsutil/nstime.c
index e9ad23c289..e7ef252dda 100644
--- a/wsutil/nstime.c
+++ b/wsutil/nstime.c
@@ -220,7 +220,7 @@ double nstime_to_sec(const nstime_t *nstime)
#ifndef TIME_T_MIN
#define TIME_T_MIN ((time_t) ((time_t)0 < (time_t) -1 ? (time_t) 0 \
- : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)))
+ : (time_t) (~0ULL << (sizeof (time_t) * CHAR_BIT - 1))))
#endif
#ifndef TIME_T_MAX
#define TIME_T_MAX ((time_t) (~ (time_t) 0 - TIME_T_MIN))
@@ -230,10 +230,6 @@ static gboolean
common_filetime_to_nstime(nstime_t *nstime, guint64 ftsecs, int nsecs)
{
gint64 secs;
- /* The next two lines are a fix needed for the
- broken SCO compiler. JRA. */
- time_t l_time_min = TIME_T_MIN;
- time_t l_time_max = TIME_T_MAX;
/*
* Shift the seconds from the Windows epoch to the UN*X epoch.
@@ -246,7 +242,7 @@ common_filetime_to_nstime(nstime_t *nstime, guint64 ftsecs, int nsecs)
*/
secs = (gint64)ftsecs - TIME_FIXUP_CONSTANT;
- if (!(l_time_min <= secs && secs <= l_time_max)) {
+ if (!(TIME_T_MIN <= secs && secs <= TIME_T_MAX)) {
/* The result won't fit in a time_t */
return FALSE;
}