[Python-checkins] CVS: python/dist/src/Modules arraymodule.c,2.52,2.53 cPickle.c,2.49,2.50

Trent Mick python-dev@python.org
Sat, 12 Aug 2000 13:58:15 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv16206

Modified Files:
	arraymodule.c cPickle.c 
Log Message:
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.



Index: arraymodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/arraymodule.c,v
retrieving revision 2.52
retrieving revision 2.53
diff -C2 -r2.52 -r2.53
*** arraymodule.c	2000/08/01 21:00:58	2.52
--- arraymodule.c	2000/08/12 20:58:11	2.53
***************
*** 1040,1045 ****
  	}
  	if (self->ob_size > 0) {
! 		if ((int)fwrite(self->ob_item, self->ob_descr->itemsize,
! 			   self->ob_size, fp) != self->ob_size) {
  			PyErr_SetFromErrno(PyExc_IOError);
  			clearerr(fp);
--- 1040,1045 ----
  	}
  	if (self->ob_size > 0) {
! 		if (fwrite(self->ob_item, self->ob_descr->itemsize,
! 			   self->ob_size, fp) != (size_t)self->ob_size) {
  			PyErr_SetFromErrno(PyExc_IOError);
  			clearerr(fp);

Index: cPickle.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cPickle.c,v
retrieving revision 2.49
retrieving revision 2.50
diff -C2 -r2.49 -r2.50
*** cPickle.c	2000/07/31 15:28:04	2.49
--- cPickle.c	2000/08/12 20:58:11	2.50
***************
*** 408,412 ****
      }
  
!     if ((int)fwrite(s, sizeof(char), n, self->fp) != n) {
          PyErr_SetFromErrno(PyExc_IOError);
          return -1;
--- 408,412 ----
      }
  
!     if (fwrite(s, sizeof(char), n, self->fp) != (size_t)n) {
          PyErr_SetFromErrno(PyExc_IOError);
          return -1;
***************
*** 504,508 ****
      }
              
!     if ((int)fread(self->buf, sizeof(char), n, self->fp) != n) {  
          if (feof(self->fp)) {
              PyErr_SetNone(PyExc_EOFError);
--- 504,508 ----
      }
              
!     if (fread(self->buf, sizeof(char), n, self->fp) != (size_t)n) {
          if (feof(self->fp)) {
              PyErr_SetNone(PyExc_EOFError);