| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Don't cast away const where possible |
| Date: | 2025-12-22 11:53:03 |
| Message-ID: | b660d0d6-e04d-4bf9-af1a-96b721be657f@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 18.12.25 14:55, Bertrand Drouvot wrote:
> Some functions are casting away the const qualifiers from their signatures in
> local variables.
@@ -1304,8 +1304,8 @@ merge_overlapping_ranges(FmgrInfo *cmp, Oid colloid,
static int
compare_distances(const void *a, const void *b)
{
- DistanceValue *da = (DistanceValue *) a;
- DistanceValue *db = (DistanceValue *) b;
+ const DistanceValue *da = (const DistanceValue *) a;
+ const DistanceValue *db = (const DistanceValue *) b;
I wonder if the better fix here wouldn't be to get rid of the cast.
It's not necessary, and without it the compiler would automatically warn
about qualifier mismatches. These comparison functions seem to be a
common pattern.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | VASUKI M | 2025-12-22 12:25:57 | Re: [PATCH] psql: tab completion for ALTER ROLE ... IN DATABASE ... |
| Previous Message | Amit Kapila | 2025-12-22 11:48:41 | Re: Improve logical replication usability when tables lack primary keys |