]> Cypherpunks repositories - gostls13.git/commitdiff
src: fix issues found by go vet std
authorRobert Hencke <robert.hencke@gmail.com>
Sun, 27 Apr 2014 02:54:48 +0000 (19:54 -0700)
committerIan Lance Taylor <iant@golang.org>
Sun, 27 Apr 2014 02:54:48 +0000 (19:54 -0700)
LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/96850043

src/cmd/link/dead_test.go
src/cmd/link/macho_test.go
src/cmd/link/prog_test.go
src/cmd/pack/pack_test.go
src/pkg/archive/tar/reader_test.go
src/pkg/crypto/x509/x509_test.go
src/pkg/debug/macho/file_test.go
src/pkg/encoding/base64/base64_test.go
src/pkg/html/template/escape.go
src/pkg/net/http/serve_test.go
src/pkg/net/http/transport_test.go

index 0e00c7da4b74e4dcfae1c4ebabb25916eebdd063..2e179b453b1d5a8af8accd6813f66f07141e5b69 100644 (file)
@@ -92,6 +92,6 @@ func checkDeadSlice(t *testing.T, obj, name string, old, new []*Sym) {
                new = new[1:]
        }
        if len(new) > 0 {
-               t.Errorf("%s: %s has unexpected symbols: %v", new)
+               t.Errorf("%s: %s has unexpected symbols: %v", obj, name, new)
        }
 }
index 62b13274974fa0363061d3d593485e029255705e..37c4418b7728874b29668cf338a477fb99487f87 100644 (file)
@@ -324,7 +324,7 @@ func machoRead(arch machoArch, data []byte) (*Prog, error) {
                        }
                        if load.Maxprot != maxprot || load.Prot != prot {
                                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 {
@@ -374,7 +374,7 @@ func machoRead(arch machoArch, data []byte) (*Prog, error) {
                                        flags = 1
                                }
                                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{
                                        Name:     strings.ToLower(strings.TrimPrefix(msect.Name, "__")),
index 768b11fc47f9499d0dc37b6200856a490f715678..0853506957d9393b18d0409f8f04f00bbfeb5a5c 100644 (file)
@@ -75,11 +75,11 @@ func diffProg(p, q *Prog) []string {
 
                for j := 0; j < len(pseg.Sections) || j < len(qseg.Sections); j++ {
                        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
                        }
                        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
                        }
                        psect := pseg.Sections[j]
index b2be74b09716f0963d84116143b3a82ab030b480..8ecca98e6375dd3f73103cba3831d5e1949ccfed 100644 (file)
@@ -210,7 +210,7 @@ func TestHello(t *testing.T) {
        run("go", "tool", char+"l", "-o", "a.out", "hello.a")
        out := run("./a.out")
        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) {
        run("go", "tool", char+"l", "-L", ".", "-o", "a.out", "main."+char)
        out := run("./a.out")
        if out != "ok\n" {
-               t.Fatal("incorrect output: %q, want %q", out, "ok\n")
+               t.Fatalf("incorrect output: %q, want %q", out, "ok\n")
        }
 }
 
index 55b19d3c2e8a023ba0ed1041adfabab452a3e5ce..6d4e06a58dd830bcf065ed460b152311405b2f3a 100644 (file)
@@ -618,7 +618,7 @@ func TestSparseFileReader(t *testing.T) {
                        tot: test.realSize,
                }
                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)
                if err != nil {
index 4b4b9d7c7686edb562395c9de35f9dd7f9bd0e4a..ce9062c4b4b4f8f65c17390e85a1dc1bb6edfa75 100644 (file)
@@ -395,7 +395,7 @@ func TestCreateSelfSignedCertificate(t *testing.T) {
                }
 
                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) {
index 0de9184c22746a22d4e1eb05f8b08b8ec7041b8b..4797780ce77918173d954c1c57ad4f8f59ba2f52 100644 (file)
@@ -184,7 +184,7 @@ func TestOpenFat(t *testing.T) {
                ftArch := &fileTests[i]
 
                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) {
@@ -202,9 +202,9 @@ func TestOpenFatFailure(t *testing.T) {
        filename = "testdata/gcc-386-darwin-exec" // not a fat Mach-O
        ff, err := OpenFat(filename)
        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 {
-               t.Errorf("OpenFat %s: got %v, want nil", ff)
+               t.Errorf("OpenFat %s: got %v, want nil", filename, ff)
        }
 }
index f1469c684207dbc737d4878daaa5280ec9739a1e..a075194e03ef1345fb1e90bff49813b1ff25ea22 100644 (file)
@@ -336,7 +336,7 @@ func TestDecoderIssue7733(t *testing.T) {
        s, err := StdEncoding.DecodeString("YWJjZA=====")
        want := CorruptInputError(8)
        if !reflect.DeepEqual(want, err) {
-               t.Errorf("Error = %v; want CorruptInputError(8)")
+               t.Errorf("Error = %v; want CorruptInputError(8)", err)
        }
        if string(s) != "abcd" {
                t.Errorf("DecodeString = %q; want abcd", s)
index 5f458d172d7ee488f2e22d6c0ec98c90c311ab6c..4e379828d4c33b5cfd86083a4e5c2a85ddccaad5 100644 (file)
@@ -221,7 +221,6 @@ func allIdents(node parse.Node) []string {
                return node.Ident
        }
        panic("unidentified node type in allIdents")
-       return nil
 }
 
 // ensurePipelineContains ensures that the pipeline has commands with
index d9a136742c5347792826a2b31bb44623693108ed..030fd6e7b226719503b0b1dd2e8cae68085f1782 100644 (file)
@@ -2325,7 +2325,7 @@ func TestServerConnState(t *testing.T) {
        ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0)
        ts.Config.ConnState = func(c net.Conn, state ConnState) {
                if c == nil {
-                       t.Error("nil conn seen in state %s", state)
+                       t.Errorf("nil conn seen in state %s", state)
                        return
                }
                mu.Lock()
index ab459738dfe5b2a95fd9d8042ac020bced9d73cb..a5aaa6bab8da55d777e746021dcb40113b034259 100644 (file)
@@ -1412,7 +1412,6 @@ func TestTransportCancelRequestInDial(t *testing.T) {
        case <-gotres:
        case <-time.After(5 * time.Second):
                panic("hang. events are: " + logbuf.String())
-               t.Fatal("timeout; cancel didn't work?")
        }
 
        got := logbuf.String()
@@ -1869,10 +1868,10 @@ func TestTransportTLSHandshakeTimeout(t *testing.T) {
                        return
                }
                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") {
-                       t.Error("expected 'handshake timeout' in error; got %v", err)
+                       t.Errorf("expected 'handshake timeout' in error; got %v", err)
                }
        }()
        select {