mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: jstultz@google.com, tglx@kernel.org, sboyd@kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kunit: time: use is_leap_year() helper
Date: Fri, 30 Jan 2026 15:11:13 +0000	[thread overview]
Message-ID: <ebff4525-b25d-477b-9d79-d32d2b7829a7@sirena.org.uk> (raw)
In-Reply-To: <20260123080940.335474-1-ruanjinjie@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  parent reply	other threads:[~2026-01-30 15:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-23  8:09 Jinjie Ruan
2026-01-26 15:22 ` [tip: timers/core] time/kunit: Use " tip-bot2 for Jinjie Ruan
2026-01-30 15:11 ` Mark Brown [this message]
2026-01-30 19:39   ` [PATCH] kunit: time: use " Mark Brown
2026-01-30 21:13     ` Thomas Gleixner
2026-01-31 13:31       ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ebff4525-b25d-477b-9d79-d32d2b7829a7@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=jstultz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ruanjinjie@huawei.com \
    --cc=sboyd@kernel.org \
    --cc=tglx@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®