* localtime.c (increment_overflow32): Remove. (daylight) [TZ_TIME_T && !USG_COMPAT]: (altzone) [TZ_TIME_T && !ALTZONE]: Remove no-longer-used macros. (time) [TZ_TIME_T]: Use increment_overflow_iinntt instead of increment_overflow32 to detect overflow. This simplifies the support for AmigaOS. Also, do not look at 'daylight' or 'altzone' as they are not relevant for AmigaOS, and 'daylight' was being misused anyway. --- localtime.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/localtime.c b/localtime.c index 1703d500..f14ee80c 100644 --- a/localtime.c +++ b/localtime.c @@ -1803,21 +1803,6 @@ increment_overflow(int *ip, int j) #endif } -static bool -increment_overflow32(int_fast32_t *const lp, int const m) -{ -#ifdef ckd_add - return ckd_add(lp, *lp, m); -#else - register int_fast32_t const l = *lp; - - if ((l >= 0) ? (m > INT_FAST32_MAX - l) : (m < INT_FAST32_MIN - l)) - return true; - *lp += m; - return false; -#endif -} - static bool increment_overflow_iinntt(iinntt *lp, int m) { @@ -2392,12 +2377,8 @@ posix2time(time_t t) #if TZ_TIME_T # if !USG_COMPAT -# define daylight 0 # define timezone 0 # endif -# if !ALTZONE -# define altzone 0 -# endif /* Convert from the underlying system's time_t to the ersatz time_tz, which is called 'time_t' in this file. Typically, this merely @@ -2415,8 +2396,9 @@ time(time_t *p) { time_t r = sys_time(0); if (r != (time_t) -1) { - int_fast32_t offset = EPOCH_LOCAL ? (daylight ? timezone : altzone) : 0; - if (increment_overflow32(&offset, -EPOCH_OFFSET) + iinntt offset = EPOCH_LOCAL ? timezone : 0; + if (increment_overflow_iinntt(&offset, -EPOCH_OFFSET) + || ! (INT_FAST32_MIN <= offset && offset <= INT_FAST32_MAX) || increment_overflow_time(&r, offset)) { errno = EOVERFLOW; r = -1; -- 2.47.0