public inbox for [email protected]  
help / color / mirror / Atom feed
From: Nathan Bossart <[email protected]>
To: [email protected]
Subject: pgsql: Remove unnecessary volatile qualifiers.
Date: Tue, 07 Jul 2026 15:58:02 +0000
Message-ID: <[email protected]> (raw)

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 <[email protected]>
Discussion: https://postgr.es/m/akQ5eJR1tCCXme8e%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/b34fd845e03aea7401d3bf403c87e171d10f7709

Modified Files
--------------
src/backend/access/transam/clog.c     |  7 +++----
src/backend/catalog/index.c           |  2 +-
src/backend/commands/async.c          |  4 ++--
src/backend/replication/syncrep.c     | 19 ++++++++-----------
src/backend/storage/ipc/procsignal.c  |  8 ++++----
src/backend/storage/ipc/shm_toc.c     | 31 ++++++++++++++-----------------
src/backend/storage/lmgr/lock.c       |  2 +-
src/backend/storage/lmgr/proc.c       |  3 +--
src/test/modules/test_shm_mq/setup.c  |  4 ++--
src/test/modules/test_shm_mq/worker.c |  2 +-
10 files changed, 37 insertions(+), 45 deletions(-)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Remove unnecessary volatile qualifiers.
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox