summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut2026-09-11 19:23:34 +0000
committerPeter Eisentraut2026-09-11 19:27:58 +0000
commit4096767a94b039aebcc84e347ea1744374a6f6eb (patch)
treecc77cc442cb473c47785e087cab3c93e7c53c215 /src
parent539b7e8290e71a253ac4b70faed75e38a7125d97 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/postmaster.c2
-rw-r--r--src/backend/utils/adt/jsonpath_scan.l2
-rw-r--r--src/bin/pg_dump/pg_dump_sort.c2
-rw-r--r--src/interfaces/libpq/fe-secure-openssl.c4
4 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 3c034c8a6c7..82a7ada7baa 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -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 */
diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l
index 72d4c5e946a..f2c20639885 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);
@@ -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;
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index 998412783b0..0586cdb6d9d 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -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 *));
diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c
index 48cec07cefb..a15069cbf6c 100644
--- a/src/interfaces/libpq/fe-secure-openssl.c
+++ b/src/interfaces/libpq/fe-secure-openssl.c
@@ -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