Skip to content

Commit 644a12b

Browse files
committed
Tweaks to keep the Microsoft compiler quier.
1 parent 8017767 commit 644a12b

8 files changed

Lines changed: 36 additions & 19 deletions

File tree

Modules/audioop.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ audioop_avg(self, args)
255255
signed char *cp;
256256
int len, size, val = 0;
257257
int i;
258-
float avg = 0.0;
258+
double avg = 0.0;
259259

260260
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
261261
return 0;
@@ -272,7 +272,7 @@ audioop_avg(self, args)
272272
if ( len == 0 )
273273
val = 0;
274274
else
275-
val = (int)(avg / (float)(len/size));
275+
val = (int)(avg / (double)(len/size));
276276
return PyInt_FromLong(val);
277277
}
278278

@@ -284,7 +284,7 @@ audioop_rms(self, args)
284284
signed char *cp;
285285
int len, size, val = 0;
286286
int i;
287-
float sum_squares = 0.0;
287+
double sum_squares = 0.0;
288288

289289
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
290290
return 0;
@@ -296,12 +296,12 @@ audioop_rms(self, args)
296296
if ( size == 1 ) val = (int)*CHARP(cp, i);
297297
else if ( size == 2 ) val = (int)*SHORTP(cp, i);
298298
else if ( size == 4 ) val = (int)*LONGP(cp, i);
299-
sum_squares += (float)val*(float)val;
299+
sum_squares += (double)val*(double)val;
300300
}
301301
if ( len == 0 )
302302
val = 0;
303303
else
304-
val = (int)sqrt(sum_squares / (float)(len/size));
304+
val = (int)sqrt(sum_squares / (double)(len/size));
305305
return PyInt_FromLong(val);
306306
}
307307

@@ -498,7 +498,7 @@ audioop_avgpp(self, args)
498498
int len, size, val = 0, prevval = 0, prevextremevalid = 0,
499499
prevextreme = 0;
500500
int i;
501-
float avg = 0.0;
501+
double avg = 0.0;
502502
int diff, prevdiff, extremediff, nextreme = 0;
503503

504504
if ( !PyArg_Parse(args, "(s#i)", &cp, &len, &size) )
@@ -544,7 +544,7 @@ audioop_avgpp(self, args)
544544
if ( nextreme == 0 )
545545
val = 0;
546546
else
547-
val = (int)(avg / (float)nextreme);
547+
val = (int)(avg / (double)nextreme);
548548
return PyInt_FromLong(val);
549549
}
550550

Modules/imageop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ PyObject *args;
572572
b = (int) (((value >> 16) & 0xff) / 255. * 3. + .5);
573573
#endif
574574
nvalue = (r<<5) | (b<<3) | g;
575-
*ncp++ = nvalue;
575+
*ncp++ = (unsigned char)nvalue;
576576
}
577577
return rv;
578578
}
@@ -653,7 +653,7 @@ PyObject *args;
653653
b = (value >> 16) & 0xff;
654654
nvalue = (int)(0.30*r + 0.59*g + 0.11*b);
655655
if ( nvalue > 255 ) nvalue = 255;
656-
*ncp++ = nvalue;
656+
*ncp++ = (unsigned char)nvalue;
657657
}
658658
return rv;
659659
}

Modules/signalmodule.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ PERFORMANCE OF THIS SOFTWARE.
3131

3232
/* Signal module -- many thanks to Lance Ellinghaus */
3333

34+
/* XXX Signals should be recorded per thread, now we have thread state. */
35+
3436
#include "Python.h"
3537
#include "intrcheck.h"
3638

39+
#ifdef MS_WIN32
40+
#include <process.h>
41+
#endif
42+
3743
#ifdef HAVE_UNISTD_H
3844
#include <unistd.h>
3945
#endif
@@ -119,7 +125,8 @@ signal_handler(sig_num)
119125
#endif
120126
is_tripped++;
121127
Handlers[sig_num].tripped = 1;
122-
Py_AddPendingCall((int (*) Py_PROTO((ANY *)))PyErr_CheckSignals, NULL);
128+
Py_AddPendingCall(
129+
(int (*) Py_PROTO((ANY *)))PyErr_CheckSignals, NULL);
123130
#ifdef WITH_THREAD
124131
}
125132
#endif

