Remove useless casts to (char *)

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-02-05T21:25:35Z
Lists: pgsql-hackers

Attachments

In the spirit of the recent patch set "Remove useless casts to (void *)" 
[0], here is patch set that removes a bunch of apparently useless casts 
to (char *).

There are two larger themes:

1) Various casts around string/memory functions such as strcpy() or 
memcpy() that pretty much don't make any sense at all (at least 
post-1989 I guess).

2) Using void * instead of char * for function arguments that deal with 
binary data.  The largest of these is XLogRegisterData() and 
XLogRegisterBufData(), which were also mentioned in [0].  (similar past 
patches: 2d4f1ba6cfc 1f605b82ba6 3b12e68a5c4 b9f0e54bc95)

The remaining (char *) casts are mostly related to signed/unsigned 
conversion, controlling pointer arithmetic, and related to 
palloc/malloc, (and probably some I missed or didn't want to touch) so 
those are all ok to keep.

[0]: 
https://www.postgresql.org/message-id/flat/461ea37c-8b58-43b4-9736-52884e862820%40eisentraut.org

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