On Wed, Feb 18, 2026 at 9:25 PM John Snow <[email protected]> wrote:
>
> When upgrading from Fedora 41 to Fedora 43 for CI tests, clippy begins
> complaining about not using checked_div instead of manually checking
> divisors. Make clippy happy and use checked_div() instead.
>
> Signed-off-by: John Snow <[email protected]>
> ---

Reviewed-by: Manos Pitsidianakis <[email protected]>

>  rust/hw/core/src/qdev.rs | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/rust/hw/core/src/qdev.rs b/rust/hw/core/src/qdev.rs
> index 145e20a984f..c4a7312168f 100644
> --- a/rust/hw/core/src/qdev.rs
> +++ b/rust/hw/core/src/qdev.rs
> @@ -425,18 +425,16 @@ pub const fn period_from_ns(ns: u64) -> u64 {
>      }
>
>      pub const fn period_from_hz(hz: u64) -> u64 {
> -        if hz == 0 {
> -            0
> -        } else {
> -            Self::PERIOD_1SEC / hz
> +        match Self::PERIOD_1SEC.checked_div(hz) {
> +            Some(value) => value,
> +            None => 0,
>          }
>      }
>
>      pub const fn period_to_hz(period: u64) -> u64 {
> -        if period == 0 {
> -            0
> -        } else {
> -            Self::PERIOD_1SEC / period
> +        match period.checked_div(Self::PERIOD_1SEC) {
> +            Some(value) => value,
> +            None => 0,
>          }
>      }
>
> --
> 2.53.0
>

Reply via email to