Re: Remove useless casts to (char *)

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Remove useless casts to (char *)
Date: 2025-02-09 12:26:13
Message-ID: c2df6122-6090-42f8-85a5-c5475fc6f016@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 06.02.25 12:49, Dagfinn Ilmari Mannsåker wrote:
> I have only skimmed the patches, but one hunk jumped out at me:
>
> Peter Eisentraut <peter(at)eisentraut(dot)org> 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?

Yeah, that makes sense. I've committed that. Here is a new patch set
rebased over that.

Attachment Content-Type Size
v2-0001-Remove-unnecessary-char-casts-string.patch text/plain 6.1 KB
v2-0002-Remove-unnecessary-char-casts-mem.patch text/plain 17.0 KB
v2-0003-Remove-unnecessary-char-casts-checksum.patch text/plain 3.0 KB
v2-0004-Remove-various-unnecessary-char-casts.patch text/plain 13.8 KB
v2-0005-backend-launchers-void-arguments-for-binary-data.patch text/plain 21.3 KB
v2-0006-backend-libpq-void-argument-for-binary-data.patch text/plain 6.2 KB
v2-0007-jsonb-internal-API-void-argument-for-binary-data.patch text/plain 4.4 KB
v2-0008-SnapBuildRestoreContents-void-argument-for-binary.patch text/plain 3.2 KB
v2-0009-XLogRegisterData-XLogRegisterBufData-void-argumen.patch text/plain 3.9 KB
v2-0010-Remove-unnecessary-char-casts-xlog.patch text/plain 69.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhang Mingli 2025-02-09 13:16:53 Re: Proposal to CREATE FOREIGN TABLE LIKE
Previous Message Rushabh Lathia 2025-02-09 12:25:23 Re: Support NOT VALID / VALIDATE constraint options for named NOT NULL constraints