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
>From 35ba0a6c90fd23c4a0d422e94ec9f57c0a94eb76 Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot <[email protected]> Date: Mon, 8 Dec 2025 07:05:19 +0000 Subject: [PATCH v1] Fix a case of indirectly casting away const This one has been missed in 8f1791c6183. Author: Bertrand Drouvot <[email protected]> Discussion: https://postgr.es/m/[email protected] --- src/port/getopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 100.0% src/port/ diff --git a/src/port/getopt.c b/src/port/getopt.c index 655fef3b0c7..2cca5a0673a 100644 --- a/src/port/getopt.c +++ b/src/port/getopt.c @@ -72,7 +72,7 @@ int getopt(int nargc, char *const *nargv, const char *ostr) { static char *place = EMSG; /* option letter processing */ - char *oli; /* option letter list index */ + const char *oli; /* option letter list index */ if (!*place) { /* update scanning pointer */ -- 2.34.1
