Use safer comparisons (only matters when sizeof(int) != sizeof(size_t)). fread

and fwrite return size_t, so it is safer to cast up to the largest type for the
comparison. I believe the cast is required at all to remove compiler warnings.
This commit is contained in:
Trent Mick 2000-08-12 20:58:11 +00:00
parent 46cc7c0f7b
commit 6c116dd56b
2 changed files with 4 additions and 4 deletions

View file

@ -1039,8 +1039,8 @@ array_tofile(arrayobject *self, PyObject *args)
return NULL;
}
if (self->ob_size > 0) {
if ((int)fwrite(self->ob_item, self->ob_descr->itemsize,
self->ob_size, fp) != self->ob_size) {
if (fwrite(self->ob_item, self->ob_descr->itemsize,
self->ob_size, fp) != (size_t)self->ob_size) {
PyErr_SetFromErrno(PyExc_IOError);
clearerr(fp);
return NULL;