From: Kevin McCarthy Date: Thu, 3 Nov 2016 01:54:06 +0000 (-0700) Subject: Attempt to silence a clang range warning. (closes #3891) X-Git-Tag: neomutt-20170225~32^2~87 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85e85255522ea8f334d2682b33c2cec954eca96a;p=neomutt Attempt to silence a clang range warning. (closes #3891) When TM_YEAR_MAX > INT_MAX, clang complains the comparison is always false. Note that this is really a compiler bug, which was fixed by gcc 9 years ago. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12963 Thanks to Vincent Lefèvre for the suggested fix and the gcc bug reference. --- diff --git a/date.c b/date.c index 6fd7eaf93..43fbeced0 100644 --- a/date.c +++ b/date.c @@ -77,8 +77,9 @@ time_t mutt_mktime (struct tm *t, int local) 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; - /* Prevent an integer overflow */ - if (t->tm_year > TM_YEAR_MAX) + /* Prevent an integer overflow. + * The time_t cast is an attempt to silence a clang range warning. */ + if ((time_t)t->tm_year > TM_YEAR_MAX) return TIME_T_MAX; /* Compute the number of days since January 1 in the same year */