From b3985abf72a15140152f28aa5b0a953eac8d3040 Mon Sep 17 00:00:00 2001 From: Brendan Abolivier Date: Wed, 5 Dec 2018 17:14:30 +0000 Subject: [PATCH] Declare syncData from the start to avoid declaration shadowing --- .../matrix-org/dendrite/syncapi/sync/requestpool.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/syncapi/sync/requestpool.go b/src/github.com/matrix-org/dendrite/syncapi/sync/requestpool.go index 4c510c128..548703738 100644 --- a/src/github.com/matrix-org/dendrite/syncapi/sync/requestpool.go +++ b/src/github.com/matrix-org/dendrite/syncapi/sync/requestpool.go @@ -45,6 +45,8 @@ func NewRequestPool(db *storage.SyncServerDatabase, n *Notifier, adb *accounts.D // called in a dedicated goroutine for this request. This function will block the goroutine // until a response is ready, or it times out. func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtypes.Device) util.JSONResponse { + var syncData *types.Response + // Extract values from request logger := util.GetLogger(req.Context()) userID := device.UserID @@ -65,7 +67,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype // If this is an initial sync or timeout=0 we return immediately if syncReq.since == nil || syncReq.timeout == 0 { - syncData, err := rp.currentSyncForUser(*syncReq, currPos) + syncData, err = rp.currentSyncForUser(*syncReq, currPos) if err != nil { return httputil.LogThenError(req, err) } @@ -103,7 +105,7 @@ func (rp *RequestPool) OnIncomingSyncRequest(req *http.Request, device *authtype // of calculating the sync only to get timed out before we // can respond - syncData, err := rp.currentSyncForUser(*syncReq, currPos) + syncData, err = rp.currentSyncForUser(*syncReq, currPos) if err != nil { return httputil.LogThenError(req, err) }