Building perl on Win32 with VC++ 6 produces a number of compiler
warnings, which I'd like to clean up if possible.
They are mainly warnings about conversions from one type to another with
possible loss of data, or signed/unsigned mismatches, e.g.
..\hv.c(1536) : warning C4244: '-=' : conversion from 'double ' to 'long
', possible loss of data
..\mg.c(148) : warning C4244: 'initializing' : conversion from 'unsigned
long ' to 'const char ', possible loss of data
..\op.c(2132) : warning C4018: '!=' : signed/unsigned mismatch
..\op.c(2150) : warning C4018: '!=' : signed/unsigned mismatch
..\op.c(2174) : warning C4018: '!=' : signed/unsigned mismatch
..\op.c(2177) : warning C4018: '!=' : signed/unsigned mismatch
..\op.c(2198) : warning C4018: '==' : signed/unsigned mismatch
[etc]
The attached patch cleans up the warnings in the top-level *.c files by
blindly adding the obvious explicit casts.
Is this any good or is it just going to break things for others?
- Steve
------------------------------------------------
Radan Computational Ltd.
The information contained in this message and any files transmitted with it are
confidential and intended for the addressee(s) only. If you have received this
message in error or there are any problems, please notify the sender
immediately. The unauthorized use, disclosure, copying or alteration of this
message is strictly forbidden. Note that any views or opinions presented in
this email are solely those of the author and do not necessarily represent
those of Radan Computational Ltd. The recipient(s) of this message should
check it and any attached files for viruses: Radan Computational will accept no
liability for any damage caused by any virus transmitted by this email.
==== //depot/perl/hv.c#195 - C:\p5p\bleadperl\hv.c ====
@@ -1533,7 +1533,7 @@
if (--items == 0) {
/* Finished. */
- HvTOTALKEYS(hv) -= HvPLACEHOLDERS(hv);
+ HvTOTALKEYS(hv) -= (IV)HvPLACEHOLDERS(hv);
if (HvKEYS(hv) == 0)
HvHASKFLAGS_off(hv);
HvPLACEHOLDERS(hv) = 0;
==== //depot/perl/mg.c#316 - C:\p5p\bleadperl\mg.c ====
@@ -145,7 +145,7 @@
Perl_mg_get(pTHX_ SV *sv)
{
const I32 mgs_ix = SSNEW(sizeof(MGS));
- const bool was_temp = SvTEMP(sv);
+ const bool was_temp = (const bool)SvTEMP(sv);
int new = 0;
MAGIC *newmg, *head, *cur, *mg;
/* guard against sv having being freed midway by holding a private
==== //depot/perl/op.c#657 - C:\p5p\bleadperl\op.c ====
@@ -2129,7 +2129,7 @@
o->op_flags |= flags;
o = CHECKOP(type, o);
- if (o->op_type != type)
+ if (o->op_type != (unsigned)type)
return o;
return fold_constants(o);
@@ -2146,7 +2146,7 @@
if (!last)
return first;
- if (first->op_type != type
+ if (first->op_type != (unsigned)type
|| (type == OP_LIST && (first->op_flags & OPf_PARENS)))
{
return newLISTOP(type, 0, first, last);
@@ -2171,10 +2171,10 @@
if (!last)
return (OP*)first;
- if (first->op_type != type)
+ if (first->op_type != (unsigned)type)
return prepend_elem(type, (OP*)first, (OP*)last);
- if (last->op_type != type)
+ if (last->op_type != (unsigned)type)
return append_elem(type, (OP*)first, (OP*)last);
first->op_last->op_sibling = last->op_first;
@@ -2195,7 +2195,7 @@
if (!last)
return first;
- if (last->op_type == type) {
+ if (last->op_type == (unsigned)type) {
if (type == OP_LIST) { /* already a PUSHMARK there */
first->op_sibling = ((LISTOP*)last)->op_first->op_sibling;
((LISTOP*)last)->op_first->op_sibling = first;
==== //depot/perl/pp_pack.c#79 - C:\p5p\bleadperl\pp_pack.c ====
@@ -585,7 +585,7 @@
val &= 0xff;
}
*s += retlen;
- return val;
+ return (U8)val;
}
#define SHIFT_BYTE(utf8, s, strend, datumtype) ((utf8) ? \
@@ -612,7 +612,7 @@
bad |= 2;
val &= 0xff;
}
- *(U8 *)buf++ = val;
+ *(U8 *)buf++ = (U8)val;
}
/* We have enough characters for the buffer. Did we have problems ? */
if (bad) {
@@ -2933,7 +2933,7 @@
GROWING(0, cat, start, cur, len+1);
end = start+SvLEN(cat)-1;
}
- *(U8 *) cur++ = auv;
+ *(U8 *) cur++ = (U8)auv;
}
}
break;
==== //depot/perl/pp_sort.c#27 - C:\p5p\bleadperl\pp_sort.c ====
@@ -1574,7 +1574,7 @@
if (SvMAGICAL(av)) {
MEXTEND(SP, max);
p2 = SP;
- for (i=0; i < (U32)max; i++) {
+ for (i=0; i < max; i++) {
SV **svp = av_fetch(av, i, FALSE);
*SP++ = (svp) ? *svp : Nullsv;
}
==== //depot/perl/pp_sys.c#385 - C:\p5p\bleadperl\pp_sys.c ====
@@ -1699,7 +1699,7 @@
read_target = sv_newmortal();
SvUPGRADE(read_target, SVt_PV);
- buffer = SvGROW(read_target, length + 1);
+ buffer = SvGROW(read_target, (STRLEN)(length + 1));
}
if (PL_op->op_type == OP_SYSREAD) {
==== //depot/perl/utf8.c#223 - C:\p5p\bleadperl\utf8.c ====
@@ -1863,7 +1863,7 @@
}
u = utf8_to_uvchr((U8*)s, 0);
if (u < 256) {
- unsigned char c = u & 0xFF;
+ unsigned char c = (unsigned char)u & 0xFF;
if (!ok && (flags & UNI_DISPLAY_BACKSLASH)) {
switch (c) {
case '\n':
==== //depot/perl/util.c#440 - C:\p5p\bleadperl\util.c ====
@@ -2816,7 +2816,7 @@
if (strEQ(scriptname, "-"))
dosearch = 0;
if (dosearch) { /* Look in '.' first. */
- char *cur = scriptname;
+ char *cur = (char *)scriptname;
#ifdef SEARCH_EXTS
if ((curext = strrchr(scriptname,'.'))) /* possible current ext */
while (ext[i])