y2038: alarm: fix half-second cut-off

Changing alarm_itimer accidentally broke the logic for arithmetic
rounding of half seconds in the return code.

Change it to a constant based on NSEC_PER_SEC, as suggested by
Ben Hutchings.

Fixes: bd40a17576 ("y2038: itimer: change implementation to timespec64")
Reported-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Arnd Bergmann 2019-11-25 21:25:46 +01:00
parent af3784689e
commit b111df8447

View File

@ -297,7 +297,7 @@ static unsigned int alarm_setitimer(unsigned int seconds)
* better return too much than too little anyway
*/
if ((!it_old.it_value.tv_sec && it_old.it_value.tv_nsec) ||
it_old.it_value.tv_nsec >= 500000)
it_old.it_value.tv_nsec >= (NSEC_PER_SEC / 2))
it_old.it_value.tv_sec++;
return it_old.it_value.tv_sec;