summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2014-06-12 21:23:14 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2014-06-13 21:41:58 -0400
commit8c2b19724d117cecfa186d044abdbf766372c679 (patch)
tree05aa26abffa2a53a577c846d81bb8f2743b99817 /pp_ctl.c
parentb017fe877ad78f04afaa3c1327fc46391f572bfb (diff)
downloadperl-8c2b19724d117cecfa186d044abdbf766372c679.tar.gz
Some low-hanging -Wunreachable-code fruits.
- after croak/die/exit (or return), break (or return!) are pointless (break is not a terminator/separator, it's a promise of a jump) - after goto, another goto (!) is pointless - in some cases (usually function ends) introduce explicit NOT_REACHED to make the noreturn nature clearer (do not do this everywhere, though, since that would mean adding NOT_REACHED after every croak) - for the added NOT_REACHED also add /* NOTREACHED */ since NOT_REACHED is for gcc (and VC), while the comment is for linters - declaring variables in switch blocks is just too fragile: it kind of works for narrowing the scope (which is nice), but breaks the moment there are initializations for the variables (they will be skipped!); in some easy cases simply hoist the declarations out of the block and move them earlier There are still a few places left.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index ab729b0334..8957a8ceed 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -1357,9 +1357,8 @@ Perl_block_gimme(pTHX)
return G_ARRAY;
default:
Perl_croak(aTHX_ "panic: bad gimme: %d\n", cxstack[cxix].blk_gimme);
- assert(0); /* NOTREACHED */
- return 0;
}
+ NOT_REACHED; /* NOTREACHED */
}
I32
@@ -4336,8 +4335,8 @@ PP(pp_leaveeval)
SvPVX_const(namesv),
SvUTF8(namesv) ? -(I32)SvCUR(namesv) : (I32)SvCUR(namesv),
G_DISCARD);
- retop = Perl_die(aTHX_ "%"SVf" did not return a true value",
- SVfARG(namesv));
+ Perl_die(aTHX_ "%"SVf" did not return a true value", SVfARG(namesv));
+ NOT_REACHED; /* NOTREACHED */
/* die_unwind() did LEAVE, or we won't be here */
}
else {