various: remove redundant parentheses (#15793)

release/1.8
Furkan KAMACI 7 years ago committed by Péter Szilágyi
parent 9d48dbf5c2
commit b8caba9709
  1. 2
      accounts/abi/argument.go
  2. 2
      cmd/swarm/config.go
  3. 8
      common/bitutil/bitutil.go
  4. 2
      crypto/ecies/ecies.go
  5. 4
      eth/handler.go
  6. 4
      les/handler.go
  7. 2
      les/serverpool.go
  8. 8
      swarm/storage/chunker_test.go
  9. 2
      swarm/storage/pyramid.go
  10. 2
      trie/trie.go
  11. 4
      whisper/whisperv5/filter_test.go
  12. 4
      whisper/whisperv6/filter_test.go

@ -202,7 +202,7 @@ func (arguments Arguments) Pack(args ...interface{}) ([]byte, error) {
inputOffset := 0 inputOffset := 0
for _, abiArg := range abiArgs { for _, abiArg := range abiArgs {
if abiArg.Type.T == ArrayTy { if abiArg.Type.T == ArrayTy {
inputOffset += (32 * abiArg.Type.Size) inputOffset += 32 * abiArg.Type.Size
} else { } else {
inputOffset += 32 inputOffset += 32
} }

@ -315,7 +315,7 @@ func checkDeprecated(ctx *cli.Context) {
func printConfig(config *bzzapi.Config) string { func printConfig(config *bzzapi.Config) string {
out, err := tomlSettings.Marshal(&config) out, err := tomlSettings.Marshal(&config)
if err != nil { if err != nil {
return (fmt.Sprintf("Something is not right with the configuration: %v", err)) return fmt.Sprintf("Something is not right with the configuration: %v", err)
} }
return string(out) return string(out)
} }

@ -40,7 +40,7 @@ func fastXORBytes(dst, a, b []byte) int {
dw[i] = aw[i] ^ bw[i] dw[i] = aw[i] ^ bw[i]
} }
} }
for i := (n - n%wordSize); i < n; i++ { for i := n - n%wordSize; i < n; i++ {
dst[i] = a[i] ^ b[i] dst[i] = a[i] ^ b[i]
} }
return n return n
@ -84,7 +84,7 @@ func fastANDBytes(dst, a, b []byte) int {
dw[i] = aw[i] & bw[i] dw[i] = aw[i] & bw[i]
} }
} }
for i := (n - n%wordSize); i < n; i++ { for i := n - n%wordSize; i < n; i++ {
dst[i] = a[i] & b[i] dst[i] = a[i] & b[i]
} }
return n return n
@ -128,7 +128,7 @@ func fastORBytes(dst, a, b []byte) int {
dw[i] = aw[i] | bw[i] dw[i] = aw[i] | bw[i]
} }
} }
for i := (n - n%wordSize); i < n; i++ { for i := n - n%wordSize; i < n; i++ {
dst[i] = a[i] | b[i] dst[i] = a[i] | b[i]
} }
return n return n
@ -168,7 +168,7 @@ func fastTestBytes(p []byte) bool {
} }
} }
} }
for i := (n - n%wordSize); i < n; i++ { for i := n - n%wordSize; i < n; i++ {
if p[i] != 0 { if p[i] != 0 {
return true return true
} }

@ -314,7 +314,7 @@ func (prv *PrivateKey) Decrypt(rand io.Reader, c, s1, s2 []byte) (m []byte, err
switch c[0] { switch c[0] {
case 2, 3, 4: case 2, 3, 4:
rLen = ((prv.PublicKey.Curve.Params().BitSize + 7) / 4) rLen = (prv.PublicKey.Curve.Params().BitSize + 7) / 4
if len(c) < (rLen + hLen + 1) { if len(c) < (rLen + hLen + 1) {
err = ErrInvalidMessage err = ErrInvalidMessage
return return

@ -394,14 +394,14 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
case query.Reverse: case query.Reverse:
// Number based traversal towards the genesis block // Number based traversal towards the genesis block
if query.Origin.Number >= query.Skip+1 { if query.Origin.Number >= query.Skip+1 {
query.Origin.Number -= (query.Skip + 1) query.Origin.Number -= query.Skip + 1
} else { } else {
unknown = true unknown = true
} }
case !query.Reverse: case !query.Reverse:
// Number based traversal towards the leaf block // Number based traversal towards the leaf block
query.Origin.Number += (query.Skip + 1) query.Origin.Number += query.Skip + 1
} }
} }
return p.SendBlockHeaders(headers) return p.SendBlockHeaders(headers)

@ -454,14 +454,14 @@ func (pm *ProtocolManager) handleMsg(p *peer) error {
case query.Reverse: case query.Reverse:
// Number based traversal towards the genesis block // Number based traversal towards the genesis block
if query.Origin.Number >= query.Skip+1 { if query.Origin.Number >= query.Skip+1 {
query.Origin.Number -= (query.Skip + 1) query.Origin.Number -= query.Skip + 1
} else { } else {
unknown = true unknown = true
} }
case !query.Reverse: case !query.Reverse:
// Number based traversal towards the leaf block // Number based traversal towards the leaf block
query.Origin.Number += (query.Skip + 1) query.Origin.Number += query.Skip + 1
} }
} }

