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 21:23:34 +02:00
parent 539b7e8290
commit 4096767a94
4 changed files with 5 additions and 5 deletions

View File

@@ -227,7 +227,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 */

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);
@@ -393,7 +392,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

@@ -150,7 +150,6 @@ static const int dbObjectTypePriority[] =
StaticAssertDecl(lengthof(dbObjectTypePriority) == (DO_SUBSCRIPTION + 1),
"array length mismatch");
static DumpId preDataBoundId;
static DumpId postDataBoundId;
@@ -540,7 +539,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

@@ -81,7 +81,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;
@@ -112,7 +114,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