Skip to content

Commit

Permalink
Fix deepsource: VET-V0008 lock erroneously passed by value internal/i…
Browse files Browse the repository at this point in the history
…nfo,iocopy,errgroup (#1860)

Signed-off-by: vankichi <[email protected]>

Signed-off-by: vankichi <[email protected]>
  • Loading branch information
vankichi authored Nov 22, 2022
1 parent dc4c84c commit 682f68d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
8 changes: 0 additions & 8 deletions internal/errgroup/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -793,11 +793,9 @@ func Test_group_closeLimitation(t *testing.T) {
type fields struct {
egctx context.Context
cancel context.CancelFunc
wg sync.WaitGroup
limitation chan struct{}
enableLimitation atomic.Value
cancelOnce sync.Once
mu sync.RWMutex
emap map[string]struct{}
errs []error
err error
Expand All @@ -822,11 +820,9 @@ func Test_group_closeLimitation(t *testing.T) {
fields: fields {
egctx: nil,
cancel: nil,
wg: sync.WaitGroup{},
limitation: nil,
enableLimitation: nil,
cancelOnce: sync.Once{},
mu: sync.RWMutex{},
emap: nil,
errs: nil,
err: nil,
Expand All @@ -844,11 +840,9 @@ func Test_group_closeLimitation(t *testing.T) {
fields: fields {
egctx: nil,
cancel: nil,
wg: sync.WaitGroup{},
limitation: nil,
enableLimitation: nil,
cancelOnce: sync.Once{},
mu: sync.RWMutex{},
emap: nil,
errs: nil,
err: nil,
Expand Down Expand Up @@ -877,11 +871,9 @@ func Test_group_closeLimitation(t *testing.T) {
g := &group{
egctx: test.fields.egctx,
cancel: test.fields.cancel,
wg: test.fields.wg,
limitation: test.fields.limitation,
enableLimitation: test.fields.enableLimitation,
cancelOnce: test.fields.cancelOnce,
mu: test.fields.mu,
emap: test.fields.emap,
errs: test.fields.errs,
err: test.fields.err,
Expand Down
2 changes: 1 addition & 1 deletion internal/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (i *info) Get() Detail {
return i.get()
}

func (i info) get() Detail {
func (i *info) get() Detail {
i.detail.StackTrace = make([]StackTrace, 0, 10)
for j := 2; ; j++ {
pc, file, line, ok := i.rtCaller(j)
Expand Down
8 changes: 6 additions & 2 deletions internal/io/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"io"
"reflect"
"sync"
"sync/atomic"
"testing"

"github.com/vdaas/vald/internal/errors"
Expand Down Expand Up @@ -279,7 +280,6 @@ func Test_copier_Copy(t *testing.T) {
}
type fields struct {
bufSize int64
pool sync.Pool
}
type want struct {
wantWritten int64
Expand Down Expand Up @@ -326,7 +326,11 @@ func Test_copier_Copy(t *testing.T) {
}
c := &copier{
bufSize: test.fields.bufSize,
pool: test.fields.pool,
}
c.pool = sync.Pool{
New: func() interface{} {
return bytes.NewBuffer(make([]byte, int(atomic.LoadInt64(&c.bufSize))))
},
}
dst := &bytes.Buffer{}

Expand Down

0 comments on commit 682f68d

Please sign in to comment.