Skip to content

Commit 8767a86

Browse files
committed
Fix variable shadowing in procarray.c.
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
1 parent e06cc02 commit 8767a86

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/backend/storage/ipc/procarray.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -552,13 +552,13 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
552552
/* Walk the list and clear all XIDs. */
553553
while (nextidx != INVALID_PGPROCNO)
554554
{
555-
PGPROC *proc = &allProcs[nextidx];
555+
PGPROC *nextproc = &allProcs[nextidx];
556556
PGXACT *pgxact = &allPgXact[nextidx];
557557

558-
ProcArrayEndTransactionInternal(proc, pgxact, proc->procArrayGroupMemberXid);
558+
ProcArrayEndTransactionInternal(nextproc, pgxact, nextproc->procArrayGroupMemberXid);
559559

560560
/* Move to next proc in list. */
561-
nextidx = pg_atomic_read_u32(&proc->procArrayGroupNext);
561+
nextidx = pg_atomic_read_u32(&nextproc->procArrayGroupNext);
562562
}
563563

564564
/* We're done with the lock now. */
@@ -573,18 +573,18 @@ ProcArrayGroupClearXid(PGPROC *proc, TransactionId latestXid)
573573
*/
574574
while (wakeidx != INVALID_PGPROCNO)
575575
{
576-
PGPROC *proc = &allProcs[wakeidx];
576+
PGPROC *nextproc = &allProcs[wakeidx];
577577

578-
wakeidx = pg_atomic_read_u32(&proc->procArrayGroupNext);
579-
pg_atomic_write_u32(&proc->procArrayGroupNext, INVALID_PGPROCNO);
578+
wakeidx = pg_atomic_read_u32(&nextproc->procArrayGroupNext);
579+
pg_atomic_write_u32(&nextproc->procArrayGroupNext, INVALID_PGPROCNO);
580580

581581
/* ensure all previous writes are visible before follower continues. */
582582
pg_write_barrier();
583583

584-
proc->procArrayGroupMember = false;
584+
nextproc->procArrayGroupMember = false;
585585

586-
if (proc != MyProc)
587-
PGSemaphoreUnlock(proc->sem);
586+
if (nextproc != MyProc)
587+
PGSemaphoreUnlock(nextproc->sem);
588588
}
589589
}
590590

0 commit comments

Comments
 (0)