public inbox for [email protected]
help / color / mirror / Atom feedFrom: Dagfinn Ilmari Mannsåker <[email protected]>
To: Peter Eisentraut <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Remove useless casts to (char *)
Date: Thu, 06 Feb 2025 11:49:00 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Hi Peter,
I have only skimmed the patches, but one hunk jumped out at me:
Peter Eisentraut <[email protected]> writes:
> diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
> index 1bf27d93cfa..937a2b02a4f 100644
> --- a/src/backend/libpq/pqcomm.c
> +++ b/src/backend/libpq/pqcomm.c
> @@ -1368,7 +1368,7 @@ internal_flush_buffer(const char *buf, size_t *start, size_t *end)
> {
> int r;
>
> - r = secure_write(MyProcPort, (char *) bufptr, bufend - bufptr);
> + r = secure_write(MyProcPort, unconstify(char *, bufptr), bufend - bufptr);
>
> if (r <= 0)
> {
Insted of unconstify here, could we not make secure_write() (and
be_tls_write()) take the buffer pointer as const void *, like the
attached?
- ilmari
Attachments:
[text/x-patch] 0001-Make-TLS-write-functions-buffe-arguments-pointers-to.txt (3.0K, ../[email protected]/2-0001-Make-TLS-write-functions-buffe-arguments-pointers-to.txt)
download | inline diff:
From 70d7fe7de4a504ece6c8289960a2014d960d7450 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= <[email protected]>
Date: Thu, 6 Feb 2025 11:46:08 +0000
Subject: [PATCH] Make TLS write functions' buffe arguments pointers to const
---
src/backend/libpq/be-secure-openssl.c | 2 +-
src/backend/libpq/be-secure.c | 2 +-
src/backend/libpq/pqcomm.c | 2 +-
src/include/libpq/libpq-be.h | 2 +-
src/include/libpq/libpq.h | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/backend/libpq/be-secure-openssl.c b/src/backend/libpq/be-secure-openssl.c
index abf67bb1b27..64ff3ce3d6a 100644
--- a/src/backend/libpq/be-secure-openssl.c
+++ b/src/backend/libpq/be-secure-openssl.c
@@ -821,7 +821,7 @@ be_tls_read(Port *port, void *ptr, size_t len, int *waitfor)
}
ssize_t
-be_tls_write(Port *port, void *ptr, size_t len, int *waitfor)
+be_tls_write(Port *port, const void *ptr, size_t len, int *waitfor)
{
ssize_t n;
int err;
diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c
index 3b4f80146be..91576f94285 100644
--- a/src/backend/libpq/be-secure.c
+++ b/src/backend/libpq/be-secure.c
@@ -302,7 +302,7 @@ secure_raw_read(Port *port, void *ptr, size_t len)
* Write data to a secure connection.
*/
ssize_t
-secure_write(Port *port, void *ptr, size_t len)
+secure_write(Port *port, const void *ptr, size_t len)
{
ssize_t n;
int waitfor;
diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c
index 1bf27d93cfa..bddd6465de2 100644
--- a/src/backend/libpq/pqcomm.c
+++ b/src/backend/libpq/pqcomm.c
@@ -1368,7 +1368,7 @@ internal_flush_buffer(const char *buf, size_t *start, size_t *end)
{
int r;
- r = secure_write(MyProcPort, (char *) bufptr, bufend - bufptr);
+ r = secure_write(MyProcPort, bufptr, bufend - bufptr);
if (r <= 0)
{
diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h
index 2f6c29200ba..3247088676a 100644
--- a/src/include/libpq/libpq-be.h
+++ b/src/include/libpq/libpq-be.h
@@ -312,7 +312,7 @@ extern ssize_t be_tls_read(Port *port, void *ptr, size_t len, int *waitfor);
/*
* Write data to a secure connection.
*/
-extern ssize_t be_tls_write(Port *port, void *ptr, size_t len, int *waitfor);
+extern ssize_t be_tls_write(Port *port, const void *ptr, size_t len, int *waitfor);
/*
* Return information about the SSL connection.
diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h
index 13d8143a893..8defcb6de19 100644
--- a/src/include/libpq/libpq.h
+++ b/src/include/libpq/libpq.h
@@ -92,7 +92,7 @@ extern void secure_destroy(void);
extern int secure_open_server(Port *port);
extern void secure_close(Port *port);
extern ssize_t secure_read(Port *port, void *ptr, size_t len);
-extern ssize_t secure_write(Port *port, void *ptr, size_t len);
+extern ssize_t secure_write(Port *port, const void *ptr, size_t len);
extern ssize_t secure_raw_read(Port *port, void *ptr, size_t len);
extern ssize_t secure_raw_write(Port *port, const void *ptr, size_t len);
--
2.48.1
view thread (5+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Remove useless casts to (char *)
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox