[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANiq72muSdubtAD03SdrbXT4H6ujUba+1YDCtGWA_ERpX35aiA@mail.gmail.com>
Date: Sat, 5 Oct 2024 20:16:32 +0200
From: Miguel Ojeda <miguel.ojeda.sandonis@...il.com>
To: Andrew Lunn <andrew@...n.ch>
Cc: FUJITA Tomonori <fujita.tomonori@...il.com>, netdev@...r.kernel.org,
rust-for-linux@...r.kernel.org, hkallweit1@...il.com, tmgross@...ch.edu,
ojeda@...nel.org, alex.gaynor@...il.com, gary@...yguo.net,
bjorn3_gh@...tonmail.com, benno.lossin@...ton.me, a.hindborg@...sung.com,
aliceryhl@...gle.com, anna-maria@...utronix.de, frederic@...nel.org,
tglx@...utronix.de, arnd@...db.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v2 2/6] rust: time: Introduce Delta type
On Sat, Oct 5, 2024 at 8:03 PM Andrew Lunn <andrew@...n.ch> wrote:
>
> But why limit it to u16, when the base value is a 63 bits? 65535 nS is
> not very long.
Agreed, for these constructors we should use (at the very least) the
biggest possible type that fits without possible wrapping.
> Dumb question. What does Rust in the kernel do if there is an
> overflow?
It is controlled by `CONFIG_RUST_OVERFLOW_CHECKS` -- it defaults to a
Rust panic, but otherwise it wraps. Either way, it is not UB and
regardless of the setting, it is considered a bug to be fixed.
(I requested upstream Rust a third mode that would allow us to report
the issue (e.g. map it to `WARN_ONCE`) and then continue with wrap.)
Cheers,
Miguel
Powered by blists - more mailing lists