]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Remove unnecessary volatile qualifiers.
authorNathan Bossart <nathan@postgresql.org>
Tue, 7 Jul 2026 15:57:48 +0000 (10:57 -0500)
committerNathan Bossart <nathan@postgresql.org>
Tue, 7 Jul 2026 15:57:48 +0000 (10:57 -0500)
commitb34fd845e03aea7401d3bf403c87e171d10f7709
tree78125e05508f4bdb5ef720fcd9f5ad118408493f
parent343594a26d37522efdbae5fe5de13e19ccf2fa72
Remove unnecessary volatile qualifiers.

This commit cleans up volatile qualifiers that fit the below
criteria:

* Accesses to shared memory protected by a spinlock or LWLock.
Before commit 0709b7ee72, callers had to use volatile when
accessing spinlock-protected shared memory.  Since spinlock
acquire/release became compiler barriers, and because LWLocks
provide the same guarantee, that is no longer necessary.  These
either predate that change or were cargo-culted from code that did.

* Pointers used only to find the address of a member.  The volatile
qualifier only affects accesses made by dereferencing the pointer,
so it is unnecessary there.

* Accesses to struct members that are marked volatile in the struct
definition.  There's no need to mark these pointers volatile,
either.

* Leftovers from removed PG_TRY blocks.  These were marked volatile
to protect a value that is modified inside a PG_TRY block, but the
PG_TRY has since been removed.

Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi>
Discussion: https://postgr.es/m/akQ5eJR1tCCXme8e%40nathan
src/backend/access/transam/clog.c
src/backend/catalog/index.c
src/backend/commands/async.c
src/backend/replication/syncrep.c
src/backend/storage/ipc/procsignal.c
src/backend/storage/ipc/shm_toc.c
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/proc.c
src/test/modules/test_shm_mq/setup.c
src/test/modules/test_shm_mq/worker.c