Re: Remove useless casts to (char *) - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Remove useless casts to (char *)
Date
Msg-id 108db65b-1ed2-4c13-8ac3-034998bdbe34@eisentraut.org
Whole thread Raw
In response to Re: Remove useless casts to (char *)  (Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>)
List 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
> 
> 




pgsql-hackers by date:

Previous
From: Tender Wang
Date:
Subject: Re: generic plans and "initial" pruning
Next
From: "Jelte Fennema-Nio"
Date:
Subject: Re: Adding extension default version to \dx