[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241023.155102.880821493029416131.fujita.tomonori@gmail.com>
Date: Wed, 23 Oct 2024 15:51:02 +0900 (JST)
From: FUJITA Tomonori <fujita.tomonori@...il.com>
To: miguel.ojeda.sandonis@...il.com
Cc: fujita.tomonori@...il.com, boqun.feng@...il.com,
netdev@...r.kernel.org, rust-for-linux@...r.kernel.org, andrew@...n.ch,
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, jstultz@...gle.com, sboyd@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v3 4/8] rust: time: Implement addition of
Ktime and Delta
On Thu, 17 Oct 2024 18:33:23 +0200
Miguel Ojeda <miguel.ojeda.sandonis@...il.com> wrote:
> On Thu, Oct 17, 2024 at 11:31 AM FUJITA Tomonori
> <fujita.tomonori@...il.com> wrote:
>>
>> We could add the Rust version of add_safe method. But looks like
>> ktime_add_safe() is used by only some core systems so we don't need to
>> add it now?
>
> There was some discussion in the past about this -- I wrote there a
> summary of the `add` variants:
>
> https://lore.kernel.org/rust-for-linux/CANiq72ka4UvJzb4dN12fpA1WirgDHXcvPurvc7B9t+iPUfWnew@mail.gmail.com/
>
> I think this is a case where following the naming of the C side would
> be worse, i.e. where it is worth not applying our usual guideline.
> Calling something `_safe`/`_unsafe` like the C macros would be quite
> confusing for Rust.
>
> Personally, I would prefer that we stay consistent, which will help
> when dealing with more code. That is (from the message above):
>
> - No suffix: not supposed to wrap. So, in Rust, map it to operators.
> - `_unsafe()`: wraps. So, in Rust, map it to `wrapping` methods.
> - `_safe()`: saturates. So, in Rust, map it to `saturating` methods.
Can we add the above to Documentation/rust/coding-guidelines.rst?
I think that it's better than adding the similar comment to every
function that performs arithmetic.
Powered by blists - more mailing lists