From: Andy Lester <andy@petdance.com>
Date: Tue, 24 May 2005 11:47:22 +0000 (-0500)
Subject: [PATCH] More embed.fnc strictures, plus consting and localizing
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1df70142a966e14eb7ff3560d69bddb190dbe2ba;p=p5sagit%2Fp5-mst-13.2.git

[PATCH] More embed.fnc strictures, plus consting and localizing
Date: Tue, 24 May 2005 11:47:22 -0500
Message-ID: <20050524164722.GC12027@petdance.com>

Subject: [PATCH] Remove unused casts
From: Andy Lester <andy@petdance.com>
Date: Tue, 24 May 2005 11:42:18 -0500
Message-ID: <20050524164218.GB12027@petdance.com>

p4raw-id: //depot/perl@24625
---

diff --git a/embed.fnc b/embed.fnc
index b55b324..19a64bf 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -348,22 +348,22 @@ ApPR	|bool	|is_uni_xdigit_lc|UV c
 Apd	|STRLEN	|is_utf8_char	|NN const U8 *p
 Apd	|bool	|is_utf8_string	|NN const U8 *s|STRLEN len
 Apd	|bool	|is_utf8_string_loc|NN const U8 *s|STRLEN len|NN const U8 **p
-Ap	|bool	|is_utf8_alnum	|NN const U8 *p
-Ap	|bool	|is_utf8_alnumc	|NN const U8 *p
-Ap	|bool	|is_utf8_idfirst|NN const U8 *p
-Ap	|bool	|is_utf8_idcont	|NN const U8 *p
-Ap	|bool	|is_utf8_alpha	|NN const U8 *p
-Ap	|bool	|is_utf8_ascii	|NN const U8 *p
-Ap	|bool	|is_utf8_space	|NN const U8 *p
-Ap	|bool	|is_utf8_cntrl	|NN const U8 *p
-Ap	|bool	|is_utf8_digit	|NN const U8 *p
-Ap	|bool	|is_utf8_graph	|NN const U8 *p
-Ap	|bool	|is_utf8_upper	|NN const U8 *p
-Ap	|bool	|is_utf8_lower	|NN const U8 *p
-Ap	|bool	|is_utf8_print	|NN const U8 *p
-Ap	|bool	|is_utf8_punct	|NN const U8 *p
-Ap	|bool	|is_utf8_xdigit	|NN const U8 *p
-Ap	|bool	|is_utf8_mark	|NN const U8 *p
+ApR	|bool	|is_utf8_alnum	|NN const U8 *p
+ApR	|bool	|is_utf8_alnumc	|NN const U8 *p
+ApR	|bool	|is_utf8_idfirst|NN const U8 *p
+ApR	|bool	|is_utf8_idcont	|NN const U8 *p
+ApR	|bool	|is_utf8_alpha	|NN const U8 *p
+ApR	|bool	|is_utf8_ascii	|NN const U8 *p
+ApR	|bool	|is_utf8_space	|NN const U8 *p
+ApR	|bool	|is_utf8_cntrl	|NN const U8 *p
+ApR	|bool	|is_utf8_digit	|NN const U8 *p
+ApR	|bool	|is_utf8_graph	|NN const U8 *p
+ApR	|bool	|is_utf8_upper	|NN const U8 *p
+ApR	|bool	|is_utf8_lower	|NN const U8 *p
+ApR	|bool	|is_utf8_print	|NN const U8 *p
+ApR	|bool	|is_utf8_punct	|NN const U8 *p
+ApR	|bool	|is_utf8_xdigit	|NN const U8 *p
+ApR	|bool	|is_utf8_mark	|NN const U8 *p
 p	|OP*	|jmaybe		|NN OP* arg
 pP	|I32	|keyword	|NN const char* d|I32 len
 Ap	|void	|leave_scope	|I32 base
@@ -562,8 +562,8 @@ pd	|PADOFFSET|pad_alloc	|I32 optype|U32 tmptype
 p	|PADOFFSET|allocmy	|NN char* name
 pd	|PADOFFSET|pad_findmy	|NN const char* name
 Ap	|PADOFFSET|find_rundefsvoffset	|
-p	|OP*	|oopsAV		|NN OP* o
-p	|OP*	|oopsHV		|NN OP* o
+pR	|OP*	|oopsAV		|NN OP* o
+pR	|OP*	|oopsHV		|NN OP* o
 pd	|void	|pad_leavemy
 Apd	|SV*	|pad_sv		|PADOFFSET po
 pd	|void	|pad_free	|PADOFFSET po
@@ -623,7 +623,7 @@ Ap	|SV*	|re_intuit_string|regexp* prog
 Ap	|I32	|regexec_flags	|NN regexp* prog|NN char* stringarg \
 				|NN char* strend|NN char* strbeg|I32 minend \
 				|SV* screamer|void* data|U32 flags
-Ap	|regnode*|regnext	|regnode* p
+ApR	|regnode*|regnext	|NN regnode* p
 Ep	|void	|regprop	|SV* sv|const regnode* o
 Ap	|void	|repeatcpy	|NN char* to|NN const char* from|I32 len|I32 count
 ApP	|char*	|rninstr	|NN const char* big|NN const char* bigend \
@@ -740,7 +740,7 @@ Apd	|void	|sv_clear	|NN SV* sv
 Apd	|I32	|sv_cmp		|NN SV* sv1|NN SV* sv2
 Apd	|I32	|sv_cmp_locale	|NN SV* sv1|NN SV* sv2
 #if defined(USE_LOCALE_COLLATE)
-Apd	|char*	|sv_collxfrm	|NN SV* sv|STRLEN* nxp
+Apd	|char*	|sv_collxfrm	|NN SV* sv|NN STRLEN* nxp
 #endif
 Ap	|OP*	|sv_compile_2op	|NN SV* sv|NN OP** startp|NN const char* code|NN PAD** padp
 Apd	|int	|getcwd_sv	|NN SV* sv
