Skip to content

Commit 9b60c13

Browse files
henrybear327ivanvc
andcommitted
Address linter issues
Changes (align with the main branch): - remove rand.Seed(s) - use rand.Read from "crypto/rand" - add //nolint:all for (*reflect.SliceHeader)(slice) -> will fix in a follow-up PR Signed-off-by: Chun-Hung Tseng <[email protected]> Co-authored-by: Iván Valdés Castillo <[email protected]>
1 parent 0b59bc1 commit 9b60c13

5 files changed

Lines changed: 5 additions & 13 deletions

File tree

cmd/bbolt/main_test.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main_test
33
import (
44
"bytes"
55
crypto "crypto/rand"
6-
"encoding/binary"
76
"fmt"
87
"io"
98
"math/rand"
@@ -304,12 +303,6 @@ func NewMain() *Main {
304303
}
305304

306305
func TestCompactCommand_Run(t *testing.T) {
307-
var s int64
308-
if err := binary.Read(crypto.Reader, binary.BigEndian, &s); err != nil {
309-
t.Fatal(err)
310-
}
311-
rand.Seed(s)
312-
313306
dstdb := btesting.MustCreateDB(t)
314307
dstdb.Close()
315308

freelist_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ func benchmark_FreelistRelease(b *testing.B, size int) {
320320
}
321321

322322
func randomPgids(n int) []pgid {
323-
rand.Seed(42)
324323
pgids := make(pgids, n)
325324
for i := range pgids {
326325
pgids[i] = pgid(rand.Int63())

manydbs_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package bbolt
22

33
import (
4+
"crypto/rand"
45
"fmt"
5-
"math/rand"
66
"os"
77
"path/filepath"
88
"testing"
@@ -46,7 +46,9 @@ func createAndPutKeys(t *testing.T) {
4646
}
4747

4848
var key [16]byte
49-
rand.Read(key[:])
49+
if _, err := rand.Read(key[:]); err != nil {
50+
return err
51+
}
5052
if err := nodes.Put(key[:], nil); err != nil {
5153
return err
5254
}

simulation_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ func testSimulate(t *testing.T, openOption *bolt.Options, round, threadCount, pa
3535
t.Skip("skipping test in short mode.")
3636
}
3737

38-
rand.Seed(int64(qseed))
39-
4038
// A list of operations that readers and writers can perform.
4139
var readerHandlers = []simulateHandler{simulateGetHandler}
4240
var writerHandlers = []simulateHandler{simulateGetHandler, simulatePutHandler}

unsafe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func unsafeByteSlice(base unsafe.Pointer, offset uintptr, i, j int) []byte {
3232
// manipulation of reflect.SliceHeader to prevent misuse, namely, converting
3333
// from reflect.SliceHeader to a Go slice type.
3434
func unsafeSlice(slice, data unsafe.Pointer, len int) {
35-
s := (*reflect.SliceHeader)(slice)
35+
s := (*reflect.SliceHeader)(slice) //nolint:staticcheck
3636
s.Data = uintptr(data)
3737
s.Cap = len
3838
s.Len = len

0 commit comments

Comments
 (0)