From: Jarkko Hietaniemi Date: Sat, 30 Jun 2001 20:59:57 +0000 (+0000) Subject: Code cleanup based on turning off the -woffs in IRIX. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=497b47a829dd93323de2c7f4f6815ab9f23d6ada;p=p5sagit%2Fp5-mst-13.2.git Code cleanup based on turning off the -woffs in IRIX. Not all of the gripes cleaned up (hairy code in hv.c and regcomp.c; unused newsp, gimme, and optype from cop.h macros; unused 'key' arguments in ?DBM_File.xs) (and the -woffs left to the IRIX hints) p4raw-id: //depot/perl@11051 --- diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs index d6d0e9e..c1040cc 100644 --- a/ext/DB_File/DB_File.xs +++ b/ext/DB_File/DB_File.xs @@ -1998,16 +1998,18 @@ db_put(db, key, value, flags=0) int db_fd(db) DB_File db - int status = 0 ; CODE: CurrentDB = db ; #ifdef DB_VERSION_MAJOR RETVAL = -1 ; - status = (db->in_memory - ? -1 - : ((db->dbp)->fd)(db->dbp, &RETVAL) ) ; - if (status != 0) - RETVAL = -1 ; + { + int status = 0 ; + status = (db->in_memory + ? -1 + : ((db->dbp)->fd)(db->dbp, &RETVAL) ) ; + if (status != 0) + RETVAL = -1 ; + } #else RETVAL = (db->in_memory ? -1 diff --git a/ext/Data/Dumper/Dumper.xs b/ext/Data/Dumper/Dumper.xs index 99cd099..b9fb54b 100644 --- a/ext/Data/Dumper/Dumper.xs +++ b/ext/Data/Dumper/Dumper.xs @@ -190,13 +190,11 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv, AV *seenentry = Nullav; char *iname; STRLEN inamelen, idlen = 0; - U32 flags; U32 realtype; if (!val) return 0; - flags = SvFLAGS(val); realtype = SvTYPE(val); if (SvGMAGICAL(val)) @@ -221,7 +219,6 @@ DD_dump(pTHX_ SV *val, char *name, STRLEN namelen, SV *retval, HV *seenhv, } ival = SvRV(val); - flags = SvFLAGS(ival); realtype = SvTYPE(ival); (void) sprintf(id, "0x%lx", (unsigned long)ival); idlen = strlen(id); @@ -776,9 +773,9 @@ Data_Dumper_Dumpxs(href, ...) HV *seenhv = Nullhv; AV *postav, *todumpav, *namesav; I32 level = 0; - I32 indent, terse, useqq, i, imax, postlen; + I32 indent, terse, i, imax, postlen; SV **svp; - SV *val, *name, *pad, *xpad, *apad, *sep, *tmp, *varname; + SV *val, *name, *pad, *xpad, *apad, *sep, *varname; SV *freezer, *toaster, *bless; I32 purity, deepcopy, quotekeys, maxdepth = 0; char tmpbuf[1024]; @@ -811,11 +808,11 @@ Data_Dumper_Dumpxs(href, ...) todumpav = namesav = Nullav; seenhv = Nullhv; - val = pad = xpad = apad = sep = tmp = varname + val = pad = xpad = apad = sep = varname = freezer = toaster = bless = &PL_sv_undef; name = sv_newmortal(); indent = 2; - terse = useqq = purity = deepcopy = 0; + terse = purity = deepcopy = 0; quotekeys = 1; retval = newSVpvn("", 0); @@ -835,8 +832,10 @@ Data_Dumper_Dumpxs(href, ...) purity = SvIV(*svp); if ((svp = hv_fetch(hv, "terse", 5, FALSE))) terse = SvTRUE(*svp); +#if 0 /* useqq currently unused */ if ((svp = hv_fetch(hv, "useqq", 5, FALSE))) useqq = SvTRUE(*svp); +#endif if ((svp = hv_fetch(hv, "pad", 3, FALSE))) pad = *svp; if ((svp = hv_fetch(hv, "xpad", 4, FALSE))) diff --git a/ext/IPC/SysV/SysV.xs b/ext/IPC/SysV/SysV.xs index 39e932d..35a8fde 100644 --- a/ext/IPC/SysV/SysV.xs +++ b/ext/IPC/SysV/SysV.xs @@ -163,27 +163,26 @@ PPCODE: { #ifdef HAS_SEM SV **sv_ptr; - SV *sv; struct semid_ds ds; AV *list = (AV*)SvRV(obj); if(!sv_isa(obj, "IPC::Semaphore::stat")) croak("method %s not called a %s object", "pack","IPC::Semaphore::stat"); - if((sv_ptr = av_fetch(list,0,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,0,TRUE)) && *sv_ptr) ds.sem_perm.uid = SvIV(*sv_ptr); - if((sv_ptr = av_fetch(list,1,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,1,TRUE)) && *sv_ptr) ds.sem_perm.gid = SvIV(*sv_ptr); - if((sv_ptr = av_fetch(list,2,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,2,TRUE)) && *sv_ptr) ds.sem_perm.cuid = SvIV(*sv_ptr); - if((sv_ptr = av_fetch(list,3,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,3,TRUE)) && *sv_ptr) ds.sem_perm.cgid = SvIV(*sv_ptr); - if((sv_ptr = av_fetch(list,4,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,4,TRUE)) && *sv_ptr) ds.sem_perm.mode = SvIV(*sv_ptr); - if((sv_ptr = av_fetch(list,5,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,5,TRUE)) && *sv_ptr) ds.sem_ctime = SvIV(*sv_ptr); - if((sv_ptr = av_fetch(list,6,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,6,TRUE)) && *sv_ptr) ds.sem_otime = SvIV(*sv_ptr); - if((sv_ptr = av_fetch(list,7,TRUE)) && (sv = *sv_ptr)) + if((sv_ptr = av_fetch(list,7,TRUE)) && *sv_ptr) ds.sem_nsems = SvIV(*sv_ptr); ST(0) = sv_2mortal(newSVpvn((char *)&ds,sizeof(ds))); XSRETURN(1); diff --git a/ext/List/Util/Util.xs b/ext/List/Util/Util.xs index f75944d..0ea2e54 100644 --- a/ext/List/Util/Util.xs +++ b/ext/List/Util/Util.xs @@ -159,7 +159,6 @@ CODE: { SV *ret; int index; - I32 markix; GV *agv,*bgv,*gv; HV *stash; CV *cv; @@ -180,7 +179,6 @@ CODE: SAVETMPS; SAVESPTR(PL_op); ret = ST(1); - markix = sp - PL_stack_base; for(index = 2 ; index < items ; index++) { GvSV(agv) = ret; GvSV(bgv) = ST(index); @@ -199,7 +197,6 @@ PROTOTYPE: &@ CODE: { int index; - I32 markix; GV *gv; HV *stash; CV *cv; @@ -216,7 +213,6 @@ CODE: PL_curpad = AvARRAY((AV*)AvARRAY(CvPADLIST(cv))[1]); SAVETMPS; SAVESPTR(PL_op); - markix = sp - PL_stack_base; for(index = 1 ; index < items ; index++) { GvSV(PL_defgv) = ST(index); PL_op = reducecop; diff --git a/ext/PerlIO/Scalar/Scalar.xs b/ext/PerlIO/Scalar/Scalar.xs index 56d11c0..d8ee701 100644 --- a/ext/PerlIO/Scalar/Scalar.xs +++ b/ext/PerlIO/Scalar/Scalar.xs @@ -225,12 +225,11 @@ PerlIOScalar_set_ptrcnt(PerlIO *f, STDCHAR *ptr, SSize_t cnt) PerlIO * PerlIOScalar_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const char *mode, int fd, int imode, int perm, PerlIO *f, int narg, SV **args) { - PerlIOScalar *s; SV *arg = (narg > 0) ? *args : PerlIOArg; if (SvROK(arg) || SvPOK(arg)) { f = PerlIO_allocate(aTHX); - s = PerlIOSelf(PerlIO_push(aTHX_ f,self,mode,arg),PerlIOScalar); + (void)PerlIOSelf(PerlIO_push(aTHX_ f,self,mode,arg),PerlIOScalar); PerlIOBase(f)->flags |= PERLIO_F_OPEN; return f; } diff --git a/gv.c b/gv.c index 0af054c..bbe8d47 100644 --- a/gv.c +++ b/gv.c @@ -1357,11 +1357,18 @@ 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 fl=0, off=0, off1, lr=0, assign=AMGf_assign & flags, notfound=0; + int off=0, off1, lr=0, assign=AMGf_assign & flags, notfound=0; int postpr = 0, force_cpy = 0, assignshift = assign ? 1 : 0; +#ifdef DEBUGGING + int fl=0; HV* stash=NULL; +#endif if (!(AMGf_noleft & flags) && SvAMAGIC(left) - && (mg = mg_find((SV*)(stash=SvSTASH(SvRV(left))), + && (mg = mg_find((SV*)( +#ifdef DEGUGGING + stash= +#endif + SvSTASH(SvRV(left))), PERL_MAGIC_overload_table)) && (ocvp = cvp = (AMT_AMAGIC((AMT*)mg->mg_ptr) ? (oamtp = amtp = (AMT*)mg->mg_ptr)->table @@ -1369,7 +1376,11 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) && ((cv = cvp[off=method+assignshift]) || (assign && amtp->fallback > AMGfallNEVER && /* fallback to * usual method */ - (fl = 1, cv = cvp[off=method])))) { + ( +#ifdef DEBUGGING + fl = 1, +#endif + cv = cvp[off=method])))) { lr = -1; /* Call method for left argument */ } else { if (cvp && amtp->fallback > AMGfallNEVER && flags & AMGf_unary) { @@ -1475,7 +1486,11 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) } if (!cv) goto not_found; } else if (!(AMGf_noright & flags) && SvAMAGIC(right) - && (mg = mg_find((SV*)(stash=SvSTASH(SvRV(right))), + && (mg = mg_find((SV*)( +#ifdef DEBUGGING + stash= +#endif + SvSTASH(SvRV(right))), PERL_MAGIC_overload_table)) && (cvp = (AMT_AMAGIC((AMT*)mg->mg_ptr) ? (amtp = (AMT*)mg->mg_ptr)->table @@ -1562,21 +1577,23 @@ Perl_amagic_call(pTHX_ SV *left, SV *right, int method, int flags) force_cpy = force_cpy || assign; } } +#ifdef DEBUGGING if (!notfound) { - DEBUG_o( Perl_deb(aTHX_ - "Overloaded operator `%s'%s%s%s:\n\tmethod%s found%s in package %s%s\n", - AMG_id2name(off), - method+assignshift==off? "" : - " (initially `", - method+assignshift==off? "" : - AMG_id2name(method+assignshift), - method+assignshift==off? "" : "')", - flags & AMGf_unary? "" : - lr==1 ? " for right argument": " for left argument", - flags & AMGf_unary? " for argument" : "", - HvNAME(stash), - fl? ",\n\tassignment variant used": "") ); + DEBUG_o(Perl_deb(aTHX_ + "Overloaded operator `%s'%s%s%s:\n\tmethod%s found%s in package %s%s\n", + AMG_id2name(off), + method+assignshift==off? "" : + " (initially `", + method+assignshift==off? "" : + AMG_id2name(method+assignshift), + method+assignshift==off? "" : "')", + flags & AMGf_unary? "" : + lr==1 ? " for right argument": " for left argument", + flags & AMGf_unary? " for argument" : "", + HvNAME(stash), + fl? ",\n\tassignment variant used": "") ); } +#endif /* Since we use shallow copy during assignment, we need * to dublicate the contents, probably calling user-supplied * version of copy operator diff --git a/mg.c b/mg.c index 30c8cdd..b9a5501 100644 --- a/mg.c +++ b/mg.c @@ -169,7 +169,6 @@ U32 Perl_mg_length(pTHX_ SV *sv) { MAGIC* mg; - char *junk; STRLEN len; for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) { @@ -186,7 +185,7 @@ Perl_mg_length(pTHX_ SV *sv) } } - junk = SvPV(sv, len); + (void)SvPV(sv, len); return len; } @@ -1148,19 +1147,16 @@ int Perl_magic_getnkeys(pTHX_ SV *sv, MAGIC *mg) { HV *hv = (HV*)LvTARG(sv); - HE *entry; I32 i = 0; - + if (hv) { - (void) hv_iterinit(hv); - if (! SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) - i = HvKEYS(hv); - else { - /*SUPPRESS 560*/ - while ((entry = hv_iternext(hv))) { - i++; - } - } + (void) hv_iterinit(hv); + if (! SvTIED_mg((SV*)hv, PERL_MAGIC_tied)) + i = HvKEYS(hv); + else { + while (hv_iternext(hv)) + i++; + } } sv_setiv(sv, (IV)i); @@ -2223,7 +2219,6 @@ Perl_sighandler(int sig) CV *cv = Nullcv; OP *myop = PL_op; U32 flags = 0; - I32 o_save_i = PL_savestack_ix; XPV *tXpv = PL_Xpv; #if defined(WIN32) && defined(PERL_IMPLICIT_CONTEXT) @@ -2247,7 +2242,6 @@ Perl_sighandler(int sig) infinity, so we fix 4 (in fact 5): */ if (flags & 1) { PL_savestack_ix += 5; /* Protect save in progress. */ - o_save_i = PL_savestack_ix; SAVEDESTRUCTOR_X(unwind_handler_stack, (void*)&flags); } if (flags & 4) diff --git a/op.c b/op.c index 913f196..90e86e0 100644 --- a/op.c +++ b/op.c @@ -3931,7 +3931,6 @@ Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP *loop, I32 whileline, OP * OP *next = 0; OP *listop; OP *o; - OP *condop; U8 loopflags = 0; if (expr && (expr->op_type == OP_READLINE || expr->op_type == OP_GLOB @@ -3993,7 +3992,7 @@ Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP *loop, I32 whileline, OP * return Nullop; /* listop already freed by new_logop */ } if (listop) - ((LISTOP*)listop)->op_last->op_next = condop = + ((LISTOP*)listop)->op_last->op_next = (o == listop ? redo : LINKLIST(o)); } else diff --git a/perlio.c b/perlio.c index 3fac35d..e20563a 100644 --- a/perlio.c +++ b/perlio.c @@ -954,8 +954,7 @@ PerlIO_binmode(pTHX_ PerlIO *f, int iotype, int mode, const char *names) if (!names && (O_TEXT != O_BINARY && (mode & O_BINARY))) { PerlIO *top = f; - PerlIOl *l; - while ((l = *top)) + while (*top) { if (PerlIOBase(top)->tab == &PerlIO_crlf) { diff --git a/pp_sys.c b/pp_sys.c index 4f7a6c2..f7e2542 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -700,7 +700,6 @@ PP(pp_binmode) MAGIC *mg; SV *discp = Nullsv; STRLEN len = 0; - char *names = NULL; if (MAXARG < 1) RETPUSHUNDEF; @@ -730,10 +729,6 @@ PP(pp_binmode) RETPUSHUNDEF; } - if (discp) { - names = SvPV(discp,len); - } - if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp), (discp) ? SvPV_nolen(discp) : Nullch)) RETPUSHYES; diff --git a/regcomp.c b/regcomp.c index 9be1523..209743e 100644 --- a/regcomp.c +++ b/regcomp.c @@ -1099,7 +1099,10 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg && !deltanext && minnext == 1 ) { /* Try to optimize to CURLYN. */ regnode *nxt = NEXTOPER(oscan) + EXTRA_STEP_2ARGS; - regnode *nxt1 = nxt, *nxt2; + regnode *nxt1 = nxt; +#ifdef DEBUGGING + regnode *nxt2; +#endif /* Skip open. */ nxt = regnext(nxt); @@ -1107,7 +1110,9 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg && !(PL_regkind[(U8)OP(nxt)] == EXACT && STR_LEN(nxt) == 1)) goto nogo; +#ifdef DEBUGGING nxt2 = nxt; +#endif nxt = regnext(nxt); if (OP(nxt) != CLOSE) goto nogo; diff --git a/sv.c b/sv.c index ef04687..6ed638c 100644 --- a/sv.c +++ b/sv.c @@ -5102,7 +5102,6 @@ coercion. See also C, which gives raw access to the xpv_cur slot. STRLEN Perl_sv_len(pTHX_ register SV *sv) { - char *junk; STRLEN len; if (!sv) @@ -5111,7 +5110,7 @@ Perl_sv_len(pTHX_ register SV *sv) if (SvGMAGICAL(sv)) len = mg_length(sv); else - junk = SvPV(sv, len); + (void)SvPV(sv, len); return len; } @@ -7782,7 +7781,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV q++; if (*q == '*') { q++; - if (EXPECT_NUMBER(q, epix) && *q++ != '$') + if (EXPECT_NUMBER(q, epix) && *q++ != '$') /* epix currently unused */ goto unknown; if (args) i = va_arg(*args, int);