Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7844e38

Browse files
committed
Keep Microsoft VC happy.
1 parent 6bf62da commit 7844e38

5 files changed

Lines changed: 31 additions & 29 deletions

File tree

Modules/arraymodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ newarrayobject(size, descr)
341341
}
342342
nbytes = size * descr->itemsize;
343343
/* Check for overflow */
344-
if (nbytes / descr->itemsize != size) {
344+
if (nbytes / descr->itemsize != (size_t)size) {
345345
return PyErr_NoMemory();
346346
}
347347
op = PyMem_NEW(arrayobject, 1);
@@ -933,7 +933,7 @@ array_tofile(self, args)
933933
return NULL;
934934
}
935935
if (self->ob_size > 0) {
936-
if (fwrite(self->ob_item, self->ob_descr->itemsize,
936+
if ((int)fwrite(self->ob_item, self->ob_descr->itemsize,
937937
self->ob_size, fp) != self->ob_size) {
938938
PyErr_SetFromErrno(PyExc_IOError);
939939
clearerr(fp);

Modules/rgbimgmodule.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ putlong(outf, val)
163163
{
164164
unsigned char buf[4];
165165

166-
buf[0] = (val >> 24);
167-
buf[1] = (val >> 16);
168-
buf[2] = (val >> 8);
169-
buf[3] = (val >> 0);
166+
buf[0] = (unsigned char) (val >> 24);
167+
buf[1] = (unsigned char) (val >> 16);
168+
buf[2] = (unsigned char) (val >> 8);
169+
buf[3] = (unsigned char) (val >> 0);
170170
return fwrite(buf, 4, 1, outf);
171171
}
172172

@@ -314,7 +314,7 @@ longimagedata(self, args)
314314
tablen = ysize * zsize * sizeof(long);
315315
starttab = (long *)malloc(tablen);
316316
lengthtab = (long *)malloc(tablen);
317-
rlebuflen = 1.05 * xsize +10;
317+
rlebuflen = (int) (1.05 * xsize +10);
318318
rledat = (unsigned char *)malloc(rlebuflen);
319319
if (!starttab || !lengthtab || !rledat) {
320320
PyErr_NoMemory();
@@ -603,7 +603,7 @@ longstoimage(self, args)
603603

604604
starttab = (long *)malloc(tablen);
605605
lengthtab = (long *)malloc(tablen);
606-
rlebuflen = 1.05 * xsize + 10;
606+
rlebuflen = (int) (1.05 * xsize + 10);
607607
rlebuf = (unsigned char *)malloc(rlebuflen);
608608
lumbuf = (unsigned char *)malloc(xsize * sizeof(long));
609609
if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
@@ -714,7 +714,7 @@ compressrow(lbuf, rlebuf, z, cnt)
714714
iptr -= 8;
715715
count = (iptr - sptr) / 4;
716716
while (count) {
717-
todo = count > 126 ? 126 : count;
717+
todo = count > 126 ? 126 : (short)count;
718718
count -= todo;
719719
*optr++ = 0x80 | todo;
720720
while (todo > 8) {
@@ -742,10 +742,10 @@ compressrow(lbuf, rlebuf, z, cnt)
742742
iptr += 4;
743743
count = (iptr - sptr) / 4;
744744
while (count) {
745-
todo = count > 126 ? 126 : count;
745+
todo = count > 126 ? 126 : (short)count;
746746
count -= todo;
747-
*optr++ = todo;
748-
*optr++ = cc;
747+
*optr++ = (unsigned char) todo;
748+
*optr++ = (unsigned char) cc;
749749
}
750750
}
751751
*optr++ = 0;

Modules/rotormodule.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ set_seed(r)
9393
}
9494

9595
/* Return the next random number in the range [0.0 .. 1.0) */
96-
static float
96+
static double
9797
r_random(r)
9898
Rotorobj *r;
9999
{
100100
int x, y, z;
101-
float val, term;
101+
double val, term;
102102

103103
x = r->seed[0];
104104
y = r->seed[1];
@@ -116,12 +116,12 @@ r_random(r)
116116
r->seed[1] = y;
117117
r->seed[2] = z;
118118

119-
term = (float)(
120-
(((float)x)/(float)30269.0) +
121-
(((float)y)/(float)30307.0) +
122-
(((float)z)/(float)30323.0)
119+
term = (double)(
120+
(((double)x)/(double)30269.0) +
121+
(((double)y)/(double)30307.0) +
122+
(((double)z)/(double)30323.0)
123123
);
124-
val = term - (float)floor((double)term);
124+
val = term - (double)floor((double)term);
125125

126126
if (val >= 1.0)
127127
val = 0.0;
@@ -134,7 +134,7 @@ r_rand(r, s)
134134
Rotorobj *r;
135135
short s;
136136
{
137-
return (short)((short)(r_random(r) * (float)s) % s);
137+
return (short)((short)(r_random(r) * (double)s) % s);
138138
}
139139

140140
static void
@@ -340,7 +340,7 @@ RTR_init(r)
340340
RTR_e_rotors(r);
341341
RTR_d_rotors(r);
342342
for (i = 0; i < r->rotors; i++) {
343-
r->positions[i] = r_rand(r,r->size);
343+
r->positions[i] = (unsigned char) r_rand(r,r->size);
344344
r->advances[i] = (1+(2*(r_rand(r,r->size/2))));
345345
RTR_permute_rotor(r,
346346
&(r->e_rotor[(i*r->size)]),

Modules/structmodule.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pack_float(x, p, incr)
179179
p += incr;
180180

181181
/* Second byte */
182-
*p = ((e&1)<<7) | (fbits>>16);
182+
*p = (char) (((e&1)<<7) | (fbits>>16));
183183
p += incr;
184184

185185
/* Third byte */
@@ -255,7 +255,7 @@ pack_double(x, p, incr)
255255
p += incr;
256256

257257
/* Second byte */
258-
*p = ((e&0xF)<<4) | (fhi>>24);
258+
*p = (char) (((e&0xF)<<4) | (fhi>>24));
259259
p += incr;
260260

261261
/* Third byte */
@@ -508,7 +508,7 @@ np_byte(p, v, f)
508508
long x;
509509
if (get_long(v, &x) < 0)
510510
return -1;
511-
*p = x;
511+
*p = (char)x;
512512
return 0;
513513
}
514514

@@ -536,7 +536,7 @@ np_short(p, v, f)
536536
long x;
537537
if (get_long(v, &x) < 0)
538538
return -1;
539-
* (short *)p = x;
539+
* (short *)p = (short)x;
540540
return 0;
541541
}
542542

@@ -700,7 +700,7 @@ bp_int(p, v, f)
700700
return -1;
701701
i = f->size;
702702
do {
703-
p[--i] = x;
703+
p[--i] = (char)x;
704704
x >>= 8;
705705
} while (i > 0);
706706
return 0;
@@ -718,7 +718,7 @@ bp_uint(p, v, f)
718718
return -1;
719719
i = f->size;
720720
do {
721-
p[--i] = x;
721+
p[--i] = (char)x;
722722
x >>= 8;
723723
} while (i > 0);
724724
return 0;
@@ -830,7 +830,7 @@ lp_int(p, v, f)
830830
return -1;
831831
i = f->size;
832832
do {
833-
*p++ = x;
833+
*p++ = (char)x;
834834
x >>= 8;
835835
} while (--i > 0);
836836
return 0;
@@ -848,7 +848,7 @@ lp_uint(p, v, f)
848848
return -1;
849849
i = f->size;
850850
do {
851-
*p++ = x;
851+
*p++ = (char)x;
852852
x >>= 8;
853853
} while (--i > 0);
854854
return 0;

Python/errors.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ extern char *PyMac_StrError PROTO((int));
8484
#endif /* macintosh */
8585

8686
#ifndef __STDC__
87+
#ifndef MS_WINDOWS
8788
extern char *strerror PROTO((int));
8889
#endif
90+
#endif
8991

9092
/* Last exception stored by err_setval() */
9193

0 commit comments

Comments
 (0)