Re: fix more casting away of qualifiers

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: fix more casting away of qualifiers
Date: 2026-08-18 10:00:09
Message-ID: 893931da-b76d-4d71-9490-39839b14a453@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 18/08/2026 12:04, Peter Eisentraut wrote:
> The attached patches fix more cases where qualifiers (const, volatile)
> are cast away either accidentally, or unnecessarily, or where it can be
> worked around easily.
>
> I split these into tiny bits to simplify review and to show that they
> are all independent.  But they could perhaps be committed all together.
> (See also similar commit 3f988629805.)
Thanks for the cleanups!

> diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c
> index e2c2919484e..defaa796a0c 100644
> --- a/src/backend/utils/misc/guc_funcs.c
> +++ b/src/backend/utils/misc/guc_funcs.c
> @@ -971,6 +971,7 @@ show_all_settings(PG_FUNCTION_ARGS)
> while (call_cntr < max_calls) /* do when there is more left to send */
> {
> struct config_generic *conf = guc_vars[call_cntr];
> + const char *cvalues[NUM_PG_SETTINGS_ATTS];
> char *values[NUM_PG_SETTINGS_ATTS];
> HeapTuple tuple;
> Datum result;
> @@ -984,7 +985,14 @@ show_all_settings(PG_FUNCTION_ARGS)
> }
>
> /* extract values for the current variable */
> - GetConfigOptionValues(conf, (const char **) values);
> + GetConfigOptionValues(conf, cvalues);
> +
> + /*
> + * This is so that both GetConfigOptionValues() and
> + * BuildTupleFromCStrings() are satisfied about the const-ness without
> + * triggering warnings.
> + */
> + memcpy(values, cvalues, sizeof(cvalues));
>
> /* build a tuple */
> tuple = BuildTupleFromCStrings(attinmeta, values);

This seems hacky. Can we change BuildTupleFromCStrings() to take a const
instead? Maybe that was part of your "difficult half" already?

I guess that requires changing all the callers: You get a warning if
pass a "char **" to a "const char **". Is there a way with some macro
magic or something that you could accept both?

All else look good to me at a quick glance.

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kwangwon Seo 2026-08-18 10:11:58 Re: [PATCH] Fix quotation logic for unreserved keywords in window specifications
Previous Message Daniel Gustafsson 2026-08-18 09:57:39 Re: basebackup: do not verify checksums on pages written before enabling checksums