From: Andy Lester Date: Mon, 20 Jun 2005 10:22:37 +0000 (-0500) Subject: The continuing adventures of Constman and Localize Boy X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=53c1dcc098c6cc47963786f1928061d90b5d30e1;p=p5sagit%2Fp5-mst-13.2.git The continuing adventures of Constman and Localize Boy Message-ID: <20050620152237.GA5032@petdance.com> p4raw-id: //depot/perl@24913 --- diff --git a/XSUB.h b/XSUB.h index bec91a8..1bcad7c 100644 --- a/XSUB.h +++ b/XSUB.h @@ -82,14 +82,17 @@ is a lexical $_ in scope. =cut */ -#ifndef LINT_UNUSED_ARG +#ifndef PERL_UNUSED_ARG # ifdef lint # include -# define LINT_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) +# define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else -# define LINT_UNUSED_ARG(x) +# define PERL_UNUSED_ARG(x) ((void)x) # endif #endif +#ifndef PERL_UNUSED_VAR +# define PERL_UNUSED_VAR(x) ((void)x) +#endif #define ST(off) PL_stack_base[ax + (off)] @@ -116,9 +119,14 @@ is a lexical $_ in scope. #define dITEMS I32 items = SP - MARK -#define dXSARGS \ - LINT_UNUSED_ARG(cv) \ +#ifdef lint +# define dXSARGS \ + NOTE(ARGUNUSED(cv)) \ + dSP; dAXMARK; dITEMS +#else +# define dXSARGS \ dSP; dAXMARK; dITEMS +#endif #define dXSTARG SV * const targ = ((PL_op->op_private & OPpENTERSUB_HASTARG) \ ? PAD_SV(PL_op->op_targ) : sv_newmortal()) diff --git a/doop.c b/doop.c index 867b45c..6ec3613 100644 --- a/doop.c +++ b/doop.c @@ -306,8 +306,8 @@ S_do_trans_simple_utf8(pTHX_ SV *sv) const I32 grows = PL_op->op_private & OPpTRANS_GROWS; STRLEN len; - SV* rv = (SV*)cSVOP->op_sv; - HV* hv = (HV*)SvRV(rv); + SV* const rv = (SV*)cSVOP->op_sv; + HV* const hv = (HV*)SvRV(rv); SV** svp = hv_fetch(hv, "NONE", 4, FALSE); const UV none = svp ? SvUV(*svp) : 0x7fffffff; const UV extra = none + 1; @@ -400,9 +400,9 @@ S_do_trans_count_utf8(pTHX_ SV *sv) I32 matches = 0; STRLEN len; - SV* rv = (SV*)cSVOP->op_sv; - HV* hv = (HV*)SvRV(rv); - SV** svp = hv_fetch(hv, "NONE", 4, FALSE); + SV* const rv = (SV*)cSVOP->op_sv; + HV* const hv = (HV*)SvRV(rv); + SV** const svp = hv_fetch(hv, "NONE", 4, FALSE); const UV none = svp ? SvUV(*svp) : 0x7fffffff; const UV extra = none + 1; U8 hibit = 0; @@ -442,8 +442,8 @@ S_do_trans_complex_utf8(pTHX_ SV *sv) const I32 squash = PL_op->op_private & OPpTRANS_SQUASH; const I32 del = PL_op->op_private & OPpTRANS_DELETE; const I32 grows = PL_op->op_private & OPpTRANS_GROWS; - SV* rv = (SV*)cSVOP->op_sv; - HV* hv = (HV*)SvRV(rv); + SV * const rv = (SV*)cSVOP->op_sv; + HV * const hv = (HV*)SvRV(rv); SV** svp = hv_fetch(hv, "NONE", 4, FALSE); const UV none = svp ? SvUV(*svp) : 0x7fffffff; const UV extra = none + 1; @@ -456,7 +456,8 @@ S_do_trans_complex_utf8(pTHX_ SV *sv) U8 *s = (U8*)SvPV(sv, len); const I32 isutf8 = SvUTF8(sv); if (!isutf8) { - const U8 *t = s, *e = s + len; + const U8 *t = s; + const U8 * const e = s + len; while (t < e) { const U8 ch = *t++; if ((hibit = !NATIVE_IS_INVARIANT(ch))) @@ -643,7 +644,7 @@ Perl_do_trans(pTHX_ SV *sv) void Perl_do_join(pTHX_ register SV *sv, SV *del, register SV **mark, register SV **sp) { - SV **oldmark = mark; + SV ** const oldmark = mark; register I32 items = sp - mark; register STRLEN len; STRLEN delimlen; @@ -700,7 +701,7 @@ void Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg) { STRLEN patlen; - const char *pat = SvPV_const(*sarg, patlen); + const char * const pat = SvPV_const(*sarg, patlen); bool do_taint = FALSE; SvUTF8_off(sv); diff --git a/embed.fnc b/embed.fnc index 828e6ec..6b515c6 100644 --- a/embed.fnc +++ b/embed.fnc @@ -114,14 +114,14 @@ p |void |boot_core_UNIVERSAL p |void |boot_core_PerlIO Ap |void |call_list |I32 oldscope|NN AV* av_list pR |bool |cando |Mode_t mode|Uid_t effective|NN const Stat_t* statbufp -Ap |U32 |cast_ulong |NV f -Ap |I32 |cast_i32 |NV f -Ap |IV |cast_iv |NV f -Ap |UV |cast_uv |NV f +ApR |U32 |cast_ulong |NV f +ApR |I32 |cast_i32 |NV f +ApR |IV |cast_iv |NV f +ApR |UV |cast_uv |NV f #if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP) -Ap |I32 |my_chsize |int fd|Off_t length +ApR |I32 |my_chsize |int fd|Off_t length #endif -p |OP* |convert |I32 optype|I32 flags|OP* o +pR |OP* |convert |I32 optype|I32 flags|OP* o Afprd |void |croak |const char* pat|... Apr |void |vcroak |const char* pat|va_list* args #if defined(PERL_IMPLICIT_CONTEXT) @@ -245,15 +245,15 @@ p |char* |getenv_len |const char* key|unsigned long *len #endif Ap |void |gp_free |GV* gv Ap |GP* |gp_ref |GP* gp -Ap |GV* |gv_AVadd |GV* gv -Ap |GV* |gv_HVadd |GV* gv -Ap |GV* |gv_IOadd |GV* gv +Ap |GV* |gv_AVadd |NN GV* gv +Ap |GV* |gv_HVadd |NN GV* gv +Ap |GV* |gv_IOadd |NN GV* gv ApR |GV* |gv_autoload4 |HV* stash|NN const char* name|STRLEN len|I32 method Ap |void |gv_check |HV* stash Ap |void |gv_efullname |SV* sv|const GV* gv Apmb |void |gv_efullname3 |SV* sv|const GV* gv|const char* prefix Ap |void |gv_efullname4 |SV* sv|const GV* gv|const char* prefix|bool keepmain -Ap |GV* |gv_fetchfile |const char* name +Ap |GV* |gv_fetchfile |NN const char* name Apd |GV* |gv_fetchmeth |HV* stash|const char* name|STRLEN len \ |I32 level Apd |GV* |gv_fetchmeth_autoload |HV* stash|const char* name|STRLEN len \ @@ -265,7 +265,7 @@ Ap |GV* |gv_fetchpv |const char* name|I32 add|I32 sv_type Ap |void |gv_fullname |SV* sv|const GV* gv Apmb |void |gv_fullname3 |SV* sv|const GV* gv|const char* prefix Ap |void |gv_fullname4 |SV* sv|const GV* gv|const char* prefix|bool keepmain -Ap |void |gv_init |GV* gv|HV* stash|const char* name \ +Ap |void |gv_init |NN GV* gv|NN HV* stash|NN const char* name \ |STRLEN len|int multi Apd |HV* |gv_stashpv |const char* name|I32 create Apd |HV* |gv_stashpvn |const char* name|U32 namelen|I32 create @@ -639,9 +639,10 @@ p |void |rxres_save |NN void** rsp|NN REGEXP* prx #if !defined(HAS_RENAME) p |I32 |same_dirent |NN const char* a|NN const char* b #endif -Apd |char* |savepv |const char* pv -Apd |char* |savesharedpv |const char* pv -Apd |char* |savepvn |const char* pv|I32 len +Apda |char* |savepv |NN const char* pv +Apda |char* |savepvn |NN const char* pv|I32 len +Apda |char* |savesharedpv |const char* pv +Apda |char* |savesvpv |NN SV* sv Ap |void |savestack_grow Ap |void |savestack_grow_cnt |I32 need Ap |void |save_aelem |const AV* av|I32 idx|SV **sptr @@ -934,22 +935,22 @@ Apr |void |newMYSUB |I32 floor|OP *o|OP *proto|OP *attrs|OP *block p |OP * |my_attrs |NN OP *o|OP *attrs p |void |boot_core_xsutils #if defined(USE_ITHREADS) -Ap |PERL_CONTEXT*|cx_dup |PERL_CONTEXT* cx|I32 ix|I32 max|CLONE_PARAMS* param -Ap |PERL_SI*|si_dup |PERL_SI* si|CLONE_PARAMS* param -Ap |ANY* |ss_dup |PerlInterpreter* proto_perl|CLONE_PARAMS* param -Ap |void* |any_dup |void* v|PerlInterpreter* proto_perl -Ap |HE* |he_dup |HE* e|bool shared|CLONE_PARAMS* param -Ap |HEK* |hek_dup |HEK* e|CLONE_PARAMS* param -Ap |REGEXP*|re_dup |REGEXP* r|CLONE_PARAMS* param -Ap |PerlIO*|fp_dup |PerlIO* fp|char type|CLONE_PARAMS* param -Ap |DIR* |dirp_dup |DIR* dp -Ap |GP* |gp_dup |GP* gp|CLONE_PARAMS* param -Ap |MAGIC* |mg_dup |MAGIC* mg|CLONE_PARAMS* param -Ap |SV* |sv_dup |SV* sstr|CLONE_PARAMS* param -Ap |void |rvpv_dup |SV* dstr|SV *sstr|CLONE_PARAMS* param -Ap |PTR_TBL_t*|ptr_table_new -Ap |void* |ptr_table_fetch|NN PTR_TBL_t *tbl|NN void *sv -Ap |void |ptr_table_store|NN PTR_TBL_t *tbl|void *oldsv|void *newsv +Apa |PERL_CONTEXT*|cx_dup |PERL_CONTEXT* cx|I32 ix|I32 max|CLONE_PARAMS* param +Apa |PERL_SI*|si_dup |PERL_SI* si|CLONE_PARAMS* param +Apa |ANY* |ss_dup |NN PerlInterpreter* proto_perl|CLONE_PARAMS* param +Apa |void* |any_dup |void* v|NN const PerlInterpreter* proto_perl +Apa |HE* |he_dup |HE* e|bool shared|CLONE_PARAMS* param +Apa |HEK* |hek_dup |HEK* e|CLONE_PARAMS* param +Apa |REGEXP*|re_dup |const REGEXP* r|CLONE_PARAMS* param +Apa |PerlIO*|fp_dup |PerlIO* fp|char type|CLONE_PARAMS* param +Apa |DIR* |dirp_dup |DIR* dp +Apa |GP* |gp_dup |GP* gp|CLONE_PARAMS* param +Apa |MAGIC* |mg_dup |NN MAGIC* mg|CLONE_PARAMS* param +Apa |SV* |sv_dup |NN SV* sstr|CLONE_PARAMS* param +Ap |void |rvpv_dup |NN SV* dstr|NN SV *sstr|CLONE_PARAMS* param +Apa |PTR_TBL_t*|ptr_table_new +Apa |void* |ptr_table_fetch|NN PTR_TBL_t *tbl|NN const void *sv +Ap |void |ptr_table_store|NN PTR_TBL_t *tbl|const void *oldsv|NN void *newsv Ap |void |ptr_table_split|NN PTR_TBL_t *tbl Ap |void |ptr_table_clear|PTR_TBL_t *tbl Ap |void |ptr_table_free|PTR_TBL_t *tbl @@ -962,8 +963,8 @@ Ap |void |sys_intern_clear Ap |void |sys_intern_init #endif -Ap |char * |custom_op_name |NN const OP* op -Ap |char * |custom_op_desc |NN const OP* op +ApR |char * |custom_op_name |NN const OP* op +ApR |char * |custom_op_desc |NN const OP* op #if defined(PERL_OLD_COPY_ON_WRITE) pMX |int |sv_release_IVX |SV *sv @@ -977,30 +978,30 @@ Adp |int |nothreadhook END_EXTERN_C #if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT) -s |I32 |do_trans_simple |NN SV *sv -s |I32 |do_trans_count |NN SV *sv -s |I32 |do_trans_complex |NN SV *sv -s |I32 |do_trans_simple_utf8 |NN SV *sv -s |I32 |do_trans_count_utf8 |NN SV *sv -s |I32 |do_trans_complex_utf8 |NN SV *sv +sR |I32 |do_trans_simple |NN SV *sv +sR |I32 |do_trans_count |NN SV *sv +sR |I32 |do_trans_complex |NN SV *sv +sR |I32 |do_trans_simple_utf8 |NN SV *sv +sR |I32 |do_trans_count_utf8 |NN SV *sv +sR |I32 |do_trans_complex_utf8 |NN SV *sv #endif #if defined(PERL_IN_GV_C) || defined(PERL_DECL_PROT) -s |void |gv_init_sv |GV *gv|I32 sv_type +s |void |gv_init_sv |NN GV *gv|I32 sv_type s |void |require_errno |NN GV *gv #endif #if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT) -s |void |hsplit |HV *hv +s |void |hsplit |NN HV *hv s |void |hfreeentries |HV *hv -sR |HE* |new_he +sa |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 +sa |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|const HEK* hek|const char* str|I32 len|U32 hash sR |HEK* |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 -s |struct xpvhv_aux*|hv_auxinit|HV *hv +s |struct xpvhv_aux*|hv_auxinit|NN HV *hv sM |SV* |hv_delete_common|HV* tb|SV* key_sv|const char* key|STRLEN klen|int k_flags|I32 d_flags|U32 hash sM |HE* |hv_fetch_common|HV* tb|SV* key_sv|const char* key|STRLEN klen|int flags|int action|SV* val|U32 hash #endif @@ -1507,7 +1508,6 @@ 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 dpR |bool |is_gv_magical_sv|SV *name|U32 flags -Apda |char* |savesvpv |NN SV* sv ApR |bool |stashpv_hvname_match|NN const COP *cop|NN const HV *hv END_EXTERN_C diff --git a/embed.h b/embed.h index 6b811be..94d7e50 100644 --- a/embed.h +++ b/embed.h @@ -675,8 +675,9 @@ #endif #endif #define savepv Perl_savepv -#define savesharedpv Perl_savesharedpv #define savepvn Perl_savepvn +#define savesharedpv Perl_savesharedpv +#define savesvpv Perl_savesvpv #define savestack_grow Perl_savestack_grow #define savestack_grow_cnt Perl_savestack_grow_cnt #define save_aelem Perl_save_aelem @@ -1629,7 +1630,6 @@ #ifdef PERL_CORE #define is_gv_magical_sv Perl_is_gv_magical_sv #endif -#define savesvpv Perl_savesvpv #define stashpv_hvname_match Perl_stashpv_hvname_match #define ck_anoncode Perl_ck_anoncode #define ck_bitop Perl_ck_bitop @@ -2647,8 +2647,9 @@ #endif #endif #define savepv(a) Perl_savepv(aTHX_ a) -#define savesharedpv(a) Perl_savesharedpv(aTHX_ a) #define savepvn(a,b) Perl_savepvn(aTHX_ a,b) +#define savesharedpv(a) Perl_savesharedpv(aTHX_ a) +#define savesvpv(a) Perl_savesvpv(aTHX_ a) #define savestack_grow() Perl_savestack_grow(aTHX) #define savestack_grow_cnt(a) Perl_savestack_grow_cnt(aTHX_ a) #define save_aelem(a,b,c) Perl_save_aelem(aTHX_ a,b,c) @@ -3593,7 +3594,6 @@ #ifdef PERL_CORE #define is_gv_magical_sv(a,b) Perl_is_gv_magical_sv(aTHX_ a,b) #endif -#define savesvpv(a) Perl_savesvpv(aTHX_ a) #define stashpv_hvname_match(a,b) Perl_stashpv_hvname_match(aTHX_ a,b) #define ck_anoncode(a) Perl_ck_anoncode(aTHX_ a) #define ck_bitop(a) Perl_ck_bitop(aTHX_ a) diff --git a/global.sym b/global.sym index 90ee9a6..bb974dd 100644 --- a/global.sym +++ b/global.sym @@ -381,8 +381,9 @@ Perl_rninstr Perl_rsignal Perl_rsignal_state Perl_savepv -Perl_savesharedpv Perl_savepvn +Perl_savesharedpv +Perl_savesvpv Perl_savestack_grow Perl_savestack_grow_cnt Perl_save_aelem @@ -689,6 +690,5 @@ Perl_hv_placeholders_get Perl_hv_placeholders_set Perl_gv_fetchpvn_flags Perl_gv_fetchsv -Perl_savesvpv Perl_stashpv_hvname_match # ex: set ro: diff --git a/gv.c b/gv.c index 31a1c82..6fb877d 100644 --- a/gv.c +++ b/gv.c @@ -1327,13 +1327,13 @@ Perl_gp_free(pTHX_ GV *gv) int Perl_magic_freeovrld(pTHX_ SV *sv, MAGIC *mg) { - AMT *amtp = (AMT*)mg->mg_ptr; - (void)sv; + AMT * const amtp = (AMT*)mg->mg_ptr; + PERL_UNUSED_ARG(sv); if (amtp && AMT_AMAGIC(amtp)) { int i; for (i = 1; i < NofAMmeth; i++) { - CV *cv = amtp->table[i]; + CV * const cv = amtp->table[i]; if (cv != Nullcv) { SvREFCNT_dec((SV *) cv); amtp->table[i] = Nullcv; @@ -1348,10 +1348,8 @@ Perl_magic_freeovrld(pTHX_ SV *sv, MAGIC *mg) bool Perl_Gv_AMupdate(pTHX_ HV *stash) { - GV* gv; - CV* cv; - MAGIC* mg=mg_find((SV*)stash, PERL_MAGIC_overload_table); - AMT *amtp = (mg) ? (AMT*)mg->mg_ptr: (AMT *) NULL; + MAGIC* const mg = mg_find((SV*)stash, PERL_MAGIC_overload_table); + AMT * const amtp = (mg) ? (AMT*)mg->mg_ptr: (AMT *) NULL; AMT amt; if (mg && amtp->was_ok_am == PL_amagic_generation @@ -1370,14 +1368,13 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) { int filled = 0, have_ovl = 0; int i, lim = 1; - SV* sv = NULL; /* Work with "fallback" key, which we assume to be first in PL_AMG_names */ /* Try to find via inheritance. */ - gv = gv_fetchmeth(stash, PL_AMG_names[0], 2, -1); - if (gv) - sv = GvSV(gv); + GV *gv = gv_fetchmeth(stash, PL_AMG_names[0], 2, -1); + SV * const sv = gv ? GvSV(gv) : NULL; + CV* cv; if (!gv) lim = DESTROY_amg; /* Skip overloading entries. */ diff --git a/mg.c b/mg.c index 0b57734..383353a 100644 --- a/mg.c +++ b/mg.c @@ -1670,6 +1670,7 @@ Perl_magic_setarylen(pTHX_ SV *sv, MAGIC *mg) int Perl_magic_freearylen_p(pTHX_ SV *sv, MAGIC *mg) { + PERL_UNUSED_ARG(sv); /* during global destruction, mg_obj may already have been freed */ if (PL_in_clean_all) return 0; diff --git a/pad.c b/pad.c index e821069..9c2b5a2 100644 --- a/pad.c +++ b/pad.c @@ -248,12 +248,12 @@ Perl_pad_undef(pTHX_ CV* cv) * children, or integrate this loop with general cleanup */ if (!PL_dirty) { /* don't bother during global destruction */ - CV *outercv = CvOUTSIDE(cv); + CV * const outercv = CvOUTSIDE(cv); const U32 seq = CvOUTSIDE_SEQ(cv); - AV *comppad_name = (AV*)AvARRAY(padlist)[0]; - SV **namepad = AvARRAY(comppad_name); - AV *comppad = (AV*)AvARRAY(padlist)[1]; - SV **curpad = AvARRAY(comppad); + AV * const comppad_name = (AV*)AvARRAY(padlist)[0]; + SV ** const namepad = AvARRAY(comppad_name); + AV * const comppad = (AV*)AvARRAY(padlist)[1]; + SV ** const curpad = AvARRAY(comppad); for (ix = AvFILLp(comppad_name); ix > 0; ix--) { SV * const namesv = namepad[ix]; if (namesv && namesv != &PL_sv_undef @@ -293,7 +293,7 @@ Perl_pad_undef(pTHX_ CV* cv) ix = AvFILLp(padlist); while (ix >= 0) { - SV* sv = AvARRAY(padlist)[ix--]; + SV* const sv = AvARRAY(padlist)[ix--]; if (!sv) continue; if (sv == (SV*)PL_comppad_name) @@ -330,7 +330,7 @@ PADOFFSET Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake) { const PADOFFSET offset = pad_alloc(OP_PADSV, SVs_PADMY); - SV* namesv = NEWSV(1102, 0); + SV* const namesv = NEWSV(1102, 0); ASSERT_CURPAD_ACTIVE("pad_add_name"); @@ -411,7 +411,7 @@ Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype) retval = AvFILLp(PL_comppad); } else { - SV **names = AvARRAY(PL_comppad_name); + SV ** const names = AvARRAY(PL_comppad_name); const SSize_t names_fill = AvFILLp(PL_comppad_name); for (;;) { /* @@ -498,7 +498,7 @@ C indicates that the name to check is an 'our' declaration void Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash) { - SV **svp, *sv; + SV **svp; PADOFFSET top, off; ASSERT_CURPAD_ACTIVE("pad_check_dup"); @@ -511,7 +511,8 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash) /* XXX DAPM - why the (I32) cast - shouldn't we ensure they're the same * type ? */ for (off = top; (I32)off > PL_comppad_name_floor; off--) { - if ((sv = svp[off]) + SV * const sv = svp[off]; + if (sv && sv != &PL_sv_undef && !SvFAKE(sv) && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0) @@ -531,7 +532,8 @@ Perl_pad_check_dup(pTHX_ const char *name, bool is_our, const HV *ourstash) /* check the rest of the pad */ if (is_our) { do { - if ((sv = svp[off]) + SV * const sv = svp[off]; + if (sv && sv != &PL_sv_undef && !SvFAKE(sv) && (SvIVX(sv) == PAD_MAX || SvIVX(sv) == 0) @@ -809,8 +811,8 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, { SV *new_namesv; - AV *ocomppad_name = PL_comppad_name; - PAD *ocomppad = PL_comppad; + AV * const ocomppad_name = PL_comppad_name; + PAD * const ocomppad = PL_comppad; PL_comppad_name = (AV*)AvARRAY(padlist)[0]; PL_comppad = (AV*)AvARRAY(padlist)[1]; PL_curpad = AvARRAY(PL_comppad); @@ -950,7 +952,6 @@ U32 Perl_intro_my(pTHX) { SV **svp; - SV *sv; I32 i; ASSERT_CURPAD_ACTIVE("intro_my"); @@ -959,9 +960,9 @@ Perl_intro_my(pTHX) svp = AvARRAY(PL_comppad_name); for (i = PL_min_intro_pending; i <= PL_max_intro_pending; i++) { - if ((sv = svp[i]) && sv != &PL_sv_undef - && !SvFAKE(sv) && !SvIVX(sv)) - { + SV * const sv = svp[i]; + + if (sv && sv != &PL_sv_undef && !SvFAKE(sv) && !SvIVX(sv)) { SvIV_set(sv, PAD_MAX); /* Don't know scope end yet. */ SvNV_set(sv, (NV)PL_cop_seqmax); DEBUG_Xv(PerlIO_printf(Perl_debug_log, @@ -992,15 +993,15 @@ void Perl_pad_leavemy(pTHX) { I32 off; - SV **svp = AvARRAY(PL_comppad_name); + SV ** const svp = AvARRAY(PL_comppad_name); PL_pad_reset_pending = FALSE; ASSERT_CURPAD_ACTIVE("pad_leavemy"); if (PL_min_intro_pending && PL_comppad_name_fill < PL_min_intro_pending) { for (off = PL_max_intro_pending; off >= PL_min_intro_pending; off--) { - const SV *sv; - if ((sv = svp[off]) && sv != &PL_sv_undef + const SV * const sv = svp[off]; + if (sv && sv != &PL_sv_undef && !SvFAKE(sv) && ckWARN_d(WARN_INTERNAL)) Perl_warner(aTHX_ packWARN(WARN_INTERNAL), "%"SVf" never introduced", sv); @@ -1008,10 +1009,8 @@ Perl_pad_leavemy(pTHX) } /* "Deintroduce" my variables that are leaving with this scope. */ for (off = AvFILLp(PL_comppad_name); off > PL_comppad_name_fill; off--) { - const SV *sv; - if ((sv = svp[off]) && sv != &PL_sv_undef - && !SvFAKE(sv) && SvIVX(sv) == PAD_MAX) - { + const SV * const sv = svp[off]; + if (sv && sv != &PL_sv_undef && !SvFAKE(sv) && SvIVX(sv) == PAD_MAX) { SvIV_set(sv, PL_cop_seqmax); DEBUG_Xv(PerlIO_printf(Perl_debug_log, "Pad leavemy: %ld \"%s\", (%ld,%ld)\n", @@ -1153,7 +1152,7 @@ Perl_pad_tidy(pTHX_ padtidy_type type) av_store(PL_comppad_name, AvFILLp(PL_comppad), Nullsv); if (type == padtidy_SUBCLONE) { - SV **namep = AvARRAY(PL_comppad_name); + SV ** const namep = AvARRAY(PL_comppad_name); PADOFFSET ix; for (ix = AvFILLp(PL_comppad); ix > 0; ix--) { @@ -1177,7 +1176,7 @@ Perl_pad_tidy(pTHX_ padtidy_type type) } else if (type == padtidy_SUB) { /* XXX DAPM this same bit of code keeps appearing !!! Rationalise? */ - AV *av = newAV(); /* Will be @_ */ + AV * const av = newAV(); /* Will be @_ */ av_extend(av, 0); av_store(PL_comppad, 0, (SV*)av); AvREIFY_only(av); @@ -1332,8 +1331,8 @@ dump the contents of a CV STATIC void S_cv_dump(pTHX_ const CV *cv, const char *title) { - const CV *outside = CvOUTSIDE(cv); - AV* padlist = CvPADLIST(cv); + const CV * const outside = CvOUTSIDE(cv); + AV* const padlist = CvPADLIST(cv); PerlIO_printf(Perl_debug_log, " %s: CV=0x%"UVxf" (%s), OUTSIDE=0x%"UVxf" (%s)\n", @@ -1376,11 +1375,11 @@ Perl_cv_clone(pTHX_ CV *proto) { dVAR; I32 ix; - AV* protopadlist = CvPADLIST(proto); - const AV* protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE); - const AV* protopad = (AV*)*av_fetch(protopadlist, 1, FALSE); - SV** pname = AvARRAY(protopad_name); - SV** ppad = AvARRAY(protopad); + AV* const protopadlist = CvPADLIST(proto); + const AV* const protopad_name = (AV*)*av_fetch(protopadlist, 0, FALSE); + const AV* const protopad = (AV*)*av_fetch(protopadlist, 1, FALSE); + SV** const pname = AvARRAY(protopad_name); + SV** const ppad = AvARRAY(protopad); const I32 fname = AvFILLp(protopad_name); const I32 fpad = AvFILLp(protopad); CV* cv; @@ -1440,7 +1439,7 @@ Perl_cv_clone(pTHX_ CV *proto) outpad = AvARRAY(AvARRAY(CvPADLIST(outside))[depth]); for (ix = fpad; ix > 0; ix--) { - SV* namesv = (ix <= fname) ? pname[ix] : Nullsv; + SV* const namesv = (ix <= fname) ? pname[ix] : Nullsv; SV *sv = Nullsv; if (namesv && namesv != &PL_sv_undef) { /* lexical */ if (SvFAKE(namesv)) { /* lexical from outside? */ @@ -1526,8 +1525,8 @@ Perl_pad_fixup_inner_anons(pTHX_ PADLIST *padlist, CV *old_cv, CV *new_cv) I32 ix; AV * const comppad_name = (AV*)AvARRAY(padlist)[0]; AV * const comppad = (AV*)AvARRAY(padlist)[1]; - SV **namepad = AvARRAY(comppad_name); - SV **curpad = AvARRAY(comppad); + SV ** const namepad = AvARRAY(comppad_name); + SV ** const curpad = AvARRAY(comppad); for (ix = AvFILLp(comppad_name); ix > 0; ix--) { const SV *namesv = namepad[ix]; if (namesv && namesv != &PL_sv_undef diff --git a/perl.h b/perl.h index 136d472..d3f8329 100644 --- a/perl.h +++ b/perl.h @@ -210,16 +210,17 @@ * for silencing unused variables that are actually used most of the time, * but we cannot quite get rid of, such as "ax" in PPCODE+noargs xsubs */ -#define PERL_UNUSED_VAR(var) ((void)var) - -#ifndef LINT_UNUSED_ARG +#ifndef PERL_UNUSED_ARG # ifdef lint # include -# define LINT_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) +# define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else -# define LINT_UNUSED_ARG(x) +# define PERL_UNUSED_ARG(x) ((void)x) # endif #endif +#ifndef PERL_UNUSED_VAR +# define PERL_UNUSED_VAR(x) ((void)x) +#endif #define NOOP (void)0 #define dNOOP extern int Perl___notused PERL_UNUSED_DECL @@ -2825,7 +2826,7 @@ typedef I32 CHECKPOINT; body arenas */ struct ptr_tbl_ent { struct ptr_tbl_ent* next; - void* oldval; + const void* oldval; void* newval; }; diff --git a/proto.h b/proto.h index 0064341..473b804 100644 --- a/proto.h +++ b/proto.h @@ -139,14 +139,26 @@ PERL_CALLCONV bool Perl_cando(pTHX_ Mode_t mode, Uid_t effective, const Stat_t* __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_3); -PERL_CALLCONV U32 Perl_cast_ulong(pTHX_ NV f); -PERL_CALLCONV I32 Perl_cast_i32(pTHX_ NV f); -PERL_CALLCONV IV Perl_cast_iv(pTHX_ NV f); -PERL_CALLCONV UV Perl_cast_uv(pTHX_ NV f); +PERL_CALLCONV U32 Perl_cast_ulong(pTHX_ NV f) + __attribute__warn_unused_result__; + +PERL_CALLCONV I32 Perl_cast_i32(pTHX_ NV f) + __attribute__warn_unused_result__; + +PERL_CALLCONV IV Perl_cast_iv(pTHX_ NV f) + __attribute__warn_unused_result__; + +PERL_CALLCONV UV Perl_cast_uv(pTHX_ NV f) + __attribute__warn_unused_result__; + #if !defined(HAS_TRUNCATE) && !defined(HAS_CHSIZE) && defined(F_FREESP) -PERL_CALLCONV I32 Perl_my_chsize(pTHX_ int fd, Off_t length); +PERL_CALLCONV I32 Perl_my_chsize(pTHX_ int fd, Off_t length) + __attribute__warn_unused_result__; + #endif -PERL_CALLCONV OP* Perl_convert(pTHX_ I32 optype, I32 flags, OP* o); +PERL_CALLCONV OP* Perl_convert(pTHX_ I32 optype, I32 flags, OP* o) + __attribute__warn_unused_result__; + PERL_CALLCONV void Perl_croak(pTHX_ const char* pat, ...) __attribute__noreturn__ __attribute__format__(__printf__,pTHX_1,pTHX_2); @@ -361,9 +373,15 @@ PERL_CALLCONV char* Perl_getenv_len(pTHX_ const char* key, unsigned long *len); #endif PERL_CALLCONV void Perl_gp_free(pTHX_ GV* gv); PERL_CALLCONV GP* Perl_gp_ref(pTHX_ GP* gp); -PERL_CALLCONV GV* Perl_gv_AVadd(pTHX_ GV* gv); -PERL_CALLCONV GV* Perl_gv_HVadd(pTHX_ GV* gv); -PERL_CALLCONV GV* Perl_gv_IOadd(pTHX_ GV* gv); +PERL_CALLCONV GV* Perl_gv_AVadd(pTHX_ GV* gv) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV GV* Perl_gv_HVadd(pTHX_ GV* gv) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV GV* Perl_gv_IOadd(pTHX_ GV* gv) + __attribute__nonnull__(pTHX_1); + PERL_CALLCONV GV* Perl_gv_autoload4(pTHX_ HV* stash, const char* name, STRLEN len, I32 method) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_2); @@ -372,7 +390,9 @@ PERL_CALLCONV void Perl_gv_check(pTHX_ HV* stash); PERL_CALLCONV void Perl_gv_efullname(pTHX_ SV* sv, const GV* gv); /* PERL_CALLCONV void Perl_gv_efullname3(pTHX_ SV* sv, const GV* gv, const char* prefix); */ PERL_CALLCONV void Perl_gv_efullname4(pTHX_ SV* sv, const GV* gv, const char* prefix, bool keepmain); -PERL_CALLCONV GV* Perl_gv_fetchfile(pTHX_ const char* name); +PERL_CALLCONV GV* Perl_gv_fetchfile(pTHX_ const char* name) + __attribute__nonnull__(pTHX_1); + PERL_CALLCONV GV* Perl_gv_fetchmeth(pTHX_ HV* stash, const char* name, STRLEN len, I32 level); PERL_CALLCONV GV* Perl_gv_fetchmeth_autoload(pTHX_ HV* stash, const char* name, STRLEN len, I32 level); PERL_CALLCONV GV* Perl_gv_fetchmethod(pTHX_ HV* stash, const char* name); @@ -381,7 +401,11 @@ PERL_CALLCONV GV* Perl_gv_fetchpv(pTHX_ const char* name, I32 add, I32 sv_type); PERL_CALLCONV void Perl_gv_fullname(pTHX_ SV* sv, const GV* gv); /* PERL_CALLCONV void Perl_gv_fullname3(pTHX_ SV* sv, const GV* gv, const char* prefix); */ PERL_CALLCONV void Perl_gv_fullname4(pTHX_ SV* sv, const GV* gv, const char* prefix, bool keepmain); -PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLEN len, int multi); +PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLEN len, int multi) + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2) + __attribute__nonnull__(pTHX_3); + PERL_CALLCONV HV* Perl_gv_stashpv(pTHX_ const char* name, I32 create); PERL_CALLCONV HV* Perl_gv_stashpvn(pTHX_ const char* name, U32 namelen, I32 create); PERL_CALLCONV HV* Perl_gv_stashsv(pTHX_ SV* sv, I32 create); @@ -1262,9 +1286,25 @@ PERL_CALLCONV I32 Perl_same_dirent(pTHX_ const char* a, const char* b) __attribute__nonnull__(pTHX_2); #endif -PERL_CALLCONV char* Perl_savepv(pTHX_ const char* pv); -PERL_CALLCONV char* Perl_savesharedpv(pTHX_ const char* pv); -PERL_CALLCONV char* Perl_savepvn(pTHX_ const char* pv, I32 len); +PERL_CALLCONV char* Perl_savepv(pTHX_ const char* pv) + __attribute__malloc__ + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV char* Perl_savepvn(pTHX_ const char* pv, I32 len) + __attribute__malloc__ + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV char* Perl_savesharedpv(pTHX_ const char* pv) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV char* Perl_savesvpv(pTHX_ SV* sv) + __attribute__malloc__ + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + PERL_CALLCONV void Perl_savestack_grow(pTHX); PERL_CALLCONV void Perl_savestack_grow_cnt(pTHX_ I32 need); PERL_CALLCONV void Perl_save_aelem(pTHX_ const AV* av, I32 idx, SV **sptr); @@ -1778,27 +1818,76 @@ PERL_CALLCONV OP * Perl_my_attrs(pTHX_ OP *o, OP *attrs) PERL_CALLCONV void Perl_boot_core_xsutils(pTHX); #if defined(USE_ITHREADS) -PERL_CALLCONV PERL_CONTEXT* Perl_cx_dup(pTHX_ PERL_CONTEXT* cx, I32 ix, I32 max, CLONE_PARAMS* param); -PERL_CALLCONV PERL_SI* Perl_si_dup(pTHX_ PERL_SI* si, CLONE_PARAMS* param); -PERL_CALLCONV ANY* Perl_ss_dup(pTHX_ PerlInterpreter* proto_perl, CLONE_PARAMS* param); -PERL_CALLCONV void* Perl_any_dup(pTHX_ void* v, PerlInterpreter* proto_perl); -PERL_CALLCONV HE* Perl_he_dup(pTHX_ HE* e, bool shared, CLONE_PARAMS* param); -PERL_CALLCONV HEK* Perl_hek_dup(pTHX_ HEK* e, CLONE_PARAMS* param); -PERL_CALLCONV REGEXP* Perl_re_dup(pTHX_ REGEXP* r, CLONE_PARAMS* param); -PERL_CALLCONV PerlIO* Perl_fp_dup(pTHX_ PerlIO* fp, char type, CLONE_PARAMS* param); -PERL_CALLCONV DIR* Perl_dirp_dup(pTHX_ DIR* dp); -PERL_CALLCONV GP* Perl_gp_dup(pTHX_ GP* gp, CLONE_PARAMS* param); -PERL_CALLCONV MAGIC* Perl_mg_dup(pTHX_ MAGIC* mg, CLONE_PARAMS* param); -PERL_CALLCONV SV* Perl_sv_dup(pTHX_ SV* sstr, CLONE_PARAMS* param); -PERL_CALLCONV void Perl_rvpv_dup(pTHX_ SV* dstr, SV *sstr, CLONE_PARAMS* param); -PERL_CALLCONV PTR_TBL_t* Perl_ptr_table_new(pTHX); -PERL_CALLCONV void* Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, void *sv) - __attribute__nonnull__(pTHX_1) +PERL_CALLCONV PERL_CONTEXT* Perl_cx_dup(pTHX_ PERL_CONTEXT* cx, I32 ix, I32 max, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV PERL_SI* Perl_si_dup(pTHX_ PERL_SI* si, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV ANY* Perl_ss_dup(pTHX_ PerlInterpreter* proto_perl, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV void* Perl_any_dup(pTHX_ void* v, const PerlInterpreter* proto_perl) + __attribute__malloc__ + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_2); -PERL_CALLCONV void Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, void *oldsv, void *newsv) +PERL_CALLCONV HE* Perl_he_dup(pTHX_ HE* e, bool shared, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV HEK* Perl_hek_dup(pTHX_ HEK* e, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV REGEXP* Perl_re_dup(pTHX_ const REGEXP* r, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV PerlIO* Perl_fp_dup(pTHX_ PerlIO* fp, char type, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV DIR* Perl_dirp_dup(pTHX_ DIR* dp) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV GP* Perl_gp_dup(pTHX_ GP* gp, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV MAGIC* Perl_mg_dup(pTHX_ MAGIC* mg, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV SV* Perl_sv_dup(pTHX_ SV* sstr, CLONE_PARAMS* param) + __attribute__malloc__ + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); +PERL_CALLCONV void Perl_rvpv_dup(pTHX_ SV* dstr, SV *sstr, CLONE_PARAMS* param) + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV PTR_TBL_t* Perl_ptr_table_new(pTHX) + __attribute__malloc__ + __attribute__warn_unused_result__; + +PERL_CALLCONV void* Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, const void *sv) + __attribute__malloc__ + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, const void *oldsv, void *newsv) + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_3); + PERL_CALLCONV void Perl_ptr_table_split(pTHX_ PTR_TBL_t *tbl) __attribute__nonnull__(pTHX_1); @@ -1817,9 +1906,11 @@ PERL_CALLCONV void Perl_sys_intern_init(pTHX); #endif PERL_CALLCONV char * Perl_custom_op_name(pTHX_ const OP* op) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); PERL_CALLCONV char * Perl_custom_op_desc(pTHX_ const OP* op) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); @@ -1836,42 +1927,54 @@ END_EXTERN_C #if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT) STATIC I32 S_do_trans_simple(pTHX_ SV *sv) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); STATIC I32 S_do_trans_count(pTHX_ SV *sv) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); STATIC I32 S_do_trans_complex(pTHX_ SV *sv) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); STATIC I32 S_do_trans_simple_utf8(pTHX_ SV *sv) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); STATIC I32 S_do_trans_count_utf8(pTHX_ SV *sv) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); STATIC I32 S_do_trans_complex_utf8(pTHX_ SV *sv) + __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); #endif #if defined(PERL_IN_GV_C) || defined(PERL_DECL_PROT) -STATIC void S_gv_init_sv(pTHX_ GV *gv, I32 sv_type); +STATIC void S_gv_init_sv(pTHX_ GV *gv, I32 sv_type) + __attribute__nonnull__(pTHX_1); + STATIC void S_require_errno(pTHX_ GV *gv) __attribute__nonnull__(pTHX_1); #endif #if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT) -STATIC void S_hsplit(pTHX_ HV *hv); +STATIC void S_hsplit(pTHX_ HV *hv) + __attribute__nonnull__(pTHX_1); + STATIC void S_hfreeentries(pTHX_ HV *hv); STATIC HE* S_new_he(pTHX) + __attribute__malloc__ __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__malloc__ __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1); @@ -1889,7 +1992,9 @@ STATIC void S_hv_notallowed(pTHX_ int flags, const char *key, I32 klen, const ch __attribute__nonnull__(pTHX_2) __attribute__nonnull__(pTHX_4); -STATIC struct xpvhv_aux* S_hv_auxinit(pTHX_ HV *hv); +STATIC struct xpvhv_aux* S_hv_auxinit(pTHX_ HV *hv) + __attribute__nonnull__(pTHX_1); + STATIC SV* S_hv_delete_common(pTHX_ HV* tb, SV* key_sv, const char* key, STRLEN klen, int k_flags, I32 d_flags, U32 hash); STATIC HE* S_hv_fetch_common(pTHX_ HV* tb, SV* key_sv, const char* key, STRLEN klen, int flags, int action, SV* val, U32 hash); #endif @@ -2826,11 +2931,6 @@ 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) - __attribute__malloc__ - __attribute__warn_unused_result__ - __attribute__nonnull__(pTHX_1); - PERL_CALLCONV bool Perl_stashpv_hvname_match(pTHX_ const COP *cop, const HV *hv) __attribute__warn_unused_result__ __attribute__nonnull__(pTHX_1) diff --git a/sv.c b/sv.c index 2d6d84d..34e26e3 100644 --- a/sv.c +++ b/sv.c @@ -286,8 +286,8 @@ S_del_sv(pTHX_ SV *p) SV* sva; bool ok = 0; for (sva = PL_sv_arenaroot; sva; sva = (SV *) SvANY(sva)) { - SV *sv = sva + 1; - SV *svend = &sva[SvREFCNT(sva)]; + const SV * const sv = sva + 1; + const SV * const svend = &sva[SvREFCNT(sva)]; if (p >= sv && p < svend) { ok = 1; break; @@ -366,7 +366,7 @@ S_visit(pTHX_ SVFUNC_t f, U32 flags, U32 mask) I32 visited = 0; for (sva = PL_sv_arenaroot; sva; sva = (SV*)SvANY(sva)) { - register SV * const svend = &sva[SvREFCNT(sva)]; + register const SV * const svend = &sva[SvREFCNT(sva)]; register SV* sv; for (sv = sva + 1; sv < svend; ++sv) { if (SvTYPE(sv) != SVTYPEMASK @@ -674,8 +674,6 @@ STATIC SV* S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, SV* keyname, I32 aindex, int subscript_type) { - AV *av; - SV *sv; SV * const name = sv_newmortal(); if (gv) { @@ -685,7 +683,7 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, * directly */ const char *p; - HV *hv = GvSTASH(gv); + HV * const hv = GvSTASH(gv); sv_setpv(name, gvtype); if (!hv) p = "???"; @@ -705,8 +703,11 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, sv_catpvn(name,GvNAME(gv),GvNAMELEN(gv)); } else { - U32 u; - CV *cv = find_runcv(&u); + U32 unused; + CV * const cv = find_runcv(&unused); + SV *sv; + AV *av; + if (!cv || !CvPADLIST(cv)) return Nullsv;; av = (AV*)(*av_fetch(CvPADLIST(cv), 0, FALSE)); @@ -716,6 +717,7 @@ S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ, } if (subscript_type == FUV_SUBSCRIPT_HASH) { + SV *sv; *SvPVX(name) = '$'; sv = NEWSV(0,0); Perl_sv_catpvf(aTHX_ name, "{%s}", @@ -919,7 +921,7 @@ S_find_uninit_var(pTHX_ OP* obase, SV* uninit_sv, bool match) /* index is an expression; * attempt to find a match within the aggregate */ if (obase->op_type == OP_HELEM) { - SV *keysv = S_find_hash_subscript(aTHX_ (HV*)sv, uninit_sv); + SV * const keysv = S_find_hash_subscript(aTHX_ (HV*)sv, uninit_sv); if (keysv) return S_varname(aTHX_ gv, "%", o->op_targ, keysv, 0, FUV_SUBSCRIPT_HASH); @@ -1079,7 +1081,7 @@ S_more_bodies (pTHX_ void **arena_root, void **root, size_t size) { char *start; const char *end; - size_t count = PERL_ARENA_SIZE/size; + const size_t count = PERL_ARENA_SIZE/size; New(0, start, count*size, char); *((void **) start) = *arena_root; *arena_root = (void *)start; @@ -1094,7 +1096,7 @@ S_more_bodies (pTHX_ void **arena_root, void **root, size_t size) *root = (void *)start; while (start < end) { - char *next = start + size; + char * const next = start + size; *(void**) start = (void *)next; start = next; } @@ -1285,7 +1287,7 @@ Perl_sv_upgrade(pTHX_ register SV *sv, U32 mt) size_t new_body_offset; void** new_body_arena; void** new_body_arenaroot; - U32 old_type = SvTYPE(sv); + const U32 old_type = SvTYPE(sv); if (mt != SVt_PV && SvIsCOW(sv)) { sv_force_normal_flags(sv, 0); @@ -1598,7 +1600,7 @@ Perl_sv_backoff(pTHX_ register SV *sv) assert(SvTYPE(sv) != SVt_PVHV); assert(SvTYPE(sv) != SVt_PVAV); if (SvIVX(sv)) { - const char *s = SvPVX_const(sv); + const char * const s = SvPVX_const(sv); SvLEN_set(sv, SvLEN(sv) + SvIVX(sv)); SvPV_set(sv, SvPVX(sv) - SvIVX(sv)); SvIV_set(sv, 0); @@ -3347,8 +3349,7 @@ void Perl_sv_copypv(pTHX_ SV *dsv, register SV *ssv) { STRLEN len; - const char *s; - s = SvPV_const(ssv,len); + const char * const s = SvPV_const(ssv,len); sv_setpvn(dsv,s,len); if (SvUTF8(ssv)) SvUTF8_on(dsv); @@ -3452,8 +3453,8 @@ Perl_sv_2bool(pTHX_ register SV *sv) return SvRV(sv) != 0; } if (SvPOKp(sv)) { - register XPV* Xpvtmp; - if ((Xpvtmp = (XPV*)SvANY(sv)) && + register XPV* const Xpvtmp = (XPV*)SvANY(sv); + if (Xpvtmp && (*sv->sv_u.svu_pv > '0' || Xpvtmp->xpv_cur > 1 || (Xpvtmp->xpv_cur && *sv->sv_u.svu_pv != '0'))) @@ -3547,13 +3548,13 @@ Perl_sv_utf8_upgrade_flags(pTHX_ register SV *sv, I32 flags) int hibit = 0; while (t < e) { - U8 ch = *t++; + const U8 ch = *t++; if ((hibit = !NATIVE_IS_INVARIANT(ch))) break; } if (hibit) { STRLEN len = SvCUR(sv) + 1; /* Plus the \0 */ - U8 *recoded = bytes_to_utf8((U8*)s, &len); + U8 * const recoded = bytes_to_utf8((U8*)s, &len); SvPV_free(sv); /* No longer using what was there before. */ @@ -8832,6 +8833,8 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV /* large enough for "%#.#f" --chip */ /* what about long double NVs? --jhi */ + PERL_UNUSED_ARG(maybe_tainted); + /* no matter what, this is a string now */ (void)SvPV_force(sv, origlen); @@ -8840,7 +8843,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV return; if (patlen == 2 && pat[0] == '%' && pat[1] == 's') { if (args) { - const char *s = va_arg(*args, char*); + const char * const s = va_arg(*args, char*); sv_catpv(sv, s ? s : nullstr); } else if (svix < svmax) { @@ -9728,7 +9731,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV sv_utf8_upgrade(sv); } else { - SV *nsv = sv_2mortal(newSVpvn(eptr, elen)); + SV * const nsv = sv_2mortal(newSVpvn(eptr, elen)); sv_utf8_upgrade(nsv); eptr = SvPVX_const(nsv); elen = SvCUR(nsv); @@ -9744,6 +9747,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV SvGROW(sv, SvCUR(sv) + need + dotstrlen + 1); p = SvEND(sv); if (esignlen && fill == '0') { + int i; for (i = 0; i < (int)esignlen; i++) *p++ = esignbuf[i]; } @@ -9752,10 +9756,12 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV p += gap; } if (esignlen && fill != '0') { + int i; for (i = 0; i < (int)esignlen; i++) *p++ = esignbuf[i]; } if (zeros) { + int i; for (i = zeros; i; i--) *p++ = '0'; } @@ -9831,7 +9837,7 @@ ptr_table_* functions. regcomp.c. AMS 20010712 */ REGEXP * -Perl_re_dup(pTHX_ REGEXP *r, CLONE_PARAMS *param) +Perl_re_dup(pTHX_ const REGEXP *r, CLONE_PARAMS *param) { dVAR; REGEXP *ret; @@ -9867,6 +9873,7 @@ Perl_re_dup(pTHX_ REGEXP *r, CLONE_PARAMS *param) if (r->data) { struct reg_data *d; const int count = r->data->count; + int i; Newc(0, d, sizeof(struct reg_data) + count*sizeof(void *), char, struct reg_data); @@ -9949,7 +9956,8 @@ PerlIO * Perl_fp_dup(pTHX_ PerlIO *fp, char type, CLONE_PARAMS *param) { PerlIO *ret; - (void)type; + + PERL_UNUSED_ARG(type); if (!fp) return (PerlIO*)NULL; @@ -10108,7 +10116,7 @@ Perl_ptr_table_new(pTHX) /* map an existing pointer using a table */ void * -Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, void *sv) +Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, const void *sv) { PTR_TBL_ENT_t *tblent; const UV hash = PTR_TABLE_HASH(sv); @@ -10124,7 +10132,7 @@ Perl_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, void *sv) /* add a new entry to a pointer-mapping table */ void -Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, void *oldv, void *newv) +Perl_ptr_table_store(pTHX_ PTR_TBL_t *tbl, const void *oldv, void *newv) { PTR_TBL_ENT_t *tblent, **otblent; /* XXX this may be pessimal on platforms where pointers aren't good @@ -10854,7 +10862,7 @@ Perl_si_dup(pTHX_ PERL_SI *si, CLONE_PARAMS* param) */ void * -Perl_any_dup(pTHX_ void *v, PerlInterpreter *proto_perl) +Perl_any_dup(pTHX_ void *v, const PerlInterpreter *proto_perl) { void *ret; @@ -10881,9 +10889,9 @@ Perl_any_dup(pTHX_ void *v, PerlInterpreter *proto_perl) ANY * Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) { - ANY *ss = proto_perl->Tsavestack; - I32 ix = proto_perl->Tsavestack_ix; - I32 max = proto_perl->Tsavestack_max; + ANY * const ss = proto_perl->Tsavestack; + const I32 max = proto_perl->Tsavestack_max; + I32 ix = proto_perl->Tsavestack_ix; ANY *nss; SV *sv; GV *gv; @@ -10897,7 +10905,6 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) char *c = NULL; void (*dptr) (void*); void (*dxptr) (pTHX_ void*); - OP *o; Newz(54, nss, max, ANY); @@ -11030,6 +11037,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) ptr = POPPTR(ss,ix); if (ptr && (((OP*)ptr)->op_private & OPpREFCOUNTED)) { /* these are assumed to be refcounted properly */ + OP *o; switch (((OP*)ptr)->op_type) { case OP_LEAVESUB: case OP_LEAVESUBLV: @@ -11157,9 +11165,9 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) static void do_mark_cloneable_stash(pTHX_ SV *sv) { - const HEK *hvname = HvNAME_HEK((HV*)sv); + const HEK * const hvname = HvNAME_HEK((HV*)sv); if (hvname) { - GV* cloner = gv_fetchmethod_autoload((HV*)sv, "CLONE_SKIP", 0); + GV* const cloner = gv_fetchmethod_autoload((HV*)sv, "CLONE_SKIP", 0); SvFLAGS(sv) |= SVphv_CLONEABLE; /* clone objects by default */ if (cloner && GvCV(cloner)) { dSP; @@ -11485,7 +11493,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_regex_padav = newAV(); { const I32 len = av_len((AV*)proto_perl->Iregex_padav); - SV** regexen = AvARRAY((AV*)proto_perl->Iregex_padav); + SV** const regexen = AvARRAY((AV*)proto_perl->Iregex_padav); IV i; av_push(PL_regex_padav, sv_dup_inc(regexen[0],param)); @@ -12007,8 +12015,8 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, identified by sv_dup() above. */ while(av_len(param->stashes) != -1) { - HV* stash = (HV*) av_shift(param->stashes); - GV* cloner = gv_fetchmethod_autoload(stash, "CLONE", 0); + HV* const stash = (HV*) av_shift(param->stashes); + GV* const cloner = gv_fetchmethod_autoload(stash, "CLONE", 0); if (cloner && GvCV(cloner)) { dSP; ENTER; diff --git a/universal.c b/universal.c index 99a3dd9..2b2dd45 100644 --- a/universal.c +++ b/universal.c @@ -819,7 +819,7 @@ XS(XS_Internals_hv_clear_placehold) XS(XS_Regexp_DESTROY) { - LINT_UNUSED_ARG(cv) + PERL_UNUSED_ARG(cv); } XS(XS_PerlIO_get_layers) @@ -952,7 +952,7 @@ XS(XS_Internals_hash_seed) /* Using dXSARGS would also have dITEM and dSP, * which define 2 unused local variables. */ dAXMARK; - LINT_UNUSED_ARG(cv) + PERL_UNUSED_ARG(cv); PERL_UNUSED_VAR(mark); XSRETURN_UV(PERL_HASH_SEED); } @@ -962,7 +962,7 @@ XS(XS_Internals_rehash_seed) /* Using dXSARGS would also have dITEM and dSP, * which define 2 unused local variables. */ dAXMARK; - LINT_UNUSED_ARG(cv) + PERL_UNUSED_ARG(cv); PERL_UNUSED_VAR(mark); XSRETURN_UV(PL_rehash_seed); } diff --git a/util.c b/util.c index 004d493..b5a2d49 100644 --- a/util.c +++ b/util.c @@ -1051,9 +1051,9 @@ Perl_write_to_stderr(pTHX_ const char* message, int msglen) else { #ifdef USE_SFIO /* SFIO can really mess with your errno */ - int e = errno; + const int e = errno; #endif - PerlIO *serr = Perl_error_log; + PerlIO * const serr = Perl_error_log; PERL_WRITE_MSG_TO_CONSOLE(serr, message, msglen); (void)PerlIO_flush(serr); @@ -1254,21 +1254,18 @@ void Perl_vwarn(pTHX_ const char* pat, va_list *args) { dVAR; - const char *message; - HV *stash; - GV *gv; - CV *cv; - SV *msv; STRLEN msglen; - I32 utf8 = 0; - - msv = vmess(pat, args); - utf8 = SvUTF8(msv); - message = SvPV_const(msv, msglen); + SV * const msv = vmess(pat, args); + const I32 utf8 = SvUTF8(msv); + const char * const message = SvPV_const(msv, msglen); if (PL_warnhook) { /* sv_2cv might call Perl_warn() */ - SV *oldwarnhook = PL_warnhook; + SV * const oldwarnhook = PL_warnhook; + CV * cv; + HV * stash; + GV * gv; + ENTER; SAVESPTR(PL_warnhook); PL_warnhook = Nullsv; @@ -1446,7 +1443,8 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) setenv(nam, val, 1); # else char *new_env; - int nlen = strlen(nam), vlen; + const int nlen = strlen(nam); + int vlen; if (!val) { val = ""; } @@ -1488,7 +1486,8 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) I32 Perl_setenv_getix(pTHX_ const char *nam) { - register I32 i, len = strlen(nam); + register I32 i; + const register I32 len = strlen(nam); for (i = 0; environ[i]; i++) { if ( @@ -2758,7 +2757,7 @@ Perl_find_script(pTHX_ const char *scriptname, bool dosearch, const char **searc int extidx = 0, i = 0; const char *curext = Nullch; #else - (void)search_ext; + PERL_UNUSED_ARG(search_ext); # define MAX_EXT_LEN 0 #endif @@ -3986,10 +3985,10 @@ Perl_new_version(pTHX_ SV *ver) if ( sv_derived_from(ver,"version") ) /* can just copy directly */ { I32 key; - AV *av = newAV(); + AV * const av = newAV(); AV *sav; /* This will get reblessed later if a derived class*/ - SV* hv = newSVrv(rv, "version"); + SV* const hv = newSVrv(rv, "version"); (void)sv_upgrade(hv, SVt_PVHV); /* needs to be an HV type */ #ifndef NODEFAULT_SHAREKEYS HvSHAREKEYS_on(hv); /* key-sharing on by default */ @@ -4007,7 +4006,7 @@ Perl_new_version(pTHX_ SV *ver) if ( hv_exists((HV*)ver, "width", 5 ) ) { - I32 width = SvIV(*hv_fetch((HV*)ver, "width", 5, FALSE)); + const I32 width = SvIV(*hv_fetch((HV*)ver, "width", 5, FALSE)); hv_store((HV *)hv, "width", 5, newSViv(width), 0); } @@ -4101,7 +4100,7 @@ Perl_vnumify(pTHX_ SV *vs) I32 i, len, digit; int width; bool alpha = FALSE; - SV *sv = newSV(0); + SV * const sv = newSV(0); AV *av; if ( SvROK(vs) ) vs = SvRV(vs); @@ -4117,7 +4116,7 @@ Perl_vnumify(pTHX_ SV *vs) /* attempt to retrieve the version array */ if ( !(av = (AV *)*hv_fetch((HV*)vs, "version", 7, FALSE) ) ) { - Perl_sv_catpv(aTHX_ sv,"0"); + sv_catpvn(sv,"0",1); return sv; } @@ -4134,8 +4133,8 @@ Perl_vnumify(pTHX_ SV *vs) { digit = SvIV(*av_fetch(av, i, 0)); if ( width < 3 ) { - int denom = (int)pow(10,(3-width)); - div_t term = div((int)PERL_ABS(digit),denom); + const int denom = (int)pow(10,(3-width)); + const div_t term = div((int)PERL_ABS(digit),denom); Perl_sv_catpvf(aTHX_ sv,"%0*d_%d", width, term.quot, term.rem); } else { @@ -4605,7 +4604,7 @@ some level of strict-ness. void Perl_sv_nosharing(pTHX_ SV *sv) { - (void)sv; + PERL_UNUSED_ARG(sv); } /* @@ -4621,7 +4620,7 @@ some level of strict-ness. void Perl_sv_nolocking(pTHX_ SV *sv) { - (void)sv; + PERL_UNUSED_ARG(sv); } @@ -4638,7 +4637,7 @@ some level of strict-ness. void Perl_sv_nounlocking(pTHX_ SV *sv) { - (void)sv; + PERL_UNUSED_ARG(sv); } U32