From e94dfb78f8e9087eae1c1cd3d41b0a124b9a2dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Fri, 17 Feb 2017 11:48:26 +0200 Subject: [PATCH 1/2] swarm/api/http: fix go vet issue on Go 1.8 --- swarm/api/http/server_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go index 0785890978..88b49b9a5e 100644 --- a/swarm/api/http/server_test.go +++ b/swarm/api/http/server_test.go @@ -113,6 +113,9 @@ func TestBzzrGetPath(t *testing.T) { url += common.ToHex(key[0])[2:] + "/" + k[1:] + "?content_type=text/plain" } resp, err = http.Get(url) + if err != nil { + t.Fatalf("Request failed: %v", err) + } defer resp.Body.Close() respbody, err = ioutil.ReadAll(resp.Body) From bf21549faa7de6e2b920855468b14856c6f503c4 Mon Sep 17 00:00:00 2001 From: Jeffrey Wilcke Date: Fri, 17 Feb 2017 18:39:43 +0100 Subject: [PATCH 2/2] common/math: "optimised" SafeMul and added comment on Exp (#3675) --- common/math/exp.go | 3 +++ common/math/integer.go | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/math/exp.go b/common/math/exp.go index 6f6c040e07..113b76b39b 100644 --- a/common/math/exp.go +++ b/common/math/exp.go @@ -27,6 +27,9 @@ const wordSize = 32 << (uint64(^big.Word(0)) >> 63) // Exp implement exponentiation by squaring algorithm. // +// Exp return a new variable; base and exponent must +// not be changed under any circumstance. +// // Courtesy @karalabe and @chfast func Exp(base, exponent *big.Int) *big.Int { result := big.NewInt(1) diff --git a/common/math/integer.go b/common/math/integer.go index 8162b19854..1689b65864 100644 --- a/common/math/integer.go +++ b/common/math/integer.go @@ -18,8 +18,8 @@ func SafeAdd(x, y uint64) (uint64, bool) { // SafeMul returns multiplication result and whether overflow occurred. func SafeMul(x, y uint64) (uint64, bool) { - if x == 0 { + if x == 0 || y == 0 { return 0, false } - return x * y, x != 0 && y != 0 && y > gmath.MaxUint64/x + return x * y, y > gmath.MaxUint64/x }