summaryrefslogtreecommitdiffstats
path: root/Modules/cPickle.c
diff options
context:
space:
mode:
authorTrent Mick <trentm@activestate.com>2000-08-12 20:58:11 (GMT)
committerTrent Mick <trentm@activestate.com>2000-08-12 20:58:11 (GMT)
commit6c116dd56bf0b27637a0b1e9721f86e8879b1e67 (patch)
tree11d2c044a0878ca578123be161a2ea08499a6af9 /Modules/cPickle.c
parent46cc7c0f7b7583927b8a253cdba87535c6522184 (diff)
downloadcpython-6c116dd56bf0b27637a0b1e9721f86e8879b1e67.zip
cpython-6c116dd56bf0b27637a0b1e9721f86e8879b1e67.tar.gz
cpython-6c116dd56bf0b27637a0b1e9721f86e8879b1e67.tar.bz2
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.
Diffstat (limited to 'Modules/cPickle.c')
-rw-r--r--Modules/cPickle.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 5a136b9..b64b1f1 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -407,7 +407,7 @@ write_file(Picklerobject *self, char *s, int n) {
return 0;
}
- if ((int)fwrite(s, sizeof(char), n, self->fp) != n) {
+ if (fwrite(s, sizeof(char), n, self->fp) != (size_t)n) {
PyErr_SetFromErrno(PyExc_IOError);
return -1;
}
@@ -503,7 +503,7 @@ read_file(Unpicklerobject *self, char **s, int n) {
self->buf_size = n;
}
- if ((int)fread(self->buf, sizeof(char), n, self->fp) != n) {
+ if (fread(self->buf, sizeof(char), n, self->fp) != (size_t)n) {
if (feof(self->fp)) {
PyErr_SetNone(PyExc_EOFError);
return -1;