From 955efed3a7f9b1ee250526ea695b23a125226da5 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Fri, 15 Nov 2024 11:45:31 +0100 Subject: [PATCH] Fix new lint checks --- cli/client.go | 8 ++++---- pkg/bench/ops.go | 26 +++++++++++++------------- pkg/generator/csv.go | 6 +++--- pkg/generator/generator.go | 16 ++++++++-------- pkg/generator/options.go | 14 +++++++------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/cli/client.go b/cli/client.go index d33b9ba5..1e2a1189 100644 --- a/cli/client.go +++ b/cli/client.go @@ -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 diff --git a/pkg/bench/ops.go b/pkg/bench/ops.go index 6f4551b8..e0361229 100644 --- a/pkg/bench/ops.go +++ b/pkg/bench/ops.go @@ -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. @@ -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, } diff --git a/pkg/generator/csv.go b/pkg/generator/csv.go index c6134456..d705e857 100644 --- a/pkg/generator/csv.go +++ b/pkg/generator/csv.go @@ -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 } diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 898d532d..3b0312e7 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -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() @@ -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)) } diff --git a/pkg/generator/options.go b/pkg/generator/options.go index 9edab33c..df719986 100644 --- a/pkg/generator/options.go +++ b/pkg/generator/options.go @@ -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 } }