Fix variable shadowing in procarray.c.
authorFujii Masao <[email protected]>
Thu, 16 Sep 2021 04:08:31 +0000 (13:08 +0900)
committerFujii Masao <[email protected]>
Thu, 16 Sep 2021 04:08:31 +0000 (13:08 +0900)
ProcArrayGroupClearXid function has a parameter named "proc",
but the same name was used for its local variables. This commit fixes
this variable shadowing, to improve code readability.

Back-patch to all supported versions, to make future back-patching
easy though this patch is classified as refactoring only.

Reported-by: Ranier Vilela
Author: Ranier Vilela, Aleksander Alekseev
https://postgr.es/m/CAEudQAqyoTZC670xWi6w-Oe2_Bk1bfu2JzXz6xRfiOUzm7xbyQ@mail.gmail.com

src/backend/storage/ipc/procarray.c

index 3f9da800b5078d9d8a98330b9d0f876a69d03b60..96bbd7296c3051390edd7012348e0e2ccd03e0dd 100644 (file)
@@ -561,13 +561,13 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
    /* Walk the list and clear all XIDs. */
    while (nextidx != INVALID_PGPROCNO)
    {
-       PGPROC     *proc = &allProcs[nextidx];
+       PGPROC     *nextproc = &allProcs[nextidx];
        PGXACT     *pgxact = &allPgXact[nextidx];
 
-       ProcArrayEndTransactionInternal(proc, pgxact, proc->procArrayGroupMemberXid);
+       ProcArrayEndTransactionInternal(nextproc, pgxact, nextproc->procArrayGroupMemberXid);
 
        /* Move to next proc in list. */
-       nextidx = pg_atomic_read_u32(&proc->procArrayGroupNext);
+       nextidx = pg_atomic_read_u32(&nextproc->procArrayGroupNext);
    }
 
    /* We're done with the lock now. */
@@ -582,18 +582,18 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
     */
    while (wakeidx != INVALID_PGPROCNO)
    {
-       PGPROC     *proc = &allProcs[wakeidx];
+       PGPROC     *nextproc = &allProcs[wakeidx];
 
-       wakeidx = pg_atomic_read_u32(&proc->procArrayGroupNext);
-       pg_atomic_write_u32(&proc->procArrayGroupNext, INVALID_PGPROCNO);
+       wakeidx = pg_atomic_read_u32(&nextproc->procArrayGroupNext);
+       pg_atomic_write_u32(&nextproc->procArrayGroupNext, INVALID_PGPROCNO);
 
        /* ensure all previous writes are visible before follower continues. */
        pg_write_barrier();
 
-       proc->procArrayGroupMember = false;
+       nextproc->procArrayGroupMember = false;
 
-       if (proc != MyProc)
-           PGSemaphoreUnlock(&proc->sem);
+       if (nextproc != MyProc)
+           PGSemaphoreUnlock(&nextproc->sem);
    }
 }