From 074bc28c5af3e498e261089f96648c9f2d165ab3 Mon Sep 17 00:00:00 2001 From: Aaron Clawson <3766680+MadVikingGod@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:06:03 -0500 Subject: [PATCH] Add comment to the safety of the uint8 cast (#5819) Closes #5666 Closes #5571 Closes #5626 The conversion referenced in both issues is impossible to overflow. This PR leaves a comment to that effect. Co-authored-by: Aaron Clawson Co-authored-by: Sam Xie --- samplers/probability/consistent/tracestate.go | 1 + 1 file changed, 1 insertion(+) diff --git a/samplers/probability/consistent/tracestate.go b/samplers/probability/consistent/tracestate.go index 332cec5497e..4d01102867f 100644 --- a/samplers/probability/consistent/tracestate.go +++ b/samplers/probability/consistent/tracestate.go @@ -198,6 +198,7 @@ func parseNumber(key string, input string, maximum uint8) (uint8, error) { if value > uint64(maximum) { return maximum + 1, parseError(key, strconv.ErrRange) } + // `value` is strictly less then the uint8 maximum. This cast is safe. return uint8(value), nil }