@@ -992,13 +992,13 @@ s	|void	|require_errno	|NN GV *gv
 #if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
 s	|void	|hsplit		|HV *hv
 s	|void	|hfreeentries	|HV *hv
-s	|HE*	|new_he
-s	|void	|del_he		|HE *p
-s	|HEK*	|save_hek_flags	|const char *str|I32 len|U32 hash|int flags
-s	|void	|hv_magic_check	|HV *hv|bool *needs_copy|bool *needs_store
-s	|void	|unshare_hek_or_pvn|HEK* hek|const char* sv|I32 len|U32 hash
-s	|HE*	|share_hek_flags|const char* sv|I32 len|U32 hash|int flags
-rs	|void	|hv_notallowed	|int flags|const char *key|I32 klen|const char *msg
+sR	|HE*	|new_he
+s	|void	|del_he		|NN HE *p
+sR	|HEK*	|save_hek_flags	|NN const char *str|I32 len|U32 hash|int flags
+s	|void	|hv_magic_check	|NN HV *hv|NN bool *needs_copy|NN bool *needs_store
+s	|void	|unshare_hek_or_pvn|HEK* hek|NN const char* sv|I32 len|U32 hash
+sR	|HE*	|share_hek_flags|const char* sv|I32 len|U32 hash|int flags
+rs	|void	|hv_notallowed	|int flags|NN const char *key|I32 klen|NN const char *msg
 #endif
 
 #if defined(PERL_IN_MG_C) || defined(PERL_DECL_PROT)
@@ -1110,7 +1110,7 @@ s	|SV **	|pack_rec	|SV *cat|struct tempsym* symptr|SV **beglist|SV **endlist
 s	|SV*	|mul128		|NN SV *sv|U8 m
 s	|I32	|measure_struct	|NN struct tempsym* symptr
 s	|bool	|next_symbol	|NN struct tempsym* symptr
-s	|SV*	|is_an_int	|NN const char *s|STRLEN l
+sR	|SV*	|is_an_int	|NN const char *s|STRLEN l
 s	|int	|div128		|NN SV *pnum|NN bool *done
 s	|const char *|group_end	|NN const char *pat|NN const char *patend|char ender
 s	|const char *|get_num	|NN const char *ppat|NN I32 *lenptr
@@ -1141,7 +1141,7 @@ s	|SV*	|method_common	|SV* meth|U32* hashp
 
 #if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
 s	|OP*	|doform		|CV *cv|GV *gv|OP *retop
-sr	|int	|emulate_eaccess|const char* path|Mode_t mode
+s	|int	|emulate_eaccess|const char* path|Mode_t mode
 #  if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
 s	|int	|dooneliner	|char *cmd|char *filename
 #  endif
@@ -1525,8 +1525,11 @@ np	|void	|my_swabn	|void* ptr|int n
 
 Ap	|GV*	|gv_fetchpvn_flags|const char* name|STRLEN len|I32 flags|I32 sv_type
 Ap	|GV*	|gv_fetchsv|SV *name|I32 flags|I32 sv_type
-dp	|bool	|is_gv_magical_sv|SV *name|U32 flags
+dpR	|bool	|is_gv_magical_sv|SV *name|U32 flags
 
 Apd	|char*	|savesvpv	|SV* sv
 
 END_EXTERN_C
