diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-11 21:57:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-11 21:57:37 +0000 |
commit | 719fb963b47d487112879ff2cb9d10cff88b84f5 (patch) | |
tree | 52f3b24fa1c69251ba451fc28d6dfd3cde250ed3 /src/util/time.c | |
parent | ac5f48c0d9c409e3cb7400b9650dc5994cdc59ae (diff) | |
download | gnunet-719fb963b47d487112879ff2cb9d10cff88b84f5.tar.gz gnunet-719fb963b47d487112879ff2cb9d10cff88b84f5.zip |
use constants instead of casting -1
Diffstat (limited to 'src/util/time.c')
-rw-r--r-- | src/util/time.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/util/time.c b/src/util/time.c index 3d53e0af2..6a5a314da 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -84,7 +84,7 @@ GNUNET_TIME_relative_get_unit () | |||
84 | struct GNUNET_TIME_Relative | 84 | struct GNUNET_TIME_Relative |
85 | GNUNET_TIME_relative_get_forever () | 85 | GNUNET_TIME_relative_get_forever () |
86 | { | 86 | { |
87 | static struct GNUNET_TIME_Relative forever = { (uint64_t) - 1LL }; | 87 | static struct GNUNET_TIME_Relative forever = { UINT64_MAX }; |
88 | return forever; | 88 | return forever; |
89 | } | 89 | } |
90 | 90 | ||
@@ -94,7 +94,7 @@ GNUNET_TIME_relative_get_forever () | |||
94 | struct GNUNET_TIME_Absolute | 94 | struct GNUNET_TIME_Absolute |
95 | GNUNET_TIME_absolute_get_forever () | 95 | GNUNET_TIME_absolute_get_forever () |
96 | { | 96 | { |
97 | static struct GNUNET_TIME_Absolute forever = { (uint64_t) - 1LL }; | 97 | static struct GNUNET_TIME_Absolute forever = { UINT64_MAX }; |
98 | return forever; | 98 | return forever; |
99 | } | 99 | } |
100 | 100 | ||
@@ -108,7 +108,7 @@ struct GNUNET_TIME_Absolute | |||
108 | GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) | 108 | GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel) |
109 | { | 109 | { |
110 | struct GNUNET_TIME_Absolute ret; | 110 | struct GNUNET_TIME_Absolute ret; |
111 | if (rel.value == (uint64_t) - 1LL) | 111 | if (rel.value == UINT64_MAX) |
112 | return GNUNET_TIME_absolute_get_forever (); | 112 | return GNUNET_TIME_absolute_get_forever (); |
113 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 113 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
114 | if (rel.value + now.value < rel.value) | 114 | if (rel.value + now.value < rel.value) |
@@ -196,7 +196,7 @@ struct GNUNET_TIME_Relative | |||
196 | GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) | 196 | GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future) |
197 | { | 197 | { |
198 | struct GNUNET_TIME_Relative ret; | 198 | struct GNUNET_TIME_Relative ret; |
199 | if (future.value == (uint64_t) - 1LL) | 199 | if (future.value == UINT64_MAX) |
200 | return GNUNET_TIME_relative_get_forever (); | 200 | return GNUNET_TIME_relative_get_forever (); |
201 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); | 201 | struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); |
202 | if (now.value > future.value) | 202 | if (now.value > future.value) |
@@ -217,7 +217,7 @@ GNUNET_TIME_absolute_get_difference (struct GNUNET_TIME_Absolute start, | |||
217 | struct GNUNET_TIME_Absolute end) | 217 | struct GNUNET_TIME_Absolute end) |
218 | { | 218 | { |
219 | struct GNUNET_TIME_Relative ret; | 219 | struct GNUNET_TIME_Relative ret; |
220 | if (end.value == (uint64_t) - 1LL) | 220 | if (end.value == UINT64_MAX) |
221 | return GNUNET_TIME_relative_get_forever (); | 221 | return GNUNET_TIME_relative_get_forever (); |
222 | if (end.value < start.value) | 222 | if (end.value < start.value) |
223 | return GNUNET_TIME_relative_get_zero (); | 223 | return GNUNET_TIME_relative_get_zero (); |
@@ -238,7 +238,7 @@ GNUNET_TIME_absolute_get_duration (struct GNUNET_TIME_Absolute hence) | |||
238 | struct GNUNET_TIME_Relative ret; | 238 | struct GNUNET_TIME_Relative ret; |
239 | 239 | ||
240 | now = GNUNET_TIME_absolute_get (); | 240 | now = GNUNET_TIME_absolute_get (); |
241 | GNUNET_assert (hence.value != (uint64_t) - 1LL); | 241 | GNUNET_assert (hence.value != UINT64_MAX); |
242 | if (hence.value > now.value) | 242 | if (hence.value > now.value) |
243 | return GNUNET_TIME_relative_get_zero (); | 243 | return GNUNET_TIME_relative_get_zero (); |
244 | ret.value = now.value - hence.value; | 244 | ret.value = now.value - hence.value; |
@@ -258,8 +258,8 @@ GNUNET_TIME_absolute_add (struct GNUNET_TIME_Absolute start, | |||
258 | { | 258 | { |
259 | struct GNUNET_TIME_Absolute ret; | 259 | struct GNUNET_TIME_Absolute ret; |
260 | 260 | ||
261 | if ((start.value == (uint64_t) - 1LL) || | 261 | if ((start.value == UINT64_MAX) || |
262 | (duration.value == (uint64_t) - 1LL)) | 262 | (duration.value == UINT64_MAX)) |
263 | return GNUNET_TIME_absolute_get_forever (); | 263 | return GNUNET_TIME_absolute_get_forever (); |
264 | if (start.value + duration.value < start.value) | 264 | if (start.value + duration.value < start.value) |
265 | { | 265 | { |
@@ -382,7 +382,7 @@ GNUNET_TIME_relative_add (struct GNUNET_TIME_Relative a1, | |||
382 | { | 382 | { |
383 | struct GNUNET_TIME_Relative ret; | 383 | struct GNUNET_TIME_Relative ret; |
384 | 384 | ||
385 | if ((a1.value == (uint64_t) - 1LL) || (a2.value == (uint64_t) - 1LL)) | 385 | if ((a1.value == UINT64_MAX) || (a2.value == UINT64_MAX)) |
386 | return GNUNET_TIME_relative_get_forever (); | 386 | return GNUNET_TIME_relative_get_forever (); |
387 | if (a1.value + a2.value < a1.value) | 387 | if (a1.value + a2.value < a1.value) |
388 | { | 388 | { |
@@ -409,7 +409,7 @@ GNUNET_TIME_relative_subtract (struct GNUNET_TIME_Relative a1, | |||
409 | 409 | ||
410 | if (a2.value >= a1.value) | 410 | if (a2.value >= a1.value) |
411 | return GNUNET_TIME_relative_get_zero (); | 411 | return GNUNET_TIME_relative_get_zero (); |
412 | if (a1.value == (uint64_t) - 1LL) | 412 | if (a1.value == UINT64_MAX) |
413 | return GNUNET_TIME_relative_get_forever (); | 413 | return GNUNET_TIME_relative_get_forever (); |
414 | ret.value = a1.value - a2.value; | 414 | ret.value = a1.value - a2.value; |
415 | return ret; | 415 | return ret; |