From d2f24df19b7a42a0944a6926a0ca54168dcefe3a Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 11 Nov 2025 07:48:54 +0100 Subject: Clean up qsort comparison function for GUC entries guc_var_compare() is invoked from qsort() on an array of struct config_generic, but the function accesses these directly as strings (char *). This relies on the name being the first field, so this works. But we can write this more clearly by using the struct and then accessing the field through the struct. Before the reorganization of the GUC structs (commit a13833c35f9), the old code was probably more convenient, but now we can write this more clearly and correctly. After this change, it is no longer required that the name is the first field in struct config_generic, so remove that comment. Reviewed-by: Tom Lane Discussion: https://www.postgresql.org/message-id/2c961fa1-14f6-44a2-985c-e30b95654e8d%40eisentraut.org --- src/backend/utils/misc/guc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/backend/utils/misc/guc.c') diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 679846da42c..7e2b17cc04e 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1164,10 +1164,10 @@ find_option(const char *name, bool create_placeholders, bool skip_errors, static int guc_var_compare(const void *a, const void *b) { - const char *namea = **(const char **const *) a; - const char *nameb = **(const char **const *) b; + const struct config_generic *ca = *(const struct config_generic *const *) a; + const struct config_generic *cb = *(const struct config_generic *const *) b; - return guc_name_compare(namea, nameb); + return guc_name_compare(ca->name, cb->name); } /* -- cgit v1.2.3