summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/arraymodule.c4
-rw-r--r--Modules/rgbimgmodule.c20
-rw-r--r--Modules/rotormodule.c18
-rw-r--r--Modules/structmodule.c16
-rw-r--r--Python/errors.c2
5 files changed, 31 insertions, 29 deletions
diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c
index 5862f6c..e732f39 100644
--- a/Modules/arraymodule.c
+++ b/Modules/arraymodule.c
@@ -341,7 +341,7 @@ newarrayobject(size, descr)
}
nbytes = size * descr->itemsize;
/* Check for overflow */
- if (nbytes / descr->itemsize != size) {
+ if (nbytes / descr->itemsize != (size_t)size) {
return PyErr_NoMemory();
}
op = PyMem_NEW(arrayobject, 1);
@@ -933,7 +933,7 @@ array_tofile(self, args)
return NULL;
}
if (self->ob_size > 0) {
- if (fwrite(self->ob_item, self->ob_descr->itemsize,
+ if ((int)fwrite(self->ob_item, self->ob_descr->itemsize,
self->ob_size, fp) != self->ob_size) {
PyErr_SetFromErrno(PyExc_IOError);
clearerr(fp);
diff --git a/Modules/rgbimgmodule.c b/Modules/rgbimgmodule.c
index 81f9fcb..d2428d1 100644
--- a/Modules/rgbimgmodule.c
+++ b/Modules/rgbimgmodule.c
@@ -163,10 +163,10 @@ putlong(outf, val)
{
unsigned char buf[4];
- buf[0] = (val >> 24);
- buf[1] = (val >> 16);
- buf[2] = (val >> 8);
- buf[3] = (val >> 0);
+ buf[0] = (unsigned char) (val >> 24);
+ buf[1] = (unsigned char) (val >> 16);
+ buf[2] = (unsigned char) (val >> 8);
+ buf[3] = (unsigned char) (val >> 0);
return fwrite(buf, 4, 1, outf);
}
@@ -314,7 +314,7 @@ longimagedata(self, args)
tablen = ysize * zsize * sizeof(long);
starttab = (long *)malloc(tablen);
lengthtab = (long *)malloc(tablen);
- rlebuflen = 1.05 * xsize +10;
+ rlebuflen = (int) (1.05 * xsize +10);
rledat = (unsigned char *)malloc(rlebuflen);
if (!starttab || !lengthtab || !rledat) {
PyErr_NoMemory();
@@ -603,7 +603,7 @@ longstoimage(self, args)
starttab = (long *)malloc(tablen);
lengthtab = (long *)malloc(tablen);
- rlebuflen = 1.05 * xsize + 10;
+ rlebuflen = (int) (1.05 * xsize + 10);
rlebuf = (unsigned char *)malloc(rlebuflen);
lumbuf = (unsigned char *)malloc(xsize * sizeof(long));
if (!starttab || !lengthtab || !rlebuf || !lumbuf) {
@@ -714,7 +714,7 @@ compressrow(lbuf, rlebuf, z, cnt)
iptr -= 8;
count = (iptr - sptr) / 4;
while (count) {
- todo = count > 126 ? 126 : count;
+ todo = count > 126 ? 126 : (short)count;
count -= todo;
*optr++ = 0x80 | todo;
while (todo > 8) {
@@ -742,10 +742,10 @@ compressrow(lbuf, rlebuf, z, cnt)
iptr += 4;
count = (iptr - sptr) / 4;
while (count) {
- todo = count > 126 ? 126 : count;
+ todo = count > 126 ? 126 : (short)count;
count -= todo;
- *optr++ = todo;
- *optr++ = cc;
+ *optr++ = (unsigned char) todo;
+ *optr++ = (unsigned char) cc;
}
}
*optr++ = 0;
diff --git a/Modules/rotormodule.c b/Modules/rotormodule.c
index 6ead93c..65c1758 100644
--- a/Modules/rotormodule.c
+++ b/Modules/rotormodule.c
@@ -93,12 +93,12 @@ set_seed(r)
}
/* Return the next random number in the range [0.0 .. 1.0) */
-static float
+static double
r_random(r)
Rotorobj *r;
{
int x, y, z;
- float val, term;
+ double val, term;
x = r->seed[0];
y = r->seed[1];
@@ -116,12 +116,12 @@ r_random(r)
r->seed[1] = y;
r->seed[2] = z;
- term = (float)(
- (((float)x)/(float)30269.0) +
- (((float)y)/(float)30307.0) +
- (((float)z)/(float)30323.0)
+ term = (double)(
+ (((double)x)/(double)30269.0) +
+ (((double)y)/(double)30307.0) +
+ (((double)z)/(double)30323.0)
);
- val = term - (float)floor((double)term);
+ val = term - (double)floor((double)term);
if (val >= 1.0)
val = 0.0;
@@ -134,7 +134,7 @@ r_rand(r, s)
Rotorobj *r;
short s;
{
- return (short)((short)(r_random(r) * (float)s) % s);
+ return (short)((short)(r_random(r) * (double)s) % s);
}
static void
@@ -340,7 +340,7 @@ RTR_init(r)
RTR_e_rotors(r);
RTR_d_rotors(r);
for (i = 0; i < r->rotors; i++) {
- r->positions[i] = r_rand(r,r->size);
+ r->positions[i] = (unsigned char) r_rand(r,r->size);
r->advances[i] = (1+(2*(r_rand(r,r->size/2))));
RTR_permute_rotor(r,
&(r->e_rotor[(i*r->size)]),
diff --git a/Modules/structmodule.c b/Modules/structmodule.c
index f0fb491..dbba9b4 100644
--- a/Modules/structmodule.c
+++ b/Modules/structmodule.c
@@ -179,7 +179,7 @@ pack_float(x, p, incr)
p += incr;
/* Second byte */
- *p = ((e&1)<<7) | (fbits>>16);
+ *p = (char) (((e&1)<<7) | (fbits>>16));
p += incr;
/* Third byte */
@@ -255,7 +255,7 @@ pack_double(x, p, incr)
p += incr;
/* Second byte */
- *p = ((e&0xF)<<4) | (fhi>>24);
+ *p = (char) (((e&0xF)<<4) | (fhi>>24));
p += incr;
/* Third byte */
@@ -508,7 +508,7 @@ np_byte(p, v, f)
long x;
if (get_long(v, &x) < 0)
return -1;
- *p = x;
+ *p = (char)x;
return 0;
}
@@ -536,7 +536,7 @@ np_short(p, v, f)
long x;
if (get_long(v, &x) < 0)
return -1;
- * (short *)p = x;
+ * (short *)p = (short)x;
return 0;
}
@@ -700,7 +700,7 @@ bp_int(p, v, f)
return -1;
i = f->size;
do {
- p[--i] = x;
+ p[--i] = (char)x;
x >>= 8;
} while (i > 0);
return 0;
@@ -718,7 +718,7 @@ bp_uint(p, v, f)
return -1;
i = f->size;
do {
- p[--i] = x;
+ p[--i] = (char)x;
x >>= 8;
} while (i > 0);
return 0;
@@ -830,7 +830,7 @@ lp_int(p, v, f)
return -1;
i = f->size;
do {
- *p++ = x;
+ *p++ = (char)x;
x >>= 8;
} while (--i > 0);
return 0;
@@ -848,7 +848,7 @@ lp_uint(p, v, f)
return -1;
i = f->size;
do {
- *p++ = x;
+ *p++ = (char)x;
x >>= 8;
} while (--i > 0);
return 0;
diff --git a/Python/errors.c b/Python/errors.c
index 526b61b..c7e9528 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -84,8 +84,10 @@ extern char *PyMac_StrError PROTO((int));
#endif /* macintosh */
#ifndef __STDC__
+#ifndef MS_WINDOWS
extern char *strerror PROTO((int));
#endif
+#endif
/* Last exception stored by err_setval() */