From: Jarkko Hietaniemi Date: Wed, 30 May 2001 23:56:14 +0000 (+0000) Subject: More -Wall sweeping. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9c5ffd7c3fe1ab64d3e7d06810ac3ab42426718b;p=p5sagit%2Fp5-mst-13.2.git More -Wall sweeping. p4raw-id: //depot/perl@10338 --- diff --git a/av.c b/av.c index 4872f94..456a21e 100644 --- a/av.c +++ b/av.c @@ -130,7 +130,9 @@ Perl_av_extend(pTHX_ AV *av, I32 key) Safefree(AvALLOC(av)); AvALLOC(av) = ary; #endif +#if defined(MYMALLOC) && !defined(LEAKTEST) resized: +#endif ary = AvALLOC(av) + AvMAX(av) + 1; tmp = newmax - AvMAX(av); if (av == PL_curstack) { /* Oops, grew stack (via av_store()?) */ diff --git a/doio.c b/doio.c index e20245a..448b9b3 100644 --- a/doio.c +++ b/doio.c @@ -1011,7 +1011,7 @@ Perl_do_eof(pTHX_ GV *gv) Off_t Perl_do_tell(pTHX_ GV *gv) { - register IO *io; + register IO *io = 0; register PerlIO *fp; if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) { @@ -1030,7 +1030,7 @@ Perl_do_tell(pTHX_ GV *gv) bool Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence) { - register IO *io; + register IO *io = 0; register PerlIO *fp; if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) { @@ -1049,7 +1049,7 @@ Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence) Off_t Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence) { - register IO *io; + register IO *io = 0; register PerlIO *fp; if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) @@ -1332,7 +1332,7 @@ Perl_do_aexec5(pTHX_ SV *really, register SV **mark, register SV **sp, Perl_croak(aTHX_ "exec? I'm not *that* kind of operating system"); #else register char **a; - char *tmps; + char *tmps = Nullch; STRLEN n_a; if (sp > mark) { diff --git a/ext/Cwd/Cwd.xs b/ext/Cwd/Cwd.xs index 745a67f..872591d 100644 --- a/ext/Cwd/Cwd.xs +++ b/ext/Cwd/Cwd.xs @@ -130,7 +130,7 @@ _cwdxs_abs_path(char *start) char dotdots[MAXPATHLEN] = { 0 }; char name[MAXPATHLEN] = { 0 }; char *cwd; - int namelen; + int namelen = 0; struct stat cst, pst, tst; if (PerlLIO_stat(start, &cst) < 0) { diff --git a/ext/Devel/DProf/DProf.xs b/ext/Devel/DProf/DProf.xs index aba6de9..0cd7daa 100644 --- a/ext/Devel/DProf/DProf.xs +++ b/ext/Devel/DProf/DProf.xs @@ -384,7 +384,7 @@ test_time(pTHX_ clock_t *r, clock_t *u, clock_t *s) int i, j, k = 0; HV *oldstash = PL_curstash; struct tms t1, t2; - clock_t realtime1, realtime2; + clock_t realtime1 = 0, realtime2 = 0; U32 ototal = g_total; U32 ostack = g_SAVE_STACK; U32 operldb = PL_perldb; diff --git a/ext/Devel/Peek/Peek.xs b/ext/Devel/Peek/Peek.xs index 1e48149..b3131b6 100644 --- a/ext/Devel/Peek/Peek.xs +++ b/ext/Devel/Peek/Peek.xs @@ -10,7 +10,7 @@ DeadCode(pTHX) return Nullsv; #else SV* sva; - SV* sv, *dbg; + SV* sv; SV* ret = newRV_noinc((SV*)newAV()); register SV* svend; int tm = 0, tref = 0, ts = 0, ta = 0, tas = 0; diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index 6e3684e..ef21d5b 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -534,6 +534,7 @@ _utf8_to_bytes(sv, ...) STRLEN len; U8 *s = (U8*)SvPV(sv, len); + RETVAL = 0; if (SvTRUE(check)) { /* Must do things the slow way */ U8 *dest; diff --git a/ext/List/Util/Util.xs b/ext/List/Util/Util.xs index 1e6d8f6..c5b5ebf 100644 --- a/ext/List/Util/Util.xs +++ b/ext/List/Util/Util.xs @@ -89,7 +89,6 @@ PROTOTYPE: @ CODE: { int index; - NV ret; if(!items) { XSRETURN_UNDEF; } @@ -193,7 +192,6 @@ first(block,...) PROTOTYPE: &@ CODE: { - SV *ret; int index; I32 markix; GV *gv; @@ -237,7 +235,7 @@ CODE: STRLEN len; char *ptr = SvPV(str,len); ST(0) = sv_newmortal(); - SvUPGRADE(ST(0),SVt_PVNV); + (void)SvUPGRADE(ST(0),SVt_PVNV); sv_setpvn(ST(0),ptr,len); if(SvNOKp(num) || !SvIOKp(num)) { SvNVX(ST(0)) = SvNV(num); diff --git a/gv.c b/gv.c index 0041693..b038031 100644 --- a/gv.c +++ b/gv.c @@ -1230,7 +1230,6 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) MAGIC* mg=mg_find((SV*)stash, PERL_MAGIC_overload_table); AMT *amtp = (mg) ? (AMT*)mg->mg_ptr: (AMT *) NULL; AMT amt; - STRLEN n_a; if (mg && amtp->was_ok_am == PL_amagic_generation && amtp->was_ok_sub == PL_sub_generation) @@ -1284,7 +1283,7 @@ Perl_Gv_AMupdate(pTHX_ HV *stash) GV *ngv; DEBUG_o( Perl_deb(aTHX_ "Resolving method `%.256s' for overloaded `%s' in package `%.256s'\n", - SvPV(GvSV(gv), n_a), cp, HvNAME(stash)) ); + SvPV_nolen(GvSV(gv)), cp, HvNAME(stash)) ); if (!SvPOK(GvSV(gv)) || !(ngv = gv_fetchmethod_autoload(stash, SvPVX(GvSV(gv)), FALSE))) @@ -1356,10 +1355,10 @@ SV* Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) { MAGIC *mg; - CV *cv; + CV *cv=NULL; CV **cvp=NULL, **ocvp=NULL; - AMT *amtp, *oamtp; - int fl=0, off, off1, lr=0, assign=AMGf_assign & flags, notfound=0; + AMT *amtp=NULL, *oamtp=NULL; + int fl=0, off=0, off1, lr=0, assign=AMGf_assign & flags, notfound=0; int postpr = 0, force_cpy = 0, assignshift = assign ? 1 : 0; HV* stash; if (!(AMGf_noleft & flags) && SvAMAGIC(left) @@ -1647,7 +1646,7 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) CATCH_SET(oldcatch); if (postpr) { - int ans; + int ans=0; switch (method) { case le_amg: case sle_amg: diff --git a/op.c b/op.c index 8cc57ec..9e1d078 100644 --- a/op.c +++ b/op.c @@ -2660,7 +2660,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) U32 max = 0; I32 bits; I32 havefinal = 0; - U32 final; + U32 final = 0; I32 from_utf = o->op_private & OPpTRANS_FROM_UTF; I32 to_utf = o->op_private & OPpTRANS_TO_UTF; U8* tsave = NULL; @@ -6295,7 +6295,7 @@ Perl_ck_sort(pTHX_ OP *o) simplify_sort(o); firstkid = cLISTOPo->op_first->op_sibling; /* get past pushmark */ if (o->op_flags & OPf_STACKED) { /* may have been cleared */ - OP *k; + OP *k = NULL; OP *kid = cUNOPx(firstkid)->op_first; /* get past null */ if (kid->op_type == OP_SCOPE || kid->op_type == OP_LEAVE) { diff --git a/pp.c b/pp.c index 976d449..4bb8d3e 100644 --- a/pp.c +++ b/pp.c @@ -1093,13 +1093,13 @@ PP(pp_modulo) { dSP; dATARGET; tryAMAGICbin(modulo,opASSIGN); { - UV left; - UV right; + UV left = 0; + UV right = 0; bool left_neg; bool right_neg; bool use_double = 0; - NV dright; - NV dleft; + NV dright = 0.0; + NV dleft = 0.0; if (SvIOK_notUV(TOPs) && !SvNOK(TOPs) && !SvPOK(TOPs)) { IV i = SvIVX(POPs); @@ -1265,8 +1265,8 @@ PP(pp_subtract) /* Unless the left argument is integer in range we are going to have to use NV maths. Hence only attempt to coerce the right argument if we know the left is integer. */ - register UV auv; - bool auvok; + register UV auv = 0; + bool auvok = FALSE; bool a_valid = 0; if (!useleft) { @@ -2716,7 +2716,7 @@ PP(pp_substr) { dSP; dTARGET; SV *sv; - I32 len; + I32 len = 0; STRLEN curlen; STRLEN utf8_curlen; I32 pos; @@ -4117,7 +4117,7 @@ PP(pp_unpack) register char *patend = pat + llen; I32 datumtype; register I32 len; - register I32 bits; + register I32 bits = 0; register char *str; /* These must not be in registers: */ @@ -4137,8 +4137,8 @@ PP(pp_unpack) float afloat; double adouble; I32 checksum = 0; - register U32 culong; - NV cdouble; + register U32 culong = 0; + NV cdouble = 0.0; int commas = 0; int star; #ifdef PERL_NATINT_PACK diff --git a/pp_ctl.c b/pp_ctl.c index 0d2d2cd..736f84d 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -312,16 +312,16 @@ PP(pp_formline) register char *s; register char *send; register I32 arg; - register SV *sv; - char *item; - I32 itemsize; - I32 fieldsize; + register SV *sv = Nullsv; + char *item = Nullch; + I32 itemsize = 0; + I32 fieldsize = 0; I32 lines = 0; bool chopspace = (strchr(PL_chopset, ' ') != Nullch); - char *chophere; - char *linemark; + char *chophere = Nullch; + char *linemark = Nullch; NV value; - bool gotsome; + bool gotsome = FALSE; STRLEN len; STRLEN fudge = SvCUR(tmpForm) * (IN_BYTE ? 1 : 3) + 1; bool item_is_utf = FALSE; @@ -887,7 +887,7 @@ PP(pp_sort) register I32 max; HV *stash; GV *gv; - CV *cv; + CV *cv = 0; I32 gimme = GIMME; OP* nextop = PL_op->op_next; I32 overloading = 0; @@ -3016,7 +3016,7 @@ PP(pp_require) SV *sv; char *name; STRLEN len; - char *tryname; + char *tryname = Nullch; SV *namesv = Nullsv; SV** svp; I32 gimme = GIMME_V; @@ -3589,14 +3589,14 @@ S_doparseform(pTHX_ SV *sv) STRLEN len; register char *s = SvPV_force(sv, len); register char *send = s + len; - register char *base; + register char *base = Nullch; register I32 skipspaces = 0; - bool noblank; - bool repeat; + bool noblank = FALSE; + bool repeat = FALSE; bool postspace = FALSE; U16 *fops; register U16 *fpc; - U16 *linepc; + U16 *linepc = 0; register I32 arg; bool ischop; diff --git a/pp_hot.c b/pp_hot.c index c198b22..5d43a79 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -395,8 +395,8 @@ PP(pp_add) /* Unless the left argument is integer in range we are going to have to use NV maths. Hence only attempt to coerce the right argument if we know the left is integer. */ - register UV auv; - bool auvok; + register UV auv = 0; + bool auvok = FALSE; bool a_valid = 0; if (!useleft) { @@ -1628,7 +1628,7 @@ PP(pp_helem) U32 defer = PL_op->op_private & OPpLVAL_DEFER; SV *sv; U32 hash = (SvFAKE(keysv) && SvREADONLY(keysv)) ? SvUVX(keysv) : 0; - I32 preeminent; + I32 preeminent = 0; if (SvTYPE(hv) == SVt_PVHV) { if (PL_op->op_private & OPpLVAL_INTRO) @@ -2991,7 +2991,7 @@ S_method_common(pTHX_ SV* meth, U32* hashp) HV* stash; char* name; STRLEN namelen; - char* packname; + char* packname = 0; STRLEN packlen; name = SvPV(meth, namelen); diff --git a/regcomp.c b/regcomp.c index e927ba0..98cf21b 100644 --- a/regcomp.c +++ b/regcomp.c @@ -949,7 +949,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg flags &= ~SCF_DO_STCLASS; } else if (strchr((char*)PL_varies,OP(scan))) { - I32 mincount, maxcount, minnext, deltanext, fl; + I32 mincount, maxcount, minnext, deltanext, fl = 0; I32 f = flags, pos_before = 0; regnode *oscan = scan; struct regnode_charclass_class this_class; @@ -1260,7 +1260,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg } } else if (strchr((char*)PL_simple,OP(scan))) { - int value; + int value = 0; if (flags & SCF_DO_SUBSTR) { scan_commit(pRExC_state,data); @@ -1914,7 +1914,6 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) if ((!r->anchored_substr || r->anchored_offset) && stclass_flag && !(data.start_class->flags & ANYOF_EOS) && !cl_is_anything(data.start_class)) { - SV *sv; I32 n = add_data(pRExC_state, 1, "f"); New(1006, RExC_rx->data->data[n], 1, @@ -1925,10 +1924,11 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) r->regstclass = (regnode*)RExC_rx->data->data[n]; r->reganch &= ~ROPT_SKIP; /* Used in find_byclass(). */ PL_regdata = r->data; /* for regprop() */ - DEBUG_r((sv = sv_newmortal(), - regprop(sv, (regnode*)data.start_class), - PerlIO_printf(Perl_debug_log, "synthetic stclass `%s'.\n", - SvPVX(sv)))); + DEBUG_r({ SV *sv = sv_newmortal(); + regprop(sv, (regnode*)data.start_class); + PerlIO_printf(Perl_debug_log, + "synthetic stclass `%s'.\n", + SvPVX(sv));}); } /* A temporary algorithm prefers floated substr to fixed one to dig more info. */ @@ -1966,7 +1966,6 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) r->check_substr = r->anchored_substr = r->float_substr = Nullsv; if (!(data.start_class->flags & ANYOF_EOS) && !cl_is_anything(data.start_class)) { - SV *sv; I32 n = add_data(pRExC_state, 1, "f"); New(1006, RExC_rx->data->data[n], 1, @@ -1976,10 +1975,11 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) struct regnode_charclass_class); r->regstclass = (regnode*)RExC_rx->data->data[n]; r->reganch &= ~ROPT_SKIP; /* Used in find_byclass(). */ - DEBUG_r((sv = sv_newmortal(), - regprop(sv, (regnode*)data.start_class), - PerlIO_printf(Perl_debug_log, "synthetic stclass `%s'.\n", - SvPVX(sv)))); + DEBUG_r({ SV* sv = sv_newmortal(); + regprop(sv, (regnode*)data.start_class); + PerlIO_printf(Perl_debug_log, + "synthetic stclass `%s'.\n", + SvPVX(sv));}); } } @@ -3265,9 +3265,9 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state) register regnode *ret; STRLEN numlen; IV namedclass; - char *rangebegin; + char *rangebegin = 0; bool need_class = 0; - SV *listsv; + SV *listsv = Nullsv; register char *e; UV n; bool optimize_invert = TRUE; diff --git a/sv.c b/sv.c index 4fa39e9..2279ea0 100644 --- a/sv.c +++ b/sv.c @@ -3677,7 +3677,8 @@ Perl_sv_setpvn(pTHX_ register SV *sv, register const char *ptr, register STRLEN else { /* len is STRLEN which is unsigned, need to copy to signed */ IV iv = len; - assert(iv >= 0); + if (iv < 0) + Perl_croak(aTHX_ "panic: sv_setpvn called with negative strlen"); } (void)SvUPGRADE(sv, SVt_PV); @@ -5124,7 +5125,7 @@ Perl_sv_gets(pTHX_ register SV *sv, register PerlIO *fp, I32 append) register STDCHAR rslast; register STDCHAR *bp; register I32 cnt; - I32 i; + I32 i = 0; SV_CHECK_THINKFIRST(sv); (void)SvUPGRADE(sv, SVt_PV); @@ -6990,7 +6991,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV STRLEN origlen; I32 svix = 0; static char nullstr[] = "(null)"; - SV *argsv; + SV *argsv = Nullsv; /* no matter what, this is a string now */ (void)SvPV_force(sv, origlen); @@ -7058,7 +7059,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV STRLEN veclen = 0; char c; int i; - unsigned base; + unsigned base = 0; IV iv; UV uv; NV nv; diff --git a/toke.c b/toke.c index ec2711b..54fcd16 100644 --- a/toke.c +++ b/toke.c @@ -184,9 +184,8 @@ int yyactlevel = -1; STATIC void S_tokereport(pTHX_ char *thing, char* s, I32 rv) { - SV *report; DEBUG_T({ - report = newSVpv(thing, 0); + SV* report = newSVpv(thing, 0); Perl_sv_catpvf(aTHX_ report, ":line %d:%"IVdf":", CopLINE(PL_curcop), (IV)rv); @@ -538,7 +537,7 @@ S_skipspace(pTHX_ register char *s) for (;;) { STRLEN prevlen; SSize_t oldprevlen, oldoldprevlen; - SSize_t oldloplen, oldunilen; + SSize_t oldloplen = 0, oldunilen = 0; while (s < PL_bufend && isSPACE(*s)) { if (*s++ == '\n' && PL_in_eval && !PL_rsfp) incline(s); @@ -4994,7 +4993,7 @@ Perl_yylex(pTHX) really_sub: { char tmpbuf[sizeof PL_tokenbuf]; - SSize_t tboffset; + SSize_t tboffset = 0; expectation attrful; bool have_name, have_proto; int key = tmp; @@ -7231,8 +7230,8 @@ Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp) */ if (!floatit) { - IV iv; - UV uv; + IV iv = 0; + UV uv = 0; errno = 0; if (*PL_tokenbuf == '-') iv = Strtol(PL_tokenbuf, (char**)NULL, 10); diff --git a/utf8.c b/utf8.c index e629087..f692164 100644 --- a/utf8.c +++ b/utf8.c @@ -243,7 +243,7 @@ Most code should use utf8_to_uvchr() rather than call this directly. UV Perl_utf8n_to_uvuni(pTHX_ U8 *s, STRLEN curlen, STRLEN *retlen, U32 flags) { - UV uv = *s, ouv; + UV uv = *s, ouv = 0; STRLEN len = 1; bool dowarn = ckWARN_d(WARN_UTF8); STRLEN expectlen = 0;