From: Andy Lester Date: Thu, 2 Jun 2005 12:19:43 +0000 (-0500) Subject: Random consting X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b464bac0b70c4876af1296864220315edde8461d;p=p5sagit%2Fp5-mst-13.2.git Random consting Message-ID: <20050602171943.GA16553@petdance.com> p4raw-id: //depot/perl@24689 --- diff --git a/doio.c b/doio.c index 191ea7c..81a0f65 100644 --- a/doio.c +++ b/doio.c @@ -103,7 +103,7 @@ Perl_do_openn(pTHX_ GV *gv, register char *name, I32 len, int as_raw, /* Collect default raw/crlf info from the op */ if (PL_op && PL_op->op_type == OP_OPEN) { /* set up IO layers */ - U8 flags = PL_op->op_private; + const U8 flags = PL_op->op_private; in_raw = (flags & OPpOPEN_IN_RAW); in_crlf = (flags & OPpOPEN_IN_CRLF); out_raw = (flags & OPpOPEN_OUT_RAW); @@ -2000,7 +2000,8 @@ Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp) { SV *astr; char *a; - I32 infosize, getinfo; + STRLEN infosize; + I32 getinfo; I32 ret = -1; const I32 id = SvIVx(*++mark); const I32 n = (optype == OP_SEMCTL) ? SvIVx(*++mark) : 0; diff --git a/dump.c b/dump.c index caf2f8c..ec1ead9 100644 --- a/dump.c +++ b/dump.c @@ -80,7 +80,7 @@ Perl_dump_packsubs(pTHX_ const HV *stash) void Perl_dump_sub(pTHX_ const GV *gv) { - SV *sv = sv_newmortal(); + SV * const sv = sv_newmortal(); gv_fullname3(sv, gv, Nullch); Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nSUB %s = ", SvPVX_const(sv)); @@ -97,7 +97,7 @@ Perl_dump_sub(pTHX_ const GV *gv) void Perl_dump_form(pTHX_ const GV *gv) { - SV *sv = sv_newmortal(); + SV * const sv = sv_newmortal(); gv_fullname3(sv, gv, Nullch); Perl_dump_indent(aTHX_ 0, Perl_debug_log, "\nFORMAT %s = ", SvPVX_const(sv)); @@ -1634,8 +1634,8 @@ Perl_debop(pTHX_ const OP *o) CV *cv = deb_curcv(cxstack_ix); SV *sv; if (cv) { - AV *padlist = CvPADLIST(cv); - AV *comppad = (AV*)(*av_fetch(padlist, 0, FALSE)); + AV * const padlist = CvPADLIST(cv); + AV * const comppad = (AV*)(*av_fetch(padlist, 0, FALSE)); sv = *av_fetch(comppad, o->op_targ, FALSE); } else sv = Nullsv; diff --git a/embed.fnc b/embed.fnc index 696d01f..5c6c8e8 100644 --- a/embed.fnc +++ b/embed.fnc @@ -24,9 +24,8 @@ : b binary backward compatibility; function is a macro : but has also Perl_ implementation (which is exported) : U suppress usage example in autogenerated documentation -: a allocates memory a la malloc/calloc -: R Return value must not be ignored. All "a" functions -: get this automatically. +: a allocates memory a la malloc/calloc. Is also "R". +: R Return value must not be ignored. : P pure function: no effects except the return value; : return value depends only on parms and/or globals : @@ -72,7 +71,7 @@ Aanop |Malloc_t|calloc |MEM_SIZE elements|MEM_SIZE size Aanop |Malloc_t|realloc |Malloc_t where|MEM_SIZE nbytes Anop |Free_t |mfree |Malloc_t where #if defined(MYMALLOC) -np |MEM_SIZE|malloced_size |void *p +npR |MEM_SIZE|malloced_size |void *p #endif Anp |void* |get_context @@ -305,9 +304,9 @@ p |void |init_debugger Ap |void |init_stacks Ap |void |init_tm |struct tm *ptm pd |U32 |intro_my -ApP |char* |instr |NN const char* big|NN const char* little -p |bool |io_close |IO* io|bool not_implicit -p |OP* |invert |OP* cmd +ApPR |char* |instr |NN const char* big|NN const char* little +pR |bool |io_close |NN IO* io|bool not_implicit +pR |OP* |invert |OP* cmd dpR |bool |is_gv_magical |const char *name|STRLEN len|U32 flags ApR |I32 |is_lvalue_sub ApPR |U32 |to_uni_upper_lc|U32 c @@ -768,8 +767,8 @@ Apd |SV* |sv_mortalcopy |NN SV* oldsv ApdR |SV* |sv_newmortal Apd |SV* |sv_newref |SV* sv Ap |char* |sv_peek |SV* sv -Apd |void |sv_pos_u2b |SV* sv|I32* offsetp|I32* lenp -Apd |void |sv_pos_b2u |SV* sv|I32* offsetp +Apd |void |sv_pos_u2b |SV* sv|NN I32* offsetp|I32* lenp +Apd |void |sv_pos_b2u |SV* sv|NN I32* offsetp Amdb |char* |sv_pvn_force |SV* sv|STRLEN* lp Apd |char* |sv_pvutf8n_force|SV* sv|STRLEN* lp Apd |char* |sv_pvbyten_force|SV* sv|STRLEN* lp @@ -996,9 +995,10 @@ 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 +s |void |unshare_hek_or_pvn|HEK* hek|const char* str|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 +asR |struct xpvhv_aux*|hv_auxinit|HV *hv #endif #if defined(PERL_IN_MG_C) || defined(PERL_DECL_PROT) @@ -1140,10 +1140,10 @@ s |SV* |method_common |SV* meth|U32* hashp #endif #if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT) -s |OP* |doform |CV *cv|GV *gv|OP *retop -s |int |emulate_eaccess|const char* path|Mode_t mode +s |OP* |doform |NN CV *cv|NN GV *gv|NN OP *retop +sr |int |emulate_eaccess|NN const char* path|Mode_t mode # if !defined(HAS_MKDIR) || !defined(HAS_RMDIR) -s |int |dooneliner |char *cmd|char *filename +sR |int |dooneliner |NN const char *cmd|NN const char *filename # endif #endif @@ -1430,17 +1430,16 @@ sM |SV* |hv_delete_common|HV* tb|SV* key_sv|const char* key|STRLEN klen|int k_fl sM |HE* |hv_fetch_common|HV* tb|SV* key_sv|const char* key|STRLEN klen|int flags|int action|SV* val|U32 hash #endif -Apd |void |hv_clear_placeholders|HV* hb - -Apd |SV* |hv_scalar |HV* hv| -Apo |I32* |hv_riter_p |HV* hv -Apo |HE** |hv_eiter_p |HV* hv -Apo |void |hv_riter_set |HV* hv|I32 riter -Apo |void |hv_eiter_set |HV* hv|HE* eiter -Apo |void |hv_name_set |HV* hv|const char *|I32 len|int flags -Apo |I32* |hv_placeholders_p |HV* hv -Apo |I32 |hv_placeholders_get |HV* hv -Apo |void |hv_placeholders_set |HV* hv|I32 ph +ApdR |SV* |hv_scalar |NN HV* hv +ApoR |I32* |hv_riter_p |NN HV* hv +ApoR |HE** |hv_eiter_p |NN HV* hv +Apo |void |hv_riter_set |NN HV* hv|I32 riter +Apo |void |hv_eiter_set |NN HV* hv|NN HE* eiter +Apo |void |hv_name_set |NN HV* hv|const char *name|I32 len|int flags +Apd |void |hv_clear_placeholders |NN HV* hb +ApoR |I32* |hv_placeholders_p |NN HV* hv +ApoR |I32 |hv_placeholders_get |NN HV* hv +ApoR |void |hv_placeholders_set |NN HV* hv|I32 ph p |SV* |magic_scalarpack|HV* hv|MAGIC* mg #ifdef PERL_IN_SV_C diff --git a/embed.h b/embed.h index 43f18b3..53e90b5 100644 --- a/embed.h +++ b/embed.h @@ -1036,6 +1036,7 @@ #define unshare_hek_or_pvn S_unshare_hek_or_pvn #define share_hek_flags S_share_hek_flags #define hv_notallowed S_hv_notallowed +#define hv_auxinit S_hv_auxinit #endif #endif #if defined(PERL_IN_MG_C) || defined(PERL_DECL_PROT) @@ -1508,8 +1509,8 @@ #define hv_fetch_common S_hv_fetch_common #endif #endif -#define hv_clear_placeholders Perl_hv_clear_placeholders #define hv_scalar Perl_hv_scalar +#define hv_clear_placeholders Perl_hv_clear_placeholders #ifdef PERL_CORE #define magic_scalarpack Perl_magic_scalarpack #endif @@ -3017,6 +3018,7 @@ #define unshare_hek_or_pvn(a,b,c,d) S_unshare_hek_or_pvn(aTHX_ a,b,c,d) #define share_hek_flags(a,b,c,d) S_share_hek_flags(aTHX_ a,b,c,d) #define hv_notallowed(a,b,c,d) S_hv_notallowed(aTHX_ a,b,c,d) +#define hv_auxinit(a) S_hv_auxinit(aTHX_ a) #endif #endif #if defined(PERL_IN_MG_C) || defined(PERL_DECL_PROT) @@ -3488,8 +3490,8 @@ #define hv_fetch_common(a,b,c,d,e,f,g,h) S_hv_fetch_common(aTHX_ a,b,c,d,e,f,g,h) #endif #endif -#define hv_clear_placeholders(a) Perl_hv_clear_placeholders(aTHX_ a) #define hv_scalar(a) Perl_hv_scalar(aTHX_ a) +#define hv_clear_placeholders(a) Perl_hv_clear_placeholders(aTHX_ a) #ifdef PERL_CORE #define magic_scalarpack(a,b) Perl_magic_scalarpack(aTHX_ a,b) #endif diff --git a/global.sym b/global.sym index dcff9d8..f8c26bb 100644 --- a/global.sym +++ b/global.sym @@ -675,13 +675,13 @@ Perl_PerlIO_stdout Perl_PerlIO_stderr Perl_save_set_svflags Perl_hv_assert -Perl_hv_clear_placeholders Perl_hv_scalar Perl_hv_riter_p Perl_hv_eiter_p Perl_hv_riter_set Perl_hv_eiter_set Perl_hv_name_set +Perl_hv_clear_placeholders Perl_hv_placeholders_p Perl_hv_placeholders_get Perl_hv_placeholders_set diff --git a/gv.c b/gv.c index 2d0fc93..504f1ec 100644 --- a/gv.c +++ b/gv.c @@ -867,7 +867,7 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, } else #endif { - const char *name2 = name + 1; + const char * const name2 = name + 1; switch (*name) { case 'A': if (strEQ(name2, "RGV")) { @@ -1194,8 +1194,7 @@ Perl_newIO(pTHX) sv_upgrade((SV *)io,SVt_PVIO); SvREFCNT(io) = 1; SvOBJECT_on(io); - /* Clear the stashcache because a new IO could overrule a - package name */ + /* Clear the stashcache because a new IO could overrule a package name */ hv_clear(PL_stashcache); iogv = gv_fetchpv("FileHandle::", FALSE, SVt_PVHV); /* unless exists($main::{FileHandle}) and defined(%main::FileHandle::) */ @@ -1431,7 +1430,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) { /* Can be an import stub (created by "can"). */ SV *gvsv = GvSV(gv); - const char *name = SvPOK(gvsv) ? SvPVX_const(gvsv) : "???"; + const char * const name = SvPOK(gvsv) ? SvPVX_const(gvsv) : "???"; Perl_croak(aTHX_ "%s method \"%.256s\" overloading \"%s\" "\ "in package \"%.256s\"", (GvCVGEN(gv) ? "Stub found while resolving" @@ -1440,8 +1439,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) } cv = GvCV(gv = ngv); } - DEBUG_o( Perl_deb(aTHX_ "Overloading \"%s\" in package \"%.256s\" "\ - "via \"%.256s::%.256s\"\n", + DEBUG_o( Perl_deb(aTHX_ "Overloading \"%s\" in package \"%.256s\" via \"%.256s::%.256s\"\n", cp, HvNAME_get(stash), HvNAME_get(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv))) ); filled = 1; @@ -1516,8 +1514,10 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) CV *cv=NULL; CV **cvp=NULL, **ocvp=NULL; AMT *amtp=NULL, *oamtp=NULL; - int off=0, off1, lr=0, assign=AMGf_assign & flags, notfound=0; - int postpr = 0, force_cpy = 0, assignshift = assign ? 1 : 0; + int off = 0, off1, lr = 0, notfound = 0; + int postpr = 0, force_cpy = 0; + int assign = AMGf_assign & flags; + const int assignshift = assign ? 1 : 0; #ifdef DEBUGGING int fl=0; #endif @@ -1891,7 +1891,7 @@ Perl_is_gv_magical(pTHX_ const char *name, STRLEN len, U32 flags) { (void)flags; if (len > 1) { - const char *name1 = name + 1; + const char * const name1 = name + 1; switch (*name) { case 'I': if (len == 3 && name1[1] == 'S' && name[2] == 'A') diff --git a/hv.c b/hv.c index 5f0f485..68ef67e 100644 --- a/hv.c +++ b/hv.c @@ -127,6 +127,7 @@ HEK * Perl_hek_dup(pTHX_ HEK *source, CLONE_PARAMS* param) { HE *shared = (HE*)ptr_table_fetch(PL_shared_hek_table, source); + (void)param; if (shared) { /* We already shared this hash key. */ @@ -991,8 +992,8 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, return Nullsv; if (is_utf8) { - const char *keysave = key; - key = (char*)bytes_from_utf8((U8*)key, &klen, &is_utf8); + const char *keysave = key; + key = (char*)bytes_from_utf8((U8*)key, &klen, &is_utf8); if (is_utf8) k_flags |= HVhek_UTF8; @@ -1519,8 +1520,8 @@ Perl_hv_clear(pTHX_ HV *hv) if (SvREADONLY(hv) && HvARRAY(hv) != NULL) { /* restricted hash: convert all keys to placeholders */ - I32 i; - for (i = 0; i <= (I32) xhv->xhv_max; i++) { + STRLEN i; + for (i = 0; i <= xhv->xhv_max; i++) { HE *entry = (HvARRAY(hv))[i]; for (; entry; entry = HeNEXT(entry)) { /* not already placeholder */ @@ -1576,11 +1577,12 @@ Perl_hv_clear_placeholders(pTHX_ HV *hv) { dVAR; I32 items = (I32)HvPLACEHOLDERS_get(hv); - I32 i = HvMAX(hv); + I32 i; if (items == 0) return; + i = HvMAX(hv); do { /* Loop down the linked list heads */ bool first = 1; @@ -1722,7 +1724,7 @@ Perl_hv_undef(pTHX_ HV *hv) mg_clear((SV*)hv); } -struct xpvhv_aux* +static struct xpvhv_aux* S_hv_auxinit(pTHX_ HV *hv) { struct xpvhv_aux *iter; char *array; @@ -1854,6 +1856,7 @@ Perl_hv_name_set(pTHX_ HV *hv, const char *name, I32 len, int flags) { struct xpvhv_aux *iter; U32 hash; + (void)flags; if (SvOOK(hv)) { iter = HvAUX(hv); @@ -2373,7 +2376,7 @@ I32 Perl_hv_placeholders_get(pTHX_ HV *hv) { dVAR; - MAGIC *mg = mg_find((SV*)hv, PERL_MAGIC_rhash); + MAGIC * const mg = mg_find((SV*)hv, PERL_MAGIC_rhash); return mg ? mg->mg_len : 0; } @@ -2382,7 +2385,7 @@ void Perl_hv_placeholders_set(pTHX_ HV *hv, I32 ph) { dVAR; - MAGIC *mg = mg_find((SV*)hv, PERL_MAGIC_rhash); + MAGIC * const mg = mg_find((SV*)hv, PERL_MAGIC_rhash); if (mg) { mg->mg_len = ph; diff --git a/malloc.c b/malloc.c index 05c0528..521248a 100644 --- a/malloc.c +++ b/malloc.c @@ -1337,7 +1337,7 @@ fill_pat_4bytes(unsigned char *s, size_t nbytes, const unsigned char *fill) { unsigned char *e = s + nbytes; long *lp; - long lfill = *(long*)fill; + const long lfill = *(long*)fill; if (PTR2UV(s) & (sizeof(long)-1)) { /* Align the pattern */ int shift = sizeof(long) - (PTR2UV(s) & (sizeof(long)-1)); @@ -1378,7 +1378,7 @@ cmp_pat_4bytes(unsigned char *s, size_t nbytes, const unsigned char *fill) { unsigned char *e = s + nbytes; long *lp; - long lfill = *(long*)fill; + const long lfill = *(long*)fill; if (PTR2UV(s) & (sizeof(long)-1)) { /* Align the pattern */ int shift = sizeof(long) - (PTR2UV(s) & (sizeof(long)-1)); @@ -2357,12 +2357,12 @@ Perl_malloced_size(void *p) { union overhead *ovp = (union overhead *) ((caddr_t)p - sizeof (union overhead) * CHUNK_SHIFT); - int bucket = OV_INDEX(ovp); + const int bucket = OV_INDEX(ovp); #ifdef RCHECK /* The caller wants to have a complete control over the chunk, disable the memory checking inside the chunk. */ if (bucket <= MAX_SHORT_BUCKET) { - MEM_SIZE size = BUCKET_SIZE_REAL(bucket); + const MEM_SIZE size = BUCKET_SIZE_REAL(bucket); ovp->ov_size = size + M_OVERHEAD - 1; *((u_int *)((caddr_t)ovp + size + M_OVERHEAD - RMAGIC_SZ)) = RMAGIC; } diff --git a/perl.c b/perl.c index 816a64c..2364a90 100644 --- a/perl.c +++ b/perl.c @@ -2282,7 +2282,6 @@ Perl_eval_sv(pTHX_ SV *sv, I32 flags) UNOP myop; /* fake syntax tree node */ volatile I32 oldmark = SP - PL_stack_base; volatile I32 retval = 0; - I32 oldscope; int ret; OP* oldop = PL_op; dJMPENV; @@ -2297,7 +2296,6 @@ Perl_eval_sv(pTHX_ SV *sv, I32 flags) Zero(PL_op, 1, UNOP); EXTEND(PL_stack_sp, 1); *++PL_stack_sp = sv; - oldscope = PL_scopestack_ix; if (!(flags & G_NOARGS)) myop.op_flags = OPf_STACKED; diff --git a/perlio.c b/perlio.c index c52458e..05963d0 100644 --- a/perlio.c +++ b/perlio.c @@ -1160,7 +1160,7 @@ PerlIO_push(pTHX_ PerlIO *f, PERLIO_FUNCS_DECL(*tab), const char *mode, SV *arg) Perl_croak(aTHX_ "Layer does not match this perl"); } if (tab->size) { - PerlIOl *l = NULL; + PerlIOl *l; if (tab->size < sizeof(PerlIOl)) { goto mismatch; } @@ -2507,7 +2507,7 @@ PerlIOUnix_read(pTHX_ PerlIO *f, void *vbuf, Size_t count) return 0; } while (1) { - SSize_t len = PerlLIO_read(fd, vbuf, count); + const SSize_t len = PerlLIO_read(fd, vbuf, count); if (len >= 0 || errno != EINTR) { if (len < 0) { if (errno != EAGAIN) { @@ -2522,6 +2522,7 @@ PerlIOUnix_read(pTHX_ PerlIO *f, void *vbuf, Size_t count) } PERL_ASYNC_CHECK(); } + /*NOTREACHED*/ } SSize_t diff --git a/pp_ctl.c b/pp_ctl.c index fbcb1c4..2ee4e88 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2945,8 +2945,8 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq) lex_end(); LEAVE; if (optype == OP_REQUIRE) { - const char* msg = SvPVx(ERRSV, n_a); - SV *nsv = cx->blk_eval.old_namesv; + const char* const msg = SvPVx(ERRSV, n_a); + const SV * const nsv = cx->blk_eval.old_namesv; (void)hv_store(GvHVn(PL_incgv), SvPVX_const(nsv), SvCUR(nsv), &PL_sv_undef, 0); DIE(aTHX_ "%sCompilation failed in require", diff --git a/pp_hot.c b/pp_hot.c index c9bfc46..83e0183 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -911,7 +911,7 @@ S_do_oddball(pTHX_ HV *hash, SV **relem, SV **firstrelem) { if (*relem) { SV *tmpstr; - HE *didstore; + const HE *didstore; if (ckWARN(WARN_MISC)) { const char *err; @@ -1294,7 +1294,6 @@ play_it_again: if (gimme == G_ARRAY) { const I32 nparens = rx->nparens; I32 i = (global && !nparens) ? 1 : 0; - I32 len; SPAGAIN; /* EVAL blocks could move the stack. */ EXTEND(SP, nparens + i); @@ -1303,7 +1302,7 @@ play_it_again: PUSHs(sv_newmortal()); /*SUPPRESS 560*/ if ((rx->startp[i] != -1) && rx->endp[i] != -1 ) { - len = rx->endp[i] - rx->startp[i]; + const I32 len = rx->endp[i] - rx->startp[i]; s = rx->startp[i] + truebase; if (rx->endp[i] < 0 || rx->startp[i] < 0 || len < 0 || len > strend - s) @@ -3000,8 +2999,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) packname = Nullch; if(SvOK(sv) && (packname = SvPV(sv, packlen))) { - HE* he; - he = hv_fetch_ent(PL_stashcache, sv, 0, 0); + const HE* const he = hv_fetch_ent(PL_stashcache, sv, 0, 0); if (he) { stash = INT2PTR(HV*,SvIV(HeVAL(he))); goto fetch; @@ -3055,7 +3053,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) /* shortcut for simple names */ if (hashp) { - HE* he = hv_fetch_ent(stash, meth, 0, *hashp); + const HE* const he = hv_fetch_ent(stash, meth, 0, *hashp); if (he) { gv = (GV*)HeVAL(he); if (isGV(gv) && GvCV(gv) && diff --git a/pp_sys.c b/pp_sys.c index 98b99e4..1171ec8 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1390,7 +1390,7 @@ PP(pp_leavewrite) cv = GvFORM(fgv); if (!cv) { SV * const sv = sv_newmortal(); - char *name; + const char *name; gv_efullname4(sv, fgv, Nullch, FALSE); name = SvPV_nolen(sv); if (name && *name) @@ -3727,9 +3727,9 @@ PP(pp_readlink) #if !defined(HAS_MKDIR) || !defined(HAS_RMDIR) STATIC int -S_dooneliner(pTHX_ char *cmd, char *filename) +S_dooneliner(pTHX_ const char *cmd, const char *filename) { - char *save_filename = filename; + char * const save_filename = filename; char *cmdline; char *s; PerlIO *myfp; diff --git a/proto.h b/proto.h index 78d3161..5964997 100644 --- a/proto.h +++ b/proto.h @@ -57,7 +57,9 @@ PERL_CALLCONV Malloc_t Perl_realloc(Malloc_t where, MEM_SIZE nbytes) PERL_CALLCONV Free_t Perl_mfree(Malloc_t where); #if defined(MYMALLOC) -PERL_CALLCONV MEM_SIZE Perl_malloced_size(void *p); +PERL_CALLCONV MEM_SIZE Perl_malloced_size(void *p) + __attribute__warn_unused_result__; + #endif PERL_CALLCONV void* Perl_get_context(void); @@ -453,12 +455,18 @@ PERL_CALLCONV void Perl_init_stacks(pTHX); PERL_CALLCONV void Perl_init_tm(pTHX_ struct tm *ptm); PERL_CALLCONV U32 Perl_intro_my(pTHX); PERL_CALLCONV char* Perl_instr(pTHX_ const char* big, const char* little) + __attribute__warn_unused_result__ __attribute__pure__ __attribute__nonnull__(pTHX_1) __attribute__nonnull__(pTHX_2); -PERL_CALLCONV bool Perl_io_close(pTHX_ IO* io, bool not_implicit); -PERL_CALLCONV OP* Perl_invert(pTHX_ OP* cmd); +PERL_CALLCONV bool Perl_io_close(pTHX_ IO* io, bool not_implicit) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV OP* Perl_invert(pTHX_ OP* cmd) + __attribute__warn_unused_result__; + PERL_CALLCONV bool Perl_is_gv_magical(pTHX_ const char *name, STRLEN len, U32 flags) __attribute__warn_unused_result__; @@ -1497,8 +1505,12 @@ PERL_CALLCONV SV* Perl_sv_newmortal(pTHX) PERL_CALLCONV SV* Perl_sv_newref(pTHX_ SV* sv); PERL_CALLCONV char* Perl_sv_peek(pTHX_ SV* sv); -PERL_CALLCONV void Perl_sv_pos_u2b(pTHX_ SV* sv, I32* offsetp, I32* lenp); -PERL_CALLCONV void Perl_sv_pos_b2u(pTHX_ SV* sv, I32* offsetp); +PERL_CALLCONV void Perl_sv_pos_u2b(pTHX_ SV* sv, I32* offsetp, I32* lenp) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_sv_pos_b2u(pTHX_ SV* sv, I32* offsetp) + __attribute__nonnull__(pTHX_2); + /* PERL_CALLCONV char* sv_pvn_force(pTHX_ SV* sv, STRLEN* lp); */ PERL_CALLCONV char* Perl_sv_pvutf8n_force(pTHX_ SV* sv, STRLEN* lp); PERL_CALLCONV char* Perl_sv_pvbyten_force(pTHX_ SV* sv, STRLEN* lp); @@ -1852,9 +1864,7 @@ STATIC void S_hv_magic_check(pTHX_ HV *hv, bool *needs_copy, bool *needs_store) __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 void S_unshare_hek_or_pvn(pTHX_ HEK* hek, const char* str, I32 len, U32 hash); STATIC HE* S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags) __attribute__warn_unused_result__; @@ -1863,6 +1873,10 @@ 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) + __attribute__malloc__ + __attribute__warn_unused_result__; + #endif #if defined(PERL_IN_MG_C) || defined(PERL_DECL_PROT) @@ -2198,10 +2212,21 @@ STATIC SV* S_method_common(pTHX_ SV* meth, U32* hashp); #endif #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); +STATIC OP* S_doform(pTHX_ CV *cv, GV *gv, OP *retop) + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2) + __attribute__nonnull__(pTHX_3); + +STATIC int S_emulate_eaccess(pTHX_ const char* path, Mode_t mode) + __attribute__noreturn__ + __attribute__nonnull__(pTHX_1); + # if !defined(HAS_MKDIR) || !defined(HAS_RMDIR) -STATIC int S_dooneliner(pTHX_ char *cmd, char *filename); +STATIC int S_dooneliner(pTHX_ const char *cmd, const char *filename) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2); + # endif #endif @@ -2565,17 +2590,43 @@ STATIC SV* S_hv_delete_common(pTHX_ HV* tb, SV* key_sv, const char* key, STRLEN 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 -PERL_CALLCONV void Perl_hv_clear_placeholders(pTHX_ HV* hb); +PERL_CALLCONV SV* Perl_hv_scalar(pTHX_ HV* hv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV I32* Perl_hv_riter_p(pTHX_ HV* hv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV HE** Perl_hv_eiter_p(pTHX_ HV* hv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV void Perl_hv_riter_set(pTHX_ HV* hv, I32 riter) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV void Perl_hv_eiter_set(pTHX_ HV* hv, HE* eiter) + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2); + +PERL_CALLCONV void Perl_hv_name_set(pTHX_ HV* hv, const char *name, I32 len, int flags) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV void Perl_hv_clear_placeholders(pTHX_ HV* hb) + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV I32* Perl_hv_placeholders_p(pTHX_ HV* hv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV I32 Perl_hv_placeholders_get(pTHX_ HV* hv) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); + +PERL_CALLCONV void Perl_hv_placeholders_set(pTHX_ HV* hv, I32 ph) + __attribute__warn_unused_result__ + __attribute__nonnull__(pTHX_1); -PERL_CALLCONV SV* Perl_hv_scalar(pTHX_ HV* hv); -PERL_CALLCONV I32* Perl_hv_riter_p(pTHX_ HV* hv); -PERL_CALLCONV HE** Perl_hv_eiter_p(pTHX_ HV* hv); -PERL_CALLCONV void Perl_hv_riter_set(pTHX_ HV* hv, I32 riter); -PERL_CALLCONV void Perl_hv_eiter_set(pTHX_ HV* hv, HE* eiter); -PERL_CALLCONV void Perl_hv_name_set(pTHX_ HV* hv, const char *, I32 len, int flags); -PERL_CALLCONV I32* Perl_hv_placeholders_p(pTHX_ HV* hv); -PERL_CALLCONV I32 Perl_hv_placeholders_get(pTHX_ HV* hv); -PERL_CALLCONV void Perl_hv_placeholders_set(pTHX_ HV* hv, I32 ph); PERL_CALLCONV SV* Perl_magic_scalarpack(pTHX_ HV* hv, MAGIC* mg); #ifdef PERL_IN_SV_C diff --git a/sv.c b/sv.c index 92a2716..aa07053 100644 --- a/sv.c +++ b/sv.c @@ -5142,7 +5142,7 @@ Perl_sv_catsv_flags(pTHX_ SV *dsv, register SV *ssv, I32 flags) dsv->sv_flags doesn't have that bit set. Andy Dougherty 12 Oct 2001 */ - I32 sutf8 = DO_UTF8(ssv); + const I32 sutf8 = DO_UTF8(ssv); I32 dutf8; if (SvGMAGICAL(dsv) && (flags & SV_GMAGIC)) @@ -5836,11 +5836,8 @@ Perl_sv_clear(pTHX_ register SV *sv) if (SvOBJECT(sv)) { if (PL_defstash) { /* Still have a symbol table? */ dSP; - CV* destructor; - - - do { + CV* destructor; stash = SvSTASH(sv); destructor = StashHANDLER(stash,DESTROY); if (destructor) { @@ -6380,16 +6377,16 @@ void Perl_sv_pos_u2b(pTHX_ register SV *sv, I32* offsetp, I32* lenp) { U8 *start; - U8 *s; STRLEN len; - STRLEN *cache = 0; - STRLEN boffset = 0; if (!sv) return; - start = s = (U8*)SvPV(sv, len); + start = (U8*)SvPV(sv, len); if (len) { + STRLEN boffset = 0; + STRLEN *cache = 0; + U8 *s = start; I32 uoffset = *offsetp; U8 *send = s + len; MAGIC *mg = 0; @@ -7829,11 +7826,6 @@ void Perl_sv_reset(pTHX_ register const char *s, HV *stash) { dVAR; - register HE *entry; - register GV *gv; - register SV *sv; - register I32 i; - register I32 max; char todo[PERL_UCHAR_MAX+1]; if (!stash) @@ -7858,7 +7850,8 @@ Perl_sv_reset(pTHX_ register const char *s, HV *stash) Zero(todo, 256, char); while (*s) { - i = (unsigned char)*s; + I32 max; + I32 i = (unsigned char)*s; if (s[1] == '-') { s += 2; } @@ -7867,10 +7860,14 @@ Perl_sv_reset(pTHX_ register const char *s, HV *stash) todo[i] = 1; } for (i = 0; i <= (I32) HvMAX(stash); i++) { + HE *entry; for (entry = HvARRAY(stash)[i]; entry; entry = HeNEXT(entry)) { + register GV *gv; + register SV *sv; + if (!todo[(U8)*HeKEY(entry)]) continue; gv = (GV*)HeVAL(entry); @@ -9072,11 +9069,11 @@ F0convert(NV nv, char *endbuf, STRLEN *len) { const int neg = nv < 0; UV uv; - char *p = endbuf; if (neg) nv = -nv; if (nv < UV_MAX) { + char *p = endbuf; nv += 0.5; uv = (UV)nv; if (uv & 1 && uv == nv) @@ -9120,8 +9117,8 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV I32 svix = 0; static const char nullstr[] = "(null)"; SV *argsv = Nullsv; - bool has_utf8; /* has the result utf8? */ - bool pat_utf8; /* the pattern is in utf8? */ + bool has_utf8 = DO_UTF8(sv); /* has the result utf8? */ + const bool pat_utf8 = has_utf8; /* the pattern is in utf8? */ SV *nsv = Nullsv; /* Times 4: a decimal digit takes more than 3 binary digits. * NV_DIG: mantissa takes than many decimal digits. @@ -9130,8 +9127,6 @@ 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 */ - has_utf8 = pat_utf8 = DO_UTF8(sv); - /* no matter what, this is a string now */ (void)SvPV_force(sv, origlen); @@ -11211,7 +11206,6 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) long longval; GP *gp; IV iv; - I32 i; char *c = NULL; void (*dptr) (void*); void (*dxptr) (pTHX_ void*); @@ -11223,7 +11217,7 @@ Perl_ss_dup(pTHX_ PerlInterpreter *proto_perl, CLONE_PARAMS* param) Newz(54, nss, max, ANY); while (ix > 0) { - i = POPINT(ss,ix); + I32 i = POPINT(ss,ix); TOPINT(nss,ix) = i; switch (i) { case SAVEt_ITEM: /* normal string */ @@ -11583,7 +11577,6 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, * constants; they need to be allocated as common memory and just * their pointers copied. */ - IV i; CLONE_PARAMS clone_params; CLONE_PARAMS* param = &clone_params; @@ -11810,6 +11803,7 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, { const I32 len = av_len((AV*)proto_perl->Iregex_padav); SV** regexen = AvARRAY((AV*)proto_perl->Iregex_padav); + IV i; av_push(PL_regex_padav, sv_dup_inc(regexen[0],param)); for(i = 1; i <= len; i++) { diff --git a/toke.c b/toke.c index ff82444..26b7f3d 100644 --- a/toke.c +++ b/toke.c @@ -9484,7 +9484,7 @@ S_scan_heredoc(pTHX_ register char *s) #ifndef PERL_STRICT_CR d = strchr(s, '\r'); if (d) { - char *olds = s; + char * const olds = s; s = d; while (s < PL_bufend) { if (*s == '\r') { @@ -9532,7 +9532,7 @@ S_scan_heredoc(pTHX_ register char *s) if (PL_lex_inwhat == OP_SUBST && PL_in_eval && !PL_rsfp) { char *bufptr = PL_sublex_info.super_bufptr; char *bufend = PL_sublex_info.super_bufend; - char *olds = s - SvCUR(herewas); + char * const olds = s - SvCUR(herewas); s = strchr(bufptr, '\n'); if (!s) s = bufend; diff --git a/util.c b/util.c index dfd912f..657a8f5 100644 --- a/util.c +++ b/util.c @@ -3018,6 +3018,8 @@ Perl_set_context(void *t) if (pthread_setspecific(PL_thr_key, t)) Perl_croak_nocontext("panic: pthread_setspecific"); # endif +#else + (void)t; #endif }