postgres.git / summary / log / commit / refs

commit    cefe7576404f5c96f25d4f683ffab72634c421fa
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Thu Jun 04 15:37:43 2026 +0000
First released in: 14.24, 15.19, 16.15, 17.11, 18.6

    Fix another case of indirectly casting away const.
    
    Like 8f1791c61, this fixes a case of implicitly casting away
    const by not treating the result of strrchr() on a const pointer
    as const.  This was missed at the time because the machines
    reporting those warnings weren't building with --with-llvm.
    
    While here, clean up another infelicity: in the probably-
    impossible case that the input string contains only one dot,
    this function would call pnstrdup() with a length of -1
    and thereby emit a module name equal to the function name.
    It seems to me we should emit modname = NULL instead.
    
    Also remove a useless Assert and two redundant assignments.
    
    Back-patch, as 8f1791c61 was, so that users of back branches
    don't see this warning when building with late-model gcc.
    
    Reported-by: hubert depesz lubaczewski <depesz@depesz.com>
    Author: Tom Lane <tgl@sss.pgh.pa.us>
    Discussion: https://postgr.es/m/aiGNJ89PBqvq2Yyz@depesz.com
    Backpatch-through: 14


src/backend/jit/llvm/llvmjit.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c index a601033fa98..2eb2fe370f5 100644 --- a/src/backend/jit/llvm/llvmjit.c +++ b/src/backend/jit/llvm/llvmjit.c @@ -1148,9 +1148,6 @@ llvm_create_types(void) void llvm_split_symbol_name(const char *name, char **modname, char **funcname) { - *modname = NULL; - *funcname = NULL; - /* * Module function names are pgextern.$module.$funcname */ @@ -1160,14 +1157,21 @@ llvm_split_symbol_name(const char *name, char **modname, char **funcname) * Symbol names cannot contain a ., therefore we can split based on * first and last occurrence of one. */ - *funcname = rindex(name, '.'); - (*funcname)++; /* jump over . */ - - *modname = pnstrdup(name + strlen("pgextern."), - *funcname - name - strlen("pgextern.") - 1); - Assert(funcname); + const char *lastdot; - *funcname = pstrdup(*funcname); + name += strlen("pgextern."); + lastdot = strrchr(name, '.'); + if (lastdot) + { + *modname = pnstrdup(name, lastdot - name); + *funcname = pstrdup(lastdot + 1); + } + else + { + /* hmm, no second dot? */ + *modname = NULL; + *funcname = pstrdup(name); + } } else { [parent: 080d61f07ce2]