Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2001)

Delta Between Two Patch Sets: cmd/vet/testdata/copylock_func.go

Issue 145360043: code review 145360043: go.tools/cmd/vet: warn about copying locks in range sta... (Closed)
Left Patch Set: Created 9 years, 6 months ago
Right Patch Set: diff -r 9c7110ab58402df527dbf8373d0fa888000779d4 https://code.google.com/p/go.tools Created 9 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « cmd/vet/copylock.go ('k') | cmd/vet/testdata/copylock_range.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // This file contains tests for the copylock checker. 5 // This file contains tests for the copylock checker's
6 // function declaration analysis.
6 7
7 package testdata 8 package testdata
8 9
9 import "sync" 10 import "sync"
10 11
11 func OkFunc(*sync.Mutex) {} 12 func OkFunc(*sync.Mutex) {}
12 func BadFunc(sync.Mutex) {} // ERROR "BadFunc passes Lock by value: sync.Mutex" 13 func BadFunc(sync.Mutex) {} // ERROR "BadFunc passes Lock by value: sync.Mutex"
13 func OkRet() *sync.Mutex {} 14 func OkRet() *sync.Mutex {}
14 func BadRet() sync.Mutex {} // ERROR "BadRet returns Lock by value: sync.Mutex" 15 func BadRet() sync.Mutex {} // ERROR "BadRet returns Lock by value: sync.Mutex"
15 16
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 type LocalOnce sync.Once 81 type LocalOnce sync.Once
81 82
82 func (LocalOnce) Bad() {} // ERROR "Bad passes Lock by value: testdata.LocalOnce contains sync.Mutex" 83 func (LocalOnce) Bad() {} // ERROR "Bad passes Lock by value: testdata.LocalOnce contains sync.Mutex"
83 84
84 // False negative: 85 // False negative:
85 // LocalMutex doesn't have a Lock method. 86 // LocalMutex doesn't have a Lock method.
86 // Nevertheless, it is probably a bad idea to pass it by value. 87 // Nevertheless, it is probably a bad idea to pass it by value.
87 type LocalMutex sync.Mutex 88 type LocalMutex sync.Mutex
88 89
89 func (LocalMutex) Bad() {} // WANTED: An error here :( 90 func (LocalMutex) Bad() {} // WANTED: An error here :(
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b