From aabf0fa09656bedabe14a4504950465a4fe13240 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 3 Nov 2026 15:39:36 +0100 Subject: [PATCH 06/10] Fix -Wcast-qual warning in guc_funcs.c show_all_settings() passed its char *values[] array to GetConfigOptionValues() by casting it to const char **, which triggers -Wcast-qual warnings. This was harmless in practice, because the only consumer, BuildTupleFromCStrings(), does not modify the strings. Fix by declaring the array as const char *values[], which is what GetConfigOptionValues() stores into it, and casting away the const with unconstify() when passing it to BuildTupleFromCStrings(). This keeps the const removal explicit and type-checked, and it compiles to the same code as before. --- src/backend/utils/misc/guc_funcs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c index 0e75c903003..e27050575fb 100644 --- a/src/backend/utils/misc/guc_funcs.c +++ b/src/backend/utils/misc/guc_funcs.c @@ -978,7 +978,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]; - char *values[NUM_PG_SETTINGS_ATTS]; + const char *values[NUM_PG_SETTINGS_ATTS]; HeapTuple tuple; Datum result; @@ -991,10 +991,15 @@ show_all_settings(PG_FUNCTION_ARGS) } /* extract values for the current variable */ - GetConfigOptionValues(conf, (const char **) values); + GetConfigOptionValues(conf, values); - /* build a tuple */ - tuple = BuildTupleFromCStrings(attinmeta, values); + /* + * build a tuple + * + * (BuildTupleFromCStrings() takes char ** but does not modify the + * strings, so it's safe to cast away const here.) + */ + tuple = BuildTupleFromCStrings(attinmeta, unconstify(char **, values)); /* make the tuple into a datum */ result = HeapTupleGetDatum(tuple); -- 2.56.0