Commit d4613483 authored by Robert Hencke's avatar Robert Hencke Committed by Ian Lance Taylor

src: fix issues found by go vet std

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96850043
parent 8409dea8
...@@ -92,6 +92,6 @@ func checkDeadSlice(t *testing.T, obj, name string, old, new []*Sym) { ...@@ -92,6 +92,6 @@ func checkDeadSlice(t *testing.T, obj, name string, old, new []*Sym) {
new = new[1:] new = new[1:]
} }
if len(new) > 0 { if len(new) > 0 {
t.Errorf("%s: %s has unexpected symbols: %v", new) t.Errorf("%s: %s has unexpected symbols: %v", obj, name, new)
} }
} }
...@@ -324,7 +324,7 @@ func machoRead(arch machoArch, data []byte) (*Prog, error) { ...@@ -324,7 +324,7 @@ func machoRead(arch machoArch, data []byte) (*Prog, error) {
} }
if load.Maxprot != maxprot || load.Prot != prot { if load.Maxprot != maxprot || load.Prot != prot {
errorf("segment %q protection is %d, %d, want %d, %d", errorf("segment %q protection is %d, %d, want %d, %d",
load.Maxprot, load.Prot, maxprot, prot) load.Name, load.Maxprot, load.Prot, maxprot, prot)
} }
for len(msects) > 0 && msects[0].Addr < load.Addr+load.Memsz { for len(msects) > 0 && msects[0].Addr < load.Addr+load.Memsz {
...@@ -374,7 +374,7 @@ func machoRead(arch machoArch, data []byte) (*Prog, error) { ...@@ -374,7 +374,7 @@ func machoRead(arch machoArch, data []byte) (*Prog, error) {
flags = 1 flags = 1
} }
if msect.Flags != flags { if msect.Flags != flags {
errorf("section %q flags = %#x, want %#x", msect.Flags, flags) errorf("section %q flags = %#x, want %#x", msect.Name, msect.Flags, flags)
} }
sect := &Section{ sect := &Section{
Name: strings.ToLower(strings.TrimPrefix(msect.Name, "__")), Name: strings.ToLower(strings.TrimPrefix(msect.Name, "__")),
......
...@@ -75,11 +75,11 @@ func diffProg(p, q *Prog) []string { ...@@ -75,11 +75,11 @@ func diffProg(p, q *Prog) []string {
for j := 0; j < len(pseg.Sections) || j < len(qseg.Sections); j++ { for j := 0; j < len(pseg.Sections) || j < len(qseg.Sections); j++ {
if j >= len(pseg.Sections) { if j >= len(pseg.Sections) {
errors = append(errors, fmt.Sprintf("segment %q missing section %q", qseg.Sections[i].Name)) errors = append(errors, fmt.Sprintf("segment %q missing section %q", pseg.Name, qseg.Sections[i].Name))
continue continue
} }
if j >= len(qseg.Sections) { if j >= len(qseg.Sections) {
errors = append(errors, fmt.Sprintf("segment %q has extra section %q", pseg.Sections[i].Name)) errors = append(errors, fmt.Sprintf("segment %q has extra section %q", pseg.Name, pseg.Sections[i].Name))
continue continue
} }
psect := pseg.Sections[j] psect := pseg.Sections[j]
......
...@@ -210,7 +210,7 @@ func TestHello(t *testing.T) { ...@@ -210,7 +210,7 @@ func TestHello(t *testing.T) {
run("go", "tool", char+"l", "-o", "a.out", "hello.a") run("go", "tool", char+"l", "-o", "a.out", "hello.a")
out := run("./a.out") out := run("./a.out")
if out != "hello world\n" { if out != "hello world\n" {
t.Fatal("incorrect output: %q, want %q", out, "hello world\n") t.Fatalf("incorrect output: %q, want %q", out, "hello world\n")
} }
} }
...@@ -271,7 +271,7 @@ func TestLargeDefs(t *testing.T) { ...@@ -271,7 +271,7 @@ func TestLargeDefs(t *testing.T) {
run("go", "tool", char+"l", "-L", ".", "-o", "a.out", "main."+char) run("go", "tool", char+"l", "-L", ".", "-o", "a.out", "main."+char)
out := run("./a.out") out := run("./a.out")
if out != "ok\n" { if out != "ok\n" {
t.Fatal("incorrect output: %q, want %q", out, "ok\n") t.Fatalf("incorrect output: %q, want %q", out, "ok\n")
} }
} }
......
...@@ -618,7 +618,7 @@ func TestSparseFileReader(t *testing.T) { ...@@ -618,7 +618,7 @@ func TestSparseFileReader(t *testing.T) {
tot: test.realSize, tot: test.realSize,
} }
if sfr.numBytes() != nb { if sfr.numBytes() != nb {
t.Errorf("test %d: Before reading, sfr.numBytes() = %d, want %d", i, sfr.numBytes, nb) t.Errorf("test %d: Before reading, sfr.numBytes() = %d, want %d", i, sfr.numBytes(), nb)
} }
buf, err := ioutil.ReadAll(sfr) buf, err := ioutil.ReadAll(sfr)
if err != nil { if err != nil {
......
...@@ -395,7 +395,7 @@ func TestCreateSelfSignedCertificate(t *testing.T) { ...@@ -395,7 +395,7 @@ func TestCreateSelfSignedCertificate(t *testing.T) {
} }
if cert.SignatureAlgorithm != test.sigAlgo { if cert.SignatureAlgorithm != test.sigAlgo {
t.Errorf("%s: SignatureAlgorithm wasn't copied from template. Got %s, want %s", test.name, cert.SignatureAlgorithm, test.sigAlgo) t.Errorf("%s: SignatureAlgorithm wasn't copied from template. Got %v, want %v", test.name, cert.SignatureAlgorithm, test.sigAlgo)
} }
if !reflect.DeepEqual(cert.ExtKeyUsage, testExtKeyUsage) { if !reflect.DeepEqual(cert.ExtKeyUsage, testExtKeyUsage) {
......
...@@ -184,7 +184,7 @@ func TestOpenFat(t *testing.T) { ...@@ -184,7 +184,7 @@ func TestOpenFat(t *testing.T) {
ftArch := &fileTests[i] ftArch := &fileTests[i]
if arch.Cpu != ftArch.hdr.Cpu || arch.SubCpu != ftArch.hdr.SubCpu { if arch.Cpu != ftArch.hdr.Cpu || arch.SubCpu != ftArch.hdr.SubCpu {
t.Error("OpenFat: architecture #%d got cpu=%#x subtype=%#x, expected cpu=%#x, subtype=%#x", i, arch.Cpu, arch.SubCpu, ftArch.hdr.Cpu, ftArch.hdr.SubCpu) t.Errorf("OpenFat: architecture #%d got cpu=%#x subtype=%#x, expected cpu=%#x, subtype=%#x", i, arch.Cpu, arch.SubCpu, ftArch.hdr.Cpu, ftArch.hdr.SubCpu)
} }
if !reflect.DeepEqual(arch.FileHeader, ftArch.hdr) { if !reflect.DeepEqual(arch.FileHeader, ftArch.hdr) {
...@@ -202,9 +202,9 @@ func TestOpenFatFailure(t *testing.T) { ...@@ -202,9 +202,9 @@ func TestOpenFatFailure(t *testing.T) {
filename = "testdata/gcc-386-darwin-exec" // not a fat Mach-O filename = "testdata/gcc-386-darwin-exec" // not a fat Mach-O
ff, err := OpenFat(filename) ff, err := OpenFat(filename)
if err != ErrNotFat { if err != ErrNotFat {
t.Errorf("OpenFat %s: got %v, want ErrNotFat", err) t.Errorf("OpenFat %s: got %v, want ErrNotFat", filename, err)
} }
if ff != nil { if ff != nil {
t.Errorf("OpenFat %s: got %v, want nil", ff) t.Errorf("OpenFat %s: got %v, want nil", filename, ff)
} }
} }
...@@ -336,7 +336,7 @@ func TestDecoderIssue7733(t *testing.T) { ...@@ -336,7 +336,7 @@ func TestDecoderIssue7733(t *testing.T) {
s, err := StdEncoding.DecodeString("YWJjZA=====") s, err := StdEncoding.DecodeString("YWJjZA=====")
want := CorruptInputError(8) want := CorruptInputError(8)
if !reflect.DeepEqual(want, err) { if !reflect.DeepEqual(want, err) {
t.Errorf("Error = %v; want CorruptInputError(8)") t.Errorf("Error = %v; want CorruptInputError(8)", err)
} }
if string(s) != "abcd" { if string(s) != "abcd" {
t.Errorf("DecodeString = %q; want abcd", s) t.Errorf("DecodeString = %q; want abcd", s)
......
...@@ -221,7 +221,6 @@ func allIdents(node parse.Node) []string { ...@@ -221,7 +221,6 @@ func allIdents(node parse.Node) []string {
return node.Ident return node.Ident
} }
panic("unidentified node type in allIdents") panic("unidentified node type in allIdents")
return nil
} }
// ensurePipelineContains ensures that the pipeline has commands with // ensurePipelineContains ensures that the pipeline has commands with
......
...@@ -2325,7 +2325,7 @@ func TestServerConnState(t *testing.T) { ...@@ -2325,7 +2325,7 @@ func TestServerConnState(t *testing.T) {
ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0) ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0)
ts.Config.ConnState = func(c net.Conn, state ConnState) { ts.Config.ConnState = func(c net.Conn, state ConnState) {
if c == nil { if c == nil {
t.Error("nil conn seen in state %s", state) t.Errorf("nil conn seen in state %s", state)
return return
} }
mu.Lock() mu.Lock()
......
...@@ -1412,7 +1412,6 @@ func TestTransportCancelRequestInDial(t *testing.T) { ...@@ -1412,7 +1412,6 @@ func TestTransportCancelRequestInDial(t *testing.T) {
case <-gotres: case <-gotres:
case <-time.After(5 * time.Second): case <-time.After(5 * time.Second):
panic("hang. events are: " + logbuf.String()) panic("hang. events are: " + logbuf.String())
t.Fatal("timeout; cancel didn't work?")
} }
got := logbuf.String() got := logbuf.String()
...@@ -1869,10 +1868,10 @@ func TestTransportTLSHandshakeTimeout(t *testing.T) { ...@@ -1869,10 +1868,10 @@ func TestTransportTLSHandshakeTimeout(t *testing.T) {
return return
} }
if !ne.Timeout() { if !ne.Timeout() {
t.Error("expected timeout error; got %v", err) t.Errorf("expected timeout error; got %v", err)
} }
if !strings.Contains(err.Error(), "handshake timeout") { if !strings.Contains(err.Error(), "handshake timeout") {
t.Error("expected 'handshake timeout' in error; got %v", err) t.Errorf("expected 'handshake timeout' in error; got %v", err)
} }
}() }()
select { select {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment