rust: time: add #[track_caller] to Delta division and remainder
Subsystems (2)
PATCH 1/1 rust: time: add #[track_caller] to Delta division and remainder
From: FUJITA Tomonori <[email protected]>
Delta's div() and rem_nanos() panic if the divisor is zero, or if i64::MIN is divided by -1. In these cases the caller passed a wrong value, but the panic message shows a line in time.rs.
Add #[track_caller] so that the panic message shows the caller's location instead.
Signed-off-by FUJITA Tomonori <[email protected]>
--- rust/kernel/time.rs | 2 ++ 1 file changed, 2 insertions(+)
rust/kernel/time.rs +2 -0
@@ -512,6 +512,7 @@ impl ops::Div for Delta {/// /// Panics if `rhs` is zero, or if `self` represents [`i64::MIN`] nanoseconds /// and `rhs` represents `-1` nanosecond. +#[track_caller] #[inline] fn div (self, rhs:Self ) ->Self ::Output {if rhs.value ==0 {
@@ -725,6 +726,7 @@ pub fn to_jiffies_timeout(self) -> Delta<Jiffy> {/// /// Panics if `divisor` is zero, or if `self` represents [`i64::MIN`] /// nanoseconds and `divisor` is `-1`. +#[track_caller] #[inline] pub fn rem_nanos (self, divisor:i32 ) ->Self {if divisor ==0 {
base-commit: 6b391eec2ddeb3ab2681cc5dee16d29e00202438
Signature · 1 line
2.43.0
Quoted 11 lines · FUJITA Tomonori
From: FUJITA Tomonori <[email protected]>
Delta's
div()andrem_nanos()panic if the divisor is zero, or ifi64::MINis divided by -1. In these cases the caller passed a wrong value, but the panic message shows a line intime.rs.Add #[track_caller] so that the panic message shows the caller's location instead.
Signed-off-by FUJITA Tomonori <[email protected]>
Reviewed-by Alice Ryhl <[email protected]>