Re: [PATCH net-next v3 3/8] rust: time: Change output of Ktime's sub operation to Delta

From: FUJITA Tomonori
Date: Thu Oct 17 2024 - 05:17:36 EST


On Wed, 16 Oct 2024 13:03:48 -0700
Boqun Feng <boqun.feng@xxxxxxxxx> wrote:

>> impl core::ops::Sub for Ktime {
>> - type Output = Ktime;
>> + type Output = Delta;
>>
>> #[inline]
>> - fn sub(self, other: Ktime) -> Ktime {
>> - Self {
>> - inner: self.inner - other.inner,
>> + fn sub(self, other: Ktime) -> Delta {
>> + Delta {
>> + nanos: self.inner - other.inner,
>
> My understanding is that ktime_t, when used as a timestamp, can only
> have a value in range [0, i64::MAX], so this substraction here never
> overflows, maybe we want add a comment here?

Sure, I'll add.