Declare err in loop to limit its scope (#8200)

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
Victor Farazdagi 2021-01-05 05:55:23 -08:00 committed by GitHub
parent 1abe92fd8b
commit 9d737d60f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -77,7 +77,7 @@ func (s *Service) SubscribeToTopic(topic string, opts ...pubsub.SubOpt) (*pubsub
if featureconfig.Get().EnablePeerScorer {
scoringParams := topicScoreParams(topic)
if scoringParams != nil {
if err = topicHandle.SetScoreParams(scoringParams); err != nil {
if err := topicHandle.SetScoreParams(scoringParams); err != nil {
return nil, err
}
}

View File

@ -78,7 +78,7 @@ func privKey(cfg *Config) (*ecdsa.PrivateKey, error) {
}
dst := make([]byte, hex.EncodedLen(len(rawbytes)))
hex.Encode(dst, rawbytes)
if err = fileutil.WriteFile(defaultKeyPath, dst); err != nil {
if err := fileutil.WriteFile(defaultKeyPath, dst); err != nil {
return nil, err
}
convertedKey := convertFromInterfacePrivKey(priv)
@ -129,7 +129,7 @@ func metaDataFromConfig(cfg *Config) (*pbp2p.MetaData, error) {
if err != nil {
return nil, err
}
if err = fileutil.WriteFile(defaultKeyPath, dst); err != nil {
if err := fileutil.WriteFile(defaultKeyPath, dst); err != nil {
return nil, err
}
return metaData, nil

View File

@ -312,7 +312,7 @@ func TestRPCBeaconBlocksByRange_RPCHandlerRateLimitOverflow(t *testing.T) {
})
stream, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl)
require.NoError(t, err)
if err = r.beaconBlocksByRangeRPCHandler(context.Background(), req, stream); err != nil {
if err := r.beaconBlocksByRangeRPCHandler(context.Background(), req, stream); err != nil {
return err
}
if testutil.WaitTimeout(&wg, 1*time.Second) {
@ -563,7 +563,7 @@ func TestRPCBeaconBlocksByRange_EnforceResponseInvariants(t *testing.T) {
})
stream, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl)
require.NoError(t, err)
if err = r.beaconBlocksByRangeRPCHandler(context.Background(), req, stream); err != nil {
if err := r.beaconBlocksByRangeRPCHandler(context.Background(), req, stream); err != nil {
return err
}
if testutil.WaitTimeout(&wg, 1*time.Second) {
@ -725,7 +725,7 @@ func TestRPCBeaconBlocksByRange_FilterBlocks(t *testing.T) {
})
stream, err := p1.BHost.NewStream(context.Background(), p2.BHost.ID(), pcl)
require.NoError(t, err)
if err = r.beaconBlocksByRangeRPCHandler(context.Background(), req, stream); err != nil {
if err := r.beaconBlocksByRangeRPCHandler(context.Background(), req, stream); err != nil {
return err
}
if testutil.WaitTimeout(&wg, 1*time.Second) {

View File

@ -72,7 +72,7 @@ func (ds *Service) DetectAttesterSlashings(
}
}
if len(slashings) > 0 {
if err = ds.slasherDB.SaveAttesterSlashings(ctx, status.Active, slashings); err != nil {
if err := ds.slasherDB.SaveAttesterSlashings(ctx, status.Active, slashings); err != nil {
return nil, err
}
}