Re: [PATCH v1] rust: time: fix as_micros_ceil() to round correctly for negative Delta

Andreas Hindborg <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux
Message-ID <[email protected]>
"FUJITA Tomonori" <[email protected]> writes:

> 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]>

Acked-by: Andreas Hindborg <[email protected]>

@Miguel, can you take this with rust fixes?

Best regards,
Andreas Hindborg
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.