From 4590301344cbe42a8bcc6b2ea7ca0b7c6ee7dd66 Mon Sep 17 00:00:00 2001 From: alingse Date: Tue, 17 Dec 2024 22:10:47 +0800 Subject: [PATCH] fix: check `r.err != nil` but return a nil value error `err` (#13120) the `err` has been checked. so it's value must be nil, so should return `r.err` I have an idea to detect code that returns a non-relevant nilness error bug. I checked the top 1000 GitHub Go repositories and found this, all result listed in https://github.com/alingse/sundrylint/issues/4 Signed-off-by: alingse --- eth/stagedsync/stage_polygon_sync.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eth/stagedsync/stage_polygon_sync.go b/eth/stagedsync/stage_polygon_sync.go index 44a6178345e..8fb3cccc1ef 100644 --- a/eth/stagedsync/stage_polygon_sync.go +++ b/eth/stagedsync/stage_polygon_sync.go @@ -1039,7 +1039,7 @@ func (s polygonSyncStageBridgeStore) LastEventIdWithinWindow(ctx context.Context return 0, err } if r.err != nil { - return 0, err + return 0, r.err } return r.id, nil