summaryrefslogtreecommitdiff
path: root/pp_sys.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2015-03-04 15:30:00 +0000
committerDavid Mitchell <davem@iabyn.com>2015-03-11 14:31:04 +0000
commit3dc78631ef832e5b64aa86228917984dc5b14f5e (patch)
treee37e85fcd00d8f5ba8cd2710615e720ccb63c44b /pp_sys.c
parent1835335041e939eb53f98ca39ac99981b211887d (diff)
downloadperl-3dc78631ef832e5b64aa86228917984dc5b14f5e.tar.gz
don't test non-null args
For lots of core functions: if a function parameter has been declared NN in embed.fnc, don't test for nullness at the start of the function, i.e. eliminate code like if (!foo) ... On debugging builds the test is redundant, as the PERL_ARGS_ASSERT_FOO at the start of the function will already have croaked. On optimised builds, it will skip the check (and so be slightly faster), but if actually passed a null arg, will now crash with a null-deref SEGV rather than doing whatever the check used to do (e.g. croak, or silently return and let the caller's code logic to go awry). But hopefully this should never happen as such instances will already have been detected on debugging builds. It also has the advantage of shutting up recent clangs which spew forth lots of stuff like: sv.c:6308:10: warning: nonnull parameter 'bigstr' will evaluate to 'true' on first encounter [-Wpointer-bool-conversion] if (!bigstr) The only exception was in dump.c, where rather than skipping the null test, I instead changed the function def in embed.fnc to allow a null arg, on the basis that dump functions are often used for debugging (where pointers may unexpectedly become NULL) and it's better there to display that this item is null than to SEGV. See the p5p thread starting at 20150224112829.GG28599@iabyn.com.
Diffstat (limited to 'pp_sys.c')
-rw-r--r--pp_sys.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index 2f70006842..2a9e24c069 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4806,7 +4806,7 @@ S_space_join_names_mortal(pTHX_ char *const *array)
PERL_ARGS_ASSERT_SPACE_JOIN_NAMES_MORTAL;
- if (array && *array) {
+ if (*array) {
target = newSVpvs_flags("", SVs_TEMP);
while (1) {
sv_catpv(target, *array);