Re: Remove useless casts to (char *)

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-02-09T12:26:13Z
Lists: pgsql-hackers

Attachments

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@eisentraut.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.

Commits

  1. backend libpq void * argument for binary data

  2. SnapBuildRestoreContents() void * argument for binary data

  3. jsonb internal API void * argument for binary data

  4. backend launchers void * arguments for binary data

  5. Remove various unnecessary (char *) casts

  6. Remove unnecessary (char *) casts [xlog]

  7. XLogRegisterData, XLogRegisterBufData void * argument for binary data

  8. Remove unnecessary (char *) casts [checksum]

  9. Remove unnecessary (char *) casts [mem]

  10. Remove unnecessary (char *) casts [string]

  11. Make TLS write functions' buffer arguments pointers const