summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1999-10-23 00:36:04 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1999-10-23 00:36:04 (GMT)
commit1953487e125b5f309df1b4bd596dede2544a278f (patch)
tree1d575e0c6b35137ea10d10298208a0b9ff173667
parent69fc209302fcf4ddd14d993b1e1aab78830c473c (diff)
downloadhdf5-1953487e125b5f309df1b4bd596dede2544a278f.zip
hdf5-1953487e125b5f309df1b4bd596dede2544a278f.tar.gz
hdf5-1953487e125b5f309df1b4bd596dede2544a278f.tar.bz2
[svn-r1788] Converted all the VFL drivers except for the stdio and multi drivers back into
the "internal" HDF5 coding standard.
-rw-r--r--src/H5Epublic.h5
-rw-r--r--src/H5FDcore.c217
-rw-r--r--src/H5FDfamily.c418
-rw-r--r--src/H5FDgass.c221
-rw-r--r--src/H5FDmpio.c443
-rw-r--r--src/H5FDmulti.c227
-rw-r--r--src/H5FDsec2.c251
-rw-r--r--src/H5FDstdio.c59
8 files changed, 1166 insertions, 675 deletions
diff --git a/src/H5Epublic.h b/src/H5Epublic.h
index ce8af46..d3790e9 100644
--- a/src/H5Epublic.h
+++ b/src/H5Epublic.h
@@ -66,7 +66,7 @@
/* And goto a label after pushing error onto stack */
#define H5Epush_goto(func,maj,min,str,label) { \
H5Epush(__FILE__,func,__LINE__,maj,min,str); \
- goto (label); \
+ goto label; \
}
/*
@@ -172,6 +172,9 @@ typedef enum H5E_minor_t {
H5E_LINK, /*link count failure */
H5E_SLINK, /*symbolic link error */
+ /* Datatype conversion errors */
+ H5E_CANTCONVERT, /*Can't convert datatypes */
+
/* Parallel errors */
H5E_MPI /*some MPI function failed */
} H5E_minor_t;
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 51f57c4..6085e6f 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -9,10 +9,12 @@
* only the HDF5 public API. This driver is useful for fast
* access to small, temporary hdf5 files.
*/
-#include <H5private.h>
-#include <H5Fprivate.h>
-#include <H5FDcore.h>
-#include <H5Pprivate.h>
+#include <H5private.h> /*library functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Fprivate.h> /*files */
+#include <H5FDcore.h> /* Core file driver */
+#include <H5MMprivate.h> /* Memory allocation */
+#include <H5Pprivate.h> /*property lists */
#undef MAX
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
@@ -112,6 +114,11 @@ static const H5FD_class_t H5FD_core_g = {
H5FD_FLMAP_SINGLE, /*fl_map */
};
+/* Interface initialization */
+#define PABLO_MASK H5FD_core_mask
+#define INTERFACE_INIT H5FD_core_init
+static intn interface_initialize_g = 0;
+
/*-------------------------------------------------------------------------
* Function: H5FD_core_init
@@ -133,10 +140,12 @@ static const H5FD_class_t H5FD_core_g = {
hid_t
H5FD_core_init(void)
{
- if (H5I_VFL!=H5Iget_type(H5FD_CORE_g)) {
- H5FD_CORE_g = H5FDregister(&H5FD_core_g);
- }
- return H5FD_CORE_g;
+ FUNC_ENTER(H5FD_core_init, FAIL);
+
+ if (H5I_VFL!=H5Iget_type(H5FD_CORE_g))
+ H5FD_CORE_g = H5FDregister(&H5FD_core_g);
+
+ FUNC_LEAVE(H5FD_CORE_g);
}
@@ -162,13 +171,20 @@ H5FD_core_init(void)
herr_t
H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store)
{
+ herr_t ret_value=FAIL;
H5FD_core_fapl_t fa;
+ FUNC_ENTER(H5FD_set_fapl_core, FAIL);
+
/* NO TRACE */
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
fa.increment = increment;
fa.backing_store = backing_store;
- return H5Pset_driver(fapl_id, H5FD_CORE, &fa);
+
+ ret_value= H5Pset_driver(fapl_id, H5FD_CORE, &fa);
+
+ FUNC_LEAVE(ret_value);
}
@@ -195,15 +211,20 @@ H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/,
{
H5FD_core_fapl_t *fa;
+ FUNC_ENTER(H5Pget_fapl_core, FAIL);
+
/* NO TRACE */
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
- if (H5FD_CORE!=H5Pget_driver(fapl_id)) return -1;
- if (NULL==(fa=H5Pget_driver_info(fapl_id))) return -1;
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
+ if (H5FD_CORE!=H5Pget_driver(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ if (NULL==(fa=H5Pget_driver_info(fapl_id)))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (increment) *increment = fa->increment;
if (backing_store) *backing_store = fa->backing_store;
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -227,11 +248,17 @@ static void *
H5FD_core_fapl_get(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
- H5FD_core_fapl_t *fa = calloc(1, sizeof(H5FD_core_fapl_t));
+ H5FD_core_fapl_t *fa = NULL;
+
+ FUNC_ENTER(H5FD_core_fapl_get, NULL);
+
+ if (NULL==(fa=H5MM_calloc(sizeof(H5FD_core_fapl_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
fa->increment = file->increment;
fa->backing_store = (file->fd>=0);
- return fa;
+
+ FUNC_LEAVE(fa);
}
@@ -261,24 +288,28 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
H5FD_core_t *file=NULL;
H5FD_core_fapl_t *fa=NULL;
int fd=-1;
+
+ FUNC_ENTER(H5FD_init_interface, NULL);
/* Check arguments */
- if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL;
- if (ADDR_OVERFLOW(maxaddr)) return NULL;
+ if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ if (ADDR_OVERFLOW(maxaddr))
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow");
if (H5P_DEFAULT!=fapl_id) fa = H5Pget_driver_info(fapl_id);
/* Open backing store */
if (fa && fa->backing_store && name &&
- (fd=open(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0) {
- return NULL;
+ (fd=open(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0) {
+ HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open backing store");
}
/* Create the new file struct */
- file = calloc(1, sizeof(H5FD_core_t));
+ if (NULL==(file=H5MM_calloc(sizeof(H5FD_core_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct");
file->fd = fd;
if (name && *name) {
- file->name = malloc(strlen(name)+1);
- strcpy(file->name, name);
+ file->name = HDstrdup(name);
}
/*
@@ -289,7 +320,7 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
file->increment = (fa && fa->increment>0) ?
fa->increment : H5FD_CORE_INCREMENT;
- return (H5FD_t*)file;
+ FUNC_LEAVE((H5FD_t*)file);
}
@@ -315,22 +346,28 @@ H5FD_core_flush(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ FUNC_ENTER(H5FD_core_flush, FAIL);
+
/* Write to backing store */
if (file->dirty && file->fd>=0) {
- haddr_t size = file->eof;
- unsigned char *ptr = file->mem;
- if (0!=lseek(file->fd, 0, SEEK_SET)) return -1;
-
- while (size) {
- ssize_t n = write(file->fd, ptr, size);
- if (n<0 && EINTR==errno) continue;
- if (n<0) return -1;
- ptr += (size_t)n;
- size -= (size_t)n;
- }
- file->dirty = FALSE;
+ haddr_t size = file->eof;
+ unsigned char *ptr = file->mem;
+
+ if (0!=lseek(file->fd, 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);
+ if (n<0 && EINTR==errno) continue;
+ if (n<0)
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "error writing backing store");
+ ptr += (size_t)n;
+ size -= (size_t)n;
+ }
+ file->dirty = FALSE;
}
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -357,15 +394,18 @@ H5FD_core_close(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ FUNC_ENTER(H5FD_core_close, FAIL);
+
/* Flush */
- if (H5FD_core_flush(_file)<0) return -1;
+ if (H5FD_core_flush(_file)<0)
+ HRETURN_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "can't flush file");
/* Release resources */
if (file->fd>=0) close(file->fd);
- if (file->name) free(file->name);
- if (file->mem) free(file->mem);
+ if (file->name) H5MM_xfree(file->name);
+ if (file->mem) H5MM_xfree(file->mem);
memset(file, 0, sizeof(H5FD_core_t));
- return 0;
+ FUNC_LEAVE(0);
}
@@ -395,16 +435,22 @@ H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
const H5FD_core_t *f1 = (const H5FD_core_t*)_f1;
const H5FD_core_t *f2 = (const H5FD_core_t*)_f2;
+ FUNC_ENTER(H5FD_core_cmp, FAIL);
+
if (NULL==f1->name && NULL==f2->name) {
- if (f1<f2) return -1;
- if (f1>f2) return 1;
- return 0;
+ if (f1<f2)
+ HRETURN(-1);
+ if (f1>f2)
+ HRETURN(1);
+ HRETURN(0);
}
- if (NULL==f1->name) return -1;
- if (NULL==f2->name) return 1;
+ if (NULL==f1->name)
+ HRETURN(-1);
+ if (NULL==f2->name)
+ HRETURN(1);
- return strcmp(f1->name, f2->name);
+ FUNC_LEAVE(HDstrcmp(f1->name, f2->name));
}
@@ -430,7 +476,10 @@ static haddr_t
H5FD_core_get_eoa(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
- return file->eoa;
+
+ FUNC_ENTER(H5FD_core_get_eoa, HADDR_UNDEF);
+
+ FUNC_LEAVE(file->eoa);
}
@@ -456,9 +505,14 @@ static herr_t
H5FD_core_set_eoa(H5FD_t *_file, haddr_t addr)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
- if (ADDR_OVERFLOW(addr)) return -1;
+
+ FUNC_ENTER(H5FD_core_set_eoa, FAIL);
+
+ if (ADDR_OVERFLOW(addr))
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow");
+
file->eoa = addr;
- return 0;
+ FUNC_LEAVE(0);
}
@@ -486,7 +540,10 @@ static haddr_t
H5FD_core_get_eof(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
- return MAX(file->eof, file->eoa);
+
+ FUNC_ENTER(H5FD_core_get_eof, HADDR_UNDEF);
+
+ FUNC_LEAVE(MAX(file->eof, file->eoa));
}
@@ -516,28 +573,33 @@ H5FD_core_read(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
H5FD_core_t *file = (H5FD_core_t*)_file;
ssize_t nbytes;
+ FUNC_ENTER(H5FD_core_read, FAIL);
+
assert(file && file->pub.cls);
assert(buf);
/* Check for overflow conditions */
- if (HADDR_UNDEF==addr) return -1;
- if (REGION_OVERFLOW(addr, size)) return -1;
- if (addr+size>file->eoa) return -1;
+ if (HADDR_UNDEF==addr)
+ HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ if (REGION_OVERFLOW(addr, size))
+ HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ if (addr+size>file->eoa)
+ HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
/* Read the part which is before the EOF marker */
if (addr<file->eof) {
- nbytes = MIN(size, file->eof-addr);
- memcpy(buf, file->mem+addr, nbytes);
- size -= nbytes;
- addr += nbytes;
- buf = (char*)buf + nbytes;
+ nbytes = MIN(size, file->eof-addr);
+ memcpy(buf, file->mem+addr, 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);
- }
- return 0;
+ if (size>0)
+ memset(buf, 0, size);
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -565,12 +627,16 @@ H5FD_core_write(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ FUNC_ENTER(H5FD_core_write, FAIL);
+
assert(file && file->pub.cls);
assert(buf);
/* Check for overflow conditions */
- if (REGION_OVERFLOW(addr, size)) return -1;
- if (addr+size>file->eoa) return -1;
+ if (REGION_OVERFLOW(addr, size))
+ HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ if (addr+size>file->eoa)
+ HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
/*
* Allocate more memory if necessary, careful of overflow. Also, if the
@@ -579,18 +645,21 @@ H5FD_core_write(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
* the first argument is null.
*/
if (addr+size>file->eof) {
- unsigned char *x;
- size_t new_eof = file->increment * ((addr+size)/file->increment);
- if ((addr+size) % file->increment) new_eof += file->increment;
- if (NULL==file->mem) x = malloc(new_eof);
- else x = realloc(file->mem, new_eof);
- if (!x) return -1;
- file->mem = x;
- file->eof = new_eof;
+ unsigned char *x;
+ size_t new_eof = file->increment * ((addr+size)/file->increment);
+
+ if ((addr+size) % file->increment) new_eof += file->increment;
+ if (NULL==file->mem) x = H5MM_malloc(new_eof);
+ else x = H5MM_realloc(file->mem, new_eof);
+ if (!x)
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate memory block");
+ file->mem = x;
+ file->eof = new_eof;
}
/* Write from BUF to memory */
memcpy(file->mem+addr, buf, size);
file->dirty = TRUE;
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index d04c9ab..f9d0c51 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -21,9 +21,13 @@
* implement holes, like nfs).
*
*/
-#include <assert.h>
-#include <hdf5.h>
-#include <stdlib.h>
+#include <H5private.h> /*library functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Fprivate.h> /*files */
+#include <H5FDfamily.h> /* Family file driver */
+#include <H5MMprivate.h> /* Memory allocation */
+#include <H5Pprivate.h> /*property lists */
+
#undef MAX
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
@@ -104,6 +108,11 @@ static const H5FD_class_t H5FD_family_g = {
H5FD_FLMAP_SINGLE, /*fl_map */
};
+/* Interface initialization */
+#define PABLO_MASK H5FD_family_mask
+#define INTERFACE_INIT H5FD_family_init
+static intn interface_initialize_g = 0;
+
/*-------------------------------------------------------------------------
* Function: H5FD_family_init
@@ -125,10 +134,12 @@ static const H5FD_class_t H5FD_family_g = {
hid_t
H5FD_family_init(void)
{
- if (H5I_VFL!=H5Iget_type(H5FD_FAMILY_g)) {
- H5FD_FAMILY_g = H5FDregister(&H5FD_family_g);
- }
- return H5FD_FAMILY_g;
+ FUNC_ENTER(H5FD_family_init, FAIL);
+
+ if (H5I_VFL!=H5Iget_type(H5FD_FAMILY_g))
+ H5FD_FAMILY_g = H5FDregister(&H5FD_family_g);
+
+ FUNC_LEAVE(H5FD_FAMILY_g);
}
@@ -155,14 +166,18 @@ H5FD_family_init(void)
herr_t
H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id)
{
+ herr_t ret_value=FAIL;
H5FD_family_fapl_t fa;
/*NO TRACE*/
+ FUNC_ENTER(H5FD_set_fapl_family, FAIL);
/* Check arguments */
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
if (H5P_DEFAULT!=memb_fapl_id &&
- H5P_FILE_ACCESS!=H5Pget_class(memb_fapl_id)) return -1;
+ H5P_FILE_ACCESS!=H5Pget_class(memb_fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
/*
* Initialize driver specific information. No need to copy it into the FA
@@ -170,7 +185,10 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id)
*/
fa.memb_size = memb_size;
fa.memb_fapl_id = memb_fapl_id;
- return H5Pset_driver(fapl_id, H5FD_FAMILY, &fa);
+
+ ret_value= H5Pset_driver(fapl_id, H5FD_FAMILY, &fa);
+
+ FUNC_LEAVE(ret_value);
}
@@ -198,13 +216,18 @@ H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size/*out*/,
H5FD_family_fapl_t *fa;
/*NO TRACE*/
-
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
- if (H5FD_FAMILY!=H5Pget_driver(fapl_id)) return -1;
- if (NULL==(fa=H5Pget_driver_info(fapl_id))) return -1;
+ FUNC_ENTER(H5Pget_fapl_family, FAIL);
+
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
+ if (H5FD_FAMILY!=H5Pget_driver(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ if (NULL==(fa=H5Pget_driver_info(fapl_id)))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (memb_size) *memb_size = fa->memb_size;
if (memb_fapl_id) *memb_fapl_id = H5Pcopy(fa->memb_fapl_id);
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -229,11 +252,17 @@ static void *
H5FD_family_fapl_get(H5FD_t *_file)
{
H5FD_family_t *file = (H5FD_family_t*)_file;
- H5FD_family_fapl_t *fa = calloc(1, sizeof(H5FD_family_fapl_t*));
+ H5FD_family_fapl_t *fa = NULL;
+
+ FUNC_ENTER(H5FD_family_fapl_get, NULL);
+
+ if (NULL==(fa=H5MM_calloc(sizeof(H5FD_family_fapl_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
fa->memb_size = file->memb_size;
fa->memb_fapl_id = H5Pcopy(file->memb_fapl_id);
- return fa;
+
+ FUNC_LEAVE(fa);
}
@@ -257,12 +286,17 @@ static void *
H5FD_family_fapl_copy(const void *_old_fa)
{
const H5FD_family_fapl_t *old_fa = (const H5FD_family_fapl_t*)_old_fa;
- H5FD_family_fapl_t *new_fa = malloc(sizeof(H5FD_family_fapl_t));
- assert(new_fa);
+ H5FD_family_fapl_t *new_fa = NULL;
+
+ FUNC_ENTER(H5FD_family_fapl_copy, NULL);
+
+ if (NULL==(new_fa=H5MM_malloc(sizeof(H5FD_family_fapl_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t));
new_fa->memb_fapl_id = H5Pcopy(old_fa->memb_fapl_id);
- return new_fa;
+
+ FUNC_LEAVE(new_fa);
}
@@ -286,9 +320,13 @@ static herr_t
H5FD_family_fapl_free(void *_fa)
{
H5FD_family_fapl_t *fa = (H5FD_family_fapl_t*)_fa;
+
+ FUNC_ENTER(H5FD_family_fapl_free, FAIL);
+
H5Pclose(fa->memb_fapl_id);
- free(fa);
- return 0;
+ H5MM_xfree(fa);
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -312,12 +350,17 @@ static void *
H5FD_family_dxpl_copy(const void *_old_dx)
{
const H5FD_family_dxpl_t *old_dx = (const H5FD_family_dxpl_t*)_old_dx;
- H5FD_family_dxpl_t *new_dx = malloc(sizeof(H5FD_family_dxpl_t));
- assert(new_dx);
+ H5FD_family_dxpl_t *new_dx = NULL;
+
+ FUNC_ENTER(H5FD_family_dxpl_copy, NULL);
+
+ if (NULL==(new_dx=H5MM_malloc(sizeof(H5FD_family_dxpl_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
memcpy(new_dx, old_dx, sizeof(H5FD_family_dxpl_t));
new_dx->memb_dxpl_id = H5Pcopy(old_dx->memb_dxpl_id);
- return new_dx;
+
+ FUNC_LEAVE(new_dx);
}
@@ -341,9 +384,13 @@ static herr_t
H5FD_family_dxpl_free(void *_dx)
{
H5FD_family_dxpl_t *dx = (H5FD_family_dxpl_t*)_dx;
+
+ FUNC_ENTER(H5FD_family_dxpl_free, FAIL);
+
H5Pclose(dx->memb_dxpl_id);
- free(dx);
- return 0;
+ H5MM_xfree(dx);
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -370,63 +417,72 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
haddr_t maxaddr)
{
H5FD_family_t *file=NULL;
+ H5FD_t *ret_value=NULL;
char memb_name[4096], temp[4096];
hsize_t eof;
unsigned t_flags = flags & ~H5F_ACC_CREAT;
+ FUNC_ENTER(H5FD_family_open, NULL);
+
/* Check arguments */
- if (!name || !*name) return NULL;
- if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL;
+ if (!name || !*name)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
+ if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
/* Initialize file from file access properties */
- if (NULL==(file=calloc(1, sizeof(H5FD_family_t)))) return NULL;
+ if (NULL==(file=H5MM_calloc(sizeof(H5FD_family_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct");
if (H5P_DEFAULT==fapl_id) {
- file->memb_fapl_id = H5P_DEFAULT;
- file->memb_size = 1024*1024*1024; /*1GB*/
+ file->memb_fapl_id = H5P_DEFAULT;
+ file->memb_size = 1024*1024*1024; /*1GB*/
} else {
- H5FD_family_fapl_t *fa = H5Pget_driver_info(fapl_id);
- file->memb_fapl_id = H5Pcopy(fa->memb_fapl_id);
- file->memb_size = fa->memb_size;
+ H5FD_family_fapl_t *fa = H5Pget_driver_info(fapl_id);
+
+ file->memb_fapl_id = H5Pcopy(fa->memb_fapl_id);
+ file->memb_size = fa->memb_size;
}
- file->name = malloc(strlen(name)+1);
- strcpy(file->name, name);
+ file->name = H5MM_strdup(name);
file->flags = flags;
/* Check that names are unique */
sprintf(memb_name, name, 0);
sprintf(temp, name, 1);
- if (!strcmp(memb_name, temp)) return NULL;
+ if (!strcmp(memb_name, temp))
+ HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL, "file names not unique");
/* Open all the family members */
while (1) {
- sprintf(memb_name, name, file->nmembs);
-
- /* Enlarge member array */
- if (file->nmembs>=file->amembs) {
- int n = MAX(64, 2*file->amembs);
- H5FD_t **x = realloc(file->memb, n*sizeof(H5FD_t*));
- if (!x) goto error;
- file->amembs = n;
- file->memb = x;
- }
-
- /*
- * Attempt to open file. If the first file cannot be opened then fail;
- * otherwise an open failure means that we've reached the last member.
- * Allow H5F_ACC_CREAT only on the first family member.
- */
- H5E_BEGIN_TRY {
- file->memb[file->nmembs] = H5FDopen(memb_name,
- 0==file->nmembs?flags:t_flags,
- file->memb_fapl_id,
- HADDR_UNDEF);
- } H5E_END_TRY;
- if (!file->memb[file->nmembs]) {
- if (0==file->nmembs) goto error;
- H5Eclear();
- break;
- }
- file->nmembs++;
+ sprintf(memb_name, name, file->nmembs);
+
+ /* Enlarge member array */
+ if (file->nmembs>=file->amembs) {
+ int n = MAX(64, 2*file->amembs);
+ H5FD_t **x = H5MM_realloc(file->memb, n*sizeof(H5FD_t*));
+ if (!x)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't reallocate members");
+ file->amembs = n;
+ file->memb = x;
+ }
+
+ /*
+ * Attempt to open file. If the first file cannot be opened then fail;
+ * otherwise an open failure means that we've reached the last member.
+ * Allow H5F_ACC_CREAT only on the first family member.
+ */
+ H5E_BEGIN_TRY {
+ file->memb[file->nmembs] = H5FDopen(memb_name,
+ 0==file->nmembs?flags:t_flags,
+ file->memb_fapl_id,
+ HADDR_UNDEF);
+ } H5E_END_TRY;
+ if (!file->memb[file->nmembs]) {
+ if (0==file->nmembs)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open member file");
+ H5Eclear();
+ break;
+ }
+ file->nmembs++;
}
/*
@@ -436,21 +492,24 @@ H5FD_family_open(const char *name, unsigned flags, hid_t fapl_id,
*/
if ((eof=H5FDget_eof(file->memb[0]))) file->memb_size = eof;
- return (H5FD_t*)file;
+ ret_value=(H5FD_t *)file;
- error:
+done:
/* Cleanup and fail */
- if (file) {
- int i;
- for (i=0; i<file->nmembs; i++) {
- if (file->memb[i]) H5FDclose(file->memb[i]);
- }
- if (file->memb) free(file->memb);
- H5Pclose(file->memb_fapl_id);
- if (file->name) free(file->name);
- free(file);
+ if (ret_value==NULL && file!=NULL) {
+ int i;
+
+ for (i=0; i<file->nmembs; i++)
+ if (file->memb[i])
+ H5FDclose(file->memb[i]);
+ if (file->memb)
+ H5MM_xfree(file->memb);
+ H5Pclose(file->memb_fapl_id);
+ if (file->name)
+ H5MM_xfree(file->name);
+ H5MM_xfree(file);
}
- return NULL;
+ FUNC_LEAVE(ret_value);
}
@@ -478,24 +537,30 @@ H5FD_family_close(H5FD_t *_file)
H5FD_family_t *file = (H5FD_family_t*)_file;
int i, nerrors=0;
+ FUNC_ENTER(H5FD_family_close, FAIL);
+
/* Close as many members as possible */
for (i=0; i<file->nmembs; i++) {
- if (file->memb[i]) {
- if (H5FDclose(file->memb[i])<0) {
- nerrors++;
- } else {
- file->memb[i] = NULL;
- }
- }
+ if (file->memb[i]) {
+ if (H5FDclose(file->memb[i])<0) {
+ nerrors++;
+ } else {
+ file->memb[i] = NULL;
+ }
+ }
}
- if (nerrors) return -1;
+ if (nerrors)
+ HRETURN_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close member files");
/* Clean up other stuff */
H5Pclose(file->memb_fapl_id);
- free(file->memb);
- free(file->name);
- free(file);
- return 0;
+ if (file->memb)
+ H5MM_xfree(file->memb);
+ if (file->name)
+ H5MM_xfree(file->name);
+ H5MM_xfree(file);
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -522,12 +587,16 @@ H5FD_family_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
{
const H5FD_family_t *f1 = (const H5FD_family_t*)_f1;
const H5FD_family_t *f2 = (const H5FD_family_t*)_f2;
+ int ret_value=(-2);
+
+ FUNC_ENTER(H5FD_family_cmp, -2);
assert(f1->nmembs>=1 && f1->memb[0]);
assert(f2->nmembs>=1 && f2->memb[0]);
+ ret_value= H5FDcmp(f1->memb[0], f2->memb[0]);
- return H5FDcmp(f1->memb[0], f2->memb[0]);
+ FUNC_LEAVE(ret_value);
}
@@ -553,7 +622,10 @@ static haddr_t
H5FD_family_get_eoa(H5FD_t *_file)
{
H5FD_family_t *file = (H5FD_family_t*)_file;
- return file->eoa;
+
+ FUNC_ENTER(H5FD_family_get_eoa, HADDR_UNDEF);
+
+ FUNC_LEAVE(file->eoa);
}
@@ -581,41 +653,45 @@ H5FD_family_set_eoa(H5FD_t *_file, haddr_t eoa)
int i;
char memb_name[4096];
+ FUNC_ENTER(H5FD_family_set_eoa, FAIL);
+
for (i=0; addr || i<file->nmembs; i++) {
- /* Enlarge member array */
- if (i>=file->amembs) {
- int n = MAX(64, 2*file->amembs);
- H5FD_t **x = realloc(file->memb, n*sizeof(H5FD_t*));
- if (!x) return -1;
- file->amembs = n;
- file->memb = x;
- file->nmembs = i;
- }
-
- /* Create another file if necessary */
- if (i>=file->nmembs || !file->memb[i]) {
- file->nmembs = MAX(file->nmembs, i+1);
- sprintf(memb_name, file->name, i);
- H5E_BEGIN_TRY {
- file->memb[i] = H5FDopen(memb_name, file->flags|H5F_ACC_CREAT,
- file->memb_fapl_id, file->memb_size);
- } H5E_END_TRY;
- if (NULL==file->memb[i]) return -1;
- }
-
- /* Set the EOA marker for the member */
- if (addr>file->memb_size) {
- H5FDset_eoa(file->memb[i], file->memb_size);
- addr -= file->memb_size;
- } else {
- H5FDset_eoa(file->memb[i], addr);
- addr = 0;
- }
+ /* Enlarge member array */
+ if (i>=file->amembs) {
+ int n = MAX(64, 2*file->amembs);
+ H5FD_t **x = H5MM_realloc(file->memb, n*sizeof(H5FD_t*));
+ if (!x)
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate memory block");
+ file->amembs = n;
+ file->memb = x;
+ file->nmembs = i;
+ }
+
+ /* Create another file if necessary */
+ if (i>=file->nmembs || !file->memb[i]) {
+ file->nmembs = MAX(file->nmembs, i+1);
+ sprintf(memb_name, file->name, i);
+ H5E_BEGIN_TRY {
+ file->memb[i] = H5FDopen(memb_name, file->flags|H5F_ACC_CREAT,
+ file->memb_fapl_id, file->memb_size);
+ } H5E_END_TRY;
+ if (NULL==file->memb[i])
+ HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "can't open member file");
+ }
+
+ /* Set the EOA marker for the member */
+ if (addr>file->memb_size) {
+ H5FDset_eoa(file->memb[i], file->memb_size);
+ addr -= file->memb_size;
+ } else {
+ H5FDset_eoa(file->memb[i], addr);
+ addr = 0;
+ }
}
file->eoa = eoa;
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -645,14 +721,18 @@ H5FD_family_get_eof(H5FD_t *_file)
haddr_t eof=0;
int i;
+ FUNC_ENTER(H5FD_family_get_eof, HADDR_UNDEF);
+
/*
* Find the last member that has a non-zero EOF and break out of the loop
* with `i' equal to that member. If all members have zero EOF then exit
* loop with i==0.
*/
for (i=file->nmembs-1; i>=0; --i) {
- if ((eof=H5FDget_eof(file->memb[i]))) break;
- if (0==i) break;
+ if ((eof=H5FDget_eof(file->memb[i])))
+ break;
+ if (0==i)
+ break;
}
/*
@@ -660,7 +740,8 @@ H5FD_family_get_eof(H5FD_t *_file)
* size of the i'th member.
*/
eof += i*file->memb_size;
- return MAX(eof, file->eoa);
+
+ FUNC_LEAVE(MAX(eof, file->eoa));
}
@@ -694,34 +775,36 @@ H5FD_family_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
haddr_t sub;
hsize_t req;
+ FUNC_ENTER(H5FD_family_read, FAIL);
+
/*
* Get the member data transfer property list. If the transfer property
* list does not belong to this driver then assume defaults
*/
if (H5P_DEFAULT!=dxpl_id && H5FD_FAMILY==H5Pget_driver(dxpl_id)) {
- H5FD_family_dxpl_t *dx = H5Pget_driver_info(dxpl_id);
- assert(H5P_DATA_XFER==H5Pget_class(dxpl_id));
- assert(dx);
- memb_dxpl_id = dx->memb_dxpl_id;
+ H5FD_family_dxpl_t *dx = H5Pget_driver_info(dxpl_id);
+
+ assert(H5P_DATA_XFER==H5Pget_class(dxpl_id));
+ assert(dx);
+ memb_dxpl_id = dx->memb_dxpl_id;
}
/* Read from each member */
while (size>0) {
- i = addr / file->memb_size;
- sub = addr % file->memb_size;
- req = MIN(size, file->memb_size-sub);
- assert(i<file->nmembs);
-
- if (H5FDread(file->memb[i], memb_dxpl_id, sub, req, buf)<0) {
- return -1;
- }
-
- addr += req;
- buf += req;
- size -= req;
+ i = addr / file->memb_size;
+ sub = addr % file->memb_size;
+ req = MIN(size, file->memb_size-sub);
+ assert(i<file->nmembs);
+
+ if (H5FDread(file->memb[i], memb_dxpl_id, sub, req, buf)<0)
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "member file read failed");
+
+ addr += req;
+ buf += req;
+ size -= req;
}
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -754,34 +837,36 @@ H5FD_family_write(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
haddr_t sub;
hsize_t req;
+ FUNC_ENTER(H5FD_family_write, FAIL);
+
/*
* Get the member data transfer property list. If the transfer property
* list does not belong to this driver then assume defaults.
*/
if (H5P_DEFAULT!=dxpl_id && H5FD_FAMILY==H5Pget_driver(dxpl_id)) {
- H5FD_family_dxpl_t *dx = H5Pget_driver_info(dxpl_id);
- assert(H5P_DATA_XFER==H5Pget_class(dxpl_id));
- assert(dx);
- memb_dxpl_id = dx->memb_dxpl_id;
+ H5FD_family_dxpl_t *dx = H5Pget_driver_info(dxpl_id);
+
+ assert(H5P_DATA_XFER==H5Pget_class(dxpl_id));
+ assert(dx);
+ memb_dxpl_id = dx->memb_dxpl_id;
}
/* Write to each member */
while (size>0) {
- i = addr / file->memb_size;
- sub = addr % file->memb_size;
- req = MIN(size, file->memb_size-sub);
- assert(i<file->nmembs);
-
- if (H5FDwrite(file->memb[i], memb_dxpl_id, sub, req, buf)<0) {
- return -1;
- }
-
- addr += req;
- buf += req;
- size -= req;
+ i = addr / file->memb_size;
+ sub = addr % file->memb_size;
+ req = MIN(size, file->memb_size-sub);
+ assert(i<file->nmembs);
+
+ if (H5FDwrite(file->memb[i], memb_dxpl_id, sub, req, buf)<0)
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "member file write failed");
+
+ addr += req;
+ buf += req;
+ size -= req;
}
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -807,11 +892,14 @@ H5FD_family_flush(H5FD_t *_file)
H5FD_family_t *file = (H5FD_family_t*)_file;
int i, nerrors=0;
- for (i=0; i<file->nmembs; i++) {
- if (file->memb[i] && H5FDflush(file->memb[i])<0) {
- nerrors++;
- }
- }
+ FUNC_ENTER(H5FD_family_flush, FAIL);
+
+ for (i=0; i<file->nmembs; i++)
+ if (file->memb[i] && H5FDflush(file->memb[i])<0)
+ nerrors++;
+
+ if (nerrors)
+ HRETURN_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "can't flush member files");
- return nerrors?-1:0;
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5FDgass.c b/src/H5FDgass.c
index 055e12f..96b7a1b 100644
--- a/src/H5FDgass.c
+++ b/src/H5FDgass.c
@@ -8,16 +8,13 @@
* Purpose: This is the GASS I/O driver.
*
*/
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <hdf5.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <unistd.h>
+#include <H5private.h> /*library functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Fprivate.h> /*files */
+#include <H5FDgass.h> /* Core file driver */
+#include <H5MMprivate.h> /* Memory allocation */
+#include <H5Pprivate.h> /*property lists */
-/* Packages needed by this file.*/
-#include <H5Eprivate.h>
#undef MAX
#define MAX(X,Y) ((X)>(Y)?(X):(Y))
@@ -144,7 +141,12 @@ static const H5FD_class_t H5FD_gass_g = {
H5FD_FLMAP_SINGLE, /*fl_map */
};
+/* Interface initialization */
+#define PABLO_MASK H5FD_gass_mask
+#define INTERFACE_INIT H5FD_gass_init
+static intn interface_initialize_g = 0;
+
/*-------------------------------------------------------------------------
* Function: H5FD_gass_init
*
@@ -165,13 +167,15 @@ static const H5FD_class_t H5FD_gass_g = {
hid_t
H5FD_gass_init(void)
{
- if (!H5FD_GASS_g) {
- H5FD_GASS_g = H5FDregister(&H5FD_gass_g);
- }
+ FUNC_ENTER(H5FD_gass_init, FAIL);
+
+ if (!H5FD_GASS_g)
+ H5FD_GASS_g = H5FDregister(&H5FD_gass_g);
+
globus_module_activate (GLOBUS_COMMON_MODULE);
globus_module_activate (GLOBUS_GASS_FILE_MODULE);
- return H5FD_GASS_g;
+ FUNC_LEAVE(H5FD_GASS_g);
}
@@ -203,19 +207,25 @@ H5FD_gass_init(void)
herr_t
H5Pset_fapl_gass(hid_t fapl_id, GASS_Info info)
{
+ herr_t ret_value=FAIL;
H5FD_gass_fapl_t fa;
/*NO TRACE*/
-
+ FUNC_ENTER(H5FD_set_fapl_gass, FAIL);
+
/* Check arguments */
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
#ifdef LATER
#warning "We need to verify that INFO contain sensible information."
#endif
/* Initialize driver specific properties */
fa.info = info;
- return H5Pset_driver(fapl_id, H5FD_GASS, &fa);
+
+ ret_value= H5Pset_driver(fapl_id, H5FD_GASS, &fa);
+
+ FUNC_LEAVE(ret_value);
}
@@ -247,13 +257,19 @@ H5Pget_fapl_gass(hid_t fapl_id, GASS_Info *info/*out*/)
H5FD_gass_fapl_t *fa;
/*NO TRACE*/
+ FUNC_ENTER(H5Pget_fapl_gass, FAIL);
+
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
+ if (H5FD_GASS!=H5Pget_driver(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ if (NULL==(fa=H5Pget_driver_info(fapl_id)))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
- if (H5FD_GASS!=H5Pget_driver(fapl_id)) return -1;
- if (NULL==(fa=H5Pget_driver_info(fapl_id))) return -1;
+ if (info)
+ *info = fa->info;
- if (info) *info = fa->info;
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -289,28 +305,33 @@ H5FD_gass_open(const char *name, unsigned flags, hid_t fapl_id,
H5FD_gass_t *file=NULL;
const H5FD_gass_fapl_t *fa=NULL;
H5FD_gass_fapl_t _fa;
- char *filename = (char *) malloc(80 * sizeof(char));
+ char *filename = (char *) H5MM_malloc(80 * sizeof(char));
+ FUNC_ENTER(H5FD_gass_open, NULL);
+
/* fprintf(stdout, "Entering H5FD_gass_open name=%s flags=0x%x\n", name, flags); */
+ /* Check arguments */
+ if (!name || !*name)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
+ if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ if (ADDR_OVERFLOW(maxaddr))
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+
strcpy (filename, name);
/* Obtain a pointer to gass-specific file access properties */
if (H5P_DEFAULT==fapl_id || H5FD_GASS!=H5Pget_driver(fapl_id)) {
- GASS_INFO_NULL (_fa.info);
- /* _fa.info = GASS_INFO_NULL; */
- /* _fa.info = {0,0}; */ /*default*/
- fa = &_fa;
+ GASS_INFO_NULL (_fa.info);
+ /* _fa.info = GASS_INFO_NULL; */
+ /* _fa.info = {0,0}; */ /*default*/
+ fa = &_fa;
} else {
- fa = H5Pget_driver_info(fapl_id);
- assert(fa);
+ fa = H5Pget_driver_info(fapl_id);
+ assert(fa);
}
- /* Check arguments */
- if (!name || !*name) return NULL;
- if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL;
- if (ADDR_OVERFLOW(maxaddr)) return NULL;
-
/* When I come down here, the possible flag values and the correct
responses are given here :-
@@ -333,62 +354,48 @@ H5FD_gass_open(const char *name, unsigned flags, hid_t fapl_id,
/* fprintf (stderr, "flags=0x%x\n", flags); */
if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR) && (flags & H5F_ACC_EXCL)) {
- if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0) {
- /* HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL, "open failed"); */
- fprintf (stderr, "Can't open file. \n");
- return NULL;
- }
+ if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0)
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL, "open failed");
}
else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR) && (flags & H5F_ACC_TRUNC)) {
- if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0) {
- /* HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed"); */
- fprintf (stderr, "Can't open file. \n");
- return NULL;
- }
+ if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0)
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
}
else if ((flags & H5F_ACC_RDWR) && (flags & H5F_ACC_TRUNC)) {
- if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0) {
- /* HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed"); */
- fprintf (stderr, "Can't open file. \n");
- return NULL;
- }
+ if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0)
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
}
else if (flags & H5F_ACC_RDWR) {
printf ("I'm here in H5FDgass_open going to call globus_gass_open with O_RDWR. \n");
printf ("Name of URL =%s \n", filename);
- if ((fd = globus_gass_open (filename, O_RDWR)) < 0) {
- /* HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed"); */
- fprintf (stderr, "Can't open file. \n");
- return NULL;
- }
+ if ((fd = globus_gass_open (filename, O_RDWR)) < 0)
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
}
else { /* This is case where H5F_ACC_RDWR is not set */
- if ((fd = globus_gass_open (filename, O_RDONLY)) < 0) {
- /* HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");*/
- fprintf (stderr, "Can't open file. \n");
- return NULL;
- }
+ if ((fd = globus_gass_open (filename, O_RDONLY)) < 0)
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
}
if (fstat(fd, &sb)<0) {
- close(fd);
- return NULL;
+ close(fd);
+ HRETURN_ERROR(H5E_IO, H5E_BADFILE, NULL, "fstat failed");
}
/* Create the new file struct */
- file = calloc(1, sizeof(H5FD_gass_t));
+ if (NULL==(file=H5MM_calloc(sizeof(H5FD_gass_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct");
file->fd = fd;
file->eof = sb.st_size;
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
file->info = fa->info;
- return (H5FD_t*)file;
+ FUNC_LEAVE((H5FD_t*)file);
}
/*-------------------------------------------------------------------------
@@ -410,20 +417,19 @@ H5FD_gass_open(const char *name, unsigned flags, hid_t fapl_id,
static herr_t
H5FD_gass_close (H5FD_t *_file)
{
- int gasserr;
- H5FD_gass_t *file = (H5FD_gass_t *)_file;
-
- if (file == NULL) {
- /* HRETURN_ERROR(H5E_IO, H5E_CANTCLOSEFILE, NULL, "close failed"); */
- fprintf (stderr, "Can't close file. \n");
- return -1;
- }
+ H5FD_gass_t *file = (H5FD_gass_t *)_file;
+
+ FUNC_ENTER(H5FD_gass_close, FAIL);
+
+ if (file == NULL)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle");
- gasserr = globus_gass_close (file->fd);
- if (gasserr == -1)
- fprintf (stderr, "GASS close failed. \n");
+ if (globus_gass_close (file->fd) < 0)
+ HRETURN_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "can't close GASS file");
- return gasserr;
+ H5MM_xfree(file);
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -449,7 +455,10 @@ static haddr_t
H5FD_gass_get_eoa(H5FD_t *_file)
{
H5FD_gass_t *file = (H5FD_gass_t *)_file;
- return file->eoa;
+
+ FUNC_ENTER(H5FD_gass_get_eoa, HADDR_UNDEF);
+
+ FUNC_LEAVE(file->eoa);
}
@@ -473,8 +482,12 @@ static herr_t
H5FD_gass_set_eoa(H5FD_t *_file, haddr_t addr)
{
H5FD_gass_t *file = (H5FD_gass_t *)_file;
+
+ FUNC_ENTER(H5FD_gass_set_eoa, FAIL);
+
file->eoa = addr;
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -502,7 +515,10 @@ static haddr_t
H5FD_gass_get_eof(H5FD_t *_file)
{
H5FD_gass_t *file = (H5FD_gass_t*)_file;
- return MAX(file->eof, file->eoa);
+
+ FUNC_ENTER(H5FD_gass_get_eof, HADDR_UNDEF);
+
+ FUNC_LEAVE(MAX(file->eof, file->eoa));
}
/*-------------------------------------------------------------------------
@@ -530,20 +546,25 @@ H5FD_gass_read(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
H5FD_gass_t *file = (H5FD_gass_t*)_file;
ssize_t nbytes;
+ FUNC_ENTER(H5FD_gass_read, FAIL);
+
assert(file && file->pub.cls);
assert(buf);
/* Check for overflow conditions */
- if (HADDR_UNDEF==addr) return -1;
- if (REGION_OVERFLOW(addr, size)) return -1;
- if (addr+size>file->eoa) return -1;
+ if (HADDR_UNDEF==addr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
+ if (REGION_OVERFLOW(addr, size))
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ if (addr+size>file->eoa)
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
/* Seek to the correct location */
if ((addr!=file->pos || OP_READ!=file->op) &&
- file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) {
+ file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) {
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- return -1;
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "gass file seek failed");
}
/*
@@ -551,13 +572,15 @@ H5FD_gass_read(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
* and the end of the file.
*/
while (size>0) {
-do nbytes = read(file->fd, buf, size);
+ do
+ nbytes = read(file->fd, buf, size);
while (-1==nbytes && EINTR==errno);
+
if (-1==nbytes) {
/* error */
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- return -1;
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "gass file read failed");
}
if (0==nbytes) {
/* end of file but not end of format address space */
@@ -574,7 +597,7 @@ do nbytes = read(file->fd, buf, size);
/* Update current position */
file->pos = addr;
file->op = OP_READ;
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
@@ -601,20 +624,25 @@ H5FD_gass_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
H5FD_gass_t *file = (H5FD_gass_t*)_file;
ssize_t nbytes;
+ FUNC_ENTER(H5FD_gass_write, FAIL);
+
assert(file && file->pub.cls);
assert(buf);
/* Check for overflow conditions */
- if (HADDR_UNDEF==addr) return -1;
- if (REGION_OVERFLOW(addr, size)) return -1;
- if (addr+size>file->eoa) return -1;
+ if (HADDR_UNDEF==addr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
+ if (REGION_OVERFLOW(addr, size))
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ if (addr+size>file->eoa)
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
/* Seek to the correct location */
if ((addr!=file->pos || OP_WRITE!=file->op) &&
file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) {
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- return -1;
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "gass file seek failed");
}
/*
@@ -622,13 +650,15 @@ H5FD_gass_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
* results
*/
while (size>0) {
- do nbytes = write(file->fd, buf, size);
+ do
+ nbytes = write(file->fd, buf, size);
while (-1==nbytes && EINTR==errno);
-if (-1==nbytes) {
+
+ if (-1==nbytes) {
/* error */
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- return -1;
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "gass file write failed");
}
assert(nbytes>0);
assert((hsize_t)nbytes<=size);
@@ -640,9 +670,10 @@ if (-1==nbytes) {
/* Update current position and eof */
file->pos = addr;
file->op = OP_WRITE;
- if (file->pos>file->eof) file->eof = file->pos;
+ if (file->pos>file->eof)
+ file->eof = file->pos;
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
-#endif
+#endif /* HAVE_GASS */
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index 7a75621..23b183b 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -20,9 +20,12 @@
* bytes read is always equal to the number requested. This
* kluge is activated by #ifdef MPI_KLUGE0202.
*/
-#include <assert.h>
-#include <hdf5.h>
-#include <stdlib.h>
+#include <H5private.h> /*library functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Fprivate.h> /*files */
+#include <H5FDmpio.h> /* MPI I/O file driver */
+#include <H5MMprivate.h> /* Memory allocation */
+#include <H5Pprivate.h> /*property lists */
/*
* The driver identification number, initialized at runtime if HAVE_PARALLEL
@@ -143,6 +146,11 @@ hbool_t H5_mpi_1_metawrite_g = TRUE;
hbool_t H5_mpi_1_metawrite_g = FALSE;
#endif
+/* Interface initialization */
+#define PABLO_MASK H5FD_mpio_mask
+#define INTERFACE_INIT H5FD_mpio_init
+static intn interface_initialize_g = 0;
+
/*-------------------------------------------------------------------------
* Function: H5FD_mpio_init
@@ -164,10 +172,12 @@ hbool_t H5_mpi_1_metawrite_g = FALSE;
hid_t
H5FD_mpio_init(void)
{
- if (H5I_VFL!=H5Iget_type(H5FD_MPIO_g)) {
- H5FD_MPIO_g = H5FDregister(&H5FD_mpio_g);
- }
- return H5FD_MPIO_g;
+ FUNC_ENTER(H5FD_mpio_init, FAIL);
+
+ if (H5I_VFL!=H5Iget_type(H5FD_MPIO_g))
+ H5FD_MPIO_g = H5FDregister(&H5FD_mpio_g);
+
+ FUNC_LEAVE(H5FD_MPIO_g);
}
@@ -222,12 +232,15 @@ H5FD_mpio_init(void)
herr_t
H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info)
{
+ herr_t ret_value=FAIL;
H5FD_mpio_fapl_t fa;
/*NO TRACE*/
+ FUNC_ENTER(H5FD_set_fapl_mpio, FAIL);
/* Check arguments */
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
#ifdef LATER
#warning "We need to verify that COMM and INFO contain sensible information."
#endif
@@ -235,7 +248,10 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info)
/* Initialize driver specific properties */
fa.comm = comm;
fa.info = info;
- return H5Pset_driver(fapl_id, H5FD_MPIO, &fa);
+
+ ret_value= H5Pset_driver(fapl_id, H5FD_MPIO, &fa);
+
+ FUNC_LEAVE(ret_value);
}
@@ -273,14 +289,19 @@ H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/)
H5FD_mpio_fapl_t *fa;
/*NO TRACE*/
+ FUNC_ENTER(H5Pget_fapl_mpio, FAIL);
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
- if (H5FD_MPIO!=H5Pget_driver(fapl_id)) return -1;
- if (NULL==(fa=H5Pget_driver_info(fapl_id))) return -1;
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
+ if (H5FD_MPIO!=H5Pget_driver(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ if (NULL==(fa=H5Pget_driver_info(fapl_id)))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (comm) *comm = fa->comm;
if (info) *info = fa->info;
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -313,18 +334,25 @@ H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/)
herr_t
H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode)
{
+ herr_t ret_value=FAIL;
H5FD_mpio_dxpl_t dx;
/*NO TRACE*/
+ FUNC_ENTER(H5Pset_dxpl_mpio, FAIL);
/* Check arguments */
- if (H5P_DATA_XFER!=H5Pget_class(dxpl_id)) return -1;
+ if (H5P_DATA_XFER!=H5Pget_class(dxpl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
if (H5FD_MPIO_INDEPENDENT!=xfer_mode &&
- H5FD_MPIO_COLLECTIVE!=xfer_mode) return -1;
+ H5FD_MPIO_COLLECTIVE!=xfer_mode) return -1;
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode");
/* Initialize driver-specific properties */
dx.xfer_mode = xfer_mode;
- return H5Pset_driver(dxpl_id, H5FD_MPIO, &dx);
+
+ ret_value= H5Pset_driver(dxpl_id, H5FD_MPIO, &dx);
+
+ FUNC_LEAVE(ret_value);
}
@@ -354,13 +382,19 @@ H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/)
H5FD_mpio_dxpl_t *dx;
/*NO TRACE*/
-
- if (H5P_DATA_XFER!=H5Pget_class(dxpl_id)) return -1;
- if (H5FD_MPIO!=H5Pget_driver(dxpl_id)) return -1;
- if (NULL==(dx=H5Pget_driver_info(dxpl_id))) return -1;
+ FUNC_ENTER(H5Pget_dxpl_mpio, FAIL);
- if (xfer_mode) *xfer_mode = dx->xfer_mode;
- return 0;
+ if (H5P_DATA_XFER!=H5Pget_class(dxpl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
+ if (H5FD_MPIO!=H5Pget_driver(dxpl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ if (NULL==(dx=H5Pget_driver_info(dxpl_id)))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+
+ if (xfer_mode)
+ *xfer_mode = dx->xfer_mode;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -385,6 +419,8 @@ H5FD_mpio_tas_allsame(H5FD_t *_file, hbool_t newval)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
hbool_t oldval;
+ FUNC_ENTER(H5FD_mpio_tas_allsame, FAIL);
+
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Entering H5FD_mpio_tas_allsame, newval=%d\n", newval);
@@ -399,7 +435,7 @@ H5FD_mpio_tas_allsame(H5FD_t *_file, hbool_t newval)
fprintf(stdout, "Leaving H5FD_mpio_tas_allsame, oldval=%d\n", oldval);
#endif
- return oldval;
+ FUNC_LEAVE(oldval);
}
@@ -423,7 +459,10 @@ MPI_Comm
H5FD_mpio_communicator(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- return file->comm;
+
+ FUNC_ENTER(H5FD_mpio_communicator, NULL);
+
+ FUNC_LEAVE(file->comm);
}
@@ -453,11 +492,14 @@ H5FD_mpio_setup(H5FD_t *_file, MPI_Datatype btype, MPI_Datatype ftype,
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
+ FUNC_ENTER(H5FD_mpio_setup, FAIL);
+
file->btype = btype;
file->ftype = ftype;
file->disp = disp;
file->use_types = use_types;
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -493,20 +535,21 @@ H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
MPI_Comm comm = file->comm;
char msgbuf[1];
- int myid, mpi_err;
+ int myid;
MPI_Status rcvstat;
- mpi_err = MPI_Comm_rank(comm, &myid);
- if (MPI_SUCCESS!=mpi_err) return -1;
+ FUNC_ENTER(H5FD_mpio_wait_for_left_neighbor, FAIL);
+
+ if (MPI_SUCCESS!= MPI_Comm_rank(comm, &myid))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_rank failed");
/* p0 has no left neighbor; all other procs wait for msg */
if (myid != 0) {
- mpi_err = MPI_Recv( &msgbuf, 1, MPI_CHAR, myid-1, MPI_ANY_TAG, comm,
- &rcvstat );
- if (MPI_SUCCESS!=mpi_err) return -1;
+ if (MPI_SUCCESS!= MPI_Recv( &msgbuf, 1, MPI_CHAR, myid-1, MPI_ANY_TAG, comm, &rcvstat ))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Recv failed");
}
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -542,17 +585,19 @@ H5FD_mpio_signal_right_neighbor(H5FD_t *_file)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
MPI_Comm comm = file->comm;
char msgbuf[1];
- int myid, numprocs, mpi_err;
+ int myid, numprocs;
+
+ FUNC_ENTER(H5FD_mpio_signal_right_neighbor, FAIL);
- mpi_err = MPI_Comm_size( comm, &numprocs );
- if (MPI_SUCCESS!=mpi_err) return -1;
- mpi_err = MPI_Comm_rank( comm, &myid );
- if (MPI_SUCCESS!=mpi_err) return -1;
+ if (MPI_SUCCESS!= MPI_Comm_size( comm, &numprocs ))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_size failed");
+ if (MPI_SUCCESS!= MPI_Comm_rank( comm, &myid ))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_rank failed");
if (myid != (numprocs-1)) {
- mpi_err = MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, myid+1, 0, comm);
- if (MPI_SUCCESS!=mpi_err) return -1;
+ if (MPI_SUCCESS!= MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, myid+1, 0, comm))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Send failed");
}
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -578,12 +623,18 @@ static void *
H5FD_mpio_fapl_get(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- H5FD_mpio_fapl_t *fa = calloc(1, sizeof(H5FD_mpio_fapl_t));
+ H5FD_mpio_fapl_t *fa = NULL;
+
+ FUNC_ENTER(H5FD_mpio_fapl_get, NULL);
+
+ if (NULL==(fa=H5MM_calloc(sizeof(H5FD_mpio_fapl_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* These should both be copied. --rpm, 1999-08-13 */
fa->comm = file->comm;
fa->info = file->info;
- return fa;
+
+ FUNC_LEAVE(fa);
}
@@ -636,6 +687,8 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
const H5FD_mpio_fapl_t *fa=NULL;
H5FD_mpio_fapl_t _fa;
+ FUNC_ENTER(H5FD_mpio_open, NULL);
+
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t']) {
fprintf(stdout, "Entering H5FD_mpio_open(name=\"%s\", flags=0x%x, "
@@ -645,19 +698,21 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
/* Obtain a pointer to mpio-specific file access properties */
if (H5P_DEFAULT==fapl_id || H5FD_MPIO!=H5Pget_driver(fapl_id)) {
- _fa.comm = MPI_COMM_SELF; /*default*/
- _fa.info = MPI_INFO_NULL; /*default*/
- fa = &_fa;
+ _fa.comm = MPI_COMM_SELF; /*default*/
+ _fa.info = MPI_INFO_NULL; /*default*/
+ fa = &_fa;
} else {
- fa = H5Pget_driver_info(fapl_id);
- assert(fa);
+ fa = H5Pget_driver_info(fapl_id);
+ assert(fa);
}
/* convert HDF5 flags to MPI-IO flags */
/* some combinations are illegal; let MPI-IO figure it out */
mpi_amode = (flags&H5F_ACC_RDWR) ? MPI_MODE_RDWR : MPI_MODE_RDONLY;
- if (flags&H5F_ACC_CREAT) mpi_amode |= MPI_MODE_CREATE;
- if (flags&H5F_ACC_EXCL) mpi_amode |= MPI_MODE_EXCL;
+ if (flags&H5F_ACC_CREAT)
+ mpi_amode |= MPI_MODE_CREATE;
+ if (flags&H5F_ACC_EXCL)
+ mpi_amode |= MPI_MODE_EXCL;
#ifdef H5FDmpio_DEBUG
{
@@ -692,27 +747,26 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
#endif
/*OKAY: CAST DISCARDS CONST*/
- mpierr = MPI_File_open(fa->comm, (char*)name, mpi_amode, fa->info, &fh);
- if (MPI_SUCCESS != mpierr) return NULL;
+ if (MPI_SUCCESS != MPI_File_open(fa->comm, (char*)name, mpi_amode, fa->info, &fh))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_File_open failed");
/* truncate the file, if requested */
if (flags & H5F_ACC_TRUNC) {
- mpierr = MPI_File_set_size(fh, (MPI_Offset)0);
- if (MPI_SUCCESS != mpierr) {
- MPI_File_close(&fh);
- return NULL;
- }
-
- /* Don't let any proc return until all have truncated the file. */
- mpierr = MPI_Barrier(fa->comm);
- if (MPI_SUCCESS!=mpierr) {
- MPI_File_close(&fh);
- return NULL;
- }
+ if (MPI_SUCCESS != MPI_File_set_size(fh, (MPI_Offset)0)) {
+ MPI_File_close(&fh);
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_File_set_size failed");
+ }
+
+ /* Don't let any proc return until all have truncated the file. */
+ if (MPI_SUCCESS!= MPI_Barrier(fa->comm)) {
+ MPI_File_close(&fh);
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_Barrier failed");
+ }
}
/* Build the return value and initialize it */
- if (NULL==(file=calloc(1, sizeof(H5FD_mpio_t)))) return NULL;
+ if (NULL==(file=H5MM_calloc(sizeof(H5FD_mpio_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
file->f = fh;
file->comm = fa->comm;
file->info = fa->info;
@@ -720,11 +774,10 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
file->ftype = MPI_DATATYPE_NULL;
/* Get current file size */
- mpierr = MPI_File_get_size(fh, &size);
- if (MPI_SUCCESS != mpierr) {
- free(file);
- MPI_File_close(&fh);
- return NULL;
+ if (MPI_SUCCESS != MPI_File_get_size(fh, &size)) {
+ H5MM_xfree(file);
+ MPI_File_close(&fh);
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_File_get_size failed");
}
file->eof = MPIOff_to_haddr(size);
@@ -734,7 +787,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
}
#endif
- return (H5FD_t*)file;
+ FUNC_LEAVE((H5FD_t*)file);
}
@@ -762,7 +815,8 @@ static herr_t
H5FD_mpio_close(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- int mpierr;
+
+ FUNC_ENTER(H5FD_mpio_close, FAIL);
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
@@ -770,15 +824,18 @@ H5FD_mpio_close(H5FD_t *_file)
#endif
/* MPI_File_close sets argument to MPI_FILE_NULL */
- mpierr = MPI_File_close(&(file->f)/*in,out*/);
- if (MPI_SUCCESS != mpierr) return -1;
+ if (MPI_SUCCESS != MPI_File_close(&(file->f)/*in,out*/))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_close failed");
+
+ /* Clean up other stuff */
+ H5MM_xfree(file);
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Leaving H5FD_mpio_close\n");
#endif
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -804,7 +861,10 @@ static haddr_t
H5FD_mpio_get_eoa(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- return file->eoa;
+
+ FUNC_ENTER(H5FD_mpio_get_eoa, HADDR_UNDEF);
+
+ FUNC_LEAVE(file->eoa);
}
@@ -830,8 +890,12 @@ static herr_t
H5FD_mpio_set_eoa(H5FD_t *_file, haddr_t addr)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
+
+ FUNC_ENTER(H5FD_mpio_set_eoa, FAIL);
+
file->eoa = addr;
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -864,7 +928,10 @@ static haddr_t
H5FD_mpio_get_eof(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
- return file->eof;
+
+ FUNC_ENTER(H5FD_mpio_get_eof, HADDR_UNDEF);
+
+ FUNC_LEAVE(file->eof);
}
@@ -928,15 +995,19 @@ H5FD_mpio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
int mpierr, size_i, bytes_read, n;
int use_types_this_time, used_types_last_time;
+ FUNC_ENTER(H5FD_mpio_read, FAIL);
+
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Entering H5FD_mpio_read\n" );
#endif
/* some numeric conversions */
- if (haddr_to_MPIOff(addr, &mpi_off/*out*/)<0) return -1;
+ if (haddr_to_MPIOff(addr, &mpi_off/*out*/)<0)
+ HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off");
size_i = (int)size;
- if ((size_t)size_i != size) return -1;
+ if ((size_t)size_i != size)
+ HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i");
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'r'])
@@ -946,11 +1017,11 @@ H5FD_mpio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
/* Obtain the data transfer properties */
if (H5P_DEFAULT==dxpl_id || H5FD_MPIO!=H5Pget_driver(dxpl_id)) {
- _dx.xfer_mode = H5FD_MPIO_INDEPENDENT; /*the default*/
- dx = &_dx;
+ _dx.xfer_mode = H5FD_MPIO_INDEPENDENT; /*the default*/
+ dx = &_dx;
} else {
- dx = H5Pget_driver_info(dxpl_id);
- assert(dx);
+ dx = H5Pget_driver_info(dxpl_id);
+ assert(dx);
}
/*
@@ -961,18 +1032,19 @@ H5FD_mpio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
*/
use_types_this_time = file->use_types;
if (use_types_this_time) {
- /* prepare for a full-blown xfer using btype, ftype, and disp */
- buf_type = file->btype;
- file_type = file->ftype;
- if (haddr_to_MPIOff(file->disp, &mpi_disp)<0) return -1;
+ /* prepare for a full-blown xfer using btype, ftype, and disp */
+ buf_type = file->btype;
+ file_type = file->ftype;
+ if (haddr_to_MPIOff(file->disp, &mpi_disp)<0)
+ HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off");
} else {
- /*
- * Prepare for a simple xfer of a contiguous block of bytes. The
- * btype, ftype, and disp fields are not used.
- */
- buf_type = MPI_BYTE;
- file_type = MPI_BYTE;
- mpi_disp = 0; /* mpi_off is sufficient */
+ /*
+ * Prepare for a simple xfer of a contiguous block of bytes. The
+ * btype, ftype, and disp fields are not used.
+ */
+ buf_type = MPI_BYTE;
+ file_type = MPI_BYTE;
+ mpi_disp = 0; /* mpi_off is sufficient */
}
/*
@@ -981,11 +1053,10 @@ H5FD_mpio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
*/
used_types_last_time = file->old_use_types;
if (used_types_last_time || /* change to new ftype or MPI_BYTE */
- use_types_this_time) { /* almost certainly a different ftype */
- /*OKAY: CAST DISCARDS CONST QUALIFIER*/
- mpierr = MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type,
- (char*)"native", file->info);
- if (MPI_SUCCESS != mpierr) return -1;
+ use_types_this_time) { /* almost certainly a different ftype */
+ /*OKAY: CAST DISCARDS CONST QUALIFIER*/
+ if (MPI_SUCCESS != MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type, (char*)"native", file->info))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_view failed");
}
/*
@@ -997,25 +1068,22 @@ H5FD_mpio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
file->use_types = 0;
/* Read the data. */
- assert(H5FD_MPIO_INDEPENDENT==dx->xfer_mode ||
- H5FD_MPIO_COLLECTIVE==dx->xfer_mode);
+ assert(H5FD_MPIO_INDEPENDENT==dx->xfer_mode || H5FD_MPIO_COLLECTIVE==dx->xfer_mode);
if (H5FD_MPIO_INDEPENDENT==dx->xfer_mode) {
- mpierr = MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type,
- &mpi_stat);
- if (MPI_SUCCESS!=mpierr) return -1;
+ if (MPI_SUCCESS!= MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_read_at failed");
} else {
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "H5FD_mpio_read: using MPIO collective mode\n");
#endif
- mpierr = MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type,
- &mpi_stat );
- if (MPI_SUCCESS!=mpierr) return -1;
+ if (MPI_SUCCESS!= MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat ))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_read_at_all failed");
}
/* How many bytes were actually read? */
- mpierr = MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_read);
- if (MPI_SUCCESS != mpierr) return -1;
+ if (MPI_SUCCESS != MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_read))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Get_count failed");
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'c'])
fprintf(stdout,
@@ -1030,22 +1098,23 @@ H5FD_mpio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
*/
bytes_read = size_i;
#endif
- if (bytes_read<0 || bytes_read>size_i) return -1;
+ if (bytes_read<0 || bytes_read>size_i)
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
/*
* This gives us zeroes beyond end of physical MPI file. What about
* reading past logical end of HDF5 file???
*/
if ((n=(size_i-bytes_read)) > 0) {
- if (use_types_this_time) {
- /*
- * INCOMPLETE rky 1998-09-18
- * Haven't implemented reading zeros beyond EOF. What to do???
- */
- return -1;
- } else {
- memset((char*)buf+bytes_read, 0, (size_t)n);
- }
+ if (use_types_this_time) {
+ /*
+ * INCOMPLETE rky 1998-09-18
+ * Haven't implemented reading zeros beyond EOF. What to do???
+ */
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "eof file read failed");
+ } else {
+ memset((char*)buf+bytes_read, 0, (size_t)n);
+ }
}
#ifdef NO
@@ -1058,7 +1127,7 @@ H5FD_mpio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
fprintf(stdout, "Leaving H5FD_mpio_read\n" );
#endif
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -1151,6 +1220,9 @@ H5FD_mpio_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
int mpi_rank;
int use_types_this_time, used_types_last_time;
hbool_t allsame;
+ herr_t ret_value=FAIL;
+
+ FUNC_ENTER(H5FD_mpio_write, FAIL);
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
@@ -1158,10 +1230,13 @@ H5FD_mpio_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
#endif
/* some numeric conversions */
- if (haddr_to_MPIOff(addr, &mpi_off)<0) return -1;
- if (haddr_to_MPIOff(file->disp, &mpi_disp)<0) return -1;
+ if (haddr_to_MPIOff(addr, &mpi_off)<0)
+ HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off");
+ if (haddr_to_MPIOff(file->disp, &mpi_disp)<0)
+ HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off");
size_i = (int)size;
- if ((size_t)size_i != size) return -1;
+ if ((size_t)size_i != size)
+ HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from size to size_i");
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'w'])
@@ -1172,25 +1247,25 @@ H5FD_mpio_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
/* Only p0 will do the actual write if all procs in comm write same data */
allsame = H5FD_mpio_tas_allsame(_file, FALSE);
if (allsame && H5_mpi_1_metawrite_g) {
- mpierr = MPI_Comm_rank(file->comm, &mpi_rank);
- if (mpierr != MPI_SUCCESS) return -1;
- if (mpi_rank != 0) {
+ if (MPI_SUCCESS != MPI_Comm_rank(file->comm, &mpi_rank))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Comm_rank failed");
+ if (mpi_rank != 0) {
#ifdef H5FDmpio_DEBUG
- if (H5FD_mpio_Debug[(int)'w']) {
- fprintf(stdout, " in H5FD_mpio_write (write omitted)\n" );
- }
+ if (H5FD_mpio_Debug[(int)'w']) {
+ fprintf(stdout, " in H5FD_mpio_write (write omitted)\n" );
+ }
#endif
- goto done; /* skip the actual write */
- }
+ HGOTO_DONE(SUCCEED) /* skip the actual write */
+ }
}
/* Obtain the data transfer properties */
if (H5P_DEFAULT==dxpl_id || H5FD_MPIO!=H5Pget_driver(dxpl_id)) {
- _dx.xfer_mode = H5FD_MPIO_INDEPENDENT; /*the default*/
- dx = &_dx;
+ _dx.xfer_mode = H5FD_MPIO_INDEPENDENT; /*the default*/
+ dx = &_dx;
} else {
- dx = H5Pget_driver_info(dxpl_id);
- assert(dx);
+ dx = H5Pget_driver_info(dxpl_id);
+ assert(dx);
}
/*
@@ -1201,18 +1276,19 @@ H5FD_mpio_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
*/
use_types_this_time = file->use_types;
if (use_types_this_time) {
- /* prepare for a full-blown xfer using btype, ftype, and disp */
- buf_type = file->btype;
- file_type = file->ftype;
- if (haddr_to_MPIOff(file->disp, &mpi_disp)<0) return -1;
+ /* prepare for a full-blown xfer using btype, ftype, and disp */
+ buf_type = file->btype;
+ file_type = file->ftype;
+ if (haddr_to_MPIOff(file->disp, &mpi_disp)<0)
+ HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "can't convert from haddr to MPI off");
} else {
- /*
- * Prepare for a simple xfer of a contiguous block of bytes.
- * The btype, ftype, and disp fields are not used.
- */
- buf_type = MPI_BYTE;
- file_type = MPI_BYTE;
- mpi_disp = 0; /* mpi_off is sufficient */
+ /*
+ * Prepare for a simple xfer of a contiguous block of bytes.
+ * The btype, ftype, and disp fields are not used.
+ */
+ buf_type = MPI_BYTE;
+ file_type = MPI_BYTE;
+ mpi_disp = 0; /* mpi_off is sufficient */
}
/*
@@ -1221,11 +1297,10 @@ H5FD_mpio_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
*/
used_types_last_time = file->old_use_types;
if (used_types_last_time || /* change to new ftype or MPI_BYTE */
- use_types_this_time) { /* almost certainly a different ftype */
- /*OKAY: CAST DISCARDS CONST QUALIFIER*/
- mpierr = MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type,
- (char*)"native", file->info);
- if (MPI_SUCCESS != mpierr) return -1;
+ use_types_this_time) { /* almost certainly a different ftype */
+ /*OKAY: CAST DISCARDS CONST QUALIFIER*/
+ if (MPI_SUCCESS != MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type, (char*)"native", file->info))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_view failed");
}
/*
@@ -1237,26 +1312,24 @@ H5FD_mpio_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
file->use_types = 0;
/* Write the data. */
- assert(H5FD_MPIO_INDEPENDENT==dx->xfer_mode ||
- H5FD_MPIO_COLLECTIVE==dx->xfer_mode);
+ assert(H5FD_MPIO_INDEPENDENT==dx->xfer_mode || H5FD_MPIO_COLLECTIVE==dx->xfer_mode);
if (H5FD_MPIO_INDEPENDENT==dx->xfer_mode) {
- /*OKAY: CAST DISCARDS CONST QUALIFIER*/
- mpierr = MPI_File_write_at(file->f, mpi_off, (void*)buf, size_i,
- buf_type, &mpi_stat);
+ /*OKAY: CAST DISCARDS CONST QUALIFIER*/
+ if (MPI_SUCCESS != MPI_File_write_at(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_write_at failed");
} else {
#ifdef H5FDmpio_DEBUG
- if (H5FD_mpio_Debug[(int)'t'])
- fprintf(stdout, "H5FD_mpio_write: using MPIO collective mode\n");
+ if (H5FD_mpio_Debug[(int)'t'])
+ fprintf(stdout, "H5FD_mpio_write: using MPIO collective mode\n");
#endif
- /*OKAY: CAST DISCARDS CONST QUALIFIER*/
- mpierr = MPI_File_write_at_all(file->f, mpi_off, (void*)buf, size_i,
- buf_type, &mpi_stat);
+ /*OKAY: CAST DISCARDS CONST QUALIFIER*/
+ if (MPI_SUCCESS != MPI_File_write_at_all(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_write_at_all failed");
}
- if (MPI_SUCCESS != mpierr) return -1;
/* How many bytes were actually written? */
- mpierr = MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_written);
- if (MPI_SUCCESS!=mpierr) return -1;
+ if (MPI_SUCCESS!= MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_written))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Get_count failed");
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'c'])
fprintf(stdout,
@@ -1271,17 +1344,18 @@ H5FD_mpio_write(H5FD_t *_file, hid_t dxpl_id/*unused*/, haddr_t addr,
*/
bytes_written = size_i;
#endif
- if (bytes_written<0 || bytes_written>size_i) return -1;
+ if (bytes_written<0 || bytes_written>size_i)
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "file write failed");
/* Forget the EOF value (see H5FD_mpio_get_eof()) --rpm 1999-08-06 */
file->eof = HADDR_UNDEF;
- done:
+done:
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Leaving H5FD_mpio_write\n" );
#endif
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -1311,20 +1385,22 @@ H5FD_mpio_flush(H5FD_t *_file)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
int mpierr;
+ FUNC_ENTER(H5FD_family_flush, FAIL);
+
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Entering H5FD_mpio_flush\n" );
#endif
- mpierr = MPI_File_sync(file->f);
- if (MPI_SUCCESS != mpierr) return -1;
+ if (MPI_SUCCESS != MPI_File_sync(file->f))
+ HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_sync failed");
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Leaving H5FD_mpio_flush\n" );
#endif
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -1353,8 +1429,16 @@ H5FD_mpio_flush(H5FD_t *_file)
static haddr_t
MPIOff_to_haddr(MPI_Offset mpi_off)
{
- if (mpi_off != (MPI_Offset)(haddr_t)mpi_off) return HADDR_UNDEF;
- return (haddr_t)mpi_off;
+ hadd_t ret_value=HADDR_UNDEF;
+
+ FUNC_ENTER(MPIOff_to_haddr, HADDR_UNDEF);
+
+ if (mpi_off != (MPI_Offset)(haddr_t)mpi_off)
+ ret_value=HADDR_UNDEF;
+ else
+ ret_value=(haddr_t)mpi_off;
+
+ FUNC_LEAVE(ret_value);
}
@@ -1386,8 +1470,17 @@ MPIOff_to_haddr(MPI_Offset mpi_off)
static herr_t
haddr_to_MPIOff(haddr_t addr, MPI_Offset *mpi_off/*out*/)
{
- if (mpi_off) *mpi_off = (MPI_Offset)addr;
- if (addr != (haddr_t)(MPI_Offset)addr) return -1;
- return 0;
+ herr_t ret_value=FAIL;
+
+ FUNC_ENTER(haddr_to_MPIOff, FAIL);
+
+ if (mpi_off)
+ *mpi_off = (MPI_Offset)addr;
+ if (addr != (haddr_t)(MPI_Offset)addr)
+ ret_value=FAIL;
+ else
+ ret_value=SUCCEED;
+
+ FUNC_LEAVE(ret_value);
}
#endif /*HAVE_PARALLEL*/
diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c
index bcae358..59c8f99 100644
--- a/src/H5FDmulti.c
+++ b/src/H5FDmulti.c
@@ -203,6 +203,9 @@ my_strdup(const char *s)
hid_t
H5FD_multi_init(void)
{
+ /* Clear the error stack */
+ H5Eclear();
+
if (H5I_VFL!=H5Iget_type(H5FD_MULTI_g)) {
H5FD_MULTI_g = H5FDregister(&H5FD_multi_g);
}
@@ -240,6 +243,9 @@ H5Pset_fapl_split(hid_t fapl, const char *meta_ext, hid_t meta_plist_id,
/*NO TRACE*/
+ /* Clear the error stack */
+ H5Eclear();
+
/* Initialize */
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
memb_map[mt] = (H5FD_MEM_DRAW==mt?mt:H5FD_MEM_SUPER);
@@ -358,11 +364,16 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map,
const char *_memb_name_ptrs[H5FD_MEM_NTYPES];
haddr_t _memb_addr[H5FD_MEM_NTYPES];
static const char *letters = "Xsbrglo";
+ static const char *func="H5FDset_fapl_multi"; /* Function Name for error reporting */
/*NO TRACE*/
+ /* Clear the error stack */
+ H5Eclear();
+
/* Check arguments and supply default values */
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "not a file access property list", -1);
if (!memb_map) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
_memb_map[mt] = H5FD_MEM_DEFAULT;
@@ -393,18 +404,20 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map,
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
/* Map usage type */
mmt = memb_map[mt];
- if (mmt<0 || mmt>=H5FD_MEM_NTYPES) return -1;
+ if (mmt<0 || mmt>=H5FD_MEM_NTYPES)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADRANGE, "file resource type out of range", -1);
if (H5FD_MEM_DEFAULT==mmt) mmt = mt;
/*
* All members of MEMB_FAPL must be either defaults or actual file
* access property lists.
*/
- if (H5P_DEFAULT!=memb_fapl[mmt] &&
- H5P_FILE_ACCESS!=H5Pget_class(memb_fapl[mmt])) return -1;
+ if (H5P_DEFAULT!=memb_fapl[mmt] && H5P_FILE_ACCESS!=H5Pget_class(memb_fapl[mmt]))
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "file resource type incorrect", -1);
/* All names must be defined */
- if (!memb_name[mmt] || !memb_name[mmt][0]) return -1;
+ if (!memb_name[mmt] || !memb_name[mmt][0])
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "file resource type not set", -1);
}
/*
@@ -445,15 +458,22 @@ H5Pget_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map/*out*/,
{
H5FD_multi_fapl_t *fa;
H5FD_mem_t mt;
+ static const char *func="H5FDget_fapl_multi"; /* Function Name for error reporting */
/*NO TRACE*/
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
- if (H5FD_MULTI!=H5Pget_driver(fapl_id)) return -1;
- if (NULL==(fa=H5Pget_driver_info(fapl_id))) return -1;
+ /* Clear the error stack */
+ H5Eclear();
+
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1);
+ if (H5FD_MULTI!=H5Pget_driver(fapl_id))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1);
+ if (NULL==(fa=H5Pget_driver_info(fapl_id)))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1);
if (memb_map) {
- memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t));
+ memcpy(memb_map, fa->memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t));
}
if (memb_fapl) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
@@ -509,15 +529,22 @@ H5Pset_dxpl_multi(hid_t dxpl_id, const hid_t *memb_dxpl)
{
H5FD_multi_dxpl_t dx;
H5FD_mem_t mt;
+ static const char *func="H5FDset_dxpl_multi"; /* Function Name for error reporting */
/*NO TRACE*/
+ /* Clear the error stack */
+ H5Eclear();
+
/* Check arguments */
- if (H5P_DATA_XFER!=H5Pget_class(dxpl_id)) return -1;
- if (!memb_dxpl) return -1;
+ if (H5P_DATA_XFER!=H5Pget_class(dxpl_id))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1);
+ if (!memb_dxpl)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid pointer", -1);
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
if (H5P_DEFAULT!=memb_dxpl[mt] &&
- H5P_DATA_XFER!=H5Pget_class(memb_dxpl[mt])) return -1;
+ H5P_DATA_XFER!=H5Pget_class(memb_dxpl[mt]))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a data transfer property list", -1);
}
/* Initialize the data transfer property list */
@@ -548,12 +575,19 @@ H5Pget_dxpl_multi(hid_t dxpl_id, hid_t *memb_dxpl/*out*/)
{
H5FD_multi_dxpl_t *dx;
H5FD_mem_t mt;
+ static const char *func="H5FDget_dxpl_multi"; /* Function Name for error reporting */
/*NO TRACE*/
- if (H5P_FILE_ACCESS!=H5Pget_class(dxpl_id)) return -1;
- if (H5FD_MULTI!=H5Pget_driver(dxpl_id)) return -1;
- if (NULL==(dx=H5Pget_driver_info(dxpl_id))) return -1;
+ /* Clear the error stack */
+ H5Eclear();
+
+ if (H5P_FILE_ACCESS!=H5Pget_class(dxpl_id))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1);
+ if (H5FD_MULTI!=H5Pget_driver(dxpl_id))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "incorrect VFL driver", -1);
+ if (NULL==(dx=H5Pget_driver_info(dxpl_id)))
+ H5Epush_ret(func, H5E_PLIST, H5E_BADVALUE, "bad VFL driver info", -1);
if (memb_dxpl) {
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
@@ -593,6 +627,9 @@ H5FD_multi_sb_size(H5FD_t *_file)
int nseen = 0;
hsize_t nbytes = 8; /*size of header*/
+ /* Clear the error stack */
+ H5Eclear();
+
/* How many unique files? */
UNIQUE_MEMBERS(file->fa.memb_map, mt) {
nseen++;
@@ -646,6 +683,10 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/,
int nseen;
size_t i;
H5FD_mem_t m;
+ static const char *func="H5FD_multi_sb_encode"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear();
/* Name and version number */
strcpy(name, "NCSAmulti");
@@ -676,7 +717,7 @@ H5FD_multi_sb_encode(H5FD_t *_file, char *name/*out*/,
} END_MEMBERS;
if (H5Tconvert(H5T_NATIVE_HADDR, H5T_STD_U64LE, nseen, buf+8, NULL,
H5P_DEFAULT)<0) {
- return -1;
+ H5Epush_ret(func, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1);
}
/* Encode all name templates */
@@ -727,9 +768,14 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
haddr_t memb_addr[H5FD_MEM_NTYPES];
haddr_t memb_eoa[H5FD_MEM_NTYPES];
haddr_t *ap;
+ static const char *func="H5FD_multi_sb_decode"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear();
/* Make sure the name/version number is correct */
- if (strcmp(name, "NCSAmult")) return -1;
+ if (strcmp(name, "NCSAmult"))
+ H5Epush_ret(func, H5E_FILE, H5E_BADVALUE, "invalid multi superblock", -1);
/* Set default values */
ALL_MEMBERS(mt) {
@@ -756,7 +802,8 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
memcpy(x, buf, nseen*2*8);
buf += nseen*2*8;
if (H5Tconvert(H5T_STD_U64LE, H5T_NATIVE_HADDR, nseen*2, x, NULL,
- H5P_DEFAULT)<0) return -1;
+ H5P_DEFAULT)<0)
+ H5Epush_ret(func, H5E_DATATYPE, H5E_CANTCONVERT, "can't convert superblock info", -1);
ap = (haddr_t*)x;
UNIQUE_MEMBERS(map, mt) {
memb_addr[_unmapped] = *ap++;
@@ -823,10 +870,12 @@ H5FD_multi_sb_decode(H5FD_t *_file, const char *name, const unsigned char *buf)
file->fa.memb_name[mt] = my_strdup(memb_name[mt]);
}
} END_MEMBERS;
- if (compute_next(file)<0) return -1;
+ if (compute_next(file)<0)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", -1);
/* Open all necessary files */
- if (open_members(file)<0) return -1;
+ if (open_members(file)<0)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", -1);
/* Set the EOA marker for all open files */
UNIQUE_MEMBERS(file->fa.memb_map, mt) {
@@ -863,6 +912,9 @@ H5FD_multi_fapl_get(H5FD_t *_file)
{
H5FD_multi_t *file = (H5FD_multi_t*)_file;
+ /* Clear the error stack */
+ H5Eclear();
+
return H5FD_multi_fapl_copy(&(file->fa));
}
@@ -890,9 +942,13 @@ H5FD_multi_fapl_copy(const void *_old_fa)
H5FD_multi_fapl_t *new_fa = malloc(sizeof(H5FD_multi_fapl_t));
H5FD_mem_t mt;
int nerrors = 0;
+ static const char *func="H5FD_multi_fapl_copy"; /* Function Name for error reporting */
assert(new_fa);
+ /* Clear the error stack */
+ H5Eclear();
+
memcpy(new_fa, old_fa, sizeof(H5FD_multi_fapl_t));
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
if (old_fa->memb_fapl[mt]>=0) {
@@ -907,12 +963,12 @@ H5FD_multi_fapl_copy(const void *_old_fa)
}
if (nerrors) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
- if (new_fa->memb_fapl[mt]>=0) H5Pclose(new_fa->memb_fapl[mt]);
- if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]);
- }
- free(new_fa);
- return NULL;
+ for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
+ if (new_fa->memb_fapl[mt]>=0) H5Pclose(new_fa->memb_fapl[mt]);
+ if (new_fa->memb_name[mt]) free(new_fa->memb_name[mt]);
+ }
+ free(new_fa);
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL);
}
return new_fa;
}
@@ -940,6 +996,9 @@ H5FD_multi_fapl_free(void *_fa)
H5FD_multi_fapl_t *fa = (H5FD_multi_fapl_t*)_fa;
H5FD_mem_t mt;
+ /* Clear the error stack */
+ H5Eclear();
+
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
if (fa->memb_fapl[mt]>=0) H5Pclose(fa->memb_fapl[mt]);
if (fa->memb_name[mt]) free(fa->memb_name[mt]);
@@ -972,9 +1031,13 @@ H5FD_multi_dxpl_copy(const void *_old_dx)
H5FD_multi_dxpl_t *new_dx = malloc(sizeof(H5FD_multi_dxpl_t));
H5FD_mem_t mt;
int nerrors = 0;
+ static const char *func="H5FD_multi_dxpl_copy"; /* Function Name for error reporting */
assert(new_dx);
+ /* Clear the error stack */
+ H5Eclear();
+
memcpy(new_dx, old_dx, sizeof(H5FD_multi_dxpl_t));
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
if (old_dx->memb_dxpl[mt]>=0) {
@@ -984,11 +1047,10 @@ H5FD_multi_dxpl_copy(const void *_old_dx)
}
if (nerrors) {
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
- H5Pclose(new_dx->memb_dxpl[mt]);
- }
- free(new_dx);
- return NULL;
+ for (mt=0; mt<H5FD_MEM_NTYPES; mt++)
+ H5Pclose(new_dx->memb_dxpl[mt]);
+ free(new_dx);
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "invalid freespace objects", NULL);
}
return new_dx;
}
@@ -1016,9 +1078,12 @@ H5FD_multi_dxpl_free(void *_dx)
H5FD_multi_dxpl_t *dx = (H5FD_multi_dxpl_t*)_dx;
H5FD_mem_t mt;
- for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
- if (dx->memb_dxpl[mt]>=0) H5Pclose(dx->memb_dxpl[mt]);
- }
+ /* Clear the error stack */
+ H5Eclear();
+
+ for (mt=0; mt<H5FD_MEM_NTYPES; mt++)
+ if (dx->memb_dxpl[mt]>=0)
+ H5Pclose(dx->memb_dxpl[mt]);
free(dx);
return 0;
}
@@ -1050,19 +1115,26 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
hid_t close_fapl=-1;
H5FD_multi_fapl_t *fa;
H5FD_mem_t m;
+ static const char *func="H5FD_multi_open"; /* Function Name for error reporting */
+ /* Clear the error stack */
+ H5Eclear();
+
/* Check arguments */
- if (!name || !*name) return NULL;
- if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL;
+ if (!name || !*name)
+ H5Epush_ret(func, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL);
+ if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ H5Epush_ret(func, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL);
/*
* Initialize the file from the file access properties, using default
* values if necessary.
*/
- if (NULL==(file=calloc(1, sizeof(H5FD_multi_t)))) return NULL;
+ if (NULL==(file=calloc(1, sizeof(H5FD_multi_t))))
+ H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL);
if (H5P_DEFAULT==fapl_id || H5FD_MULTI!=H5Pget_driver(fapl_id)) {
- close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE);
+ close_fapl = fapl_id = H5Pcreate(H5P_FILE_ACCESS);
+ H5Pset_fapl_multi(fapl_id, NULL, NULL, NULL, NULL, TRUE);
}
fa = H5Pget_driver_info(fapl_id);
assert(fa);
@@ -1083,20 +1155,23 @@ H5FD_multi_open(const char *name, unsigned flags, hid_t fapl_id,
file->fa.relax = fa->relax;
file->flags = flags;
file->name = my_strdup(name);
- if (close_fapl>=0) H5Pclose(close_fapl);
+ if (close_fapl>=0)
+ H5Pclose(close_fapl);
/* Compute derived properties and open member files */
- if (compute_next(file)<0) goto error;
- if (open_members(file)<0) goto error;
+ if (compute_next(file)<0)
+ H5Epush_goto(func, H5E_INTERNAL, H5E_BADVALUE, "compute_next() failed", error);
+ if (open_members(file)<0)
+ H5Epush_goto(func, H5E_INTERNAL, H5E_BADVALUE, "open_members() failed", error);
/* We must have opened at least the superblock file */
if (H5FD_MEM_DEFAULT==(m=file->fa.memb_map[H5FD_MEM_SUPER])) {
- m = H5FD_MEM_SUPER;
+ m = H5FD_MEM_SUPER;
}
if (NULL==file->memb[m]) goto error;
return (H5FD_t*)file;
- error:
+error:
/* Cleanup and fail */
if (file) {
ALL_MEMBERS(mt) {
@@ -1134,9 +1209,14 @@ H5FD_multi_close(H5FD_t *_file)
{
H5FD_multi_t *file = (H5FD_multi_t*)_file;
int nerrors=0;
+ static const char *func="H5FD_multi_close"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear();
/* Flush our own data */
- if (H5FD_multi_flush(_file)<0) nerrors++;
+ if (H5FD_multi_flush(_file)<0)
+ nerrors++;
/* Close as many members as possible */
ALL_MEMBERS(mt) {
@@ -1158,7 +1238,8 @@ H5FD_multi_close(H5FD_t *_file)
}
}
} END_MEMBERS;
- if (nerrors) return -1;
+ if (nerrors)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error closing member files", -1);
/* Clean up other stuff */
ALL_MEMBERS(mt) {
@@ -1200,6 +1281,9 @@ H5FD_multi_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
H5FD_mem_t mt;
int cmp=0;
+ /* Clear the error stack */
+ H5Eclear();
+
for (mt=0; mt<H5FD_MEM_NTYPES; mt++) {
if (f1->memb[mt] && f2->memb[mt]) break;
if (!cmp) {
@@ -1236,6 +1320,10 @@ static haddr_t
H5FD_multi_get_eoa(H5FD_t *_file)
{
H5FD_multi_t *file = (H5FD_multi_t*)_file;
+
+ /* Clear the error stack */
+ H5Eclear();
+
return file->eoa;
}
@@ -1265,6 +1353,10 @@ H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa)
H5FD_multi_t *file = (H5FD_multi_t*)_file;
H5FD_mem_t mt, mmt;
herr_t status;
+ static const char *func="H5FD_multi_set_eoa"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear();
/* Find the subfile in which the new EOA value falls */
for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
@@ -1283,7 +1375,8 @@ H5FD_multi_set_eoa(H5FD_t *_file, haddr_t eoa)
H5E_BEGIN_TRY {
status = H5FDset_eoa(file->memb[mmt], eoa-file->fa.memb_addr[mmt]);
} H5E_END_TRY;
- if (status<0) return -1;
+ if (status<0)
+ H5Epush_ret(func, H5E_FILE, H5E_BADVALUE, "member H5FDset_eoa failed", -1);
}
/* Save new eoa for return later */
@@ -1316,13 +1409,18 @@ H5FD_multi_get_eof(H5FD_t *_file)
{
H5FD_multi_t *file = (H5FD_multi_t*)_file;
haddr_t eof=0, tmp;
+ static const char *func="H5FD_multi_eof"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear();
UNIQUE_MEMBERS(file->fa.memb_map, mt) {
if (file->memb[mt]) {
H5E_BEGIN_TRY {
tmp = H5FDget_eof(file->memb[mt]);
} H5E_END_TRY;
- if (HADDR_UNDEF==tmp) return HADDR_UNDEF;
+ if (HADDR_UNDEF==tmp)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "member file has unknown eof", HADDR_UNDEF);
if (tmp>0) tmp += file->fa.memb_addr[mt];
} else if (file->fa.relax) {
@@ -1334,7 +1432,7 @@ H5FD_multi_get_eof(H5FD_t *_file)
assert(HADDR_UNDEF!=tmp);
} else {
- return HADDR_UNDEF;
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "bad eof", HADDR_UNDEF);
}
if (tmp>eof) eof = tmp;
@@ -1366,12 +1464,13 @@ H5FD_multi_alloc(H5FD_t *_file, H5FD_mem_t type, hsize_t size)
H5FD_multi_t *file = (H5FD_multi_t*)_file;
H5FD_mem_t mmt;
haddr_t addr;
+ static const char *func="H5FD_multi_alloc"; /* Function Name for error reporting */
mmt = file->fa.memb_map[type];
if (H5FD_MEM_DEFAULT==mmt) mmt = type;
if (HADDR_UNDEF==(addr=H5FDalloc(file->memb[mmt], type, size))) {
- return HADDR_UNDEF;
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "member file can't alloc", HADDR_UNDEF);
}
addr += file->fa.memb_addr[mmt];
if (addr+size>file->eoa) file->eoa = addr+size;
@@ -1401,6 +1500,9 @@ H5FD_multi_free(H5FD_t *_file, H5FD_mem_t type, haddr_t addr, hsize_t size)
H5FD_multi_t *file = (H5FD_multi_t*)_file;
H5FD_mem_t mmt;
+ /* Clear the error stack */
+ H5Eclear();
+
mmt = file->fa.memb_map[type];
if (H5FD_MEM_DEFAULT==mmt) mmt = type;
@@ -1438,6 +1540,9 @@ H5FD_multi_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
H5FD_mem_t mt, mmt, hi=H5FD_MEM_DEFAULT;
haddr_t start_addr=0;
+ /* Clear the error stack */
+ H5Eclear();
+
/* Get the data transfer properties */
if (H5P_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) {
dx = H5Pget_driver_info(dxpl_id);
@@ -1490,6 +1595,9 @@ H5FD_multi_write(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
H5FD_mem_t mt, mmt, hi=H5FD_MEM_DEFAULT;
haddr_t start_addr=0;
+ /* Clear the error stack */
+ H5Eclear();
+
/* Get the data transfer properties */
if (H5P_DEFAULT!=dxpl_id && H5FD_MULTI==H5Pget_driver(dxpl_id)) {
dx = H5Pget_driver_info(dxpl_id);
@@ -1537,6 +1645,7 @@ H5FD_multi_flush(H5FD_t *_file)
H5FD_multi_t *file = (H5FD_multi_t*)_file;
H5FD_mem_t mt;
int nerrors=0;
+ static const char *func="H5FD_multi_flush"; /* Function Name for error reporting */
#if 0
H5FD_mem_t mmt;
@@ -1570,6 +1679,9 @@ H5FD_multi_flush(H5FD_t *_file)
}
#endif
+ /* Clear the error stack */
+ H5Eclear();
+
/* Flush each file */
for (mt=1; mt<H5FD_MEM_NTYPES; mt++) {
if (file->memb[mt]) {
@@ -1578,8 +1690,10 @@ H5FD_multi_flush(H5FD_t *_file)
} H5E_END_TRY;
}
}
+ if (nerrors)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error flushing member files", -1);
- return nerrors ? -1 : 0;
+ return 0;
}
@@ -1603,6 +1717,9 @@ H5FD_multi_flush(H5FD_t *_file)
static int
compute_next(H5FD_multi_t *file)
{
+ /* Clear the error stack */
+ H5Eclear();
+
ALL_MEMBERS(mt) {
file->memb_next[mt] = HADDR_UNDEF;
} END_MEMBERS;
@@ -1645,7 +1762,11 @@ open_members(H5FD_multi_t *file)
{
char tmp[1024];
int nerrors=0;
+ static const char *func="(H5FD_multi)open_members"; /* Function Name for error reporting */
+ /* Clear the error stack */
+ H5Eclear();
+
UNIQUE_MEMBERS(file->fa.memb_map, mt) {
if (file->memb[mt]) continue; /*already open*/
assert(file->fa.memb_name[mt]);
@@ -1673,6 +1794,8 @@ open_members(H5FD_multi_t *file)
}
}
} END_MEMBERS;
+ if (nerrors)
+ H5Epush_ret(func, H5E_INTERNAL, H5E_BADVALUE, "error opening member files", -1);
- return nerrors?-1:0;
+ return 0;
}
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index 6f13a78..f91e594 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -12,21 +12,12 @@
* I/O from this driver with I/O from other parts of the
* application to the same file).
*/
-#include <H5private.h>
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <hdf5.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef WIN32
-#include <windows.h>
-#endif
-
-
+#include <H5private.h> /*library functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Fprivate.h> /*files */
+#include <H5FDsec2.h> /* Sec2 file driver */
+#include <H5MMprivate.h> /* Memory allocation */
+#include <H5Pprivate.h> /*property lists */
#ifdef MAX
#undef MAX
@@ -166,6 +157,11 @@ static const H5FD_class_t H5FD_sec2_g = {
H5FD_FLMAP_SINGLE, /*fl_map */
};
+/* Interface initialization */
+#define PABLO_MASK H5FD_sec2_mask
+#define INTERFACE_INIT H5FD_sec2_init
+static intn interface_initialize_g = 0;
+
/*-------------------------------------------------------------------------
* Function: H5FD_sec2_init
@@ -187,10 +183,12 @@ static const H5FD_class_t H5FD_sec2_g = {
hid_t
H5FD_sec2_init(void)
{
- if (H5I_VFL!=H5Iget_type(H5FD_SEC2_g)) {
- H5FD_SEC2_g = H5FDregister(&H5FD_sec2_g);
- }
- return H5FD_SEC2_g;
+ FUNC_ENTER(H5FD_sec2_init, FAIL);
+
+ if (H5I_VFL!=H5Iget_type(H5FD_SEC2_g))
+ H5FD_SEC2_g = H5FDregister(&H5FD_sec2_g);
+
+ FUNC_LEAVE(H5FD_SEC2_g);
}
@@ -213,9 +211,17 @@ H5FD_sec2_init(void)
herr_t
H5Pset_fapl_sec2(hid_t fapl_id)
{
+ herr_t ret_value=FAIL;
+
/*NO TRACE*/
- if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id)) return -1;
- return H5Pset_driver(fapl_id, H5FD_SEC2, NULL);
+ FUNC_ENTER(H5FD_set_fapl_sec2, FAIL);
+
+ if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
+ HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
+
+ ret_value= H5Pset_driver(fapl_id, H5FD_SEC2, NULL);
+
+ FUNC_LEAVE(ret_value);
}
@@ -251,26 +257,33 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id,
int results;
#endif
+ FUNC_ENTER(H5FD_sec2_open, NULL);
+
/* Check arguments */
- if (!name || !*name) return NULL;
- if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL;
- if (ADDR_OVERFLOW(maxaddr)) return NULL;
+ if (!name || !*name)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
+ if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ if (ADDR_OVERFLOW(maxaddr))
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");
/* Build the open flags */
o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
if (H5F_ACC_TRUNC & flags) o_flags |= O_TRUNC;
if (H5F_ACC_CREAT & flags) o_flags |= O_CREAT;
if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL;
- /* Open the file */
- if ((fd=HDopen(name, o_flags, 0666))<0) return NULL;
+ /* Open the file */
+ if ((fd=HDopen(name, o_flags, 0666))<0)
+ HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file");
if (fstat(fd, &sb)<0) {
- close(fd);
- return NULL;
+ close(fd);
+ HRETURN_ERROR(H5E_FILE, H5E_BADFILE, NULL, "can't fstat file");
}
/* Create the new file struct */
- file = calloc(1, sizeof(H5FD_sec2_t));
+ if (NULL==(file=H5MM_calloc(sizeof(H5FD_sec2_t))))
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct");
file->fd = fd;
file->eof = sb.st_size;
file->pos = HADDR_UNDEF;
@@ -284,7 +297,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id,
file->device = sb.st_dev;
file->inode = sb.st_ino;
#endif
- return (H5FD_t*)file;
+ FUNC_LEAVE((H5FD_t*)file);
}
@@ -309,10 +322,16 @@ H5FD_sec2_close(H5FD_t *_file)
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
- if (H5FD_sec2_flush(_file)<0) return -1;
- if (close(file->fd)<0) return -1;
- free(file);
- return 0;
+ FUNC_ENTER(H5FD_sec2_close, FAIL);
+
+ if (H5FD_sec2_flush(_file)<0)
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "can't flush file");
+ if (close(file->fd)<0)
+ HRETURN_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "can't close file");
+
+ H5MM_xfree(file);
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -339,21 +358,26 @@ H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
{
const H5FD_sec2_t *f1 = (const H5FD_sec2_t*)_f1;
const H5FD_sec2_t *f2 = (const H5FD_sec2_t*)_f2;
+ int ret_value=0;
+
+ FUNC_ENTER(H5FD_sec2_cmp, -2);
+
#ifdef WIN32
- if (f1->fileindexhi < f2->fileindexhi) return -1;
- if (f1->fileindexhi > f2->fileindexhi) return 1;
+ if (f1->fileindexhi < f2->fileindexhi) ret_value= -1;
+ if (f1->fileindexhi > f2->fileindexhi) ret_value= 1;
- if (f1->fileindexlo < f2->fileindexlo) return -1;
- if (f1->fileindexlo > f2->fileindexlo) return 1;
+ if (f1->fileindexlo < f2->fileindexlo) ret_value= -1;
+ if (f1->fileindexlo > f2->fileindexlo) ret_value= 1;
#else
- if (f1->device < f2->device) return -1;
- if (f1->device > f2->device) return 1;
+ if (f1->device < f2->device) ret_value= -1;
+ if (f1->device > f2->device) ret_value= 1;
- if (f1->inode < f2->inode) return -1;
- if (f1->inode > f2->inode) return 1;
+ if (f1->inode < f2->inode) ret_value= -1;
+ if (f1->inode > f2->inode) ret_value= 1;
#endif
- return 0;
+
+ FUNC_LEAVE(ret_value);
}
@@ -379,7 +403,10 @@ static haddr_t
H5FD_sec2_get_eoa(H5FD_t *_file)
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
- return file->eoa;
+
+ FUNC_ENTER(H5FD_sec2_get_eoa, HADDR_UNDEF);
+
+ FUNC_LEAVE(file->eoa);
}
@@ -405,8 +432,12 @@ static herr_t
H5FD_sec2_set_eoa(H5FD_t *_file, haddr_t addr)
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
+
+ FUNC_ENTER(H5FD_sec2_set_eoa, FAIL);
+
file->eoa = addr;
- return 0;
+
+ FUNC_LEAVE(SUCCEED);
}
@@ -434,7 +465,10 @@ static haddr_t
H5FD_sec2_get_eof(H5FD_t *_file)
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
- return MAX(file->eof, file->eoa);
+
+ FUNC_ENTER(H5FD_get_get_eof, HADDR_UNDEF);
+
+ FUNC_LEAVE(MAX(file->eof, file->eoa));
}
@@ -464,20 +498,25 @@ H5FD_sec2_read(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
ssize_t nbytes;
+ FUNC_ENTER(H5FD_sec2_read, FAIL);
+
assert(file && file->pub.cls);
assert(buf);
/* Check for overflow conditions */
- if (HADDR_UNDEF==addr) return -1;
- if (REGION_OVERFLOW(addr, size)) return -1;
- if (addr+size>file->eoa) return -1;
+ if (HADDR_UNDEF==addr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
+ if (REGION_OVERFLOW(addr, size))
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ if (addr+size>file->eoa)
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
/* Seek to the correct location */
if ((addr!=file->pos || OP_READ!=file->op) &&
- file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) {
- file->pos = HADDR_UNDEF;
- file->op = OP_UNKNOWN;
- return -1;
+ file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) {
+ file->pos = HADDR_UNDEF;
+ file->op = OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "can't seek to proper position");
}
/*
@@ -485,30 +524,31 @@ H5FD_sec2_read(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
* and the end of the file.
*/
while (size>0) {
- do nbytes = read(file->fd, buf, size);
- while (-1==nbytes && EINTR==errno);
- if (-1==nbytes) {
- /* error */
- file->pos = HADDR_UNDEF;
- file->op = OP_UNKNOWN;
- return -1;
- }
- if (0==nbytes) {
- /* end of file but not end of format address space */
- memset(buf, 0, size);
- size = 0;
- }
- assert(nbytes>=0);
- assert((hsize_t)nbytes<=size);
- size -= (hsize_t)nbytes;
- addr += (haddr_t)nbytes;
- buf = (char*)buf + nbytes;
+ do
+ nbytes = read(file->fd, buf, size);
+ while (-1==nbytes && EINTR==errno);
+ if (-1==nbytes) {
+ /* error */
+ file->pos = HADDR_UNDEF;
+ file->op = OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
+ }
+ if (0==nbytes) {
+ /* end of file but not end of format address space */
+ memset(buf, 0, size);
+ size = 0;
+ }
+ assert(nbytes>=0);
+ assert((hsize_t)nbytes<=size);
+ size -= (hsize_t)nbytes;
+ addr += (haddr_t)nbytes;
+ buf = (char*)buf + nbytes;
}
/* Update current position */
file->pos = addr;
file->op = OP_READ;
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -537,20 +577,25 @@ H5FD_sec2_write(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
ssize_t nbytes;
+ FUNC_ENTER(H5FD_sec2_write, FAIL);
+
assert(file && file->pub.cls);
assert(buf);
/* Check for overflow conditions */
- if (HADDR_UNDEF==addr) return -1;
- if (REGION_OVERFLOW(addr, size)) return -1;
- if (addr+size>file->eoa) return -1;
+ if (HADDR_UNDEF==addr)
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
+ if (REGION_OVERFLOW(addr, size))
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ if (addr+size>file->eoa)
+ HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
/* Seek to the correct location */
if ((addr!=file->pos || OP_WRITE!=file->op) &&
- file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) {
- file->pos = HADDR_UNDEF;
- file->op = OP_UNKNOWN;
- return -1;
+ file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0) {
+ file->pos = HADDR_UNDEF;
+ file->op = OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "can't seek to proper position");
}
/*
@@ -558,27 +603,29 @@ H5FD_sec2_write(H5FD_t *_file, hid_t UNUSED dxpl_id, haddr_t addr,
* results
*/
while (size>0) {
- do nbytes = write(file->fd, buf, size);
- while (-1==nbytes && EINTR==errno);
- if (-1==nbytes) {
- /* error */
- file->pos = HADDR_UNDEF;
- file->op = OP_UNKNOWN;
- return -1;
- }
- assert(nbytes>0);
- assert((hsize_t)nbytes<=size);
- size -= (hsize_t)nbytes;
- addr += (haddr_t)nbytes;
- buf = (const char*)buf + nbytes;
+ do
+ nbytes = write(file->fd, buf, size);
+ while (-1==nbytes && EINTR==errno);
+ if (-1==nbytes) {
+ /* error */
+ file->pos = HADDR_UNDEF;
+ file->op = OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
+ }
+ assert(nbytes>0);
+ assert((hsize_t)nbytes<=size);
+ size -= (hsize_t)nbytes;
+ addr += (haddr_t)nbytes;
+ buf = (const char*)buf + nbytes;
}
/* Update current position and eof */
file->pos = addr;
file->op = OP_WRITE;
- if (file->pos>file->eof) file->eof = file->pos;
+ if (file->pos>file->eof)
+ file->eof = file->pos;
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
@@ -604,13 +651,17 @@ H5FD_sec2_flush(H5FD_t *_file)
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
+ FUNC_ENTER(H5FD_sec2_seek, FAIL);
+
if (file->eoa>file->eof) {
- if (-1==file_seek(file->fd, file->eoa-1, SEEK_SET)) return -1;
- if (write(file->fd, "", 1)!=1) return -1;
- file->eof = file->eoa;
- file->pos = file->eoa;
- file->op = OP_WRITE;
+ if (-1==file_seek(file->fd, file->eoa-1, SEEK_SET))
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "can't seek to proper position");
+ if (write(file->fd, "", 1)!=1)
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
+ file->eof = file->eoa;
+ file->pos = file->eoa;
+ file->op = OP_WRITE;
}
- return 0;
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5FDstdio.c b/src/H5FDstdio.c
index ac8cdc2..0052b69 100644
--- a/src/H5FDstdio.c
+++ b/src/H5FDstdio.c
@@ -163,6 +163,9 @@ static const H5FD_class_t H5FD_stdio_g = {
hid_t
H5FD_stdio_init(void)
{
+ /* Clear the error stack */
+ H5Eclear();
+
if (H5I_VFL!=H5Iget_type(H5FD_STDIO_g))
H5FD_STDIO_g = H5FDregister(&H5FD_stdio_g);
return(H5FD_STDIO_g);
@@ -189,8 +192,13 @@ H5FD_stdio_init(void)
herr_t
H5Pset_fapl_stdio(hid_t fapl_id)
{
+ static const char *func="H5FDset_fapl_stdio"; /* Function Name for error reporting */
+
+ /* Clear the error stack */
+ H5Eclear();
+
if (H5P_FILE_ACCESS!=H5Pget_class(fapl_id))
- return -1;
+ H5Epush_ret(func, H5E_PLIST, H5E_BADTYPE, "not a file access property list", -1);
return(H5Pset_driver(fapl_id, H5FD_STDIO, NULL));
}
@@ -243,23 +251,26 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id,
/* Shut compiler up */
fapl_id=fapl_id;
+ /* Clear the error stack */
+ H5Eclear();
+
/* Check arguments */
- if (!name || !*name) return NULL;
- if (0==maxaddr || HADDR_UNDEF==maxaddr) return NULL;
- if (ADDR_OVERFLOW(maxaddr)) return NULL;
+ if (!name || !*name)
+ H5Epush_ret(func, H5E_ARGS, H5E_BADVALUE, "invalid file name", NULL);
+ if (0==maxaddr || HADDR_UNDEF==maxaddr)
+ H5Epush_ret(func, H5E_ARGS, H5E_BADRANGE, "bogus maxaddr", NULL);
+ if (ADDR_OVERFLOW(maxaddr))
+ H5Epush_ret(func, H5E_ARGS, H5E_OVERFLOW, "maxaddr too large", NULL);
if (access(name, F_OK) < 0) {
if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_RDWR)) {
f = fopen(name, "wb+");
write_access=1; /* Note the write access */
} else {
- H5Epush_ret(func, H5E_IO, H5E_CANTOPENFILE,
- "file doesn't exist and CREAT wasn't specified", NULL);
+ H5Epush_ret(func, H5E_IO, H5E_CANTOPENFILE, "file doesn't exist and CREAT wasn't specified", NULL);
}
} else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_EXCL)) {
- H5Epush_ret(func, H5E_IO, H5E_FILEEXISTS,
- "file exists but CREAT and EXCL were specified", NULL);
-
+ H5Epush_ret(func, H5E_IO, H5E_FILEEXISTS, "file exists but CREAT and EXCL were specified", NULL);
} else if (flags & H5F_ACC_RDWR) {
if (flags & H5F_ACC_TRUNC)
f = fopen(name, "wb+");
@@ -273,10 +284,8 @@ H5FD_stdio_open( const char *name, unsigned flags, hid_t fapl_id,
H5Epush_ret(func, H5E_IO, H5E_CANTOPENFILE, "fopen failed", NULL);
/* Build the return value */
- if (NULL==(file = calloc(1,sizeof(H5FD_stdio_t)))) {
- H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE,
- "memory allocation failed", NULL);
- }
+ if (NULL==(file = calloc(1,sizeof(H5FD_stdio_t))))
+ H5Epush_ret(func, H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed", NULL);
file->fp = f;
file->op = H5FD_STDIO_OP_SEEK;
file->pos = HADDR_UNDEF;
@@ -329,6 +338,9 @@ H5FD_stdio_close(H5FD_t *_file)
H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
static const char *func="H5FD_stdio_close"; /* Function Name for error reporting */
+ /* Clear the error stack */
+ H5Eclear();
+
if (H5FD_stdio_flush(_file)<0)
H5Epush_ret(func, H5E_IO, H5E_WRITEERROR, "flush failed", -1);
if (fclose(file->fp) < 0)
@@ -365,6 +377,9 @@ H5FD_stdio_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
const H5FD_stdio_t *f1 = (const H5FD_stdio_t*)_f1;
const H5FD_stdio_t *f2 = (const H5FD_stdio_t*)_f2;
+ /* Clear the error stack */
+ H5Eclear();
+
#ifdef WIN32
if (f1->fileindexhi < f2->fileindexhi) return -1;
if (f1->fileindexhi > f2->fileindexhi) return 1;
@@ -407,6 +422,9 @@ H5FD_stdio_get_eoa(H5FD_t *_file)
{
H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
+ /* Clear the error stack */
+ H5Eclear();
+
return(file->eoa);
}
@@ -435,6 +453,9 @@ H5FD_stdio_set_eoa(H5FD_t *_file, haddr_t addr)
{
H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
+ /* Clear the error stack */
+ H5Eclear();
+
file->eoa = addr;
return(0);
@@ -467,6 +488,9 @@ H5FD_stdio_get_eof(H5FD_t *_file)
{
H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
+ /* Clear the error stack */
+ H5Eclear();
+
return(MAX(file->eof, file->eoa));
}
@@ -506,6 +530,9 @@ H5FD_stdio_read(H5FD_t *_file, hid_t dxpl_id, haddr_t addr, hsize_t size,
/* Shut compiler up */
dxpl_id=dxpl_id;
+ /* Clear the error stack */
+ H5Eclear();
+
/* Check for overflow */
if (HADDR_UNDEF==addr)
H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1);
@@ -600,6 +627,9 @@ H5FD_stdio_write(H5FD_t *_file, hid_t dxpl_id, haddr_t addr,
/* Shut compiler up */
dxpl_id=dxpl_id;
+ /* Clear the error stack */
+ H5Eclear();
+
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
H5Epush_ret (func, H5E_IO, H5E_OVERFLOW, "file address overflowed", -1);
@@ -671,6 +701,9 @@ H5FD_stdio_flush(H5FD_t *_file)
H5FD_stdio_t *file = (H5FD_stdio_t*)_file;
static const char *func="H5FD_stdio_flush"; /* Function Name for error reporting */
+ /* Clear the error stack */
+ H5Eclear();
+
/* Only try to flush the file if we have write access */
if(file->write_access) {
/* Makes sure that the true file size is the same (or larger) than the end-of-address. */