Skip to content

Commit a32a2b9

Browse files
mueslikaralabe
authored andcommitted
cmd, contracts, eth, p2p, signer, whisper: fixed ineffectual assignments (#19869)
Fixed assigning values to variables we don't end up using.
1 parent 04e175b commit a32a2b9

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

cmd/clef/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ func testExternalUI(api *core.SignerAPI) {
767767
data := `{"types":{"EIP712Domain":[{"name":"name","type":"string"},{"name":"version","type":"string"},{"name":"chainId","type":"uint256"},{"name":"verifyingContract","type":"address"}],"Person":[{"name":"name","type":"string"},{"name":"test","type":"uint8"},{"name":"wallet","type":"address"}],"Mail":[{"name":"from","type":"Person"},{"name":"to","type":"Person"},{"name":"contents","type":"string"}]},"primaryType":"Mail","domain":{"name":"Ether Mail","version":"1","chainId":"1","verifyingContract":"0xCCCcccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"message":{"from":{"name":"Cow","test":"3","wallet":"0xcD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"},"to":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB","test":"2"},"contents":"Hello, Bob!"}}`
768768
//_, err := api.SignData(ctx, accounts.MimetypeTypedData, *addr, hexutil.Encode([]byte(data)))
769769
var typedData core.TypedData
770-
err := json.Unmarshal([]byte(data), &typedData)
771-
_, err = api.SignTypedData(ctx, *addr, typedData)
770+
json.Unmarshal([]byte(data), &typedData)
771+
_, err := api.SignTypedData(ctx, *addr, typedData)
772772
expectApprove("sign 712 typed data", err)
773773
}
774774
{ // Sign data test - plain text

cmd/geth/retesteth.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -768,10 +768,10 @@ func (api *RetestethAPI) StorageRangeAt(ctx context.Context,
768768
}
769769
// Ensure any modifications are committed to the state
770770
// Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect
771-
root = statedb.IntermediateRoot(vmenv.ChainConfig().IsEIP158(block.Number()))
771+
_ = statedb.IntermediateRoot(vmenv.ChainConfig().IsEIP158(block.Number()))
772772
if idx == int(txIndex) {
773773
// This is to make sure root can be opened by OpenTrie
774-
root, err = statedb.Commit(vmenv.ChainConfig().IsEIP158(block.Number()))
774+
_, err = statedb.Commit(vmenv.ChainConfig().IsEIP158(block.Number()))
775775
if err != nil {
776776
return StorageRangeResult{}, err
777777
}
@@ -832,7 +832,7 @@ func retesteth(ctx *cli.Context) error {
832832
log.Info("Welcome to retesteth!")
833833
// register signer API with server
834834
var (
835-
extapiURL = "n/a"
835+
extapiURL string
836836
)
837837
apiImpl := &RetestethAPI{}
838838
var testApi RetestethTestAPI = apiImpl

contracts/checkpointoracle/oracle_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ func TestCheckpointRegister(t *testing.T) {
241241

242242
// Test transaction replay protection
243243
validateOperation(t, c, contractBackend, func() {
244-
number, hash := getRecent()
244+
number, _ := getRecent()
245245
v, r, s := collectSig(0, checkpoint0.Hash(), 2, nil)
246-
hash = common.HexToHash("deadbeef")
246+
hash := common.HexToHash("deadbeef")
247247
c.SetCheckpoint(transactOpts, number, hash, checkpoint0.Hash(), 0, v, r, s)
248248
}, func(events <-chan *contract.CheckpointOracleNewCheckpointVote) error {
249249
return assert(0, emptyHash, big.NewInt(0))

eth/downloader/downloader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ func (d *Downloader) fetchHeaders(p *peerConnection, from uint64, pivot uint64)
997997
// chain errors.
998998
if n := len(headers); n > 0 {
999999
// Retrieve the current head we're at
1000-
head := uint64(0)
1000+
var head uint64
10011001
if d.mode == LightSync {
10021002
head = d.lightchain.CurrentHeader().Number.Uint64()
10031003
} else {

p2p/simulations/adapters/exec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func startExecNodeStack() (*node.Node, error) {
416416
}
417417

418418
// create enode record
419-
nodeTcpConn, err := net.ResolveTCPAddr("tcp", conf.Stack.P2P.ListenAddr)
419+
nodeTcpConn, _ := net.ResolveTCPAddr("tcp", conf.Stack.P2P.ListenAddr)
420420
if nodeTcpConn.IP == nil {
421421
nodeTcpConn.IP = net.IPv4(127, 0, 0, 1)
422422
}

signer/core/signed_data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ func (typedData *TypedData) EncodeData(primaryType string, data map[string]inter
484484

485485
func parseInteger(encType string, encValue interface{}) (*big.Int, error) {
486486
var (
487-
length = 0
487+
length int
488488
signed = strings.HasPrefix(encType, "int")
489489
b *big.Int
490490
)

whisper/mailserver/server_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func singleRequest(t *testing.T, server *WMailServer, env *whisper.Envelope, p *
172172
}
173173

174174
src[0]++
175-
ok, lower, upper, bloom = server.validateRequest(src, request)
175+
ok, lower, upper, _ = server.validateRequest(src, request)
176176
if !ok {
177177
// request should be valid regardless of signature
178178
t.Fatalf("request validation false negative, seed: %d (lower: %d, upper: %d).", seed, lower, upper)

whisper/whisperv6/peer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (peer *Peer) handshake() error {
130130
}
131131
}
132132

133-
isRemotePeerLightNode, err := s.Bool()
133+
isRemotePeerLightNode, _ := s.Bool()
134134
if isRemotePeerLightNode && isLightNode && isRestrictedLightNodeConnection {
135135
return fmt.Errorf("peer [%x] is useless: two light client communication restricted", peer.ID())
136136
}

0 commit comments

Comments
 (0)