From 2e6ee684091b64c29c4f394d8ec2ca8734263cbe Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 18 Aug 2017 11:45:16 -0700 Subject: [PATCH] fix: [minor] Avoid unnecessary typecasting. (#4828) We don't need to typecast identifiers from their base to type to same type again. This is not a bug and compiler is fine to skip it but it is better to avoid if not needed. --- cmd/erasure-readfile.go | 4 ++-- cmd/signature-v4.go | 4 ++-- cmd/xl-v1-object.go | 2 +- cmd/xl-v1-utils.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/erasure-readfile.go b/cmd/erasure-readfile.go index eeb161269..b054754cb 100644 --- a/cmd/erasure-readfile.go +++ b/cmd/erasure-readfile.go @@ -75,8 +75,8 @@ func (s ErasureStorage) ReadFile(writer io.Writer, volume, path string, offset, return f, err } startOffset = 0 - f.Size += int64(n) - length -= int64(n) + f.Size += n + length -= n } f.Algorithm = algorithm diff --git a/cmd/signature-v4.go b/cmd/signature-v4.go index dec9340a9..007a66922 100644 --- a/cmd/signature-v4.go +++ b/cmd/signature-v4.go @@ -238,13 +238,13 @@ func doesPresignedSignatureMatch(hashedPayload string, r *http.Request, region s return ErrRequestNotReadyYet } - if UTCNow().Sub(pSignValues.Date) > time.Duration(pSignValues.Expires) { + if UTCNow().Sub(pSignValues.Date) > pSignValues.Expires { return ErrExpiredPresignRequest } // Save the date and expires. t := pSignValues.Date - expireSeconds := int(time.Duration(pSignValues.Expires) / time.Second) + expireSeconds := int(pSignValues.Expires / time.Second) // Construct the query. query.Set("X-Amz-Date", t.Format(iso8601Format)) diff --git a/cmd/xl-v1-object.go b/cmd/xl-v1-object.go index 254602a6e..82a416926 100644 --- a/cmd/xl-v1-object.go +++ b/cmd/xl-v1-object.go @@ -571,7 +571,7 @@ func (xl xlObjects) PutObject(bucket string, object string, size int64, data io. // Should return IncompleteBody{} error when reader has fewer bytes // than specified in request header. - if file.Size < int64(curPartSize) { + if file.Size < curPartSize { return ObjectInfo{}, traceError(IncompleteBody{}) } diff --git a/cmd/xl-v1-utils.go b/cmd/xl-v1-utils.go index 26acf7e53..087574c9a 100644 --- a/cmd/xl-v1-utils.go +++ b/cmd/xl-v1-utils.go @@ -117,7 +117,7 @@ func hashOrder(key string, cardinality int) []int { nums := make([]int, cardinality) keyCrc := crc32.Checksum([]byte(key), crc32.IEEETable) - start := int(uint32(keyCrc)%uint32(cardinality)) | 1 + start := int(keyCrc%uint32(cardinality)) | 1 for i := 1; i <= cardinality; i++ { nums[i-1] = 1 + ((start + i) % cardinality) }