From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: const qualifier for list APIs |
Date: | 2022-11-16 14:45:48 |
Message-ID: | 1340488.1668609948@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> writes:
> Functions like lappend_*() in list.c do not modify the second
> argument. So it can be qualified as const. Any reason why we don't do
> that? Is it because the target pointer ptr_value is not const
> qualified?
It would be a lie in many (most?) cases, wherever somebody later pulls the
pointer out of the list without applying "const" to it. So I can't see
that adding "const" there would be an improvement.
> So the coding practice though questionable, is
> safe and avoids unnecessary pallocs. But SonarQube does complain about
> it.
Maybe an explicit cast to (void *) would shut it up.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Anton A. Melnikov | 2022-11-16 14:52:50 | Re: [BUG] Logical replica crash if there was an error in a function. |
Previous Message | Anton A. Melnikov | 2022-11-16 14:41:16 | Make a 100_bugs.pl test more faster. |