Small refactor to get rid of -Wshadow=compatible-local warning
authorDavid Rowley <[email protected]>
Thu, 25 Aug 2022 14:46:56 +0000 (02:46 +1200)
committerDavid Rowley <[email protected]>
Thu, 25 Aug 2022 14:46:56 +0000 (02:46 +1200)
Further reduce -Wshadow=compatible-local warnings by 1 by refactoring the
code in gistRelocateBuildBuffersOnSplit() to make use of
foreach_current_index() instead of manually incrementing a variable on
each loop.

Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvpGZX-X=Bn4moyXgfFa0CdSUwoa04d3isit3=1qo8F8Bw@mail.gmail.com

src/backend/access/gist/gistbuildbuffers.c

index eabf746018261a784775d4b7a9208c4950e5214b..c6c7dfe4c2d7b9312228fbba627fe61fa48f81ab 100644 (file)
@@ -543,8 +543,7 @@ gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate,
    GISTNodeBuffer *nodeBuffer;
    BlockNumber blocknum;
    IndexTuple  itup;
-   int         splitPagesCount = 0,
-               i;
+   int         splitPagesCount = 0;
    GISTENTRY   entry[INDEX_MAX_KEYS];
    bool        isnull[INDEX_MAX_KEYS];
    GISTNodeBuffer oldBuf;
@@ -595,11 +594,11 @@ gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate,
     * Fill relocation buffers information for node buffers of pages produced
     * by split.
     */
-   i = 0;
    foreach(lc, splitinfo)
    {
        GISTPageSplitInfo *si = (GISTPageSplitInfo *) lfirst(lc);
        GISTNodeBuffer *newNodeBuffer;
+       int             i = foreach_current_index(lc);
 
        /* Decompress parent index tuple of node buffer page. */
        gistDeCompressAtt(giststate, r,
@@ -618,8 +617,6 @@ gistRelocateBuildBuffersOnSplit(GISTBuildBuffers *gfbb, GISTSTATE *giststate,
 
        relocationBuffersInfos[i].nodeBuffer = newNodeBuffer;
        relocationBuffersInfos[i].splitinfo = si;
-
-       i++;
    }
 
    /*