Keep gcc -Wall and Microsoft VC happy.

This commit is contained in:
Guido van Rossum 1997-04-11 20:37:35 +00:00
parent 90126035ca
commit 6bf62dad9e
6 changed files with 31 additions and 28 deletions

View file

@ -93,7 +93,7 @@ getishortarg(args, nargs, i, p_arg)
long x; long x;
if (!getilongarg(args, nargs, i, &x)) if (!getilongarg(args, nargs, i, &x))
return 0; return 0;
*p_arg = x; *p_arg = (short) x;
return 1; return 1;
} }
@ -129,15 +129,15 @@ extractfloat(v, p_arg)
/* Fall through to error return at end of function */ /* Fall through to error return at end of function */
} }
else if (is_floatobject(v)) { else if (is_floatobject(v)) {
*p_arg = GETFLOATVALUE((floatobject *)v); *p_arg = (float) GETFLOATVALUE((floatobject *)v);
return 1; return 1;
} }
else if (is_intobject(v)) { else if (is_intobject(v)) {
*p_arg = GETINTVALUE((intobject *)v); *p_arg = (float) GETINTVALUE((intobject *)v);
return 1; return 1;
} }
else if (is_longobject(v)) { else if (is_longobject(v)) {
*p_arg = dgetlongvalue(v); *p_arg = (float) dgetlongvalue(v);
return 1; return 1;
} }
return err_badarg(); return err_badarg();
@ -221,7 +221,7 @@ getishortarraysize(args, nargs, i, p_arg)
long x; long x;
if (!getilongarraysize(args, nargs, i, &x)) if (!getilongarraysize(args, nargs, i, &x))
return 0; return 0;
*p_arg = x; *p_arg = (short) x;
return 1; return 1;
} }
@ -287,7 +287,7 @@ getishortarray(args, nargs, i, n, p_arg)
if (!is_intobject(w)) { if (!is_intobject(w)) {
return err_badarg(); return err_badarg();
} }
p_arg[i] = getintvalue(w); p_arg[i] = (short) getintvalue(w);
} }
return 1; return 1;
} }
@ -300,7 +300,7 @@ getishortarray(args, nargs, i, n, p_arg)
if (!is_intobject(w)) { if (!is_intobject(w)) {
return err_badarg(); return err_badarg();
} }
p_arg[i] = getintvalue(w); p_arg[i] = (short) getintvalue(w);
} }
return 1; return 1;
} }

View file

@ -42,6 +42,8 @@ PERFORMANCE OF THIS SOFTWARE.
#include "mymath.h" #include "mymath.h"
#include <ctype.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #endif
@ -233,7 +235,7 @@ builtin_chr(self, args)
err_setstr(ValueError, "chr() arg not in range(256)"); err_setstr(ValueError, "chr() arg not in range(256)");
return NULL; return NULL;
} }
s[0] = x; s[0] = (char)x;
return newsizedstringobject(s, 1); return newsizedstringobject(s, 1);
} }
@ -301,7 +303,7 @@ builtin_complex(self, args)
object *args; object *args;
{ {
object *r, *i, *tmp; object *r, *i, *tmp;
number_methods *nbr, *nbi; number_methods *nbr, *nbi = NULL;
Py_complex cr, ci; Py_complex cr, ci;
int own_r = 0; int own_r = 0;
@ -484,7 +486,7 @@ builtin_eval(self, args)
return NULL; return NULL;
} }
str = getstringvalue(cmd); str = getstringvalue(cmd);
if (strlen(str) != getstringsize(cmd)) { if ((int)strlen(str) != getstringsize(cmd)) {
err_setstr(ValueError, err_setstr(ValueError,
"embedded '\\0' in string arg"); "embedded '\\0' in string arg");
return NULL; return NULL;

View file

@ -93,7 +93,7 @@ getishortarg(args, nargs, i, p_arg)
long x; long x;
if (!getilongarg(args, nargs, i, &x)) if (!getilongarg(args, nargs, i, &x))
return 0; return 0;
*p_arg = x; *p_arg = (short) x;
return 1; return 1;
} }
@ -129,15 +129,15 @@ extractfloat(v, p_arg)
/* Fall through to error return at end of function */ /* Fall through to error return at end of function */
} }
else if (is_floatobject(v)) { else if (is_floatobject(v)) {
*p_arg = GETFLOATVALUE((floatobject *)v); *p_arg = (float) GETFLOATVALUE((floatobject *)v);
return 1; return 1;
} }
else if (is_intobject(v)) { else if (is_intobject(v)) {
*p_arg = GETINTVALUE((intobject *)v); *p_arg = (float) GETINTVALUE((intobject *)v);
return 1; return 1;
} }
else if (is_longobject(v)) { else if (is_longobject(v)) {
*p_arg = dgetlongvalue(v); *p_arg = (float) dgetlongvalue(v);
return 1; return 1;
} }
return err_badarg(); return err_badarg();
@ -221,7 +221,7 @@ getishortarraysize(args, nargs, i, p_arg)
long x; long x;
if (!getilongarraysize(args, nargs, i, &x)) if (!getilongarraysize(args, nargs, i, &x))
return 0; return 0;
*p_arg = x; *p_arg = (short) x;
return 1; return 1;
} }
@ -287,7 +287,7 @@ getishortarray(args, nargs, i, n, p_arg)
if (!is_intobject(w)) { if (!is_intobject(w)) {
return err_badarg(); return err_badarg();
} }
p_arg[i] = getintvalue(w); p_arg[i] = (short) getintvalue(w);
} }
return 1; return 1;
} }
@ -300,7 +300,7 @@ getishortarray(args, nargs, i, n, p_arg)
if (!is_intobject(w)) { if (!is_intobject(w)) {
return err_badarg(); return err_badarg();
} }
p_arg[i] = getintvalue(w); p_arg[i] = (short) getintvalue(w);
} }
return 1; return 1;
} }

