dovecot: utc_mktime() was broken with 32bit time_t. Also don't t...
dovecot at dovecot.org
dovecot at dovecot.org
Sun Oct 21 04:49:49 EEST 2007
details: http://hg.dovecot.org/dovecot/rev/4fb613eb8ce9
changeset: 6584:4fb613eb8ce9
user: Timo Sirainen <tss at iki.fi>
date: Sun Oct 21 04:49:45 2007 +0300
description:
utc_mktime() was broken with 32bit time_t. Also don't try to optimize away
the seconds, it doesn't really help and it makes the lowest time_t values
unusable.
diffstat:
1 file changed, 4 insertions(+), 12 deletions(-)
src/lib/utc-mktime.c | 16 ++++------------
diffs (38 lines):
diff -r 104a8929ef7c -r 4fb613eb8ce9 src/lib/utc-mktime.c
--- a/src/lib/utc-mktime.c Sun Oct 21 03:33:21 2007 +0300
+++ b/src/lib/utc-mktime.c Sun Oct 21 04:49:45 2007 +0300
@@ -23,8 +23,7 @@ time_t utc_mktime(const struct tm *tm)
time_t utc_mktime(const struct tm *tm)
{
const struct tm *try_tm;
- struct tm nosec_tm;
- time_t t;
+ int t;
int bits, dir;
/* we'll do a binary search across the entire valid time_t range.
@@ -33,21 +32,14 @@ time_t utc_mktime(const struct tm *tm)
values, -1 is returned. */
#ifdef TIME_T_SIGNED
t = 0;
- bits = TIME_T_MAX_BITS - 1;
#else
t = 1 << (TIME_T_MAX_BITS - 1);
- bits = TIME_T_MAX_BITS - 2;
#endif
-
- /* we can ignore seconds in checks and add them back when returning */
- nosec_tm = *tm;
- nosec_tm.tm_sec = 0;
-
- for (;; bits--) {
+ for (bits = TIME_T_MAX_BITS - 2;; bits--) {
try_tm = gmtime(&t);
- dir = tm_cmp(&nosec_tm, try_tm);
+ dir = tm_cmp(tm, try_tm);
if (dir == 0)
- return t + tm->tm_sec;
+ return t;
if (bits < 0)
break;
More information about the dovecot-cvs
mailing list