+/*
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */
diff --git a/op.c b/op.c
index 9d0ca5d..20661f8 100644
--- a/op.c
+++ b/op.c
@@ -4652,6 +4652,7 @@ Perl_newXS(pTHX_ const char *name, XSUBADDR_t subaddr, const char *filename)
 	}
 	else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) {
 	    /* already defined (or promised) */
+	    /* XXX It's possible for this HvNAME_get to return null, and get passed into strEQ */
 	    if (ckWARN(WARN_REDEFINE) && !(CvGV(cv) && GvSTASH(CvGV(cv))
 			    && strEQ(HvNAME_get(GvSTASH(CvGV(cv))), "autouse"))) {
 		const line_t oldline = CopLINE(PL_curcop);
@@ -4959,8 +4960,8 @@ Perl_ck_bitop(pTHX_ OP *o)
 	     || o->op_type == OP_BIT_AND
 	     || o->op_type == OP_BIT_XOR))
     {
-	const OP * left = cBINOPo->op_first;
-	const OP * right = left->op_sibling;
+	const OP * const left = cBINOPo->op_first;
+	const OP * const right = left->op_sibling;
 	if ((OP_IS_NUMCOMPARE(left->op_type) &&
 		(left->op_flags & OPf_PARENS) == 0) ||
 	    (OP_IS_NUMCOMPARE(right->op_type) &&
diff --git a/pp_sys.c b/pp_sys.c
index 25acd78..2017104 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -791,7 +791,7 @@ PP(pp_tie)
     HV* stash;
     GV *gv;
     SV *sv;
-    I32 markoff = MARK - PL_stack_base;
+    const I32 markoff = MARK - PL_stack_base;
     const char *methname;
     int how = PERL_MAGIC_tied;
     U32 items;
@@ -878,7 +878,7 @@ PP(pp_untie)
     dVAR; dSP;
     MAGIC *mg;
     SV *sv = POPs;
-    char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
+    const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
 		? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
     if (SvTYPE(sv) == SVt_PVGV && !(sv = (SV *)GvIOp(sv)))
@@ -917,7 +917,7 @@ PP(pp_tied)
     dSP;
     MAGIC *mg;
     SV *sv = POPs;
-    char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
+    const char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
 		? PERL_MAGIC_tied : PERL_MAGIC_tiedscalar;
 
     if (SvTYPE(sv) == SVt_PVGV && !(sv = (SV *)GvIOp(sv)))
@@ -1166,10 +1166,10 @@ Perl_setdefout(pTHX_ GV *gv)
 PP(pp_select)
 {
     dSP; dTARGET;
-    GV *newdefout, *egv;
+    GV *egv;
     HV *hv;
 
-    newdefout = (PL_op->op_private > 0) ? ((GV *) POPs) : (GV *) NULL;
+    GV * const newdefout = (PL_op->op_private > 0) ? ((GV *) POPs) : (GV *) NULL;
 
     egv = GvEGV(PL_defoutgv);
     if (!egv)
@@ -1299,14 +1299,14 @@ PP(pp_enterwrite)
 
     cv = GvFORM(fgv);
     if (!cv) {
-        char *name = NULL;
 	if (fgv) {
-	    SV *tmpsv = sv_newmortal();
+	    SV * const tmpsv = sv_newmortal();
+	    char *name;
 	    gv_efullname4(tmpsv, fgv, Nullch, FALSE);
 	    name = SvPV_nolen(tmpsv);
+	    if (name && *name)
+		DIE(aTHX_ "Undefined format \"%s\" called", name);
 	}
-	if (name && *name)
-	    DIE(aTHX_ "Undefined format \"%s\" called", name);
 	DIE(aTHX_ "Not a format reference");
     }
     if (CvCLONE(cv))
@@ -1388,20 +1388,18 @@ PP(pp_leavewrite)
 	if (!fgv)
 	    DIE(aTHX_ "bad top format reference");
 	cv = GvFORM(fgv);
-	{
-	    char *name = NULL;
-	    if (!cv) {
-	        SV *sv = sv_newmortal();
-		gv_efullname4(sv, fgv, Nullch, FALSE);
-		name = SvPV_nolen(sv);
-	    }
+	if (!cv) {
+	    SV * const sv = sv_newmortal();
+	    char *name;
+	    gv_efullname4(sv, fgv, Nullch, FALSE);
+	    name = SvPV_nolen(sv);
 	    if (name && *name)
-	        DIE(aTHX_ "Undefined top format \"%s\" called",name);
-	    /* why no:
-	    else
-	        DIE(aTHX_ "Undefined top format called");
-	    ?*/
+		DIE(aTHX_ "Undefined top format \"%s\" called",name);
 	}
+	/* why no:
+	else
+	    DIE(aTHX_ "Undefined top format called");
+	?*/
 	if (CvCLONE(cv))
 	    cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
 	return doform(cv,gv,PL_op);
@@ -1525,13 +1523,9 @@ PP(pp_sysopen)
     SV *sv;
     char *tmps;
     STRLEN len;
-    int mode, perm;
+    const int perm = (MAXARG > 3) ? POPi : 0666;
+    const int mode = POPi;
 
-    if (MAXARG > 3)
-	perm = POPi;
-    else
-	perm = 0666;
-    mode = POPi;
     sv = POPs;
     gv = (GV *)POPs;
 
@@ -1751,7 +1745,7 @@ PP(pp_sysread)
     (void)SvPOK_only(read_target);
     if (fp_utf8 && !IN_BYTES) {
 	/* Look at utf8 we got back and count the characters */
-	char *bend = buffer + count;
+	const char *bend = buffer + count;
 	while (buffer < bend) {
 	    if (charstart) {
 	        skip = UTF8SKIP(buffer);
@@ -1805,7 +1799,7 @@ PP(pp_sysread)
 PP(pp_syswrite)
 {
     dVAR; dSP;
-    int items = (SP - PL_stack_base) - TOPMARK;
+    const int items = (SP - PL_stack_base) - TOPMARK;
     if (items == 2) {
 	SV *sv;
         EXTEND(SP, 1);
@@ -1922,9 +1916,8 @@ PP(pp_send)
     }
 #ifdef HAS_SOCKET
     else if (SP > MARK) {
-	char *sockbuf;
 	STRLEN mlen;
-	sockbuf = SvPVx(*++MARK, mlen);
+	char * const sockbuf = SvPVx(*++MARK, mlen);
 	/* length is really flags */
 	retval = PerlSock_sendto(PerlIO_fileno(IoIFP(io)), buffer, blen,
 				 length, (struct sockaddr *)sockbuf, mlen);
@@ -2048,7 +2041,7 @@ PP(pp_sysseek)
     dVAR; dSP;
     GV *gv;
     IO *io;
-    int whence = POPi;
+    const int whence = POPi;
 #if LSEEKSIZE > IVSIZE
     Off_t offset = (Off_t)SvNVx(POPs);
 #else
@@ -2201,7 +2194,7 @@ PP(pp_ioctl)
 {
     dSP; dTARGET;
     SV *argsv = POPs;
-    unsigned int func = POPu;
+    const unsigned int func = POPu;
     const int optype = PL_op->op_type;
     char *s;
     IV retval;
diff --git a/proto.h b/proto.h
index c52d760..a89c45f 100644
--- a/proto.h
+++ b/proto.h
@@ -616,51 +616,67 @@ PERL_CALLCONV bool	Perl_is_utf8_string_loc(pTHX_ const U8 *s, STRLEN len, const
 			__attribute__nonnull__(pTHX_3);
 
 PERL_CALLCONV bool	Perl_is_utf8_alnum(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_alnumc(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_idfirst(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_idcont(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_alpha(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_ascii(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_space(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_cntrl(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_digit(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_graph(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_upper(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_lower(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_print(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_punct(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_xdigit(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV bool	Perl_is_utf8_mark(pTHX_ const U8 *p)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV OP*	Perl_jmaybe(pTHX_ OP* arg)
@@ -1074,9 +1090,11 @@ PERL_CALLCONV PADOFFSET	Perl_pad_findmy(pTHX_ const char* name)
 
 PERL_CALLCONV PADOFFSET	Perl_find_rundefsvoffset(pTHX);
 PERL_CALLCONV OP*	Perl_oopsAV(pTHX_ OP* o)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV OP*	Perl_oopsHV(pTHX_ OP* o)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 PERL_CALLCONV void	Perl_pad_leavemy(pTHX);
@@ -1180,7 +1198,10 @@ PERL_CALLCONV I32	Perl_regexec_flags(pTHX_ regexp* prog, char* stringarg, char*
 			__attribute__nonnull__(pTHX_3)
 			__attribute__nonnull__(pTHX_4);
 
-PERL_CALLCONV regnode*	Perl_regnext(pTHX_ regnode* p);
+PERL_CALLCONV regnode*	Perl_regnext(pTHX_ regnode* p)
+			__attribute__warn_unused_result__
+			__attribute__nonnull__(pTHX_1);
+
 PERL_CALLCONV void	Perl_regprop(pTHX_ SV* sv, const regnode* o);
 PERL_CALLCONV void	Perl_repeatcpy(pTHX_ char* to, const char* from, I32 len, I32 count)
 			__attribute__nonnull__(pTHX_1)
@@ -1403,7 +1424,8 @@ PERL_CALLCONV I32	Perl_sv_cmp_locale(pTHX_ SV* sv1, SV* sv2)
 
 #if defined(USE_LOCALE_COLLATE)
 PERL_CALLCONV char*	Perl_sv_collxfrm(pTHX_ SV* sv, STRLEN* nxp)
-			__attribute__nonnull__(pTHX_1);
+			__attribute__nonnull__(pTHX_1)
+			__attribute__nonnull__(pTHX_2);
 
 #endif
 PERL_CALLCONV OP*	Perl_sv_compile_2op(pTHX_ SV* sv, OP** startp, const char* code, PAD** padp)
@@ -1815,14 +1837,31 @@ STATIC void	S_require_errno(pTHX_ GV *gv)
 #if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
 STATIC void	S_hsplit(pTHX_ HV *hv);
 STATIC void	S_hfreeentries(pTHX_ HV *hv);
-STATIC HE*	S_new_he(pTHX);
-STATIC void	S_del_he(pTHX_ HE *p);
-STATIC HEK*	S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags);
-STATIC void	S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store);
-STATIC void	S_unshare_hek_or_pvn(pTHX_ HEK* hek, const char* sv, I32 len, U32 hash);
-STATIC HE*	S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags);
+STATIC HE*	S_new_he(pTHX)
+			__attribute__warn_unused_result__;
+
+STATIC void	S_del_he(pTHX_ HE *p)
+			__attribute__nonnull__(pTHX_1);
+
+STATIC HEK*	S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags)
+			__attribute__warn_unused_result__
+			__attribute__nonnull__(pTHX_1);
+
+STATIC void	S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store)
+			__attribute__nonnull__(pTHX_1)
+			__attribute__nonnull__(pTHX_2)
+			__attribute__nonnull__(pTHX_3);
+
+STATIC void	S_unshare_hek_or_pvn(pTHX_ HEK* hek, const char* sv, I32 len, U32 hash)
+			__attribute__nonnull__(pTHX_2);
+
+STATIC HE*	S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags)
+			__attribute__warn_unused_result__;
+
 STATIC void	S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const char *msg)
-			__attribute__noreturn__;
+			__attribute__noreturn__
+			__attribute__nonnull__(pTHX_2)
+			__attribute__nonnull__(pTHX_4);
 
 #endif
 
@@ -2114,6 +2153,7 @@ STATIC bool	S_next_symbol(pTHX_ struct tempsym* symptr)
 			__attribute__nonnull__(pTHX_1);
 
 STATIC SV*	S_is_an_int(pTHX_ const char *s, STRLEN l)
+			__attribute__warn_unused_result__
 			__attribute__nonnull__(pTHX_1);
 
 STATIC int	S_div128(pTHX_ SV *pnum, bool *done)
@@ -2159,9 +2199,7 @@ STATIC SV*	S_method_common(pTHX_ SV* meth, U32* hashp);
 
 #if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
 STATIC OP*	S_doform(pTHX_ CV *cv, GV *gv, OP *retop);
-STATIC int	S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
-			__attribute__noreturn__;
-
+STATIC int	S_emulate_eaccess(pTHX_ const char* path, Mode_t mode);
 #  if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
 STATIC int	S_dooneliner(pTHX_ char *cmd, char *filename);
 #  endif
@@ -2622,9 +2660,14 @@ PERL_CALLCONV void	Perl_my_swabn(void* ptr, int n);
 
 PERL_CALLCONV GV*	Perl_gv_fetchpvn_flags(pTHX_ const char* name, STRLEN len, I32 flags, I32 sv_type);
 PERL_CALLCONV GV*	Perl_gv_fetchsv(pTHX_ SV *name, I32 flags, I32 sv_type);
-PERL_CALLCONV bool	Perl_is_gv_magical_sv(pTHX_ SV *name, U32 flags);
+PERL_CALLCONV bool	Perl_is_gv_magical_sv(pTHX_ SV *name, U32 flags)
+			__attribute__warn_unused_result__;
+
 
 PERL_CALLCONV char*	Perl_savesvpv(pTHX_ SV* sv);
 
 END_EXTERN_C
+/*
+ * ex: set ts=8 sts=4 sw=4 noet:
+ */
 /* ex: set ro: */
diff --git a/regcomp.c b/regcomp.c
index e600885..b035cb2 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -2784,21 +2784,22 @@ S_add_data(pTHX_ RExC_state_t *pRExC_state, I32 n, const char *s)
 void
 Perl_reginitcolors(pTHX)
 {
-    int i = 0;
-    char *s = PerlEnv_getenv("PERL_RE_COLORS");
-	
+    const char * const s = PerlEnv_getenv("PERL_RE_COLORS");
     if (s) {
-	PL_colors[0] = s = savepv(s);
+	char *t = savepv(s);
+	int i = 0;
+	PL_colors[0] = t;
 	while (++i < 6) {
-	    s = strchr(s, '\t');
-	    if (s) {
-		*s = '\0';
-		PL_colors[i] = ++s;
+	    t = strchr(t, '\t');
+	    if (t) {
+		*t = '\0';
+		PL_colors[i] = ++t;
 	    }
 	    else
-		PL_colors[i] = s = (char *)"";
+		PL_colors[i] = t = (char *)"";
 	}
     } else {
+	int i = 0;
 	while (i < 6)
 	    PL_colors[i++] = (char *)"";
     }
@@ -3007,13 +3008,10 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
 	    !(r->reganch & ROPT_ANCH) )
 	{
 	    /* turn .* into ^.* with an implied $*=1 */
-	    int type = OP(NEXTOPER(first));
-
-	    if (type == REG_ANY)
-		type = ROPT_ANCH_MBOL;
-	    else
-		type = ROPT_ANCH_SBOL;
-
+	    const int type =
+		(OP(NEXTOPER(first)) == REG_ANY)
+		    ? ROPT_ANCH_MBOL
+		    : ROPT_ANCH_SBOL;
 	    r->reganch |= type | ROPT_IMPLICIT;
 	    first = NEXTOPER(first);
 	    goto again;
@@ -3128,7 +3126,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
 	    && !(data.start_class->flags & ANYOF_EOS)
 	    && !cl_is_anything(data.start_class))
 	{
-	    I32 n = add_data(pRExC_state, 1, "f");
+	    const I32 n = add_data(pRExC_state, 1, "f");
 
 	    New(1006, RExC_rx->data->data[n], 1,
 		struct regnode_charclass_class);
@@ -3184,7 +3182,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
 	if (!(data.start_class->flags & ANYOF_EOS)
 	    && !cl_is_anything(data.start_class))
 	{
-	    I32 n = add_data(pRExC_state, 1, "f");
+	    const I32 n = add_data(pRExC_state, 1, "f");
 
 	    New(1006, RExC_rx->data->data[n], 1,
 		struct regnode_charclass_class);
@@ -3714,7 +3712,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp)
     register char op;
     register char *next;
     I32 flags;
-    char *origparse = RExC_parse;
+    const char * const origparse = RExC_parse;
     char *maxpos;
     I32 min;
     I32 max = REG_INFTY;
@@ -4120,7 +4118,7 @@ tryagain:
 	case '1': case '2': case '3': case '4':
 	case '5': case '6': case '7': case '8': case '9':
 	    {
-		I32 num = atoi(RExC_parse);
+		const I32 num = atoi(RExC_parse);
 
 		if (num > 9 && num >= RExC_npar)
 		    goto defchar;
@@ -4170,7 +4168,6 @@ tryagain:
 	    register UV ender;
 	    register char *p;
 	    char *oldp, *s;
-	    STRLEN numlen;
 	    STRLEN foldlen;
 	    U8 tmpbuf[UTF8_MAXBYTES_CASE+1], *foldbuf;
 
@@ -4246,7 +4243,7 @@ tryagain:
 			break;
 		    case 'x':
 			if (*++p == '{') {
-			    char* e = strchr(p, '}');
+			    char* const e = strchr(p, '}');
 	
 			    if (!e) {
 				RExC_parse = p + 1;
@@ -4255,7 +4252,7 @@ tryagain:
 			    else {
                                 I32 flags = PERL_SCAN_ALLOW_UNDERSCORES
                                     | PERL_SCAN_DISALLOW_PREFIX;
-                                numlen = e - p - 1;
+                                STRLEN numlen = e - p - 1;
 				ender = grok_hex(p + 1, &numlen, &flags, NULL);
 				if (ender > 0xff)
 				    RExC_utf8 = 1;
@@ -4264,7 +4261,7 @@ tryagain:
 			}
 			else {
                             I32 flags = PERL_SCAN_DISALLOW_PREFIX;
-			    numlen = 2;
+			    STRLEN numlen = 2;
 			    ender = grok_hex(p, &numlen, &flags, NULL);
 			    p += numlen;
 			}
@@ -4279,7 +4276,7 @@ tryagain:
 			if (*p == '0' ||
 			  (isDIGIT(p[1]) && atoi(p) >= RExC_npar) ) {
                             I32 flags = 0;
-			    numlen = 3;
+			    STRLEN numlen = 3;
 			    ender = grok_oct(p, &numlen, &flags, NULL);
 			    p += numlen;
 			}
@@ -4301,6 +4298,7 @@ tryagain:
 		default:
 		  normal_default:
 		    if (UTF8_IS_START(*p) && UTF) {
+			STRLEN numlen;
 			ender = utf8n_to_uvchr((U8*)p, RExC_end - p,
 					       &numlen, 0);
 			p += numlen;
@@ -4323,6 +4321,7 @@ tryagain:
 
 			 if (FOLD) {
 			      /* Emit all the Unicode characters. */
+			      STRLEN numlen;
 			      for (foldbuf = tmpbuf;
 				   foldlen;
 				   foldlen -= numlen) {
@@ -4360,6 +4359,7 @@ tryagain:
 
 		     if (FOLD) {
 		          /* Emit all the Unicode characters. */
+			  STRLEN numlen;
 			  for (foldbuf = tmpbuf;
 			       foldlen;
 			       foldlen -= numlen) {
@@ -4423,8 +4423,8 @@ tryagain:
 	if (RExC_utf8)
 	    SvUTF8_on(sv);
 	if (sv_utf8_downgrade(sv, TRUE)) {
-	    char *s       = sv_recode_to_utf8(sv, PL_encoding);
-	    STRLEN newlen = SvCUR(sv);
+	    const char * const s = sv_recode_to_utf8(sv, PL_encoding);
+	    const STRLEN newlen = SvCUR(sv);
 
 	    if (SvUTF8(sv))
 		RExC_utf8 = 1;
@@ -4480,7 +4480,7 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
     if (value == '[' && RExC_parse + 1 < RExC_end &&
 	/* I smell either [: or [= or [. -- POSIX has been here, right? */
 	POSIXCC(UCHARAT(RExC_parse))) {
-	char  c = UCHARAT(RExC_parse);
+	const char c = UCHARAT(RExC_parse);
 	char* s = RExC_parse++;
 	
 	while (RExC_parse < RExC_end && UCHARAT(RExC_parse) != c)
@@ -4489,7 +4489,7 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
 	    /* Grandfather lone [:, [=, [. */
 	    RExC_parse = s;
 	else {
-	    char* t = RExC_parse++; /* skip over the c */
+	    const char* t = RExC_parse++; /* skip over the c */
 
 	    assert(*t == c);
 
@@ -4497,8 +4497,8 @@ S_regpposixcc(pTHX_ RExC_state_t *pRExC_state, I32 value)
   		RExC_parse++; /* skip over the ending ] */
   		posixcc = s + 1;
 		if (*s == ':') {
-		    I32 complement = *posixcc == '^' ? *posixcc++ : 0;
-		    I32 skip = t - posixcc;
+		    const I32 complement = *posixcc == '^' ? *posixcc++ : 0;
+		    const I32 skip = t - posixcc;
 
 		    /* Initially switch on the length of the name.  */
 		    switch (skip) {
@@ -4634,8 +4634,8 @@ STATIC void
 S_checkposixcc(pTHX_ RExC_state_t *pRExC_state)
 {
     if (!SIZE_ONLY && POSIXCC(UCHARAT(RExC_parse))) {
-	char *s = RExC_parse;
- 	char  c = *s++;
+	const char *s = RExC_parse;
+	const char  c = *s++;
 
 	while(*s && isALNUM(*s))
 	    s++;
@@ -4756,7 +4756,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
 		if (RExC_parse >= RExC_end)
 		    vFAIL2("Empty \\%c{}", (U8)value);
 		if (*RExC_parse == '{') {
-		    U8 c = (U8)value;
+		    const U8 c = (U8)value;
 		    e = strchr(RExC_parse++, '}');
                     if (!e)
                         vFAIL2("Missing right brace on \\%c{}", c);
@@ -5283,7 +5283,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
 	    IV i;
 
 	    if (prevvalue < 256) {
-	        IV ceilvalue = value < 256 ? value : 255;
+	        const IV ceilvalue = value < 256 ? value : 255;
 
 #ifdef EBCDIC
 		/* In EBCDIC [\x89-\x91] should include
@@ -5308,8 +5308,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
 			  ANYOF_BITMAP_SET(ret, i);
 	  }
 	  if (value > 255 || UTF) {
-	        UV prevnatvalue  = NATIVE_TO_UNI(prevvalue);
-		UV natvalue      = NATIVE_TO_UNI(value);
+	        const UV prevnatvalue  = NATIVE_TO_UNI(prevvalue);
+		const UV natvalue      = NATIVE_TO_UNI(value);
 
 		ANYOF_FLAGS(ret) |= ANYOF_UNICODE;
 		if (prevnatvalue < natvalue) { /* what about > ? */
@@ -5321,7 +5321,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
 		    if (FOLD) {
 			 U8 foldbuf[UTF8_MAXBYTES_CASE+1];
 			 STRLEN foldlen;
-			 UV f = to_uni_fold(natvalue, foldbuf, &foldlen);
+			 const UV f = to_uni_fold(natvalue, foldbuf, &foldlen);
 
 			 /* If folding and foldable and a single
 			  * character, insert also the folded version
@@ -5873,10 +5873,10 @@ Perl_regdump(pTHX_ regexp *r)
 	PerlIO_printf(Perl_debug_log, "with eval ");
     PerlIO_printf(Perl_debug_log, "\n");
     if (r->offsets) {
-        U32 i;
         const U32 len = r->offsets[0];
         GET_RE_DEBUG_FLAGS_DECL;
         DEBUG_OFFSETS_r({
+	    U32 i;
 	    PerlIO_printf(Perl_debug_log, "Offsets: [%"UVuf"]\n\t", (UV)r->offsets[0]);
 	    for (i = 1; i <= len; i++)
 	        PerlIO_printf(Perl_debug_log, "%"UVuf"[%"UVuf"] ", 
@@ -5926,8 +5926,8 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o)
 	/* Using is_utf8_string() is a crude hack but it may
 	 * be the best for now since we have no flag "this EXACTish
 	 * node was UTF-8" --jhi */
-	bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o));
-	char *s    = do_utf8 ?
+	const bool do_utf8 = is_utf8_string((U8*)STRING(o), STR_LEN(o));
+	const char *s = do_utf8 ?
 	  pv_uni_display(dsv, (U8*)STRING(o), STR_LEN(o), 60,
 			 UNI_DISPLAY_REGEX) :
 	  STRING(o);
@@ -6040,7 +6040,7 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o)
 		    U8 s[UTF8_MAXBYTES_CASE+1];
 		
 		    for (i = 0; i <= 256; i++) { /* just the first 256 */
-			U8 *e = uvchr_to_utf8(s, i);
+			uvchr_to_utf8(s, i);
 			
 			if (i < 256 && swash_fetch(sw, s, TRUE)) {
 			    if (rangestart == -1)
@@ -6050,15 +6050,17 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o)
 			
 			    if (i <= rangestart + 3)
 				for (; rangestart < i; rangestart++) {
+				    U8 *e;
 				    for(e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++)
 					put_byte(sv, *p);
 				}
 			    else {
+				U8 *e;
 				for (e = uvchr_to_utf8(s, rangestart), p = s; p < e; p++)
 				    put_byte(sv, *p);
 				sv_catpv(sv, "-");
-				    for (e = uvchr_to_utf8(s, i - 1), p = s; p < e; p++)
-					put_byte(sv, *p);
+				for (e = uvchr_to_utf8(s, i - 1), p = s; p < e; p++)
+				    put_byte(sv, *p);
 				}
 				rangestart = -1;
 			    }
@@ -6074,7 +6076,7 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o)
 		    while(*s && *s != '\n') s++;
 		
 		    if (*s == '\n') {
-			char *t = ++s;
+			const char *t = ++s;
 			
 			while (*s) {
 			    if (*s == '\n')
@@ -6354,13 +6356,13 @@ Perl_save_re_context(pTHX)
 
     {
 	/* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */
-	U32 i;
-	GV *mgv;
 	REGEXP *rx;
-	char digits[TYPE_CHARS(long)];
 
 	if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
+	    U32 i;
 	    for (i = 1; i <= rx->nparens; i++) {
+		GV *mgv;
+		char digits[TYPE_CHARS(long)];
 		sprintf(digits, "%lu", (long)i);
 		if ((mgv = gv_fetchpv(digits, FALSE, SVt_PV)))
 		    save_scalar(mgv);
diff --git a/regexec.c b/regexec.c
index 6e420d3..d350417 100644
--- a/regexec.c
+++ b/regexec.c
@@ -221,7 +221,6 @@ S_regcppop(pTHX)
     I32 i;
     U32 paren = 0;
     char *input;
-    I32 tmps;
 
     GET_RE_DEBUG_FLAGS_DECL;
 
@@ -237,6 +236,7 @@ S_regcppop(pTHX)
     /* Now restore the parentheses context. */
     for (i -= (REGCP_OTHER_ELEMS - REGCP_FRAME_ELEMS);
 	 i > 0; i -= REGCP_PAREN_ELEMS) {
+	I32 tmps;
 	paren = (U32)SSPOPINT;
 	PL_reg_start_tmp[paren] = (char *) SSPOPPTR;
 	PL_regstartp[paren] = SSPOPINT;
@@ -410,7 +410,7 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     I32 ml_anch;
     register char *other_last = Nullch;	/* other substr checked before this */
     char *check_at = Nullch;		/* check substr found at this pos */
-    I32 multiline = prog->reganch & PMf_MULTILINE;
+    const I32 multiline = prog->reganch & PMf_MULTILINE;
 #ifdef DEBUGGING
     char *i_strpos = strpos;
     SV *dsv = PERL_DEBUG_PAD_ZERO(0);
@@ -427,10 +427,10 @@ Perl_re_intuit_start(pTHX_ regexp *prog, SV *sv, char *strpos,
     }
 
     DEBUG_EXECUTE_r({
-	 char *s   = PL_reg_match_utf8 ?
+	 const char *s   = PL_reg_match_utf8 ?
 	                 sv_uni_display(dsv, sv, 60, UNI_DISPLAY_REGEX) :
 	                 strpos;
-	 int   len = PL_reg_match_utf8 ?
+	 const int   len = PL_reg_match_utf8 ?
 	                 strlen(s) : strend - strpos;
 	 if (!PL_colorset)
 	      reginitcolors();
@@ -966,7 +966,7 @@ STATIC char *
 S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32 norun)
 {
 	dVAR;
-	I32 doevery = (prog->reganch & ROPT_SKIP) == 0;
+	const I32 doevery = (prog->reganch & ROPT_SKIP) == 0;
 	char *m;
 	STRLEN ln;
 	STRLEN lnc;
@@ -1079,7 +1079,6 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32
 	    if (do_utf8) {
 	        UV c, f;
 	        U8 tmpbuf [UTF8_MAXBYTES+1];
-		U8 foldbuf[UTF8_MAXBYTES_CASE+1];
 		STRLEN len, foldlen;
 		
 		if (c1 == c2) {
@@ -1096,6 +1095,7 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32
 			     && (norun || regtry(prog, s)) )
 			    goto got_it;
 			else {
+			     U8 foldbuf[UTF8_MAXBYTES_CASE+1];
 			     uvchr_to_utf8(tmpbuf, c);
 			     f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
 			     if ( f != c
@@ -1135,6 +1135,7 @@ S_find_byclass(pTHX_ regexp * prog, regnode *c, char *s, const char *strend, I32
 			     && (norun || regtry(prog, s)) )
 			    goto got_it;
 			else {
+			     U8 foldbuf[UTF8_MAXBYTES_CASE+1];
 			     uvchr_to_utf8(tmpbuf, c);
 			     f = to_utf8_fold(tmpbuf, foldbuf, &foldlen);
 			     if ( f != c
@@ -1632,13 +1633,11 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
     register char *startpos = stringarg;
     I32 minlen;		/* must match at least this many chars */
     I32 dontbother = 0;	/* how many characters not to try at end */
-    /* I32 start_shift = 0; */		/* Offset of the start to find
-					 constant substr. */		/* CC */
     I32 end_shift = 0;			/* Same for the end. */		/* CC */
     I32 scream_pos = -1;		/* Internal iterator of scream. */
     char *scream_olds;
     SV* oreplsv = GvSV(PL_replgv);
-    bool do_utf8 = DO_UTF8(sv);
+    const bool do_utf8 = DO_UTF8(sv);
     const I32 multiline = prog->reganch & PMf_MULTILINE;
 #ifdef DEBUGGING
     SV *dsv0 = PERL_DEBUG_PAD_ZERO(0);
@@ -1647,6 +1646,7 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
 
     GET_RE_DEBUG_FLAGS_DECL;
 
+    (void)data; /* Currently unused */
     RX_MATCH_UTF8_set(prog,do_utf8);
 
     PL_regcc = 0;
@@ -1731,14 +1731,14 @@ Perl_regexec_flags(pTHX_ register regexp *prog, char *stringarg, register char *
     }
 
     DEBUG_EXECUTE_r({
-	 char *s0   = UTF ?
-	   pv_uni_display(dsv0, (U8*)prog->precomp, prog->prelen, 60,
-			  UNI_DISPLAY_REGEX) :
-	   prog->precomp;
-	 int   len0 = UTF ? SvCUR(dsv0) : prog->prelen;
-	 char *s1   = do_utf8 ? sv_uni_display(dsv1, sv, 60,
+	const char * const s0   = UTF
+	    ? pv_uni_display(dsv0, (U8*)prog->precomp, prog->prelen, 60,
+			  UNI_DISPLAY_REGEX)
+	    : prog->precomp;
+	const int len0 = UTF ? SvCUR(dsv0) : prog->prelen;
+	const char * const s1 = do_utf8 ? sv_uni_display(dsv1, sv, 60,
 					       UNI_DISPLAY_REGEX) : startpos;
-	 int   len1 = do_utf8 ? SvCUR(dsv1) : strend - startpos;
+	const int len1 = do_utf8 ? SvCUR(dsv1) : strend - startpos;
 	 if (!PL_colorset)
 	     reginitcolors();
 	 PerlIO_printf(Perl_debug_log,
@@ -2427,8 +2427,8 @@ S_regmatch(pTHX_ regnode *prog)
 
         DEBUG_EXECUTE_r( {
 	    SV *prop = sv_newmortal();
-	    int docolor = *PL_colors[0];
-	    int taill = (docolor ? 10 : 7); /* 3 chars for "> <" */
+	    const int docolor = *PL_colors[0];
+	    const int taill = (docolor ? 10 : 7); /* 3 chars for "> <" */
 	    int l = (PL_regeol - locinput) > taill ? taill : (PL_regeol - locinput);
 	    /* The part of the string before starttry has one color
 	       (pref0_len chars), between starttry and current
@@ -2454,22 +2454,22 @@ S_regmatch(pTHX_ regnode *prog)
 		pref0_len = pref_len;
 	    regprop(prop, scan);
 	    {
-	      char *s0 =
+	      const char * const s0 =
 		do_utf8 && OP(scan) != CANY ?
 		pv_uni_display(dsv0, (U8*)(locinput - pref_len),
 			       pref0_len, 60, UNI_DISPLAY_REGEX) :
 		locinput - pref_len;
-	      int len0 = do_utf8 ? strlen(s0) : pref0_len;
-	      char *s1 = do_utf8 && OP(scan) != CANY ?
+	      const int len0 = do_utf8 ? strlen(s0) : pref0_len;
+	      const char * const s1 = do_utf8 && OP(scan) != CANY ?
 		pv_uni_display(dsv1, (U8*)(locinput - pref_len + pref0_len),
 			       pref_len - pref0_len, 60, UNI_DISPLAY_REGEX) :
 		locinput - pref_len + pref0_len;
-	      int len1 = do_utf8 ? strlen(s1) : pref_len - pref0_len;
-	      char *s2 = do_utf8 && OP(scan) != CANY ?
+	      const int len1 = do_utf8 ? strlen(s1) : pref_len - pref0_len;
+	      const char * const s2 = do_utf8 && OP(scan) != CANY ?
 		pv_uni_display(dsv2, (U8*)locinput,
 			       PL_regeol - locinput, 60, UNI_DISPLAY_REGEX) :
 		locinput;
-	      int len2 = do_utf8 ? strlen(s2) : l;
+	      const int len2 = do_utf8 ? strlen(s2) : l;
 	      PerlIO_printf(Perl_debug_log,
 			    "%4"IVdf" <%s%.*s%s%s%.*s%s%s%s%.*s%s>%*s|%3"IVdf":%*s%s\n",
 			    (IV)(locinput - PL_bostr),
@@ -2588,7 +2588,6 @@ S_regmatch(pTHX_ regnode *prog)
 		UV uvc = 0;
 		STRLEN len = 0;
 		STRLEN foldlen = 0;
-		U8 foldbuf[ UTF8_MAXBYTES_CASE + 1 ];
 		U8 *uscan = (U8*)NULL;
 		STRLEN bufflen=0;
 		accepted = 0;
@@ -2617,6 +2616,7 @@ S_regmatch(pTHX_ regnode *prog)
 				uscan += len;
 				len=0;
 			    } else {
+				U8 foldbuf[ UTF8_MAXBYTES_CASE + 1 ];
 				uvc = utf8n_to_uvuni( (U8*)uc, UTF8_MAXLEN, &len, uniflags );
 				uvc = to_uni_fold( uvc, foldbuf, &foldlen );
 				foldlen -= UNISKIP( uvc );
diff --git a/scope.c b/scope.c
index 50258df..5fce68a 100644
--- a/scope.c
+++ b/scope.c
@@ -865,7 +865,7 @@ Perl_leave_scope(pTHX_ I32 base)
 	    break;
 	case SAVEt_FREEPV:
 	    ptr = SSPOPPTR;
-	    Safefree((char*)ptr);
+	    Safefree(ptr);
 	    break;
 	case SAVEt_CLEARSV:
 	    ptr = (void*)&PL_curpad[SSPOPLONG];
diff --git a/sv.c b/sv.c
index df40915..82664c0 100644
--- a/sv.c
+++ b/sv.c
@@ -534,7 +534,7 @@ Perl_sv_free_arenas(pTHX)
 	    svanext = (SV*) SvANY(svanext);
 
 	if (!SvFAKE(sva))
-	    Safefree((void *)sva);
+	    Safefree(sva);
     }
 
     for (arena = PL_xnv_arenaroot; arena; arena = arenanext) {
@@ -4949,7 +4949,7 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags)
     if (SvREADONLY(sv)) {
 	if (SvFAKE(sv)) {
 	    char *pvx = SvPVX(sv);
-	    int is_utf8 = SvUTF8(sv);
+	    const int is_utf8 = SvUTF8(sv);
 	    STRLEN len = SvCUR(sv);
             U32 hash   = SvUVX(sv);
 	    SvFAKE_off(sv);