Skip to content

Commit 074bc28

Browse files
MadVikingGodXSAM
andauthored
Add comment to the safety of the uint8 cast (open-telemetry#5819)
Closes open-telemetry#5666 Closes open-telemetry#5571 Closes open-telemetry#5626 The conversion referenced in both issues is impossible to overflow. This PR leaves a comment to that effect. Co-authored-by: Aaron Clawson <[email protected]> Co-authored-by: Sam Xie <[email protected]>
1 parent 522f603 commit 074bc28

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

samplers/probability/consistent/tracestate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ func parseNumber(key string, input string, maximum uint8) (uint8, error) {
198198
if value > uint64(maximum) {
199199
return maximum + 1, parseError(key, strconv.ErrRange)
200200
}
201+
// `value` is strictly less then the uint8 maximum. This cast is safe.
201202
return uint8(value), nil
202203
}
203204

0 commit comments

Comments
 (0)