From: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
Date: Mon, 7 Jun 2021 03:24:32 +0000 (+0000)
Subject: Fix nil context being passed to function
X-Git-Tag: v1.29.0~33
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=a68f040ea6785461e83a5b7b45366fcbbf3a3078;p=btrtrc.git

Fix nil context being passed to function
---

diff --git a/storage/sqlite/sqlite-storage.go b/storage/sqlite/sqlite-storage.go
index 38f734fe..9eb97e85 100644
--- a/storage/sqlite/sqlite-storage.go
+++ b/storage/sqlite/sqlite-storage.go
@@ -252,7 +252,7 @@ func NewPiecesStorage(opts NewPiecesStorageOpts) (_ storage.ClientImplCloser, er
 	if opts.SetJournalMode == "" && !opts.Memory {
 		opts.SetJournalMode = "wal"
 	}
-	err = initPoolConns(nil, conns, opts.InitConnOpts)
+	err = initPoolConns(context.TODO(), conns, opts.InitConnOpts)
 	if err != nil {
 		conns.Close()
 		return
@@ -494,7 +494,7 @@ type ConnPool interface {
 }
 
 func withPoolConn(pool ConnPool, with func(conn)) {
-	c := pool.Get(nil)
+	c := pool.Get(context.TODO())
 	defer pool.Put(c)
 	with(c)
 }
diff --git a/storage/sqlite/sqlite-storage_test.go b/storage/sqlite/sqlite-storage_test.go
index 2494ce6d..1fe1314e 100644
--- a/storage/sqlite/sqlite-storage_test.go
+++ b/storage/sqlite/sqlite-storage_test.go
@@ -5,6 +5,7 @@ package sqliteStorage
 
 import (
 	"bytes"
+	"context"
 	"errors"
 	"fmt"
 	"io"
@@ -34,7 +35,7 @@ func newConnsAndProv(t *testing.T, opts NewPoolOpts) (ConnPool, *provider) {
 	if !opts.Memory && opts.SetJournalMode == "" {
 		opts.SetJournalMode = "wal"
 	}
-	qt.Assert(t, initPoolConns(nil, pool, opts.InitConnOpts), qt.IsNil)
+	qt.Assert(t, initPoolConns(context.TODO(), pool, opts.InitConnOpts), qt.IsNil)
 	prov, err := NewProvider(pool, ProviderOpts{BatchWrites: pool.NumConns() > 1})
 	require.NoError(t, err)
 	t.Cleanup(func() { prov.Close() })