Skip to content

Commit

Permalink
Add comment to the safety of the uint8 cast (open-telemetry#5819)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
3 people authored Jun 28, 2024
1 parent 522f603 commit 074bc28
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions samplers/probability/consistent/tracestate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 074bc28

Please sign in to comment.