Remove useless casting to the same type

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Remove useless casting to the same type
Date: 2025-11-24 10:26:32
Message-ID: aSQy2JawavlVlEB0@ip-10-97-1-34.eu-west-3.compute.internal
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

Attached is a patch to $SUBJECT.

This is the same kind of idea as 7f798aca1d5 and ef8fe693606, as their presence
could cause risks of hiding actual type mismatches in the future or silently
discarding qualifiers. I think that it also improves readability.

Those have been found with a coccinelle script as:

"
@@
type T;
T E;
@@

- (T)
E
"

which removes casts when it's casting to the same type.

Note that it generated more that what is in the attached. I chose not to remove
some of them (mainly arithmetic ones) to keep the patch focused on what matters
here.

Thoughts?

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v1-0001-Remove-useless-casting-to-same-type.patch text/x-diff 33.7 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-11-24 10:35:55 Re: make -C src/test/isolation failure in index-killtuples due to btree_gist
Previous Message Peter Eisentraut 2025-11-24 10:20:56 get rid of Pointer type, mostly