diff --git a/src/common/byteswap.c b/src/common/byteswap.c index 35567fb10..6ef7b1fe6 100644 --- a/src/common/byteswap.c +++ b/src/common/byteswap.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: byteswap.c,v 3.1 2006/12/23 17:27:45 greg Exp $"; +static const char RCSid[] = "$Id: byteswap.c,v 3.2 2021/01/15 18:31:38 greg Exp $"; #endif /* * Byte swapping routines @@ -12,11 +12,11 @@ static const char RCSid[] = "$Id: byteswap.c,v 3.1 2006/12/23 17:27:45 greg Exp void swap16( /* swap n 16-bit words */ - register char *wp, - int n + char *wp, + size_t n ) { - register int t; + int t; while (n-- > 0) { t = wp[0]; wp[0] = wp[1]; wp[1] = t; @@ -27,11 +27,11 @@ swap16( /* swap n 16-bit words */ void swap32( /* swap n 32-bit words */ - register char *wp, - int n + char *wp, + size_t n ) { - register int t; + int t; while (n-- > 0) { t = wp[0]; wp[0] = wp[3]; wp[3] = t; @@ -43,11 +43,11 @@ swap32( /* swap n 32-bit words */ void swap64( /* swap n 64-bit words */ - register char *wp, - int n + char *wp, + size_t n ) { - register int t; + int t; while (n-- > 0) { t = wp[0]; wp[0] = wp[7]; wp[7] = t; diff --git a/src/common/portio.c b/src/common/portio.c index c631293fc..a00d1f337 100644 --- a/src/common/portio.c +++ b/src/common/portio.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: portio.c,v 2.22 2019/07/15 21:27:25 greg Exp $"; +static const char RCSid[] = "$Id: portio.c,v 2.23 2021/01/15 18:31:38 greg Exp $"; #endif /* * Portable i/o for binary files @@ -62,15 +62,15 @@ putflt( /* put out floating point number */ } -int +size_t putbinary( /* fwrite() replacement for small objects */ const void *p, - int elsiz, - int nel, + size_t elsiz, + size_t nel, FILE *fp) { const char *s = (const char *)p; - int nbytes = elsiz*nel; + size_t nbytes = elsiz*nel; if (nbytes > 128) return(fwrite(p, elsiz, nel, fp)); @@ -143,15 +143,15 @@ getflt( /* get a floating point number */ } -int +size_t getbinary( /* fread() replacement for small objects */ void *p, - int elsiz, - int nel, + size_t elsiz, + size_t nel, FILE *fp) { char *s = (char *)p; - int nbytes = elsiz*nel; + size_t nbytes = elsiz*nel; int c; if (nbytes > 128) diff --git a/src/common/rtio.h b/src/common/rtio.h index d1e922ef3..56c4da6fa 100644 --- a/src/common/rtio.h +++ b/src/common/rtio.h @@ -1,4 +1,4 @@ -/* RCSid $Id: rtio.h,v 3.23 2019/11/07 23:20:28 greg Exp $ */ +/* RCSid $Id: rtio.h,v 3.24 2021/01/15 18:31:38 greg Exp $ */ /* * Radiance i/o and string routines */ @@ -89,18 +89,18 @@ extern char *gethomedir(char *uname, char *path, int plen); /* defined in getpath.c */ extern char *getpath(char *fname, char *searchpath, int mode); /* defined in byteswap.c */ -extern void swap16(char *wp, int n); -extern void swap32(char *wp, int n); -extern void swap64(char *wp, int n); +extern void swap16(char *wp, size_t n); +extern void swap32(char *wp, size_t n); +extern void swap64(char *wp, size_t n); /* defined in portio.c */ extern void putstr(char *s, FILE *fp); extern void putint(long i, int siz, FILE *fp); extern void putflt(double f, FILE *fp); -extern int putbinary(const void *s, int elsiz, int nel, FILE *fp); +extern size_t putbinary(const void *s, size_t elsiz, size_t nel, FILE *fp); extern char *getstr(char *s, FILE *fp); extern long getint(int siz, FILE *fp); extern double getflt(FILE *fp); -extern int getbinary(void *s, int elsiz, int nel, FILE *fp); +extern size_t getbinary(void *s, size_t elsiz, size_t nel, FILE *fp); /* defined in rexpr.c */ extern int ecompile(char *sp, int iflg, int wflag); extern char *expsave(void); diff --git a/src/util/cmatrix.c b/src/util/cmatrix.c index b4013ad17..30f71ed00 100644 --- a/src/util/cmatrix.c +++ b/src/util/cmatrix.c @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: cmatrix.c,v 2.30 2021/01/15 17:22:23 greg Exp $"; +static const char RCSid[] = "$Id: cmatrix.c,v 2.31 2021/01/15 18:31:38 greg Exp $"; #endif /* * Color matrix routines. @@ -309,14 +309,14 @@ cm_load(const char *inspec, int nrows, int ncols, int dtype) } } else { /* read binary file */ if (sizeof(COLOR) == cm_elem_size[dtype]) { - int nread = 0; + size_t nread = 0; do { /* read all we can */ nread += getbinary(cm->cmem + 3*nread, sizeof(COLOR), - cm->nrows*cm->ncols - nread, + (size_t)cm->nrows*cm->ncols - nread, fp); if (nrows <= 0) { /* unknown length */ - if (nread == cm->nrows*cm->ncols) + if (nread == (size_t)cm->nrows*cm->ncols) /* need more space? */ cm = cm_resize(cm, cm->nrows+ROWINC); else if (nread && !(nread % cm->ncols)) @@ -324,22 +324,22 @@ cm_load(const char *inspec, int nrows, int ncols, int dtype) cm = cm_resize(cm, nread/cm->ncols); else /* ended mid-row */ goto EOFerror; - } else if (nread < cm->nrows*cm->ncols) + } else if (nread < (size_t)cm->nrows*cm->ncols) goto EOFerror; - } while (nread < cm->nrows*cm->ncols); + } while (nread < (size_t)cm->nrows*cm->ncols); if (swap) { if (sizeof(COLORV) == 4) swap32((char *)cm->cmem, - 3*cm->nrows*cm->ncols); + 3*(size_t)cm->nrows*cm->ncols); else /* sizeof(COLORV) == 8 */ swap64((char *)cm->cmem, - 3*cm->nrows*cm->ncols); + 3*(size_t)cm->nrows*cm->ncols); } } else if (dtype == DTdouble) { double dc[3]; /* load from double */ COLORV *cvp = cm->cmem; - int n = nrows*ncols; + size_t n = (size_t)nrows*ncols; if (n <= 0) goto not_handled; @@ -353,7 +353,7 @@ cm_load(const char *inspec, int nrows, int ncols, int dtype) } else /* dtype == DTfloat */ { float fc[3]; /* load from float */ COLORV *cvp = cm->cmem; - int n = nrows*ncols; + size_t n = (size_t)nrows*ncols; if (n <= 0) goto not_handled;