mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
tsdb: Avoid potential overflow in comparisons
Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
02680b42f6
commit
4e5bb43fed
|
@ -459,7 +459,16 @@ func analyzeBlock(ctx context.Context, path, blockID string, limit int, runExten
|
||||||
postingInfos := []postingInfo{}
|
postingInfos := []postingInfo{}
|
||||||
|
|
||||||
printInfo := func(postingInfos []postingInfo) {
|
printInfo := func(postingInfos []postingInfo) {
|
||||||
slices.SortFunc(postingInfos, func(a, b postingInfo) int { return int(b.metric) - int(a.metric) })
|
slices.SortFunc(postingInfos, func(a, b postingInfo) int {
|
||||||
|
switch {
|
||||||
|
case b.metric < a.metric:
|
||||||
|
return -1
|
||||||
|
case b.metric > a.metric:
|
||||||
|
return 1
|
||||||
|
default:
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
for i, pc := range postingInfos {
|
for i, pc := range postingInfos {
|
||||||
if i >= limit {
|
if i >= limit {
|
||||||
|
|
Loading…
Reference in a new issue