Re: [PATCH] kunit: time: use is_leap_year() helper

From: Mark Brown

Date: Fri Jan 30 2026 - 10:11:25 EST


On Fri, Jan 23, 2026 at 04:09:40PM +0800, Jinjie Ruan wrote:

> Use the is_leap_year() helper from rtc.h instead of
> writing it by hand

This patch introduces a regression:

[14:26:27] =============== time_test_cases (1 subtest) ================
[14:26:27] # time64_to_tm_test_date_range: ASSERTION FAILED at kernel/time/time_test.c:73
[14:26:27] Expected month - 1 == result.tm_mon, but
[14:26:27] month - 1 == 2 (0x2)
[14:26:27] result.tm_mon == 1 (0x1)
[14:26:27] -77996/03/01 (59) : -29206923
[14:26:27] # time64_to_tm_test_date_range.speed: slow
[14:26:27] [FAILED] time64_to_tm_test_date_range
[14:26:27] # module: time_test
[14:26:27] ================= [FAILED] time_test_cases =================
[14:26:27] ============================================================
[14:26:27] Testing complete. Ran 1 tests: failed: 1

> -/*
> - * Traditional implementation of leap year evaluation.
> - */
> -static bool is_leap(long year)
> -{
> - return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
> -}

gets replaced by is_leap_year() which is:

static inline bool is_leap_year(unsigned int year)
{
return (!(year % 4) && (year % 100)) || !(year % 400);
}

which looks like it ought to work out the same from a quick look
although it is written less clearly. I'll look properly later when I've
got through the rest of the pile of regressions.

Attachment: signature.asc
Description: PGP signature