View file

@ -453,7 +453,7 @@ convertsimple1(arg, p_format, p_va)
if (ival == -1 && err_occurred()) if (ival == -1 && err_occurred())
return "integer<b>"; return "integer<b>";
else else
*p = ival; *p = (char) ival;
break; break;
} }
@ -464,7 +464,7 @@ convertsimple1(arg, p_format, p_va)
if (ival == -1 && err_occurred()) if (ival == -1 && err_occurred())
return "integer<h>"; return "integer<h>";
else else
*p = ival; *p = (short) ival;
break; break;
} }
@ -497,7 +497,7 @@ convertsimple1(arg, p_format, p_va)
if (err_occurred()) if (err_occurred())
return "float<f>"; return "float<f>";
else else
*p = dval; *p = (float) dval;
break; break;
} }
@ -548,7 +548,7 @@ convertsimple1(arg, p_format, p_va)
*q = getstringsize(arg); *q = getstringsize(arg);
format++; format++;
} }
else if (strlen(*p) != getstringsize(arg)) else if ((int)strlen(*p) != getstringsize(arg))
return "string without null bytes"; return "string without null bytes";
break; break;
} }
@ -571,7 +571,7 @@ convertsimple1(arg, p_format, p_va)
format++; format++;
} }
else if (*p != NULL && else if (*p != NULL &&
strlen(*p) != getstringsize(arg)) (int)strlen(*p) != getstringsize(arg))
return "None or string without null bytes"; return "None or string without null bytes";
break; break;
} }

View file

@ -436,6 +436,7 @@ find_module(name, path, buf, buflen, p_fp)
FILE *fp = NULL; FILE *fp = NULL;
#ifdef MS_COREDLL #ifdef MS_COREDLL
extern FILE *PyWin_FindRegisteredModule();
if ((fp=PyWin_FindRegisteredModule(name, &fdp, buf, buflen))!=NULL) { if ((fp=PyWin_FindRegisteredModule(name, &fdp, buf, buflen))!=NULL) {
*p_fp = fp; *p_fp = fp;
return fdp; return fdp;
@ -460,7 +461,7 @@ find_module(name, path, buf, buflen, p_fp)
if (len + 2 + namelen + import_maxsuffixsize >= buflen) if (len + 2 + namelen + import_maxsuffixsize >= buflen)
continue; /* Too long */ continue; /* Too long */
strcpy(buf, getstringvalue(v)); strcpy(buf, getstringvalue(v));
if (strlen(buf) != len) if ((int)strlen(buf) != len)
continue; /* v contains '\0' */ continue; /* v contains '\0' */
#ifdef macintosh #ifdef macintosh
if ( PyMac_FindResourceModule(name, buf) ) { if ( PyMac_FindResourceModule(name, buf) ) {
@ -740,10 +741,10 @@ imp_get_magic(self, args)
if (!newgetargs(args, "")) if (!newgetargs(args, ""))
return NULL; return NULL;
buf[0] = (MAGIC >> 0) & 0xff; buf[0] = (char) ((MAGIC >> 0) & 0xff);
buf[1] = (MAGIC >> 8) & 0xff; buf[1] = (char) ((MAGIC >> 8) & 0xff);
buf[2] = (MAGIC >> 16) & 0xff; buf[2] = (char) ((MAGIC >> 16) & 0xff);
buf[3] = (MAGIC >> 24) & 0xff; buf[3] = (char) ((MAGIC >> 24) & 0xff);
return newsizedstringobject(buf, 4); return newsizedstringobject(buf, 4);
} }

View file

@ -196,7 +196,7 @@ tb_displayline(f, filename, lineno, name)
if (len + 1 + taillen >= MAXPATHLEN) if (len + 1 + taillen >= MAXPATHLEN)
continue; /* Too long */ continue; /* Too long */
strcpy(namebuf, getstringvalue(v)); strcpy(namebuf, getstringvalue(v));
if (strlen(namebuf) != len) if ((int)strlen(namebuf) != len)
continue; /* v contains '\0' */ continue; /* v contains '\0' */
if (len > 0 && namebuf[len-1] != SEP) if (len > 0 && namebuf[len-1] != SEP)
namebuf[len++] = SEP; namebuf[len++] = SEP;