Remove harmful casts in gmtime_r()

In case time_t is long, then the cast to long is a nop.  In case time_t
is __int_least64_t, then the cast to long may truncate the value before
the division.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
This commit is contained in:
Sebastian Huber 2017-09-07 15:01:47 +02:00
parent f9205f1d47
commit ad45b86533
1 changed files with 2 additions and 2 deletions

View File

@ -56,8 +56,8 @@ _DEFUN (gmtime_r, (tim_p, res),
unsigned erayear, yearday, month, day;
unsigned long eraday;
days = ((long)lcltime) / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
rem = ((long)lcltime) % SECSPERDAY;
days = lcltime / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
rem = lcltime % SECSPERDAY;
if (rem < 0)
{
rem += SECSPERDAY;