You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-mail/dovecot/files/dovecot-2.3.13-32-bit-tests...

53 lines
1.9 KiB

https://bugs.gentoo.org/764713
https://github.com/dovecot/core/commit/2cc1feca9087651902a5ea3cda021c8a0b3217ce.patch
From 2cc1feca9087651902a5ea3cda021c8a0b3217ce Mon Sep 17 00:00:00 2001
From: Paul Howarth <paul@city-fan.org>
Date: Mon, 4 Jan 2021 16:31:03 +0000
Subject: [PATCH] lib: Fix timeval_cmp_margin for 32-bit systems
The test suite compares times with seconds values of -INT_MAX and
INT_MAX. The result of this comparison does not fit in a value of
type int and so the test suite fails on 32-bit systems where time_t
is an int. To fix this, calculations on seconds values are done
using long long integers.
Broken by 16ab5542
---
src/lib/time-util.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/lib/time-util.c b/src/lib/time-util.c
index 294bb02310..3f4cd01c9e 100644
--- a/src/lib/time-util.c
+++ b/src/lib/time-util.c
@@ -38,21 +38,23 @@ int timeval_cmp(const struct timeval *tv1, const struct timeval *tv2)
int timeval_cmp_margin(const struct timeval *tv1, const struct timeval *tv2,
unsigned int usec_margin)
{
- long long usecs_diff;
+ long long secs_diff, usecs_diff;
int sec_margin, ret;
if (tv1->tv_sec < tv2->tv_sec) {
sec_margin = ((int)usec_margin / 1000000) + 1;
- if ((tv2->tv_sec - tv1->tv_sec) > sec_margin)
+ secs_diff = (long long)tv2->tv_sec - (long long)tv1->tv_sec;
+ if (secs_diff > sec_margin)
return -1;
- usecs_diff = (tv2->tv_sec - tv1->tv_sec) * 1000000LL +
+ usecs_diff = secs_diff * 1000000LL +
(tv2->tv_usec - tv1->tv_usec);
ret = -1;
} else if (tv1->tv_sec > tv2->tv_sec) {
sec_margin = ((int)usec_margin / 1000000) + 1;
- if ((tv1->tv_sec - tv2->tv_sec) > sec_margin)
+ secs_diff = (long long)tv1->tv_sec - (long long)tv2->tv_sec;
+ if (secs_diff > sec_margin)
return 1;
- usecs_diff = (tv1->tv_sec - tv2->tv_sec) * 1000000LL +
+ usecs_diff = secs_diff * 1000000LL +
(tv1->tv_usec - tv2->tv_usec);
ret = 1;
} else if (tv1->tv_usec < tv2->tv_usec) {