mirror of
https://github.com/python/cpython.git
synced 2025-08-31 22:18:28 +00:00
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:
parent
46cc7c0f7b
commit
6c116dd56b
2 changed files with 4 additions and 4 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue