1
0
mirror of https://github.com/postgres/postgres.git synced 2026-10-23 13:29:09 +03:00

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
This commit is contained in:
Peter Eisentraut
2026-09-11 17:43:11 +02:00
parent 00126dedef
commit d61f79b747
5 changed files with 5 additions and 17 deletions

View File

@@ -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)
{

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 *));

View File

@@ -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