@ -618,7 +618,7 @@ func (e *knownEntry) Weight() int64 {
if e.state != psNotConnected || !e.known || e.delayedRetry { if e.state != psNotConnected || !e.known || e.delayedRetry {
return 0 return 0
} }
return int64(1000000000 * e.connectStats.recentAvg() * math.Exp(-float64(e.lastConnected.fails)*failDropLn-e.responseStats.recentAvg()/float64(responseScoreTC)-e.delayStats.recentAvg()/float64(delayScoreTC)) * math.Pow((1-e.timeoutStats.recentAvg()), timeoutPow)) return int64(1000000000 * e.connectStats.recentAvg() * math.Exp(-float64(e.lastConnected.fails)*failDropLn-e.responseStats.recentAvg()/float64(responseScoreTC)-e.delayStats.recentAvg()/float64(delayScoreTC)) * math.Pow(1-e.timeoutStats.recentAvg(), timeoutPow))
} }
// poolEntryAddress is a separate object because currently it is necessary to remember // poolEntryAddress is a separate object because currently it is necessary to remember

@ -60,7 +60,7 @@ func (self *chunkerTester) Split(chunker Splitter, data io.Reader, size int64, c
for { for {
select { select {
case <-timeout: case <-timeout:
return errors.New(("Split timeout error")) return errors.New("Split timeout error")
case <-quitC: case <-quitC:
return nil return nil
case chunk := <-chunkC: case chunk := <-chunkC:
@ -97,7 +97,7 @@ func (self *chunkerTester) Append(chunker Splitter, rootKey Key, data io.Reader,
for { for {
select { select {
case <-timeout: case <-timeout:
return errors.New(("Append timeout error")) return errors.New("Append timeout error")
case <-quitC: case <-quitC:
return nil return nil
case chunk := <-chunkC: case chunk := <-chunkC:
@ -146,7 +146,7 @@ func (self *chunkerTester) Join(chunker Chunker, key Key, c int, chunkC chan *Ch
for { for {
select { select {
case <-timeout: case <-timeout:
return errors.New(("Join timeout error")) return errors.New("Join timeout error")
case chunk, ok := <-chunkC: case chunk, ok := <-chunkC:
if !ok { if !ok {
close(quitC) close(quitC)
@ -155,7 +155,7 @@ func (self *chunkerTester) Join(chunker Chunker, key Key, c int, chunkC chan *Ch
// this just mocks the behaviour of a chunk store retrieval // this just mocks the behaviour of a chunk store retrieval
stored, success := self.chunks[chunk.Key.String()] stored, success := self.chunks[chunk.Key.String()]
if !success { if !success {
return errors.New(("Not found")) return errors.New("Not found")
} }
chunk.SData = stored.SData chunk.SData = stored.SData
chunk.Size = int64(binary.LittleEndian.Uint64(chunk.SData[0:8])) chunk.Size = int64(binary.LittleEndian.Uint64(chunk.SData[0:8]))

@ -338,7 +338,7 @@ func (self *PyramidChunker) loadTree(chunkLevel [][]*TreeEntry, key Key, chunkC
chunkLevel[depth-1] = append(chunkLevel[depth-1], newEntry) chunkLevel[depth-1] = append(chunkLevel[depth-1], newEntry)
// Add the rest of the tree // Add the rest of the tree
for lvl := (depth - 1); lvl >= 1; lvl-- { for lvl := depth - 1; lvl >= 1; lvl-- {
//TODO(jmozah): instead of loading finished branches and then trim in the end, //TODO(jmozah): instead of loading finished branches and then trim in the end,
//avoid loading them in the first place //avoid loading them in the first place

@ -489,7 +489,7 @@ func (t *Trie) Commit() (root common.Hash, err error) {
func (t *Trie) CommitTo(db DatabaseWriter) (root common.Hash, err error) { func (t *Trie) CommitTo(db DatabaseWriter) (root common.Hash, err error) {
hash, cached, err := t.hashRoot(db) hash, cached, err := t.hashRoot(db)
if err != nil { if err != nil {
return (common.Hash{}), err return common.Hash{}, err
} }
t.root = cached t.root = cached
t.cachegen++ t.cachegen++

@ -88,7 +88,7 @@ func generateTestCases(t *testing.T, SizeTestFilters int) []FilterTestCase {
for i := 0; i < SizeTestFilters; i++ { for i := 0; i < SizeTestFilters; i++ {
f, _ := generateFilter(t, true) f, _ := generateFilter(t, true)
cases[i].f = f cases[i].f = f
cases[i].alive = (mrand.Int()&int(1) == 0) cases[i].alive = mrand.Int()&int(1) == 0
} }
return cases return cases
} }
@ -122,7 +122,7 @@ func TestInstallFilters(t *testing.T) {
for i, testCase := range tst { for i, testCase := range tst {
fil := filters.Get(testCase.id) fil := filters.Get(testCase.id)
exist := (fil != nil) exist := fil != nil
if exist != testCase.alive { if exist != testCase.alive {
t.Fatalf("seed %d: failed alive: %d, %v, %v", seed, i, exist, testCase.alive) t.Fatalf("seed %d: failed alive: %d, %v, %v", seed, i, exist, testCase.alive)
} }

@ -88,7 +88,7 @@ func generateTestCases(t *testing.T, SizeTestFilters int) []FilterTestCase {
for i := 0; i < SizeTestFilters; i++ { for i := 0; i < SizeTestFilters; i++ {
f, _ := generateFilter(t, true) f, _ := generateFilter(t, true)
cases[i].f = f cases[i].f = f
cases[i].alive = (mrand.Int()&int(1) == 0) cases[i].alive = mrand.Int()&int(1) == 0
} }
return cases return cases
} }
@ -122,7 +122,7 @@ func TestInstallFilters(t *testing.T) {
for i, testCase := range tst { for i, testCase := range tst {
fil := filters.Get(testCase.id) fil := filters.Get(testCase.id)
exist := (fil != nil) exist := fil != nil
if exist != testCase.alive { if exist != testCase.alive {
t.Fatalf("seed %d: failed alive: %d, %v, %v", seed, i, exist, testCase.alive) t.Fatalf("seed %d: failed alive: %d, %v, %v", seed, i, exist, testCase.alive)
} }

Loading…
Cancel
Save