postgres.git / summary / log / commit / refs

commit    b9f3db23b7b5c7f522162e16482b096d9c930f80
Author:   Andres Freund <andres@anarazel.de>
Date:     Mon Jul 15 16:26:02 2024 +0000
First released in: 18.0, 12.20, 13.16, 14.13, 15.8, 16.4, 17.0

    Fix type confusion in guc_var_compare()
    
    Before this change guc_var_compare() cast the input arguments to
    const struct config_generic *.  That's not quite right however, as the input
    on one side is often just a char * on one side.
    
    Instead just use char *, the first field in config_generic.
    
    This fixes a -Warray-bounds warning with some versions of gcc. While the
    warning is only known to be triggered for <= 15, the issue the warning points
    out seems real, so apply the fix everywhere.
    
    Author: Nazir Bilal Yavuz <byavuz81@gmail.com>
    Reported-by: Erik Rijkers <er@xs4all.nl>
    Suggested-by: Andres Freund <andres@anarazel.de>
    Discussion: https://postgr.es/m/a74a1a0d-0fd2-3649-5224-4f754e8f91aa%40xs4all.nl


src/backend/utils/misc/guc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 07d6538f590..9f98c6e2b21 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5721,10 +5721,10 @@ find_option(const char *name, bool create_placeholders, bool skip_errors, static int guc_var_compare(const void *a, const void *b) { - const struct config_generic *confa = *(struct config_generic *const *) a; - const struct config_generic *confb = *(struct config_generic *const *) b; + const char *namea = **(const char ** const *) a; + const char *nameb = **(const char ** const *) b; - return guc_name_compare(confa->name, confb->name); + return guc_name_compare(namea, nameb); } /* [parent: e7f9f44e3bd9]