Modules/socketmodule.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ getsockaddrarg,PySocketSockObject *,s, PyObject *,args, struct sockaddr **,addr_
417417
if (setipaddr(host, addr) < 0)
418418
return 0;
419419
addr->sin_family = AF_INET;
420-
addr->sin_port = htons(port);
420+
addr->sin_port = htons((short)port);
421421
*addr_ret = (struct sockaddr *) addr;
422422
*len_ret = sizeof *addr;
423423
return 1;
@@ -516,7 +516,9 @@ static PyObject *
516516
BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
517517
{
518518
int block;
519+
#ifndef MS_WINDOWS
519520
int delay_flag;
521+
#endif
520522
if (!PyArg_GetInt(args, &block))
521523
return NULL;
522524
Py_BEGIN_ALLOW_THREADS

Python/compile.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ typeobject Codetype = {
182182
(hashfunc)code_hash, /*tp_hash*/
183183
};
184184

185+
#define NAME_CHARS \
186+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz"
187+
185188
codeobject *
186189
newcodeobject(argcount, nlocals, stacksize, flags,
187190
code, consts, names, varnames, filename, name,
@@ -237,7 +240,7 @@ newcodeobject(argcount, nlocals, stacksize, flags,
237240
if (!is_stringobject(v))
238241
continue;
239242
p = getstringvalue(v);
240-
if (strspn(p, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz")
243+
if ((int)strspn(p, NAME_CHARS)
241244
!= getstringsize(v))
242245
continue;
243246
PyString_InternInPlace(&PyTuple_GET_ITEM(consts, i));

Python/importdl.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,13 +503,16 @@ load_dynamic_module(name, pathname, fp)
503503
perror(funcname);
504504
}
505505
#endif /* hpux */
506+
#ifdef USE_SHLIB
506507
got_it:
508+
#endif
507509
if (p == NULL) {
508510
err_setstr(ImportError,
509511
"dynamic module does not define init function");
510512
return NULL;
511513
}
512514
(*p)();
515+
/* XXX Need check for err_occurred() here */
513516

514517
m = dictlookup(import_modules, name);
515518
if (m == NULL) {

Python/mystrtoul.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ int base;
141141
*ptr = str;
142142
if (ovf)
143143
{
144-
result = ~0;
144+
result = (unsigned long) ~0L;
145145
errno = ERANGE;
146146
}
147147
return result;

Python/structmember.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,23 +186,23 @@ setmember(addr, mlist, name, v)
186186
err_badarg();
187187
return -1;
188188
}
189-
*(char*)addr = getintvalue(v);
189+
*(char*)addr = (char) getintvalue(v);
190190
break;
191191
case T_SHORT:
192192
case T_USHORT:
193193
if (!is_intobject(v)) {
194194
err_badarg();
195195
return -1;
196196
}
197-
*(short*)addr = getintvalue(v);
197+
*(short*)addr = (short) getintvalue(v);
198198
break;
199199
case T_UINT:
200200
case T_INT:
201201
if (!is_intobject(v)) {
202202
err_badarg();
203203
return -1;
204204
}
205-
*(int*)addr = getintvalue(v);
205+
*(int*)addr = (int) getintvalue(v);
206206
break;
207207
case T_LONG:
208208
if (!is_intobject(v)) {
@@ -223,17 +223,19 @@ setmember(addr, mlist, name, v)
223223
break;
224224
case T_FLOAT:
225225
if (is_intobject(v))
226-
*(float*)addr = getintvalue(v);
226+
*(float*)addr = (float) getintvalue(v);
227227
else if (is_floatobject(v))
228-
*(float*)addr = getfloatvalue(v);
228+
*(float*)addr =
229+
(float) getfloatvalue(v);
229230
else {
230231
err_badarg();
231232
return -1;
232233
}
233234
break;
234235
case T_DOUBLE:
235236
if (is_intobject(v))
236-
*(double*)addr = getintvalue(v);
237+
*(double*)addr =
238+
(double) getintvalue(v);
237239
else if (is_floatobject(v))
238240
*(double*)addr = getfloatvalue(v);
239241
else {

0 commit comments

Comments
 (0)