summaryrefslogtreecommitdiffstats
path: root/src/H5FDstdio.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2001-01-09 21:22:30 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2001-01-09 21:22:30 (GMT)
commit35bc545296209684a5c46db0cde11beb9403a4dc (patch)
tree98b5a037ed928085b98abc1fee71fc62f81073c1 /src/H5FDstdio.c
parent1290c4808d3e9890c765b1445f66b823c9026734 (diff)
downloadhdf5-35bc545296209684a5c46db0cde11beb9403a4dc.zip
hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.tar.gz
hdf5-35bc545296209684a5c46db0cde11beb9403a4dc.tar.bz2
[svn-r3252] Purpose:
Code cleanup. Description: Fixed _lots_ (I mean _tons_) of warnings spit out by the gcc with the extra warnings. Including a few show-stoppers for compression on IRIX machines. Solution: Changed lots of variables' types to more sensible and consistent types, more range-checking, more variable typecasts, etc. Platforms tested: FreeBSD 4.2 (hawkwind), IRIX64-64 (modi4)
Diffstat (limited to 'src/H5FDstdio.c')
-rw-r--r--src/H5FDstdio.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index 0319561..571e1a4 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -608,7 +608,8 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi
if (0 == size)
return(0);
if ((haddr_t)addr >= file->eof) {
- memset(buf, 0, size);
+ assert(size==(hsize_t)((size_t)size)); /*check for overflow*/
+ memset(buf, 0, (size_t)size);
return(0);
}
@@ -649,13 +650,15 @@ H5FD_stdio_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsi
* will advance the file position by N. If N is negative or an error
* occurs then the file position is undefined.
*/
- n = fread(buf, 1, size, file->fp);
+ assert(size==(hsize_t)((size_t)size)); /*check for overflow*/
+ n = fread(buf, 1, (size_t)size, file->fp);
if (n <= 0 && ferror(file->fp)) {
file->op = H5FD_STDIO_OP_UNKNOWN;
file->pos = HADDR_UNDEF;
H5Epush_ret(func, H5E_IO, H5E_READERROR, "fread failed", -1);
} else if (n < size) {
- memset((unsigned char *)buf + n, 0, size - n);
+ assert((size-n)==(hsize_t)((size_t)(size-n))); /*check for overflow*/
+ memset((unsigned char *)buf + n, 0, (size_t)(size - n));
}
/*
@@ -740,7 +743,8 @@ H5FD_stdio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
* advanced by the number of bytes read. Otherwise nobody knows where it
* is.
*/
- if (size != fwrite(buf, 1, size, file->fp)) {
+ assert(size==(hsize_t)((size_t)size)); /*check for overflow*/
+ if (size != fwrite(buf, 1, (size_t)size, file->fp)) {
file->op = H5FD_STDIO_OP_UNKNOWN;
file->pos = HADDR_UNDEF;
H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "fwrite failed", -1);