Skip to content

Commit

Permalink
Fix new lint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
klauspost committed Nov 15, 2024
1 parent b4b5d86 commit 955efed
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
8 changes: 4 additions & 4 deletions cli/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@ func newClient(ctx *cli.Context) func() (cl *minio.Client, done func()) {
}
}
find := func() int {
min := math.MaxInt32
minN := math.MaxInt32
for _, n := range running {
if n < min {
min = n
if n < minN {
minN = n
}
}
earliest := time.Now().Add(time.Second)
earliestIdx := 0
for i, n := range running {
if n == min {
if n == minN {
if lastFinished[i].Before(earliest) {
earliest = lastFinished[i]
earliestIdx = i
Expand Down
26 changes: 13 additions & 13 deletions pkg/bench/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,22 +560,22 @@ func (o Operations) MultipleSizes() bool {
}

// MinMaxSize returns the minimum and maximum operation sizes.
func (o Operations) MinMaxSize() (min, max int64) {
func (o Operations) MinMaxSize() (minSize, maxSize int64) {
if len(o) == 0 {
return 0, 0
}

min = o[0].Size
max = o[0].Size
minSize = o[0].Size
maxSize = o[0].Size
for _, op := range o {
if op.Size < min {
min = op.Size
if op.Size < minSize {
minSize = op.Size
}
if op.Size > max {
max = op.Size
if op.Size > maxSize {
maxSize = op.Size
}
}
return min, max
return minSize, maxSize
}

// AvgSize returns the average operation size.
Expand Down Expand Up @@ -672,18 +672,18 @@ var log10ToLog2Size = map[int]int64{
}

func (o Operations) SingleSizeSegment() SizeSegment {
min, max := o.MinMaxSize()
minSize, maxSize := o.MinMaxSize()
var minL10, maxL10 int
for min > log10ToLog2Size[minL10+1] {
for minSize > log10ToLog2Size[minL10+1] {
minL10++
}
for max >= log10ToLog2Size[maxL10] {
for maxSize >= log10ToLog2Size[maxL10] {
maxL10++
}
return SizeSegment{
Smallest: min,
Smallest: minSize,
SmallestLog10: minL10,
Biggest: max,
Biggest: maxSize,
BiggestLog10: maxL10,
Ops: o,
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/generator/csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func (o CsvOpts) Comma(c byte) CsvOpts {
}

// FieldLen sets the length of each field.
func (o CsvOpts) FieldLen(min, max int) CsvOpts {
o.minLen = min
o.maxLen = max
func (o CsvOpts) FieldLen(minN, maxN int) CsvOpts {
o.minLen = minN
o.maxLen = maxN
return o
}

Expand Down
16 changes: 8 additions & 8 deletions pkg/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,17 @@ func randASCIIBytes(dst []byte, rng *rand.Rand) {
// GetExpRandSize will return an exponential random size from 1 to and including max.
// Minimum size: 127 bytes, max scale is 256 times smaller than max size.
// Average size will be max_size * 0.179151.
func GetExpRandSize(rng *rand.Rand, min, max int64) int64 {
if max-min < 10 {
if max-min <= 0 {
func GetExpRandSize(rng *rand.Rand, minN, maxN int64) int64 {
if maxN-minN < 10 {
if maxN-minN <= 0 {
return 0
}
return 1 + min + rng.Int63n(max-min)
return 1 + minN + rng.Int63n(maxN-minN)
}
logSizeMax := math.Log2(float64(max - 1))
logSizeMax := math.Log2(float64(maxN - 1))
logSizeMin := math.Max(7, logSizeMax-8)
if min > 0 {
logSizeMin = math.Log2(float64(min - 1))
if minN > 0 {
logSizeMin = math.Log2(float64(minN - 1))
}
lsDelta := logSizeMax - logSizeMin
random := rng.Float64()
Expand All @@ -195,5 +195,5 @@ func GetExpRandSize(rng *rand.Rand, min, max int64) int64 {
return 1 + int64(math.Pow(2, logSize+logSizeMin))
}
// For lowest part, do equal distribution
return 1 + min + int64(random*math.Pow(2, logSizeMin+1))
return 1 + minN + int64(random*math.Pow(2, logSizeMin+1))
}
14 changes: 7 additions & 7 deletions pkg/generator/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,23 @@ func WithSizeHistograms(encoded string) Option {
}

// WithMinMaxSize sets the min and max size of the generated data.
func WithMinMaxSize(min, max int64) Option {
func WithMinMaxSize(minN, maxN int64) Option {
return func(o *Options) error {
if min <= 0 {
if minN <= 0 {
return errors.New("WithMinMaxSize: minSize must be >= 0")
}
if max < 0 {
if maxN < 0 {
return errors.New("WithMinMaxSize: maxSize must be > 0")
}
if min > max {
if minN > maxN {
return errors.New("WithMinMaxSize: minSize must be < maxSize")
}
if o.randSize && max < 256 {
if o.randSize && maxN < 256 {
return errors.New("WithMinMaxSize: random sized objects should be at least 256 bytes")
}

o.totalSize = max
o.minSize = min
o.totalSize = maxN
o.minSize = minN
return nil
}
}
Expand Down

0 comments on commit 955efed

Please sign in to comment.