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:
parent
f9205f1d47
commit
ad45b86533
|
@ -56,8 +56,8 @@ _DEFUN (gmtime_r, (tim_p, res),
|
||||||
unsigned erayear, yearday, month, day;
|
unsigned erayear, yearday, month, day;
|
||||||
unsigned long eraday;
|
unsigned long eraday;
|
||||||
|
|
||||||
days = ((long)lcltime) / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
|
days = lcltime / SECSPERDAY + EPOCH_ADJUSTMENT_DAYS;
|
||||||
rem = ((long)lcltime) % SECSPERDAY;
|
rem = lcltime % SECSPERDAY;
|
||||||
if (rem < 0)
|
if (rem < 0)
|
||||||
{
|
{
|
||||||
rem += SECSPERDAY;
|
rem += SECSPERDAY;
|
||||||
|
|
Loading…
Reference in New Issue