summaryrefslogtreecommitdiffstats
path: root/src/H5FDcore.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/H5FDcore.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/H5FDcore.c')
-rw-r--r--src/H5FDcore.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index ac20921..ae70cbe 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -303,7 +303,7 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
/* Open backing store */
if (fa && fa->backing_store && name &&
- (fd=open(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0) {
+ (fd=HDopen(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0) {
HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
"unable to open backing store");
}
@@ -358,12 +358,15 @@ H5FD_core_flush(H5FD_t *_file)
haddr_t size = file->eof;
unsigned char *ptr = file->mem;
- if (0!=lseek(file->fd, 0, SEEK_SET))
+ if (0!=HDlseek(file->fd, (off_t)0, SEEK_SET))
HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL,
"error seeking in backing store");
while (size) {
- ssize_t n = write(file->fd, ptr, size);
+ ssize_t n;
+
+ assert(size==(hsize_t)((size_t)size)); /*check for overflow*/
+ n = HDwrite(file->fd, ptr, (size_t)size);
if (n<0 && EINTR==errno) continue;
if (n<0)
HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
@@ -408,10 +411,10 @@ H5FD_core_close(H5FD_t *_file)
HRETURN_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file");
/* Release resources */
- if (file->fd>=0) close(file->fd);
+ if (file->fd>=0) HDclose(file->fd);
if (file->name) H5MM_xfree(file->name);
if (file->mem) H5MM_xfree(file->mem);
- memset(file, 0, sizeof(H5FD_core_t));
+ HDmemset(file, 0, sizeof(H5FD_core_t));
H5MM_xfree(file);
FUNC_LEAVE(0);
}
@@ -595,15 +598,18 @@ H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
if (addr < file->eof) {
hsize_t nbytes = MIN(size, file->eof-addr);
- memcpy(buf, file->mem + addr, nbytes);
+ assert(nbytes==(hsize_t)((size_t)nbytes)); /*check for overflow*/
+ HDmemcpy(buf, file->mem + addr, (size_t)nbytes);
size -= nbytes;
addr += nbytes;
buf = (char *)buf + nbytes;
}
/* Read zeros for the part which is after the EOF markers */
- if (size > 0)
- memset(buf, 0, size);
+ if (size > 0) {
+ assert(size==(hsize_t)((size_t)size)); /*check for overflow*/
+ HDmemset(buf, 0, (size_t)size);
+ }
FUNC_LEAVE(SUCCEED);
}
@@ -665,7 +671,8 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
}
/* Write from BUF to memory */
- memcpy(file->mem+addr, buf, size);
+ assert(size==(hsize_t)((size_t)size)); /*check for overflow*/
+ HDmemcpy(file->mem+addr, buf, (size_t)size);
file->dirty = TRUE;
FUNC_LEAVE(SUCCEED);