diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-26 12:27:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-26 12:27:28 +0000 |
commit | 65a922f1144a89ad9aa95a29899fc3338ad8a35a (patch) | |
tree | f39ae23be05b5da4ba0b122904aa1d35a481f753 /src/util/time.c | |
parent | 874f5684e15a99d6ed4316088d33dca55f484c33 (diff) | |
download | gnunet-65a922f1144a89ad9aa95a29899fc3338ad8a35a.tar.gz gnunet-65a922f1144a89ad9aa95a29899fc3338ad8a35a.zip |
change time multiplication/division API to long long to avoid accidental range reduction
Diffstat (limited to 'src/util/time.c')
-rw-r--r-- | src/util/time.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util/time.c b/src/util/time.c index 91bbbf72a..eb168d531 100644 --- a/src/util/time.c +++ b/src/util/time.c | |||
@@ -427,7 +427,7 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start, | |||
427 | */ | 427 | */ |
428 | struct GNUNET_TIME_Relative | 428 | struct GNUNET_TIME_Relative |
429 | GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, | 429 | GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, |
430 | unsigned int factor) | 430 | unsigned long long factor) |
431 | { | 431 | { |
432 | struct GNUNET_TIME_Relative ret; | 432 | struct GNUNET_TIME_Relative ret; |
433 | 433 | ||
@@ -435,7 +435,7 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, | |||
435 | return GNUNET_TIME_UNIT_ZERO; | 435 | return GNUNET_TIME_UNIT_ZERO; |
436 | if (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) | 436 | if (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us) |
437 | return GNUNET_TIME_UNIT_FOREVER_REL; | 437 | return GNUNET_TIME_UNIT_FOREVER_REL; |
438 | ret.rel_value_us = rel.rel_value_us * (unsigned long long) factor; | 438 | ret.rel_value_us = rel.rel_value_us * factor; |
439 | if (ret.rel_value_us / factor != rel.rel_value_us) | 439 | if (ret.rel_value_us / factor != rel.rel_value_us) |
440 | { | 440 | { |
441 | GNUNET_break (0); | 441 | GNUNET_break (0); |
@@ -454,14 +454,14 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel, | |||
454 | */ | 454 | */ |
455 | struct GNUNET_TIME_Relative | 455 | struct GNUNET_TIME_Relative |
456 | GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, | 456 | GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel, |
457 | unsigned int factor) | 457 | unsigned long long factor) |
458 | { | 458 | { |
459 | struct GNUNET_TIME_Relative ret; | 459 | struct GNUNET_TIME_Relative ret; |
460 | 460 | ||
461 | if ((0 == factor) || | 461 | if ((0 == factor) || |
462 | (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)) | 462 | (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)) |
463 | return GNUNET_TIME_UNIT_FOREVER_REL; | 463 | return GNUNET_TIME_UNIT_FOREVER_REL; |
464 | ret.rel_value_us = rel.rel_value_us / (unsigned long long) factor; | 464 | ret.rel_value_us = rel.rel_value_us / factor; |
465 | return ret; | 465 | return ret; |
466 | } | 466 | } |
467 | 467 | ||