From dec63526aa152329f5649d509a72aa1975170868 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 15 Sep 2026 08:43:09 +0200 Subject: [PATCH v2 4/8] Fix -Wcast-qual warnings with external APIs These casts were there only drop a qualifier to satisfy some external API. Convert them to unconstify to make the purpose clear. --- src/backend/libpq/be-secure-gssapi.c | 2 +- src/backend/libpq/be-secure-openssl.c | 2 +- src/backend/port/win32/socket.c | 2 +- src/bin/psql/tab-complete.in.c | 2 +- src/interfaces/libpq/fe-secure-gssapi.c | 2 +- src/interfaces/libpq/fe-secure-openssl.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/backend/libpq/be-secure-gssapi.c b/src/backend/libpq/be-secure-gssapi.c index 540ed62a5cc..eb841cb0c96 100644 --- a/src/backend/libpq/be-secure-gssapi.c +++ b/src/backend/libpq/be-secure-gssapi.c @@ -195,7 +195,7 @@ be_gssapi_write(Port *port, const void *ptr, size_t len) else input.length = bytes_to_encrypt; - input.value = (char *) ptr + bytes_encrypted; + input.value = unconstify(char *, (const char *) ptr + bytes_encrypted); output.value = NULL; output.length = 0; diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c index b7ded8a0250..bf403142fd4 100644 --- a/src/backend/libpq/be-secure-openssl.c +++ b/src/backend/libpq/be-secure-openssl.c @@ -1804,7 +1804,7 @@ alpn_cb(SSL *ssl, Assert(outlen != NULL); Assert(in != NULL); - retval = SSL_select_next_proto((unsigned char **) out, outlen, + retval = SSL_select_next_proto(unconstify(unsigned char **, out), outlen, alpn_protos, sizeof(alpn_protos), in, inlen); if (*out == NULL || *outlen > sizeof(alpn_protos) || *outlen <= 0) diff --git a/src/backend/port/win32/socket.c b/src/backend/port/win32/socket.c index e16fd85ddd4..092d41e3f63 100644 --- a/src/backend/port/win32/socket.c +++ b/src/backend/port/win32/socket.c @@ -466,7 +466,7 @@ pgwin32_send(SOCKET s, const void *buf, int len, int flags) return -1; wbuf.len = len; - wbuf.buf = (char *) buf; + wbuf.buf = unconstify(void *, buf); /* * Readiness of socket to send data to UDP socket may be not true: socket diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index e27a3e2208a..f4c06bed666 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1514,7 +1514,7 @@ static char *dequote_file_name(char *fname, int quote_char); void initialize_readline(void) { - rl_readline_name = (char *) pset.progname; + rl_readline_name = unconstify(char *, pset.progname); rl_attempted_completion_function = psql_completion; #ifdef USE_FILENAME_QUOTING_FUNCTIONS diff --git a/src/interfaces/libpq/fe-secure-gssapi.c b/src/interfaces/libpq/fe-secure-gssapi.c index cc60240582d..5ae10af5678 100644 --- a/src/interfaces/libpq/fe-secure-gssapi.c +++ b/src/interfaces/libpq/fe-secure-gssapi.c @@ -185,7 +185,7 @@ pg_GSS_write(PGconn *conn, const void *ptr, size_t len) else input.length = bytes_to_encrypt; - input.value = (char *) ptr + bytes_encrypted; + input.value = unconstify(char *, (const char *) ptr) + bytes_encrypted; output.value = NULL; output.length = 0; diff --git a/src/interfaces/libpq/fe-secure-openssl.c b/src/interfaces/libpq/fe-secure-openssl.c index 8895a17ff8a..243ed240087 100644 --- a/src/interfaces/libpq/fe-secure-openssl.c +++ b/src/interfaces/libpq/fe-secure-openssl.c @@ -1153,7 +1153,7 @@ initialize_SSL(PGconn *conn) !(strspn(host, "0123456789.") == strlen(host) || strchr(host, ':'))) { - if (SSL_set_tlsext_host_name(conn->ssl, host) != 1) + if (SSL_set_tlsext_host_name(conn->ssl, unconstify(char *, host)) != 1) { char *errm = SSLerrmessage(ERR_get_error()); -- 2.55.0