From 3d50648cc4f452d51a0564164a214e51dd6aad95 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Mon, 23 Jul 2018 09:15:38 +0100 Subject: Don't compile S_env_alloc() when not used RT #133360 I recently added S_env_alloc() as a helper function for Perl_my_setenv(); but it's not needed on all platforms, so #ifdef it to only be compiled on platforms where its needed. Avoids a compiler warning. --- util.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'util.c') diff --git a/util.c b/util.c index 9d3f5ba0f1..37a71a1a81 100644 --- a/util.c +++ b/util.c @@ -2065,10 +2065,19 @@ Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const char *const bits, #ifdef USE_ENVIRON_ARRAY /* NB: VMS' my_setenv() is in vms.c */ +/* Configure doesn't test for HAS_SETENV yet, so decide based on platform. + * For Solaris, setenv() and unsetenv() were introduced in Solaris 9, so + * testing for HAS UNSETENV is sufficient. + */ +# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN) +# define MY_HAS_SETENV +# endif + /* small wrapper for use by Perl_my_setenv that mallocs, or reallocs if * 'current' is non-null, with up to three sizes that are added together. * It handles integer overflow. */ +# ifndef MY_HAS_SETENV static char * S_env_alloc(void *current, Size_t l1, Size_t l2, Size_t l3, Size_t size) { @@ -2093,6 +2102,7 @@ S_env_alloc(void *current, Size_t l1, Size_t l2, Size_t l3, Size_t size) panic: croak_memory_wrap(); } +# endif # if !defined(WIN32) && !defined(NETWARE) @@ -2174,13 +2184,7 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) # endif /* !PERL_USE_SAFE_PUTENV */ - /* This next branch should only be called #if defined(HAS_SETENV), but - Configure doesn't test for that yet. For Solaris, setenv() and - unsetenv() were introduced in Solaris 9, so testing for HAS - UNSETENV is sufficient. - */ -# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__) || (defined(__sun) && defined(HAS_UNSETENV)) || defined(PERL_DARWIN) - +# ifdef MY_HAS_SETENV # if defined(HAS_UNSETENV) if (val == NULL) { (void)unsetenv(nam); @@ -2218,7 +2222,7 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) my_setenv_format(new_env, nam, nlen, val, vlen); (void)putenv(new_env); -# endif /* __CYGWIN__ */ +# endif /* MY_HAS_SETENV */ # ifndef PERL_USE_SAFE_PUTENV } -- cgit v1.2.1