summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2005-06-02 07:19:43 -0500
committerNicholas Clark <nick@ccl4.org>2005-09-20 08:19:03 +0000
commit481da01c67edce9ed8875f3ca084e61422cd12a2 (patch)
treef5e3eb7e84269669c434fd398c5301115c3b6e11
parent0612e8695661dbfefd8634295c877390668c2967 (diff)
downloadperl-481da01c67edce9ed8875f3ca084e61422cd12a2.tar.gz
Integrate:
[ 24689] Subject: [PATCH] Random consting Message-ID: <20050602171943.GA16553@petdance.com> p4raw-link: @24689 on //depot/perl: b464bac0b70c4876af1296864220315edde8461d p4raw-id: //depot/maint-5.8/perl@25508 p4raw-edited: from //depot/perl@24689 'edit in' embed.fnc sv.c (@24682..) p4raw-integrated: from //depot/perl@24689 'copy in' malloc.c (@24666..) 'edit in' pp_ctl.c (@24642..) pp_hot.c (@24670..) hv.c (@24676..) 'ignore' global.sym (@24619..) proto.h (@24682..) 'merge in' embed.h (@24605..) dump.c (@24619..) perlio.c (@24622..) doio.c (@24666..) gv.c util.c (@24669..) pp_sys.c (@24670..) perl.c (@24674..) toke.c (@24677..)
-rw-r--r--doio.c5
-rw-r--r--dump.c8
-rw-r--r--embed.fnc29
-rw-r--r--global.sym4
-rw-r--r--gv.c18
-rw-r--r--hv.c11
-rw-r--r--malloc.c8
-rw-r--r--perl.c2
-rw-r--r--perlio.c5
-rw-r--r--pp_ctl.c2
-rw-r--r--pp_hot.c8
-rw-r--r--pp_sys.c6
-rw-r--r--proto.h52
-rw-r--r--sv.c40
-rw-r--r--toke.c4
-rw-r--r--util.c2
16 files changed, 112 insertions, 92 deletions
diff --git a/doio.c b/doio.c
index c8682b4e13..58cbd9565b 100644
--- a/doio.c
+++ b/doio.c
@@ -102,7 +102,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);
@@ -1991,7 +1991,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 ea1a596cd2..2a726f9648 100644
--- a/dump.c
+++ b/dump.c
@@ -78,7 +78,7 @@ Perl_dump_packsubs(pTHX_ HV *stash)
void
Perl_dump_sub(pTHX_ 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));
@@ -95,7 +95,7 @@ Perl_dump_sub(pTHX_ GV *gv)
void
Perl_dump_form(pTHX_ 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));
@@ -1493,8 +1493,8 @@ Perl_debop(pTHX_ 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 3df379b8f1..48fa17ddbe 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
@@ -317,9 +316,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 |char *name|STRLEN len|U32 flags
ApR |I32 |is_lvalue_sub
ApPR |U32 |to_uni_upper_lc|U32 c
@@ -776,8 +775,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
@@ -1020,7 +1019,7 @@ 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 |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
#endif
@@ -1138,10 +1137,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
@@ -1417,13 +1416,13 @@ p |int |get_debug_opts |char **s
-Apd |void |hv_clear_placeholders|HV* hb
+Apd |void |hv_clear_placeholders|NN HV* hb
#if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
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
-Apd |SV* |hv_scalar |HV* hv|
+ApdR |SV* |hv_scalar |NN HV* hv|
p |SV* |magic_scalarpack|HV* hv|MAGIC* mg
#if defined(DEBUGGING)
diff --git a/global.sym b/global.sym
index d5a9154bb9..80ff9dd6d4 100644
--- a/global.sym
+++ b/global.sym
@@ -212,9 +212,8 @@ Perl_is_uni_print_lc
Perl_is_uni_punct_lc
Perl_is_uni_xdigit_lc
Perl_is_utf8_char
-Perl_is_utf8_string
Perl_is_utf8_string_loc
-Perl_is_utf8_string_loclen
+Perl_is_utf8_string
Perl_is_utf8_alnum
Perl_is_utf8_alnumc
Perl_is_utf8_idfirst
@@ -715,4 +714,5 @@ Perl_ck_substr
Perl_ck_svconst
Perl_ck_trunc
Perl_ck_unpack
+Perl_is_utf8_string_loclen
# ex: set ro:
diff --git a/gv.c b/gv.c
index baad7e629d..71c34be362 100644
--- a/gv.c
+++ b/gv.c
@@ -862,7 +862,7 @@ Perl_gv_fetchpv(pTHX_ const char *nambeg, I32 add, I32 sv_type)
} else
#endif
{
- const char *name2 = name + 1;
+ const char * const name2 = name + 1;
switch (*name) {
case 'A':
if (strEQ(name2, "RGV")) {
@@ -1182,8 +1182,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::) */
@@ -1419,7 +1418,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"
@@ -1428,8 +1427,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;
@@ -1503,8 +1501,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
@@ -1862,7 +1862,7 @@ Perl_is_gv_magical(pTHX_ 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 5ae011abca..10d5658f7d 100644
--- a/hv.c
+++ b/hv.c
@@ -967,8 +967,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;
@@ -1470,8 +1470,8 @@ Perl_hv_clear(pTHX_ HV *hv)
if (SvREADONLY(hv) && xhv->xhv_array != 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 = ((HE**)xhv->xhv_array)[i];
for (; entry; entry = HeNEXT(entry)) {
/* not already placeholder */
@@ -1524,11 +1524,12 @@ void
Perl_hv_clear_placeholders(pTHX_ HV *hv)
{
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;
diff --git a/malloc.c b/malloc.c
index 05c0528e39..521248ab6d 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 5da9861431..89ba116ec8 100644
--- a/perl.c
+++ b/perl.c
@@ -2379,7 +2379,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;
@@ -2394,7 +2393,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 ff98c772e6..39ffda7058 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;
}
@@ -2504,7 +2504,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) {
@@ -2519,6 +2519,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 a83a461b8c..4b5b92088f 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2870,7 +2870,7 @@ 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);
+ const char* const msg = SvPVx(ERRSV, n_a);
DIE(aTHX_ "%sCompilation failed in require",
*msg ? msg : "Unknown error\n");
}
diff --git a/pp_hot.c b/pp_hot.c
index 7d28d333a7..8e31716cb4 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -1355,7 +1355,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);
@@ -1364,7 +1363,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)
@@ -3145,8 +3144,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;
@@ -3200,7 +3198,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 35b1e133d4..7d32b1a6a3 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1386,7 +1386,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)
@@ -3654,9 +3654,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 10c4288a84..d65842b22f 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);
@@ -465,12 +467,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_ char *name, STRLEN len, U32 flags)
__attribute__warn_unused_result__;
@@ -1488,8 +1496,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);
@@ -1854,9 +1866,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 HEK* S_share_hek_flags(pTHX_ const char* sv, I32 len, U32 hash, int flags)
__attribute__warn_unused_result__;
@@ -2050,10 +2060,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
@@ -2414,13 +2435,18 @@ PERL_CALLCONV int Perl_get_debug_opts(pTHX_ char **s);
-PERL_CALLCONV void Perl_hv_clear_placeholders(pTHX_ HV* hb);
+PERL_CALLCONV void Perl_hv_clear_placeholders(pTHX_ HV* hb)
+ __attribute__nonnull__(pTHX_1);
+
#if defined(PERL_IN_HV_C) || defined(PERL_DECL_PROT)
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
-PERL_CALLCONV SV* Perl_hv_scalar(pTHX_ HV* hv);
+PERL_CALLCONV SV* Perl_hv_scalar(pTHX_ HV* hv)
+ __attribute__warn_unused_result__
+ __attribute__nonnull__(pTHX_1);
+
PERL_CALLCONV SV* Perl_magic_scalarpack(pTHX_ HV* hv, MAGIC* mg);
#if defined(DEBUGGING)
diff --git a/sv.c b/sv.c
index cab35f5bc5..e16077933d 100644
--- a/sv.c
+++ b/sv.c
@@ -4511,7 +4511,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))
@@ -5171,11 +5171,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) {
@@ -5693,16 +5690,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;
@@ -7150,12 +7147,7 @@ Note that the perl-level function is vaguely deprecated.
void
Perl_sv_reset(pTHX_ register char *s, HV *stash)
{
- register HE *entry;
- register GV *gv;
- register SV *sv;
- register I32 i;
register PMOP *pm;
- register I32 max;
char todo[PERL_UCHAR_MAX+1];
if (!stash)
@@ -7175,7 +7167,8 @@ Perl_sv_reset(pTHX_ register 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;
}
@@ -7184,10 +7177,14 @@ Perl_sv_reset(pTHX_ register 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);
@@ -8388,11 +8385,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)
@@ -8438,8 +8435,8 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV
I32 svix = 0;
static 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.
@@ -8448,8 +8445,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);
@@ -10525,7 +10520,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*);
@@ -10534,7 +10528,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 */
@@ -10884,7 +10878,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;
@@ -11115,6 +11108,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 a9e0136cc6..de02676c85 100644
--- a/toke.c
+++ b/toke.c
@@ -9406,7 +9406,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') {
@@ -9454,7 +9454,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 861ae19e16..98e2adc330 100644
--- a/util.c
+++ b/util.c
@@ -3009,6 +3009,8 @@ Perl_set_context(void *t)
if (pthread_setspecific(PL_thr_key, t))
Perl_croak_nocontext("panic: pthread_setspecific");
# endif
+#else
+ (void)t;
#endif
}