Re: pgsql: Remove unnecessary casts in free() and pfree()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Remove unnecessary casts in free() and pfree()
Date: 2022-08-27 14:15:17
Message-ID: 2295181.1661609717@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Justin Pryzby <pryzby(at)telsasoft(dot)com> writes:
> On Fri, Aug 26, 2022 at 02:02:33PM +0000, Peter Eisentraut wrote:
>> Remove unnecessary casts in free() and pfree()

> This seems to be breaking cfbot's "warnings" test.

> [07:49:48.983] label.c:665:10: error: passing argument 1 of ‘pfree’ discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
> [07:49:48.983] 665 | pfree(temp);

Hmm, well, casting away const is certainly not within pfree's remit,
so I'm glad we changed this.

A quick-n-dirty fix is to cast away const at this call site, but
I wonder whether this isn't a symptom of poor const choices.
I'll take a look later today if no one beats me to it.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2022-08-27 14:49:39 Re: pgsql: Remove unnecessary casts in free() and pfree()
Previous Message Alexander Korotkov 2022-08-27 11:54:28 Re: pgsql: Move memory management away from writetup() and tuplesort_put*()