From f80d8c10a3e5ff2ecb9ed60ec5533a882ac132d5 Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Wed, 17 Sep 2025 06:39:50 -0600 Subject: [PATCH] Make savesharedpvn arg Non-Null It was NULLOK only to stop a compiler warning. No warning happens with c99 and a slight rearrangement; and NULLs are not acceptable input. --- embed.fnc | 2 +- proto.h | 3 ++- util.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/embed.fnc b/embed.fnc index 4eb1df93843a..914adcba0ea5 100644 --- a/embed.fnc +++ b/embed.fnc @@ -3014,7 +3014,7 @@ Cdp |void |save_set_svflags \ Aadp |char * |savesharedpv |NULLOK const char *pv : NULLOK only to suppress a compiler warning -Aadp |char * |savesharedpvn |NULLOK const char * const pv \ +Aadp |char * |savesharedpvn |NN const char * const pv \ |const STRLEN len Cdp |void |save_shared_pvref \ |NN char **str diff --git a/proto.h b/proto.h index 2a9e2e05227b..957af9284bef 100644 --- a/proto.h +++ b/proto.h @@ -4162,7 +4162,8 @@ PERL_CALLCONV char * Perl_savesharedpvn(pTHX_ const char * const pv, const STRLEN len) __attribute__malloc__ __attribute__warn_unused_result__; -#define PERL_ARGS_ASSERT_SAVESHAREDPVN +#define PERL_ARGS_ASSERT_SAVESHAREDPVN \ + assert(pv) PERL_CALLCONV void Perl_savestack_grow(pTHX); diff --git a/util.c b/util.c index 982a318011a4..edbaffbf179d 100644 --- a/util.c +++ b/util.c @@ -1359,10 +1359,10 @@ Perl_savesharedpv(pTHX_ const char *pv) char * Perl_savesharedpvn(pTHX_ const char *const pv, const STRLEN len) { - char *const newaddr = (char*)PerlMemShared_malloc(len + 1); - + PERL_ARGS_ASSERT_SAVESHAREDPVN; PERL_UNUSED_CONTEXT; - /* PERL_ARGS_ASSERT_SAVESHAREDPVN; */ + + char *const newaddr = (char*)PerlMemShared_malloc(len + 1); if (!newaddr) { croak_no_mem_ext(STR_WITH_LEN("util:savesharedpvn"));