Re: More const-marking cleanup
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-12-08T07:43:34Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix some cases of indirectly casting away const.
- de77775a7b50 18.4 landed
- cc9c22a5160a 15.18 landed
- a56a70141e09 17.10 landed
- 244c047205bb 14.23 landed
- 0969bfd0db86 16.14 landed
- 8f1791c61836 19 (unreleased) landed
-
Fix another case of indirectly casting away const.
- 9f7565c6c2d4 19 (unreleased) landed
-
ecpg: refactor to eliminate cast-away-const in find_variable().
- 4eda42e8bdf5 19 (unreleased) landed
Attachments
Hi, On Fri, Dec 05, 2025 at 03:52:40PM -0500, Tom Lane wrote: > I wrote: > > Ah. Your script didn't notice the need for const'ification of > > additional variables in map_locale() :-(. Ah, right, thanks for letting me know. It would need more work to catch those. That said I improved the script [1] so that: - It found one more (see the attached) - It is able to detect cases even for functions created in the code tree. It found that skip_drive() (path.c) and bsearch_arg() (bsearch_arg.c) are also functions that cast away const in their return values - It also checked callers for the 2 functions above and did not find const to add > Adding these comments feels a bit like putting lipstick on a pig. > find_variable and its subroutines are an inelegant, duplicative > mess that fails to handle cases it easily could handle if it were > rewritten. But I've put enough brain cells into this already, > and also it appears that there are restrictions elsewhere in ecpg > that'd have to be lifted before it'd make a difference. I also look at those (even if already pushed in 4eda42e8bdf) and they LGTM. [1]: https://github.com/bdrouvot/coccinelle_on_pg/blob/main/misc/indirectly_casting_away_const.cocci Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com