From: Roderick Schertler Date: Thu, 13 Feb 1997 22:24:31 +0000 (-0500) Subject: Make format strings correspond exactly to parameters X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bf81aadd817bdea29720b072eef945df2da8463b;p=p5sagit%2Fp5-mst-13.2.git Make format strings correspond exactly to parameters Subject: Re: Hereis weirdness in 5.003_26 On Thu, 13 Feb 1997 15:13:18 -0500 (EST), Chip Salzenberg said: > According to Ilya Zakharevich: >> >> Why was not it catched by gcc prototypes? > > I don't use gcc. Does anyone who uses gcc compile with -Wproto ? -Wformat, you mean. I wasn't previously, but I will in the future. It turned up a few bugs (some universal, some which would trigger only where I32 != int or the like). I think -Wformat should be added to CFLAGS automatically when appropriate. p5p-msgid: --- diff --git a/doio.c b/doio.c index ec3181e..14ecf1a 100644 --- a/doio.c +++ b/doio.c @@ -1370,8 +1370,8 @@ SV **sp; { a = SvPV(astr, len); if (len != infosize) - croak("Bad arg length for %s, is %d, should be %d", - op_desc[optype], len, infosize); + croak("Bad arg length for %s, is %d, should be %ld", + op_desc[optype], len, (long)infosize); } } else diff --git a/ext/DB_File/DB_File.xs b/ext/DB_File/DB_File.xs index 092958e..796c5c6 100644 --- a/ext/DB_File/DB_File.xs +++ b/ext/DB_File/DB_File.xs @@ -161,7 +161,7 @@ const DBT * key2 ; SPAGAIN ; if (count != 1) - croak ("DB_File btree_compare: expected 1 return value from %s, got %d\n", count) ; + croak ("DB_File btree_compare: expected 1 return value from compare sub, got %d\n", count) ; retval = POPi ; @@ -208,7 +208,7 @@ const DBT * key2 ; SPAGAIN ; if (count != 1) - croak ("DB_File btree_prefix: expected 1 return value from %s, got %d\n", count) ; + croak ("DB_File btree_prefix: expected 1 return value from prefix sub, got %d\n", count) ; retval = POPi ; @@ -245,7 +245,7 @@ size_t size ; SPAGAIN ; if (count != 1) - croak ("DB_File hash_cb: expected 1 return value from %s, got %d\n", count) ; + croak ("DB_File hash_cb: expected 1 return value from hash sub, got %d\n", count) ; retval = POPi ; @@ -339,7 +339,7 @@ I32 value ; /* check for attempt to write before start of array */ if (length + value + 1 <= 0) - croak("Modification of non-creatable array value attempted, subscript %d", value) ; + croak("Modification of non-creatable array value attempted, subscript %ld", (long)value) ; value = length + value + 1 ; } diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index 1fd2c6b..28678ed 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -156,7 +156,7 @@ set_opset_bits(bitmap, bitspec, on, opname) if (myopcode >= maxo || myopcode < 0) croak("panic: opcode \"%s\" value %d is invalid", opname, myopcode); if (opcode_debug >= 2) - warn("set_opset_bits bit %2d (off=%d, bit=%d) %s on\n", + warn("set_opset_bits bit %2d (off=%d, bit=%d) %s %s\n", myopcode, offset, bit, opname, (on)?"on":"off"); if (on) bitmap[offset] |= 1 << bit; @@ -175,8 +175,8 @@ set_opset_bits(bitmap, bitspec, on, opname) while(len-- > 0) bitmap[len] &= ~specbits[len]; } else - croak("panic: invalid bitspec for \"%s\" (type %d)", - opname, SvTYPE(bitspec)); + croak("panic: invalid bitspec for \"%s\" (type %lu)", + opname, (unsigned long)SvTYPE(bitspec)); } @@ -235,7 +235,7 @@ BOOT: assert(maxo < OP_MASK_BUF_SIZE); opset_len = (maxo + 7) / 8; if (opcode_debug >= 1) - warn("opset_len %d\n", opset_len); + warn("opset_len %ld\n", (long)opset_len); op_names_init(); @@ -413,8 +413,8 @@ opdesc(...) } } else - croak("panic: invalid bitspec for \"%s\" (type %d)", - opname, SvTYPE(bitspec)); + croak("panic: invalid bitspec for \"%s\" (type %lu)", + opname, (unsigned long)SvTYPE(bitspec)); } diff --git a/gv.c b/gv.c index 010a391..7f6b2ce 100644 --- a/gv.c +++ b/gv.c @@ -341,7 +341,7 @@ I32 create; #ifdef VMS warn("Weird package name \"%s\" truncated", name); #else - warn("Weird package name \"%.*s...\" truncated", namelen, name); + warn("Weird package name \"%.*s...\" truncated", (int)namelen, name); #endif } Copy(name,tmpbuf,namelen,char); diff --git a/op.c b/op.c index 664802a..7e94b9a 100644 --- a/op.c +++ b/op.c @@ -3800,8 +3800,8 @@ OP *op; OP *newop = newAVREF(newGVOP(OP_GV, 0, gv_fetchpv(name, TRUE, SVt_PVAV) )); if (dowarn) - warn("Array @%s missing the @ in argument %d of %s()", - name, numargs, op_desc[type]); + warn("Array @%s missing the @ in argument %ld of %s()", + name, (long)numargs, op_desc[type]); op_free(kid); kid = newop; kid->op_sibling = sibl; @@ -3818,8 +3818,8 @@ OP *op; OP *newop = newHVREF(newGVOP(OP_GV, 0, gv_fetchpv(name, TRUE, SVt_PVHV) )); if (dowarn) - warn("Hash %%%s missing the %% in argument %d of %s()", - name, numargs, op_desc[type]); + warn("Hash %%%s missing the %% in argument %ld of %s()", + name, (long)numargs, op_desc[type]); op_free(kid); kid = newop; kid->op_sibling = sibl; diff --git a/perl.c b/perl.c index 1e3c6fd..c8276aa 100644 --- a/perl.c +++ b/perl.c @@ -349,13 +349,13 @@ register PerlInterpreter *sv_interp; FREETMPS; if (destruct_level >= 2) { if (scopestack_ix != 0) - warn("Unbalanced scopes: %d more ENTERs than LEAVEs\n", scopestack_ix); + warn("Unbalanced scopes: %ld more ENTERs than LEAVEs\n", (long)scopestack_ix); if (savestack_ix != 0) - warn("Unbalanced saves: %d more saves than restores\n", savestack_ix); + warn("Unbalanced saves: %ld more saves than restores\n", (long)savestack_ix); if (tmps_floor != -1) - warn("Unbalanced tmps: %d more allocs than frees\n", tmps_floor + 1); + warn("Unbalanced tmps: %ld more allocs than frees\n", (long)tmps_floor + 1); if (cxstack_ix != -1) - warn("Unbalanced context: %d more PUSHes than POPs\n", cxstack_ix + 1); + warn("Unbalanced context: %ld more PUSHes than POPs\n", (long)cxstack_ix + 1); } /* Now absolutely destruct everything, somehow or other, loops or no. */ @@ -399,7 +399,7 @@ register PerlInterpreter *sv_interp; SvREFCNT_dec(strtab); if (sv_count != 0) - warn("Scalars leaked: %d\n", sv_count); + warn("Scalars leaked: %ld\n", (long)sv_count); sv_free_arenas(); @@ -1785,12 +1785,12 @@ char *scriptname; (void)PerlIO_close(rsfp); if (rsfp = my_popen("/bin/mail root","w")) { /* heh, heh */ PerlIO_printf(rsfp, -"User %d tried to run dev %d ino %d in place of dev %d ino %d!\n\ -(Filename of set-id script was %s, uid %d gid %d.)\n\nSincerely,\nperl\n", - uid,tmpstatbuf.st_dev, tmpstatbuf.st_ino, - statbuf.st_dev, statbuf.st_ino, +"User %ld tried to run dev %ld ino %ld in place of dev %ld ino %ld!\n\ +(Filename of set-id script was %s, uid %ld gid %ld.)\n\nSincerely,\nperl\n", + (long)uid,(long)tmpstatbuf.st_dev, (long)tmpstatbuf.st_ino, + (long)statbuf.st_dev, (long)statbuf.st_ino, SvPVX(GvSV(curcop->cop_filegv)), - statbuf.st_uid, statbuf.st_gid); + (long)statbuf.st_uid, (long)statbuf.st_gid); (void)my_pclose(rsfp); } croak("Permission denied\n"); diff --git a/pp_ctl.c b/pp_ctl.c index 6baf002..be49bca 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2200,7 +2200,7 @@ PP(pp_entereval) /* switch to eval mode */ SAVESPTR(compiling.cop_filegv); - sprintf(tmpbuf, "_<(eval %d)", ++evalseq); + sprintf(tmpbuf, "_<(eval %lu)", (unsigned long)++evalseq); compiling.cop_filegv = gv_fetchfile(tmpbuf+2); compiling.cop_line = 1; /* XXX For Cs within BEGIN {} blocks, this ends up diff --git a/pp_sys.c b/pp_sys.c index 098b64f..a1229e5 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -523,8 +523,8 @@ PP(pp_untie) mg = mg_find(sv, 'q') ; if (mg && SvREFCNT(SvRV(mg->mg_obj)) > 1) - warn("untie attempted while %d inner references still exist", - SvREFCNT(SvRV(mg->mg_obj)) - 1 ) ; + warn("untie attempted while %lu inner references still exist", + (unsigned long)SvREFCNT(SvRV(mg->mg_obj)) - 1 ) ; } } diff --git a/regcomp.c b/regcomp.c index 9e39afe..a356867 100644 --- a/regcomp.c +++ b/regcomp.c @@ -456,7 +456,7 @@ I32 *flagp; break; case '$': case '@': - croak("Sequence (?%c...) not implemented", paren); + croak("Sequence (?%c...) not implemented", (int)paren); break; case '#': while (*regparse && *regparse != ')') diff --git a/toke.c b/toke.c index c57b888..dc285ca 100644 --- a/toke.c +++ b/toke.c @@ -1101,7 +1101,7 @@ filter_add(funcp, datasv) die("Can't upgrade filter_add data to SVt_PVIO"); IoDIRP(datasv) = (DIR*)funcp; /* stash funcp into spare field */ if (filter_debug) - warn("filter_add func %lx (%s)", funcp, SvPV(datasv,na)); + warn("filter_add func %p (%s)", funcp, SvPV(datasv,na)); av_unshift(rsfp_filters, 1); av_store(rsfp_filters, 0, datasv) ; return(datasv); @@ -1114,7 +1114,7 @@ filter_del(funcp) filter_t funcp; { if (filter_debug) - warn("filter_del func %lx", funcp); + warn("filter_del func %p", funcp); if (!rsfp_filters || AvFILL(rsfp_filters)<0) return; /* if filter is on top of stack (usual case) just pop it off */ @@ -1180,7 +1180,7 @@ filter_read(idx, buf_sv, maxlen) /* Get function pointer hidden within datasv */ funcp = (filter_t)IoDIRP(datasv); if (filter_debug) - warn("filter_read %d: via function %lx (%s)\n", + warn("filter_read %d: via function %p (%s)\n", idx, funcp, SvPV(datasv,na)); /* Call function. The function is expected to */ /* call "FILTER_READ(idx+1, buf_sv)" first. */ @@ -1733,7 +1733,7 @@ yylex() if (strnEQ(s,"=>",2)) { if (dowarn) warn("Ambiguous use of -%c => resolved to \"-%c\" =>", - tmp, tmp); + (int)tmp, (int)tmp); s = force_word(bufptr,WORD,FALSE,FALSE,FALSE); OPERATOR('-'); /* unary minus */ } @@ -1768,7 +1768,7 @@ yylex() case 'A': gv_fetchpv("\024",TRUE, SVt_PV); FTST(OP_FTATIME); case 'C': gv_fetchpv("\024",TRUE, SVt_PV); FTST(OP_FTCTIME); default: - croak("Unrecognized file test: -%c", tmp); + croak("Unrecognized file test: -%c", (int)tmp); break; } } @@ -2062,7 +2062,7 @@ yylex() if (tmp == '~') PMop(OP_MATCH); if (dowarn && tmp && isSPACE(*s) && strchr("+-*/%.^&|<",tmp)) - warn("Reversed %c= operator",tmp); + warn("Reversed %c= operator",(int)tmp); s--; if (expect == XSTATE && isALPHA(tmp) && (s == linestart+1 || s[-2] == '\n') ) @@ -5170,7 +5170,7 @@ char *s; if (multi_start < multi_end && (U32)(curcop->cop_line - multi_end) <= 1) { sprintf(buf+strlen(buf), " (Might be a runaway multi-line %c%c string starting on line %ld)\n", - multi_open,multi_close,(long)multi_start); + (int)multi_open,(int)multi_close,(long)multi_start); multi_end = 0; } if (in_eval & 2)