prysm-pulse/tools/analyzers/recursivelock/testdata/badlockswithmethods.go
Chase Jeter 0ea4b02b8b
Added analyzer for detecting recursive/nested mutex read locks. (#10066)
* Added analyzer for detecting recursive/nested mutex read locks.

* Added type assertion checks and removed unused 'iTypes' directory

* Clean up

* Bazel file fixes

* Cleaned up code and added comments.

Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
2022-01-14 17:12:21 +08:00

27 lines
651 B
Go

// recursive read lock calls with methods
package testdata
func (p *ProtectResource) NestedMethod() {
p.RLock()
p.GetResource() // want `found recursive read lock call`
p.RUnlock()
}
func (p *ProtectResource) NestedMethod2() {
p.RLock()
p.GetResourceNested() // want `found recursive read lock call`
p.RUnlock()
}
func (p *NestedProtectResource) MultiLevelStruct() {
p.nestedPR.RLock()
p.nestedPR.GetResource() // want `found recursive read lock call`
p.nestedPR.RUnlock()
}
func (p *NestedProtectResource) MultiLevelStruct2() {
p.nestedPR.RLock()
p.GetNestedPResource() // want `found recursive read lock call`
p.nestedPR.RUnlock()
}