pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Remove unnecessary casts in free() and pfree()
4+ messages / 3 participants
[nested] [flat]

Commits from this thread:
  2022-08-27 94077df1c2  Avoid casting away const in sepgsql's quote_object_name.
* pgsql: Remove unnecessary casts in free() and pfree()
@ 2022-08-26 14:02  Peter Eisentraut <peter@eisentraut.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Peter Eisentraut @ 2022-08-26 14:02 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Remove unnecessary casts in free() and pfree()

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://www.postgresql.org/message-id/flat/cf26e970-8e92-59f1-247a-aa265235075b%40enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/45987aae260a441886a010323bf3e143ce8e82d6

Modified Files
--------------
contrib/sepgsql/label.c        | 8 ++++----
src/backend/utils/fmgr/dfmgr.c | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Remove unnecessary casts in free() and pfree()
@ 2022-08-27 11:23  Justin Pryzby <pryzby@telsasoft.com>
  parent: Peter Eisentraut <peter@eisentraut.org>
  0 siblings, 1 reply; 4+ messages in thread

From: Justin Pryzby @ 2022-08-27 11:23 UTC (permalink / raw)
  To: Peter Eisentraut <peter@eisentraut.org>; +Cc: pgsql-committers@lists.postgresql.org

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);

I imagine it would've been reported earlier, except that this commit was within
60min of the commit that broke perl.

-- 
Justin





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Remove unnecessary casts in free() and pfree()
@ 2022-08-27 14:15  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Justin Pryzby <pryzby@telsasoft.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Tom Lane @ 2022-08-27 14:15 UTC (permalink / raw)
  To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: Peter Eisentraut <peter@eisentraut.org>; pgsql-committers@lists.postgresql.org

Justin Pryzby <pryzby@telsasoft.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





^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: pgsql: Remove unnecessary casts in free() and pfree()
@ 2022-08-27 14:49  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Tom Lane @ 2022-08-27 14:49 UTC (permalink / raw)
  To: Justin Pryzby <pryzby@telsasoft.com>; +Cc: Peter Eisentraut <peter@eisentraut.org>; pgsql-committers@lists.postgresql.org

I wrote:
> Justin Pryzby <pryzby@telsasoft.com> writes:
>> This seems to be breaking cfbot's "warnings" test.

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

Oh, I see: sepgsql's quote_object_name() is doing

	const char *temp;

	temp = quote_identifier(src1);
	appendStringInfoString(&result, temp);
	if (src1 != temp)
		pfree(temp);

evidently because whoever wrote this felt a compulsion to override
quote_identifier's judgment that possibly leaking the quoted identifier
wasn't worth worrying about.  I think we should just nuke this code
altogether and write

	appendStringInfoString(&result, quote_identifier(src1));

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2022-08-27 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 14:02 pgsql: Remove unnecessary casts in free() and pfree() Peter Eisentraut <peter@eisentraut.org>
2022-08-27 11:23 ` Justin Pryzby <pryzby@telsasoft.com>
2022-08-27 14:15   ` Tom Lane <tgl@sss.pgh.pa.us>
2022-08-27 14:49     ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox