diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 06fa26c..b328c63 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -11,6 +11,5 @@ jobs: - run: make fmt - run: make race - run: make test - # Enable when fixed (same as make lint) - # - name: golangci-lint - # uses: golangci/golangci-lint-action@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 diff --git a/cmd/bbolt/main.go b/cmd/bbolt/main.go index 5009aec..bec49be 100644 --- a/cmd/bbolt/main.go +++ b/cmd/bbolt/main.go @@ -1631,7 +1631,11 @@ func (cmd *BenchCommand) startProfiling(options *BenchOptions) { fmt.Fprintf(cmd.Stderr, "bench: could not create cpu profile %q: %v\n", options.CPUProfile, err) os.Exit(1) } - pprof.StartCPUProfile(cpuprofile) + err = pprof.StartCPUProfile(cpuprofile) + if err != nil { + fmt.Fprintf(cmd.Stderr, "bench: could not start cpu profile %q: %v\n", options.CPUProfile, err) + os.Exit(1) + } } // Start memory profiling. @@ -1664,13 +1668,19 @@ func (cmd *BenchCommand) stopProfiling() { } if memprofile != nil { - pprof.Lookup("heap").WriteTo(memprofile, 0) + err := pprof.Lookup("heap").WriteTo(memprofile, 0) + if err != nil { + fmt.Fprintf(cmd.Stderr, "bench: could not write mem profile") + } memprofile.Close() memprofile = nil } if blockprofile != nil { - pprof.Lookup("block").WriteTo(blockprofile, 0) + err := pprof.Lookup("block").WriteTo(blockprofile, 0) + if err != nil { + fmt.Fprintf(cmd.Stderr, "bench: could not write block profile") + } blockprofile.Close() blockprofile = nil runtime.SetBlockProfileRate(0) diff --git a/compact.go b/compact.go index e4fe91b..5f1d4c3 100644 --- a/compact.go +++ b/compact.go @@ -12,7 +12,11 @@ func Compact(dst, src *DB, txMaxSize int64) error { if err != nil { return err } - defer tx.Rollback() + defer func() { + if tempErr := tx.Rollback(); tempErr != nil { + err = tempErr + } + }() if err := walk(src, func(keys [][]byte, k, v []byte, seq uint64) error { // On each key/value, check if we have exceeded tx size. @@ -73,8 +77,9 @@ func Compact(dst, src *DB, txMaxSize int64) error { }); err != nil { return err } + err = tx.Commit() - return tx.Commit() + return err } // walkFunc is the type of the function called for keys (buckets and "normal" diff --git a/db_test.go b/db_test.go index c7c63cf..84794e5 100644 --- a/db_test.go +++ b/db_test.go @@ -647,8 +647,14 @@ func TestDB_Concurrent_WriteTo(t *testing.T) { panic(err) } time.Sleep(time.Duration(rand.Intn(20)+1) * time.Millisecond) - tx.WriteTo(f) - tx.Rollback() + _, err = tx.WriteTo(f) + if err != nil { + panic(err) + } + err = tx.Rollback() + if err != nil { + panic(err) + } f.Close() snap := &DB{nil, f.Name(), o} snap.MustReopen() diff --git a/tx.go b/tx.go index 869d412..451cc2c 100644 --- a/tx.go +++ b/tx.go @@ -574,7 +574,7 @@ func (tx *Tx) write() error { for i := range buf { buf[i] = 0 } - tx.db.pagePool.Put(buf) + tx.db.pagePool.Put(buf) //nolint:staticcheck } return nil diff --git a/tx_test.go b/tx_test.go index 14345d0..4fe99db 100644 --- a/tx_test.go +++ b/tx_test.go @@ -57,7 +57,10 @@ func TestTx_Check_ReadOnly(t *testing.T) { } } // Close the view transaction - tx.Rollback() + err = tx.Rollback() + if err != nil { + t.Fatal(err) + } } // Ensure that committing a closed transaction returns an error. @@ -112,7 +115,10 @@ func TestTx_Commit_ErrTxNotWritable(t *testing.T) { t.Fatal(err) } // Close the view transaction - tx.Rollback() + err = tx.Rollback() + if err != nil { + t.Fatal(err) + } } // Ensure that a transaction can retrieve a cursor on the root bucket. diff --git a/unix_test.go b/unix_test.go index ac06c4f..d39dfd8 100644 --- a/unix_test.go +++ b/unix_test.go @@ -108,10 +108,10 @@ func skipOnMemlockLimitBelow(t *testing.T, memlockLimitRequest uint64) { } if info.Cur < memlockLimitRequest { - t.Skip(fmt.Sprintf( - "skipping as RLIMIT_MEMLOCK is unsufficient: %v < %v", + t.Skipf( + "skipping as RLIMIT_MEMLOCK is insufficient: %v < %v", info.Cur, memlockLimitRequest, - )) + ) } }