From fab954f13ffcda6e5114f35dccec1c1e2d3fe00c Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Wed, 18 Feb 2015 15:33:19 -0800 Subject: [PATCH] Run govet and fix --- Makefile | 4 +++- pkg/api/minioapi/definitions.go | 4 ++-- pkg/storage/erasure/erasure_decode.go | 2 -- pkg/storage/erasure/erasure_encode.go | 2 -- pkg/storage/inmemory/inmemory.go | 8 ++++++++ pkg/utils/checksum/crc32c/crc32c_darwin.go | 14 ++++++-------- pkg/utils/checksum/crc32c/crc32c_linux.go | 2 -- pkg/utils/config/config.go | 2 -- pkg/utils/cpu/cpu.go | 2 -- pkg/utils/cpu/cpu_test.go | 2 -- pkg/utils/crypto/sha1/sha1.go | 2 -- pkg/utils/split/split.go | 2 -- 12 files changed, 19 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 447116d85..cbfc27643 100644 --- a/Makefile +++ b/Makefile @@ -12,10 +12,12 @@ checkgopath: getdeps: checkdeps checkgopath @go get github.com/tools/godep && echo "Installed godep" - @go get golang.org/x/tools/cmd/cover && echo "Installed cover" + @go get golang.org/x/tools/cmd/vet && echo "Install govet" + @go get golang.org/x/tools/cmd/cover && echo "Installed gocover" build-all: getdeps @echo "Building Libraries" + @godep go vet ./... @godep go generate ./... @godep go build ./... diff --git a/pkg/api/minioapi/definitions.go b/pkg/api/minioapi/definitions.go index acc82cc8a..28f17598d 100644 --- a/pkg/api/minioapi/definitions.go +++ b/pkg/api/minioapi/definitions.go @@ -30,7 +30,7 @@ type ObjectListResponse struct { Marker string MaxKeys int IsTruncated bool - Contents []*Item `xml:"Contents",innerxml` + Contents []*Item `xml:,innerxml` } type BucketListResponse struct { @@ -38,7 +38,7 @@ type BucketListResponse struct { Owner Owner Buckets struct { Bucket []*Bucket - } `xml:"Buckets",innerxml` // Buckets are nested + } `xml:,innerxml` // Buckets are nested } type Bucket struct { diff --git a/pkg/storage/erasure/erasure_decode.go b/pkg/storage/erasure/erasure_decode.go index 92aa38256..4e821ca0f 100644 --- a/pkg/storage/erasure/erasure_decode.go +++ b/pkg/storage/erasure/erasure_decode.go @@ -14,8 +14,6 @@ * limitations under the License. */ -// +build amd64 - package erasure // #cgo CFLAGS: -O0 diff --git a/pkg/storage/erasure/erasure_encode.go b/pkg/storage/erasure/erasure_encode.go index 849bdbd52..637e4e6b1 100644 --- a/pkg/storage/erasure/erasure_encode.go +++ b/pkg/storage/erasure/erasure_encode.go @@ -14,8 +14,6 @@ * limitations under the License. */ -// +build amd64 - package erasure // #cgo CFLAGS: -O0 diff --git a/pkg/storage/inmemory/inmemory.go b/pkg/storage/inmemory/inmemory.go index 1bea65b4f..77de88980 100644 --- a/pkg/storage/inmemory/inmemory.go +++ b/pkg/storage/inmemory/inmemory.go @@ -23,6 +23,7 @@ import ( "io" "sort" "strings" + "sync" "time" mstorage "github.com/minio-io/minio/pkg/storage" @@ -32,6 +33,7 @@ import ( type storage struct { bucketdata map[string]storedBucket objectdata map[string]storedObject + lock *sync.RWMutex } type storedBucket struct { @@ -67,6 +69,9 @@ func (storage *storage) GetBucketPolicy(bucket string) (interface{}, error) { } func (storage *storage) StoreObject(bucket, key, contentType string, data io.Reader) error { + storage.lock.Lock() + defer storage.lock.Unlock() + objectKey := bucket + ":" + key if _, ok := storage.bucketdata[bucket]; ok == false { @@ -104,6 +109,8 @@ func (storage *storage) StoreObject(bucket, key, contentType string, data io.Rea } func (storage *storage) StoreBucket(bucketName string) error { + storage.lock.Lock() + defer storage.lock.Unlock() if !mstorage.IsValidBucket(bucketName) { return mstorage.BucketNameInvalid{Bucket: bucketName} } @@ -170,6 +177,7 @@ func Start() (chan<- string, <-chan error, *storage) { return ctrlChannel, errorChannel, &storage{ bucketdata: make(map[string]storedBucket), objectdata: make(map[string]storedObject), + lock: new(sync.RWMutex), } } diff --git a/pkg/utils/checksum/crc32c/crc32c_darwin.go b/pkg/utils/checksum/crc32c/crc32c_darwin.go index a1e706e92..8cbe843e7 100644 --- a/pkg/utils/checksum/crc32c/crc32c_darwin.go +++ b/pkg/utils/checksum/crc32c/crc32c_darwin.go @@ -14,22 +14,20 @@ * limitations under the License. */ -// +build amd64 - package crc32c import ( "errors" - "hash/crc32" + "hash/crc32" ) var castanagoliTable = crc32.MakeTable(crc32.Castagnoli) func Crc32c(buffer []byte) (uint32, error) { - crc := crc32.New(castanagoliTable) - if len(buffer) <= 0 { - return 0, errors.New("input buffer cannot be null") - } - crc.Write(buffer) + crc := crc32.New(castanagoliTable) + if len(buffer) <= 0 { + return 0, errors.New("input buffer cannot be null") + } + crc.Write(buffer) return crc.Sum32(), nil } diff --git a/pkg/utils/checksum/crc32c/crc32c_linux.go b/pkg/utils/checksum/crc32c/crc32c_linux.go index 499e25eeb..cd40154da 100644 --- a/pkg/utils/checksum/crc32c/crc32c_linux.go +++ b/pkg/utils/checksum/crc32c/crc32c_linux.go @@ -14,8 +14,6 @@ * limitations under the License. */ -// +build amd64 - package crc32c // #include diff --git a/pkg/utils/config/config.go b/pkg/utils/config/config.go index 9ca7d3ca9..41f1bb0b3 100644 --- a/pkg/utils/config/config.go +++ b/pkg/utils/config/config.go @@ -141,8 +141,6 @@ func (c *Config) ReadConfig() error { default: return err } - c.Users = users - return nil } func Loadusers() map[string]User { diff --git a/pkg/utils/cpu/cpu.go b/pkg/utils/cpu/cpu.go index d4c6ec588..8d552bfaa 100644 --- a/pkg/utils/cpu/cpu.go +++ b/pkg/utils/cpu/cpu.go @@ -14,8 +14,6 @@ * limitations under the License. */ -// +build amd64 - package cpu // int has_sse41 (void); diff --git a/pkg/utils/cpu/cpu_test.go b/pkg/utils/cpu/cpu_test.go index 5c2d889a0..5126f2a31 100644 --- a/pkg/utils/cpu/cpu_test.go +++ b/pkg/utils/cpu/cpu_test.go @@ -14,8 +14,6 @@ * limitations under the License. */ -// +build amd64 - package cpu import ( diff --git a/pkg/utils/crypto/sha1/sha1.go b/pkg/utils/crypto/sha1/sha1.go index b888e92c1..b379f8eaa 100644 --- a/pkg/utils/crypto/sha1/sha1.go +++ b/pkg/utils/crypto/sha1/sha1.go @@ -14,8 +14,6 @@ * limitations under the License. */ -// +build amd64 - package sha1 // #include diff --git a/pkg/utils/split/split.go b/pkg/utils/split/split.go index 5319036bc..0dede2b9b 100644 --- a/pkg/utils/split/split.go +++ b/pkg/utils/split/split.go @@ -14,8 +14,6 @@ * limitations under the License. */ -// +build amd64 - package split import (