From 4ac9938c8bc1a993cf17d76128080b7f11438239 Mon Sep 17 00:00:00 2001 From: tnt Date: Tue, 1 Jul 2014 11:46:45 +0200 Subject: [PATCH] Fixed some formatting functions that were called with invalid number/type of arguments. Change-Id: I261c6fb732a6cf1e54e01fa3e5388c39c6deb720 --- pkg/blobserver/encrypt/encrypt.go | 2 +- pkg/blobserver/localdisk/upgrade32.go | 2 +- pkg/blobserver/storagetest/storagetest.go | 2 +- pkg/importer/twitter/twitter.go | 2 +- pkg/media/audio.go | 2 +- pkg/misc/amazon/s3/auth_test.go | 2 +- pkg/misc/closure/gendeps.go | 2 +- pkg/netutil/ident.go | 2 +- pkg/schema/filewriter.go | 2 +- pkg/singleflight/singleflight_test.go | 2 +- pkg/types/types.go | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/blobserver/encrypt/encrypt.go b/pkg/blobserver/encrypt/encrypt.go index 9c9340504..b7a67b094 100644 --- a/pkg/blobserver/encrypt/encrypt.go +++ b/pkg/blobserver/encrypt/encrypt.go @@ -273,7 +273,7 @@ func (s *storage) ReceiveBlob(plainBR blob.Ref, source io.Reader) (sb blob.Sized err = s.index.Set(plainBR.String(), meta) if err != nil { - return sb, fmt.Errorf("encrypt: error updating index for encrypted %v (plaintext %v): %v", err) + return sb, fmt.Errorf("encrypt: error updating index for encrypted %v (plaintext %v): %v", encBR, plainBR, err) } return blob.SizedRef{plainBR, uint32(plainSize)}, nil diff --git a/pkg/blobserver/localdisk/upgrade32.go b/pkg/blobserver/localdisk/upgrade32.go index 3010eb4e9..12cf88f5d 100644 --- a/pkg/blobserver/localdisk/upgrade32.go +++ b/pkg/blobserver/localdisk/upgrade32.go @@ -86,7 +86,7 @@ func (ds *DiskStorage) migrate3to2() error { } dst := ds.blobPath(br) if fi, err := os.Stat(dst); !os.IsNotExist(err) { - return fmt.Errorf("Expected %s to not exist; got stat %v, %v", fi, err) + return fmt.Errorf("Expected %s to not exist; got stat %v, %v", dst, fi, err) } if err := os.Rename(path, dst); err != nil { return err diff --git a/pkg/blobserver/storagetest/storagetest.go b/pkg/blobserver/storagetest/storagetest.go index c268009c6..c8de4b3b0 100644 --- a/pkg/blobserver/storagetest/storagetest.go +++ b/pkg/blobserver/storagetest/storagetest.go @@ -150,7 +150,7 @@ func testSizedBlob(t *testing.T, r io.Reader, b1 blob.Ref, size int64) { t.Fatalf("error reading from %s: %v", r, err) } if n != size { - t.Fatalf("read %d bytes from %s, metadata said %d!", n, size) + t.Fatalf("read %d bytes from %s, metadata said %d!", n, r, size) } b2 := blob.RefFromHash(h) if b2 != b1 { diff --git a/pkg/importer/twitter/twitter.go b/pkg/importer/twitter/twitter.go index 5f0727be9..9b7b9fde1 100644 --- a/pkg/importer/twitter/twitter.go +++ b/pkg/importer/twitter/twitter.go @@ -456,7 +456,7 @@ func (r *run) importTweet(parent *importer.Object, tweet tweetItem, viaAPI bool) tried++ res, err := r.HTTPClient().Get(mediaURL) if err != nil { - return false, fmt.Errorf("Error fetching %s for tweet %s : %v", mediaURL, url) + return false, fmt.Errorf("Error fetching %s for tweet %s : %v", mediaURL, url, err) } if res.StatusCode == http.StatusNotFound { continue diff --git a/pkg/media/audio.go b/pkg/media/audio.go index 695ad7ced..2611c9af1 100644 --- a/pkg/media/audio.go +++ b/pkg/media/audio.go @@ -42,7 +42,7 @@ func HasID3v1Tag(r types.SizeReaderAt) (bool, error) { buf := make([]byte, len(id3v1Magic), len(id3v1Magic)) if _, err := r.ReadAt(buf, r.Size()-ID3v1TagLength); err != nil { - return false, fmt.Errorf("Failed to read ID3v1 data: ", err) + return false, fmt.Errorf("Failed to read ID3v1 data: %v", err) } if bytes.Equal(buf, id3v1Magic) { return true, nil diff --git a/pkg/misc/amazon/s3/auth_test.go b/pkg/misc/amazon/s3/auth_test.go index 6aee9e2ea..9ad84ac47 100644 --- a/pkg/misc/amazon/s3/auth_test.go +++ b/pkg/misc/amazon/s3/auth_test.go @@ -31,7 +31,7 @@ type reqAndExpected struct { func req(s string) *http.Request { req, err := http.ReadRequest(bufio.NewReader(strings.NewReader(s))) if err != nil { - panic(fmt.Sprintf("bad request in test: %q (error: %v)", req, err)) + panic(fmt.Sprintf("bad request in test: %v (error: %v)", req, err)) } return req } diff --git a/pkg/misc/closure/gendeps.go b/pkg/misc/closure/gendeps.go index b94f72109..69178c247 100644 --- a/pkg/misc/closure/gendeps.go +++ b/pkg/misc/closure/gendeps.go @@ -185,7 +185,7 @@ func ParseDeps(r io.Reader) (providedBy map[string]string, requires map[string][ } providedBy[namespace] = jsfile if _, ok := requires[namespace]; ok { - return nil, nil, fmt.Errorf("Name %v has two sets of dependencies") + return nil, nil, fmt.Errorf("Name %v has two sets of dependencies", namespace) } if required != nil { requires[namespace] = required diff --git a/pkg/netutil/ident.go b/pkg/netutil/ident.go index d144bd4d8..1776b25d8 100644 --- a/pkg/netutil/ident.go +++ b/pkg/netutil/ident.go @@ -55,7 +55,7 @@ func HostPortToIP(hostport string, ctx *net.TCPAddr) (hostaddr *net.TCPAddr, err } iport, err := strconv.Atoi(port) if err != nil || iport < 0 || iport > 0xFFFF { - return nil, fmt.Errorf("invalid port %s", iport) + return nil, fmt.Errorf("invalid port %d", iport) } var addr net.IP if ctx != nil && host == "localhost" { diff --git a/pkg/schema/filewriter.go b/pkg/schema/filewriter.go index 8fd428ddb..946612edd 100644 --- a/pkg/schema/filewriter.go +++ b/pkg/schema/filewriter.go @@ -106,7 +106,7 @@ func writeFileMapOld(bs blobserver.StatReceiver, file *Builder, r io.Reader) (bl return blob.Ref{}, err } if want := (blob.SizedRef{br, uint32(n)}); sb != want { - return blob.Ref{}, fmt.Errorf("schema/filewriter: wrote %s, expect", sb, want) + return blob.Ref{}, fmt.Errorf("schema/filewriter: wrote %s, expect %s", sb, want) } } diff --git a/pkg/singleflight/singleflight_test.go b/pkg/singleflight/singleflight_test.go index b75b608b4..40edcf30b 100644 --- a/pkg/singleflight/singleflight_test.go +++ b/pkg/singleflight/singleflight_test.go @@ -45,7 +45,7 @@ func TestDoErr(t *testing.T) { return nil, someErr }) if err != someErr { - t.Errorf("Do error = %v; want someErr", err, someErr) + t.Errorf("Do error = %v; want someErr %v", err, someErr) } if v != nil { t.Errorf("unexpected non-nil value %#v", v) diff --git a/pkg/types/types.go b/pkg/types/types.go index aa08f7fa3..61eb40409 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -71,7 +71,7 @@ func (t *Time3339) UnmarshalJSON(b []byte) error { return nil } if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { - return fmt.Errorf("types: failed to unmarshal non-string value %q as an RFC 3339 time") + return fmt.Errorf("types: failed to unmarshal non-string value %q as an RFC 3339 time", b) } s := string(b[1 : len(b)-1]) if s == "" {