Re: [PATCH v1] rust: time: fix as_micros_ceil() to round correctly for negative Delta
Miguel Ojeda <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux |
|---|---|
| Message-ID | <CANiq72mTuwbuSba679a11_ESKz0fbcpvj98S41gyRt1EXOqZxQ@mail.gmail.com> |
On Tue, Jul 14, 2026 at 12:52 AM FUJITA Tomonori <[email protected]> wrote: > > From: FUJITA Tomonori <[email protected]> > > The ceiling-division idiom `(n + d - 1) / d` only produces the > correct result when `n` is non-negative. > > For example, if n = -1000 (exactly -1us), the old code computed (-1000 > + 999) / 1000 == 0 instead of -1. > > For negative n, truncating division already rounds towards positive > infinity, so no bias is needed in that case. > > Fixes: fae0cdc12340 ("rust: time: Introduce Delta type") > Signed-off-by: FUJITA Tomonori <[email protected]> Applied to `rust-fixes` -- thanks everyone! Cc: [email protected] Cheers, Miguel