On Wed, Feb 25, 2026 at 11:49 AM Martin Kletzander <[email protected]> wrote: > > On Thu, Feb 19, 2026 at 01:54:09PM -0500, John Snow 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]> > >--- > > 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..b2e5441079d 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 Self::PERIOD_1SEC.checked_div(period) { > >+ Some(value) => value, > >+ None => 0, > > This looks like unwrap_or_default: >
unwrap_or_default is not stable in const contexts so won't compile. > > in case you want to make it shorter O:-) > > > } > > } > > > >-- > >2.53.0 > > > > -- Manos Pitsidianakis Emulation and Virtualization Engineer at Linaro Ltd
