Re: [PATCH v2] rust: time: fix as_micros_ceil() rounding near i64::MAX

Miguel Ojeda <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux
Message-ID <CANiq72k5uVLXeUurGFE2-Mu=MzTpo0As5hMtMAAd-AjfvkRgXg@mail.gmail.com>
On Fri, Aug 7, 2026 at 3:05 PM FUJITA Tomonori <[email protected]> wrote:
>
> From: FUJITA Tomonori <[email protected]>
>
> The ceiling adjustment used saturating_add(NSEC_PER_USEC - 1) before
> dividing. Once the nanosecond value gets within NSEC_PER_USEC - 1 of
> i64::MAX the addition saturates to i64::MAX, which drops the ceiling
> bias and can yield a result one microsecond too small.
>
> Fixes: fae0cdc12340 ("rust: time: Introduce Delta type")
> Reported-by: Miguel Ojeda <[email protected]>
> Closes: https://lore.kernel.org/rust-for-linux/CANiq72mtS0ABA2JnT5tpz6J9c_mnxY+vyPvghV_ukngWvN8F2w@mail.gmail.com/
> Signed-off-by: FUJITA Tomonori <[email protected]>

Applied to `rust-next` -- thanks everyone!

    Cc: [email protected]

Cheers,
Miguel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.