From b9fcb41e6d31b51214725a21f76f8cb90702f8e5 Mon Sep 17 00:00:00 2001 From: Jessica Frazelle Date: Wed, 16 Mar 2016 19:43:26 -0700 Subject: [PATCH] fix variables that werent being called Signed-off-by: Jessica Frazelle --- authorization/authz_unix_test.go | 2 +- directory/directory_test.go | 3 +++ directory/directory_windows.go | 7 ------- jsonlog/jsonlog_marshalling.go | 6 ++---- jsonlog/jsonlogbytes.go | 6 ++---- mount/sharedsubtree_linux.go | 3 +-- pools/pools_test.go | 3 +-- symlink/fs_windows.go | 3 +-- tarsum/tarsum_test.go | 8 ++++++++ 9 files changed, 19 insertions(+), 22 deletions(-) diff --git a/authorization/authz_unix_test.go b/authorization/authz_unix_test.go index 7d673fe..1c6dc8a 100644 --- a/authorization/authz_unix_test.go +++ b/authorization/authz_unix_test.go @@ -241,7 +241,7 @@ func (t *authZPluginTestServer) start() { r.HandleFunc("/Plugin.Activate", t.activate) r.HandleFunc("/"+AuthZApiRequest, t.auth) r.HandleFunc("/"+AuthZApiResponse, t.auth) - t.listener, err = net.Listen("tcp", pluginAddress) + t.listener, _ = net.Listen("tcp", pluginAddress) server := http.Server{Handler: r, Addr: pluginAddress} server.Serve(l) } diff --git a/directory/directory_test.go b/directory/directory_test.go index 1b196b1..4611062 100644 --- a/directory/directory_test.go +++ b/directory/directory_test.go @@ -168,6 +168,9 @@ func TestMoveToSubdir(t *testing.T) { } // validate that the files were moved to the subdirectory infos, err := ioutil.ReadDir(subDir) + if err != nil { + t.Fatal(err) + } if len(infos) != 4 { t.Fatalf("Should be four files in the subdir after the migration: actual length: %d", len(infos)) } diff --git a/directory/directory_windows.go b/directory/directory_windows.go index 6d41777..7a9f8cb 100644 --- a/directory/directory_windows.go +++ b/directory/directory_windows.go @@ -5,17 +5,10 @@ package directory import ( "os" "path/filepath" - - "github.com/docker/docker/pkg/longpath" ) // Size walks a directory tree and returns its total size in bytes. func Size(dir string) (size int64, err error) { - fixedPath, err := filepath.Abs(dir) - if err != nil { - return - } - fixedPath = longpath.AddPrefix(fixedPath) err = filepath.Walk(dir, func(d string, fileInfo os.FileInfo, e error) error { // Ignore directory sizes if fileInfo == nil { diff --git a/jsonlog/jsonlog_marshalling.go b/jsonlog/jsonlog_marshalling.go index 31b047e..83ce684 100644 --- a/jsonlog/jsonlog_marshalling.go +++ b/jsonlog/jsonlog_marshalling.go @@ -93,7 +93,7 @@ func (mj *JSONLog) MarshalJSONBuf(buf *bytes.Buffer) error { ffjsonWriteJSONString(buf, mj.Log) } if len(mj.Stream) != 0 { - if first == true { + if first { first = false } else { buf.WriteString(`,`) @@ -101,9 +101,7 @@ func (mj *JSONLog) MarshalJSONBuf(buf *bytes.Buffer) error { buf.WriteString(`"stream":`) ffjsonWriteJSONString(buf, mj.Stream) } - if first == true { - first = false - } else { + if !first { buf.WriteString(`,`) } buf.WriteString(`"time":`) diff --git a/jsonlog/jsonlogbytes.go b/jsonlog/jsonlogbytes.go index ff7aaf1..df522c0 100644 --- a/jsonlog/jsonlogbytes.go +++ b/jsonlog/jsonlogbytes.go @@ -39,7 +39,7 @@ func (mj *JSONLogs) MarshalJSONBuf(buf *bytes.Buffer) error { ffjsonWriteJSONString(buf, mj.Stream) } if len(mj.RawAttrs) > 0 { - if first == true { + if first { first = false } else { buf.WriteString(`,`) @@ -47,9 +47,7 @@ func (mj *JSONLogs) MarshalJSONBuf(buf *bytes.Buffer) error { buf.WriteString(`"attrs":`) buf.Write(mj.RawAttrs) } - if first == true { - first = false - } else { + if !first { buf.WriteString(`,`) } buf.WriteString(`"time":`) diff --git a/mount/sharedsubtree_linux.go b/mount/sharedsubtree_linux.go index 47303bb..8ceec84 100644 --- a/mount/sharedsubtree_linux.go +++ b/mount/sharedsubtree_linux.go @@ -61,8 +61,7 @@ func ensureMountedAs(mountPoint, options string) error { return err } } - mounted, err = Mounted(mountPoint) - if err != nil { + if _, err = Mounted(mountPoint); err != nil { return err } diff --git a/pools/pools_test.go b/pools/pools_test.go index 7868980..1661b78 100644 --- a/pools/pools_test.go +++ b/pools/pools_test.go @@ -112,8 +112,7 @@ func TestBufioWriterPoolPutAndGet(t *testing.T) { buf.Reset() BufioWriter32KPool.Put(writer) // Try to write something - written, err = writer.Write([]byte("barfoo")) - if err != nil { + if _, err = writer.Write([]byte("barfoo")); err != nil { t.Fatal(err) } // If we now try to flush it, it should panic (the writer is nil) diff --git a/symlink/fs_windows.go b/symlink/fs_windows.go index 70988a3..449fe56 100644 --- a/symlink/fs_windows.go +++ b/symlink/fs_windows.go @@ -23,8 +23,7 @@ func toShort(path string) (string, error) { } if n > uint32(len(b)) { b = make([]uint16, n) - n, err = syscall.GetShortPathName(&p[0], &b[0], uint32(len(b))) - if err != nil { + if _, err = syscall.GetShortPathName(&p[0], &b[0], uint32(len(b))); err != nil { return "", err } } diff --git a/tarsum/tarsum_test.go b/tarsum/tarsum_test.go index 8962666..54bec53 100644 --- a/tarsum/tarsum_test.go +++ b/tarsum/tarsum_test.go @@ -560,6 +560,10 @@ func Benchmark9kTar(b *testing.B) { return } n, err := io.Copy(buf, fh) + if err != nil { + b.Error(err) + return + } fh.Close() reader := bytes.NewReader(buf.Bytes()) @@ -586,6 +590,10 @@ func Benchmark9kTarGzip(b *testing.B) { return } n, err := io.Copy(buf, fh) + if err != nil { + b.Error(err) + return + } fh.Close() reader := bytes.NewReader(buf.Bytes())