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-23T14:23:57Z
Lists: pgsql-hackers
I have committed the rest of this with the adjustments you suggested. On 10.02.25 18:44, Dagfinn Ilmari Mannsåker wrote: >> Here is a new patch set rebased over that. > > I had a more thorough read-through this time (as well as applying and > building it), and it does make the code a lot more readable. > > I noticed you in some places added extra parens around remaining casts > with offset additions, e.g. > > - XLogRegisterData((char *) old_key_tuple->t_data + SizeofHeapTupleHeader, > + XLogRegisterData(((char *) old_key_tuple->t_data) + SizeofHeapTupleHeader, > old_key_tuple->t_len - SizeofHeapTupleHeader); > > But not in others: > > - memcpy((char *) tuple->t_data + SizeofHeapTupleHeader, > - (char *) data, > - datalen); > + memcpy((char *) tuple->t_data + SizeofHeapTupleHeader, data, datalen); > > > I don't have a particularly strong opinion either way (maybe -0.2 on the > extra parens), but I mainly think we should keep it consistent, and not > change it gratuitously. > > Greppig indicates to me that the paren-less version is more common: > > $ git grep -P '\(\w+\s*\**\) [\w>-]+ \+ \w+' | wc -l > 283 > $ git grep -P '\(\(\w+\s*\**\) [\w>-]+\) \+ \w+' | wc -l > 96 > > So I think we should leave them as they are. > > - ilmari > >
Commits
-
backend libpq void * argument for binary data
- 454c182f8542 18.0 landed
-
SnapBuildRestoreContents() void * argument for binary data
- ebdccead1647 18.0 landed
-
jsonb internal API void * argument for binary data
- f98765f0ce90 18.0 landed
-
backend launchers void * arguments for binary data
- 7202d72787d3 18.0 landed
-
Remove various unnecessary (char *) casts
- 3e4d86861540 18.0 landed
-
Remove unnecessary (char *) casts [xlog]
- ed5e5f071033 18.0 landed
-
XLogRegisterData, XLogRegisterBufData void * argument for binary data
- cdaeff9b39d9 18.0 landed
-
Remove unnecessary (char *) casts [checksum]
- 1b5841d46150 18.0 landed
-
Remove unnecessary (char *) casts [mem]
- 827b4060a8e3 18.0 landed
-
Remove unnecessary (char *) casts [string]
- 506183bce73a 18.0 landed
-
Make TLS write functions' buffer arguments pointers const
- a9258629edab 18.0 landed