mirror of
https://github.com/golang/go
synced 2024-11-17 02:04:48 -07:00
std: fix more nilness findings
(found with x/tools/go/analysis/passes/nilness) Change-Id: I1bdc7811efbecea95608e634f894cb6c656e3a5b Reviewed-on: https://go-review.googlesource.com/c/go/+/564221 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
0fefe417db
commit
f8b4653500
@ -836,7 +836,7 @@ func (check *Checker) rangeStmt(inner stmtContext, s *ast.RangeStmt) {
|
||||
type identType = ast.Ident
|
||||
identName := func(n *identType) string { return n.Name }
|
||||
sKey, sValue := s.Key, s.Value
|
||||
var sExtra ast.Expr = nil
|
||||
var sExtra ast.Expr = nil // (used only in types2 fork)
|
||||
isDef := s.Tok == token.DEFINE
|
||||
rangeVar := s.X
|
||||
noNewVarPos := inNode(s, s.TokPos)
|
||||
|
@ -1659,8 +1659,8 @@ func TestCancelErrors(t *testing.T) {
|
||||
// This test should kill the child process after 1ms,
|
||||
// To maximize compatibility with existing uses of exec.CommandContext, the
|
||||
// resulting error should be an exec.ExitError without additional wrapping.
|
||||
if ee, ok := err.(*exec.ExitError); !ok {
|
||||
t.Errorf("Wait error = %v; want %T", err, *ee)
|
||||
if _, ok := err.(*exec.ExitError); !ok {
|
||||
t.Errorf("Wait error = %v; want *exec.ExitError", err)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -68,18 +68,14 @@ func TestTCPEcho(t *testing.T) {
|
||||
defer subProcess.Process.Kill()
|
||||
|
||||
var conn net.Conn
|
||||
var err error
|
||||
for {
|
||||
var err error
|
||||
conn, err = net.Dial("tcp", host)
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
if err != nil {
|
||||
t.Log(b.String())
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
payload := []byte("foobar")
|
||||
|
@ -261,9 +261,7 @@ func traceCPUSample(gp *g, mp *m, pp *p, stk []uintptr) {
|
||||
if gp != nil {
|
||||
hdr[1] = gp.goid
|
||||
}
|
||||
if mp != nil {
|
||||
hdr[2] = uint64(mp.procid)
|
||||
}
|
||||
hdr[2] = uint64(mp.procid)
|
||||
|
||||
// Allow only one writer at a time
|
||||
for !trace.signalLock.CompareAndSwap(0, 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user