postgres.git / summary / log / commit / refs
commit d61f79b747c5cc351c8129f33ea28dc16f3660ec
Author: Peter Eisentraut <peter@eisentraut.org>
Date: Fri Sep 11 15:43:11 2026 +0000
First released in: 14.25, 15.20, 16.16, 17.12, 18.7, 19.0
Remove unused global variables
The new clang 23 has a new warning about set-but-unused
static (internal-linkage) global variables: -Wunused-but-set-global,
which is activated in PostgreSQL builds via -Wall. This triggers a
few warnings in PostgreSQL code. This commit removes several such
variables that were either never used or whose last use was removed
some time ago.
For pq_init_crypto_lib, we apply the same #ifdef HAVE_CRYPTO_LOCK that
the other uses of the variable already have, so that the variable is
either fully used or fully nonexistent, depending on the
configuration, not half-way.
Reinit was already documented in a comment as dead code, and it was
removed in a later branch. To minimize the surgery there, just add an
unused attribute to silence the warning.
Reviewed-by: Andreas Karlsson <andreas@proxel.se>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/eb013f9d-2247-444e-8815-9d17b4ce78e7%40eisentraut.org
src/backend/access/transam/xlog.c | 9 ---------
src/backend/postmaster/postmaster.c | 5 +----
src/backend/utils/adt/jsonpath_scan.l | 2 --
src/bin/pg_dump/pg_dump_sort.c | 2 --
src/interfaces/libpq/fe-secure-openssl.c | 4 ++++
5 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index e9508fe9d7b..fcfd19cf46e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -624,7 +624,6 @@ static TimeLineID openLogTLI = 0;
* Those values are kept consistent as long as crash recovery runs.
*/
static XLogRecPtr LocalMinRecoveryPoint;
-static TimeLineID LocalMinRecoveryPointTLI;
static bool updateMinRecoveryPoint = true;
/* For WALInsertLockAcquire/Release functions */
@@ -2457,7 +2456,6 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force)
/* update local copy */
LocalMinRecoveryPoint = ControlFile->minRecoveryPoint;
- LocalMinRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
if (XLogRecPtrIsInvalid(LocalMinRecoveryPoint))
updateMinRecoveryPoint = false;
@@ -2492,7 +2490,6 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force)
ControlFile->minRecoveryPointTLI = newMinRecoveryPointTLI;
UpdateControlFile();
LocalMinRecoveryPoint = newMinRecoveryPoint;
- LocalMinRecoveryPointTLI = newMinRecoveryPointTLI;
ereport(DEBUG2,
(errmsg_internal("updated min recovery point to %X/%X on timeline %u",
@@ -2870,7 +2867,6 @@ XLogNeedsFlush(XLogRecPtr record)
if (!LWLockConditionalAcquire(ControlFileLock, LW_SHARED))
return true;
LocalMinRecoveryPoint = ControlFile->minRecoveryPoint;
- LocalMinRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
LWLockRelease(ControlFileLock);
/*
@@ -5204,12 +5200,10 @@ StartupXLOG(void)
if (InArchiveRecovery)
{
LocalMinRecoveryPoint = ControlFile->minRecoveryPoint;
- LocalMinRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
}
else
{
LocalMinRecoveryPoint = InvalidXLogRecPtr;
- LocalMinRecoveryPointTLI = 0;
}
/* Check that the GUCs used to generate the WAL allow recovery */
@@ -5691,7 +5685,6 @@ SwitchIntoArchiveRecovery(XLogRecPtr EndRecPtr, TimeLineID replayTLI)
}
/* update local copy */
LocalMinRecoveryPoint = ControlFile->minRecoveryPoint;
- LocalMinRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
/*
* The startup process can update its local copy of minRecoveryPoint from
@@ -7165,7 +7158,6 @@ CreateRestartPoint(int flags)
/* update local copy */
LocalMinRecoveryPoint = ControlFile->minRecoveryPoint;
- LocalMinRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
}
if (flags & CHECKPOINT_IS_SHUTDOWN)
ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY;
@@ -7941,7 +7933,6 @@ xlog_redo(XLogReaderState *record)
if (InArchiveRecovery)
{
LocalMinRecoveryPoint = ControlFile->minRecoveryPoint;
- LocalMinRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
}
if (LocalMinRecoveryPoint != InvalidXLogRecPtr && LocalMinRecoveryPoint < lsn)
{
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 5c9876d7140..26e615c14e3 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -229,7 +229,7 @@ static pgsocket ListenSocket[MAXLISTEN];
* the postmaster stop (rather than kill) peers and not reinitialize
* shared data structures. (Reinit is currently dead code, though.)
*/
-static bool Reinit = true;
+pg_attribute_unused() static bool Reinit = true;
static int SendStop = false;
/* still more option variables */
@@ -354,8 +354,6 @@ static time_t AbortStartTime = 0;
/* Length of said timeout */
#define SIGKILL_CHILDREN_AFTER_SECS 5
-static bool ReachedNormalRunning = false; /* T if we've reached PM_RUN */
-
bool ClientAuthInProgress = false; /* T during new-client
* authentication */
@@ -3095,7 +3093,6 @@ reaper(SIGNAL_ARGS)
StartupStatus = STARTUP_NOT_RUNNING;
FatalError = false;
AbortStartTime = 0;
- ReachedNormalRunning = true;
pmState = PM_RUN;
connsAllowed = true;
diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l
index 4351f6ec981..8d8f8317ec9 100644
--- a/src/backend/utils/adt/jsonpath_scan.l
+++ b/src/backend/utils/adt/jsonpath_scan.l
@@ -25,7 +25,6 @@ static JsonPathString scanstring;
/* Handles to the buffer that the lexer uses internally */
static YY_BUFFER_STATE scanbufhandle;
static char *scanbuf;
-static int scanbuflen;
static void addstring(bool init, char *s, int l);
static void addchar(bool init, char s);
@@ -389,7 +388,6 @@ jsonpath_scanner_init(const char *str, int slen)
* Make a scan buffer with special termination needed by flex.
*/
- scanbuflen = slen;
scanbuf = palloc(slen + 2);
memcpy(scanbuf, str, slen);
scanbuf[slen] = scanbuf[slen + 1] = YY_END_OF_BUFFER_CHAR;
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index 0066601b3c0..0358c90559f 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -152,7 +152,6 @@ static const int dbObjectTypePriority[] =
StaticAssertDecl(lengthof(dbObjectTypePriority) == (DO_SUBSCRIPTION + 1),
"array length mismatch");
-static DumpId preDataBoundId;
static DumpId postDataBoundId;
@@ -553,7 +552,6 @@ sortDumpableObjects(DumpableObject **objs, int numObjs,
* Saving the boundary IDs in static variables is a bit grotty, but seems
* better than adding them to parameter lists of subsidiary functions.
*/
- preDataBoundId = preBoundaryId;
postDataBoundId = postBoundaryId;
ordering = (DumpableObject **) pg_malloc(numObjs * sizeof(DumpableObject *));
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 7e53ff3be93..0ba0c9324c2 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -90,7 +90,9 @@ static int my_SSL_set_fd(PGconn *conn, int fd);
static bool pq_init_ssl_lib = true;
+#ifdef HAVE_CRYPTO_LOCK
static bool pq_init_crypto_lib = true;
+#endif
static bool ssl_lib_initialized = false;
@@ -121,7 +123,9 @@ pgtls_init_library(bool do_ssl, int do_crypto)
#endif
pq_init_ssl_lib = do_ssl;
+#ifdef HAVE_CRYPTO_LOCK
pq_init_crypto_lib = do_crypto;
+#endif
}
PostgresPollingStatusType
[parent: 00126dedef74]