Skip to content

Commit 2498933

Browse files
broonieThomas Gleixner
authored andcommitted
time/kunit: Document handling of negative years of is_leap()
The code local is_leap() helper was tried to be replaced by the RTC is_leap_year() function. Unfortunately the two aren't exactly equivalent, as the kunit variant uses a signed value for the year and the RTC an unsigned one. Since the KUnit tests cover a 16000 year range around the epoch they use year values that are very comfortably negative and hence get mishandled when passed into is_leap_year(). The change was reverted, so add a comment which prevents further attempts to do so. [ tglx: Adapted to the revert ] Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Thomas Gleixner <tglx@kernel.org> Link: https://patch.msgid.link/20260130-kunit-fix-leap-year-v1-1-92ddf55dffd7@kernel.org
1 parent 5653467 commit 2498933

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

kernel/time/time_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include <linux/time.h>
55

66
/*
7-
* Traditional implementation of leap year evaluation.
7+
* Traditional implementation of leap year evaluation, but note that long
8+
* is a signed type and the tests do cover negative year values. So this
9+
* can't use the is_leap_year() helper from rtc.h.
810
*/
911
static bool is_leap(long year)
1012
{

0 commit comments

Comments
 (0)