From 15da7de53aba7d95406b3e0c361e20b3785ed004 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 3 Nov 2026 15:39:36 +0100 Subject: [PATCH v2 06/11] 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. Discussion: https://www.postgresql.org/message-id/flat/70b86618-4038-4b19-8847-1a400d99d477%40eisentraut.org --- src/backend/utils/misc/guc_funcs.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c index b137bf08e56..e950d38dacf 100644 --- a/src/backend/utils/misc/guc_funcs.c +++ b/src/backend/utils/misc/guc_funcs.c @@ -915,7 +915,7 @@ show_all_settings(PG_FUNCTION_ARGS) for (int i = 0; i < num_vars; i++) { struct config_generic *conf = guc_vars[i]; - char *values[NUM_PG_SETTINGS_ATTS]; + const char *values[NUM_PG_SETTINGS_ATTS]; HeapTuple tuple; /* skip if marked NO_SHOW_ALL or if not visible to current user */ @@ -924,10 +924,17 @@ show_all_settings(PG_FUNCTION_ARGS) continue; /* extract values for the current variable */ - GetConfigOptionValues(conf, (const char **) values); + GetConfigOptionValues(conf, values); - /* build a tuple and store it */ - 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)); + + /* store it */ tuplestore_puttuple(rsinfo->setResult, tuple); } -- 2.56.0