Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deepsource: VET-V0008 Lock erroneously passed by value (pkg/agent) #1868

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions pkg/agent/core/ngt/service/kvs/ou_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package kvs

import (
"reflect"
"sync"
"sync/atomic"
"testing"
"unsafe"
Expand Down Expand Up @@ -101,7 +100,6 @@ func Test_ou_Load(t *testing.T) {
key uint32
}
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand Down Expand Up @@ -137,7 +135,6 @@ func Test_ou_Load(t *testing.T) {
key: 0,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -156,7 +153,6 @@ func Test_ou_Load(t *testing.T) {
key: 0,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -183,7 +179,6 @@ func Test_ou_Load(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand Down Expand Up @@ -282,7 +277,6 @@ func Test_ou_Store(t *testing.T) {
value string
}
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand Down Expand Up @@ -310,7 +304,6 @@ func Test_ou_Store(t *testing.T) {
value: "",
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -330,7 +323,6 @@ func Test_ou_Store(t *testing.T) {
value: "",
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -357,7 +349,6 @@ func Test_ou_Store(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand Down Expand Up @@ -617,7 +608,6 @@ func Test_ou_LoadOrStore(t *testing.T) {
value string
}
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand Down Expand Up @@ -654,7 +644,6 @@ func Test_ou_LoadOrStore(t *testing.T) {
value: "",
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -674,7 +663,6 @@ func Test_ou_LoadOrStore(t *testing.T) {
value: "",
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -701,7 +689,6 @@ func Test_ou_LoadOrStore(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand Down Expand Up @@ -813,7 +800,6 @@ func Test_ou_LoadAndDelete(t *testing.T) {
key uint32
}
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand Down Expand Up @@ -849,7 +835,6 @@ func Test_ou_LoadAndDelete(t *testing.T) {
key: 0,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -868,7 +853,6 @@ func Test_ou_LoadAndDelete(t *testing.T) {
key: 0,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -895,7 +879,6 @@ func Test_ou_LoadAndDelete(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand All @@ -914,7 +897,6 @@ func Test_ou_Delete(t *testing.T) {
key uint32
}
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand All @@ -941,7 +923,6 @@ func Test_ou_Delete(t *testing.T) {
key: 0,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -960,7 +941,6 @@ func Test_ou_Delete(t *testing.T) {
key: 0,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -987,7 +967,6 @@ func Test_ou_Delete(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand Down Expand Up @@ -1085,7 +1064,6 @@ func Test_ou_Range(t *testing.T) {
f func(key uint32, value string) bool
}
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand All @@ -1112,7 +1090,6 @@ func Test_ou_Range(t *testing.T) {
f: nil,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -1131,7 +1108,6 @@ func Test_ou_Range(t *testing.T) {
f: nil,
},
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -1158,7 +1134,6 @@ func Test_ou_Range(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand All @@ -1174,7 +1149,6 @@ func Test_ou_Range(t *testing.T) {

func Test_ou_missLocked(t *testing.T) {
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand All @@ -1197,7 +1171,6 @@ func Test_ou_missLocked(t *testing.T) {
{
name: "test_case_1",
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -1213,7 +1186,6 @@ func Test_ou_missLocked(t *testing.T) {
return test {
name: "test_case_2",
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -1240,7 +1212,6 @@ func Test_ou_missLocked(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand All @@ -1256,7 +1227,6 @@ func Test_ou_missLocked(t *testing.T) {

func Test_ou_dirtyLocked(t *testing.T) {
type fields struct {
mu sync.Mutex
read atomic.Value
dirty map[uint32]*entryOu
misses int
Expand All @@ -1279,7 +1249,6 @@ func Test_ou_dirtyLocked(t *testing.T) {
{
name: "test_case_1",
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -1295,7 +1264,6 @@ func Test_ou_dirtyLocked(t *testing.T) {
return test {
name: "test_case_2",
fields: fields {
mu: sync.Mutex{},
read: nil,
dirty: nil,
misses: 0,
Expand All @@ -1322,7 +1290,6 @@ func Test_ou_dirtyLocked(t *testing.T) {
test.checkFunc = defaultCheckFunc
}
m := &ou{
mu: test.fields.mu,
read: test.fields.read,
dirty: test.fields.dirty,
misses: test.fields.misses,
Expand Down
Loading