summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5.c42
-rw-r--r--src/H5A.c389
-rw-r--r--src/H5AC.c246
-rw-r--r--src/H5B.c666
-rw-r--r--src/H5D.c37
-rw-r--r--src/H5Dcontig.c140
-rw-r--r--src/H5Distore.c295
-rw-r--r--src/H5Dseq.c20
-rw-r--r--src/H5E.c12
-rw-r--r--src/H5Eprivate.h16
-rw-r--r--src/H5F.c417
-rw-r--r--src/H5FD.c588
-rw-r--r--src/H5FDcore.c118
-rw-r--r--src/H5FDfamily.c109
-rw-r--r--src/H5FDgass.c97
-rw-r--r--src/H5FDlog.c119
-rw-r--r--src/H5FDmpio.c215
-rw-r--r--src/H5FDmpiposix.c60
-rw-r--r--src/H5FDsec2.c138
-rw-r--r--src/H5FDsrb.c158
-rw-r--r--src/H5FDstream.c266
-rw-r--r--src/H5FL.c47
-rw-r--r--src/H5Fcontig.c140
-rw-r--r--src/H5Fistore.c295
-rw-r--r--src/H5Fseq.c20
-rw-r--r--src/H5G.c1039
-rw-r--r--src/H5Gent.c62
-rw-r--r--src/H5Gnode.c339
-rw-r--r--src/H5Gstab.c83
-rw-r--r--src/H5HG.c124
-rw-r--r--src/H5HL.c233
-rw-r--r--src/H5I.c30
-rw-r--r--src/H5MF.c37
-rw-r--r--src/H5MM.c47
-rw-r--r--src/H5O.c664
-rw-r--r--src/H5Oattr.c65
-rw-r--r--src/H5Ocomp.c93
-rw-r--r--src/H5Ocont.c15
-rw-r--r--src/H5Odtype.c447
-rw-r--r--src/H5Oefl.c136
-rw-r--r--src/H5Ofill.c130
-rw-r--r--src/H5Olayout.c54
-rw-r--r--src/H5Omtime.c55
-rw-r--r--src/H5Oname.c44
-rw-r--r--src/H5Osdspace.c90
-rw-r--r--src/H5Oshared.c26
-rw-r--r--src/H5Ostab.c50
-rw-r--r--src/H5P.c253
-rw-r--r--src/H5R.c151
-rw-r--r--src/H5S.c233
-rw-r--r--src/H5Shyper.c185
-rw-r--r--src/H5Smpio.c121
-rw-r--r--src/H5Snone.c25
-rw-r--r--src/H5Spoint.c65
-rw-r--r--src/H5Sselect.c29
-rw-r--r--src/H5T.c2466
-rw-r--r--src/H5TB.c80
-rw-r--r--src/H5Tbit.c35
-rw-r--r--src/H5Tconv.c3586
-rw-r--r--src/H5Tvlen.c97
-rw-r--r--src/H5V.c30
-rw-r--r--src/H5Vprivate.h64
-rw-r--r--src/H5Z.c90
-rw-r--r--src/H5detect.c66
64 files changed, 7713 insertions, 8376 deletions
diff --git a/src/H5.c b/src/H5.c
index 529c4ba..3f7f34a 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -71,6 +71,8 @@ static int interface_initialize_g = 0;
herr_t
H5_init_library(void)
{
+ herr_t ret_value=SUCCEED;
+
FUNC_ENTER_NOAPI(H5_init_library, FAIL);
/*
@@ -115,28 +117,21 @@ H5_init_library(void)
* & dataset interfaces though, in order to provide them with the proper
* property classes.
*/
- if (H5P_init()<0) {
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to initialize property list interface");
- }
- if (H5F_init()<0) {
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to initialize file interface");
- }
- if (H5T_init()<0) {
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to initialize datatype interface");
- }
- if (H5D_init()<0) {
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to initialize dataset interface");
- }
+ if (H5P_init()<0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface");
+ if (H5F_init()<0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize file interface");
+ if (H5T_init()<0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize datatype interface");
+ if (H5D_init()<0)
+ HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize dataset interface");
/* Debugging? */
H5_debug_mask("-all");
H5_debug_mask(HDgetenv("HDF5_DEBUG"));
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -252,16 +247,19 @@ done:
herr_t
H5dont_atexit(void)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API_NOINIT(H5dont_atexit);
H5_trace(FALSE, "H5dont_atexit", "");
if (dont_atexit_g)
- HRETURN(FAIL);
+ HGOTO_DONE(FAIL);
dont_atexit_g = TRUE;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -495,6 +493,7 @@ H5check_version (unsigned majnum, unsigned minnum, unsigned relnum)
char lib_str[256];
char substr[] = H5_VERS_SUBRELEASE;
static int checked = 0;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API_NOINIT(H5check_version);
@@ -513,7 +512,7 @@ H5check_version (unsigned majnum, unsigned minnum, unsigned relnum)
}
if (checked)
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
checked = 1;
/*
@@ -539,7 +538,8 @@ H5check_version (unsigned majnum, unsigned minnum, unsigned relnum)
H5_VERS_SUBRELEASE, H5_VERS_INFO);
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5A.c b/src/H5A.c
index 42190e1..a9efaec 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -60,18 +60,18 @@ DESCRIPTION
static herr_t
H5A_init_interface(void)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5A_init_interface);
/*
* Create attribute group.
*/
- if (H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS,
- (H5I_free_t)H5A_close)<0) {
- HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to initialize interface");
- }
+ if (H5I_init_group(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS, (H5I_free_t)H5A_close)<0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to initialize interface");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -163,28 +163,22 @@ H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
H5TRACE5("i","isiii",loc_id,name,type_id,space_id,plist_id);
/* check arguments */
- if (H5I_FILE==H5I_get_type(loc_id) ||
- H5I_ATTR==H5I_get_type(loc_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "location is not valid for an attribute");
- }
- if (NULL==(ent=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute");
+ if (NULL==(ent=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
if (NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type");
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
/* Go do the real work for attaching the attribute to the dataset */
- if ((ret_value=H5A_create(ent,name,type,space))<0) {
- HRETURN_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL,
- "unable to create attribute");
- }
+ if ((ret_value=H5A_create(ent,name,type,space))<0)
+ HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute");
+done:
FUNC_LEAVE(ret_value);
} /* H5Acreate() */
@@ -228,15 +222,22 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
/* Build the attribute information */
if((attr = H5MM_calloc(sizeof(H5A_t)))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for attribute info");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for attribute info");
+
+ /* Copy the attribute name */
attr->name=HDstrdup(name);
+
+ /* Copy the attribute's datatype */
attr->dt=H5T_copy(type, H5T_COPY_ALL);
+
/* Mark any VL datatypes as being on disk now */
- if (H5T_vlen_mark(attr->dt, ent->file, H5T_VLEN_DISK)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
- }
+ if (H5T_vlen_mark(attr->dt, ent->file, H5T_VLEN_DISK)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
+
+ /* Copy the dataspace for the attribute */
attr->ds=H5S_copy(space);
+
+ /* Mark it initially set to initialized */
attr->initialized = TRUE; /*for now, set to false later*/
/* Copy the symbol table entry */
@@ -261,8 +262,7 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
*/
if(HDstrcmp(found_attr.name,attr->name)==0) {
H5O_reset (H5O_ATTR, &found_attr);
- HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, FAIL,
- "attribute already exists");
+ HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, FAIL, "attribute already exists");
}
H5O_reset (H5O_ATTR, &found_attr);
seq++;
@@ -271,22 +271,20 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
/* Create the attribute message and save the attribute index */
if (H5O_modify(&(attr->ent), H5O_ATTR, H5O_NEW_MESG, 0, attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL,
- "unable to update attribute header messages");
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages");
/* Register the new attribute and get an ID for it */
- if ((ret_value = H5I_register(H5I_ATTR, attr)) < 0) {
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register attribute for ID");
- }
+ if ((ret_value = H5I_register(H5I_ATTR, attr)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID");
/* Now it's safe to say it's uninitialized */
attr->initialized = FALSE;
done:
if (ret_value < 0) {
- if(attr) H5A_close(attr);
- }
+ if(attr)
+ H5A_close(attr);
+ } /* end if */
FUNC_LEAVE(ret_value);
} /* H5A_create() */
@@ -316,7 +314,8 @@ static int
H5A_get_index(H5G_entry_t *ent, const char *name)
{
H5A_t found_attr;
- int ret_value=FAIL, i;
+ int i; /* Index variable */
+ int ret_value=FAIL; /* Return value */
FUNC_ENTER_NOINIT(H5A_get_index);
@@ -340,11 +339,10 @@ H5A_get_index(H5G_entry_t *ent, const char *name)
}
H5E_clear ();
- if(ret_value<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL,
- "attribute not found");
- }
+ if(ret_value<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found");
+done:
FUNC_LEAVE(ret_value);
} /* H5A_get_index() */
@@ -380,34 +378,28 @@ H5Aopen_name(hid_t loc_id, const char *name)
{
H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute*/
int idx=0;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Aopen_name, FAIL);
H5TRACE2("i","is",loc_id,name);
/* check arguments */
- if (H5I_FILE==H5I_get_type(loc_id) ||
- H5I_ATTR==H5I_get_type(loc_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "location is not valid for an attribute");
- }
- if (NULL==(ent=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute");
+ if (NULL==(ent=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
/* Look up the attribute for the object */
if((idx=H5A_get_index(ent,name))<0)
- HRETURN_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "attribute not found");
+ HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "attribute not found");
/* Go do the real work for opening the attribute */
- if ((ret_value=H5A_open(ent, (unsigned)idx))<0) {
- HRETURN_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL,
- "unable to open attribute");
- }
+ if ((ret_value=H5A_open(ent, (unsigned)idx))<0)
+ HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute");
+done:
FUNC_LEAVE(ret_value);
} /* H5Aopen_name() */
@@ -443,27 +435,22 @@ hid_t
H5Aopen_idx(hid_t loc_id, unsigned idx)
{
H5G_entry_t *ent = NULL; /*Symtab entry of object to attribute */
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Aopen_idx, FAIL);
H5TRACE2("i","iIu",loc_id,idx);
/* check arguments */
- if (H5I_FILE==H5I_get_type(loc_id) ||
- H5I_ATTR==H5I_get_type(loc_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "location is not valid for an attribute");
- }
- if (NULL==(ent=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
+ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute");
+ if (NULL==(ent=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
/* Go do the real work for opening the attribute */
- if ((ret_value=H5A_open(ent, idx))<0) {
- HRETURN_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL,
- "unable to open attribute");
- }
+ if ((ret_value=H5A_open(ent, idx))<0)
+ HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute");
+done:
FUNC_LEAVE(ret_value);
} /* H5Aopen_idx() */
@@ -551,26 +538,24 @@ H5Awrite(hid_t attr_id, hid_t type_id, const void *buf)
{
H5A_t *attr = NULL;
const H5T_t *mem_type = NULL;
- herr_t ret_value = FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Awrite, FAIL);
H5TRACE3("e","iix",attr_id,type_id,buf);
/* check arguments */
if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
if (NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (NULL == buf) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (NULL == buf)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer");
/* Go write the actual data to the attribute */
- if ((ret_value=H5A_write(attr,mem_type,buf))<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL,
- "unable to write attribute");
- }
+ if ((ret_value=H5A_write(attr,mem_type,buf))<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute");
+done:
FUNC_LEAVE(ret_value);
} /* H5Awrite() */
@@ -701,26 +686,24 @@ H5Aread(hid_t attr_id, hid_t type_id, void *buf)
{
H5A_t *attr = NULL;
const H5T_t *mem_type = NULL;
- herr_t ret_value = FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Aread, FAIL);
H5TRACE3("e","iix",attr_id,type_id,buf);
/* check arguments */
if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
if (NULL == (mem_type = H5I_object_verify(type_id, H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (NULL == buf) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (NULL == buf)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer");
/* Go write the actual data to the attribute */
- if ((ret_value=H5A_read(attr,mem_type,buf))<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_READERROR, FAIL,
- "unable to read attribute");
- }
+ if ((ret_value=H5A_read(attr,mem_type,buf))<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute");
+done:
FUNC_LEAVE(ret_value);
} /* H5Aread() */
@@ -842,27 +825,24 @@ H5Aget_space(hid_t attr_id)
{
H5A_t *attr = NULL;
H5S_t *dst = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Aget_space, FAIL);
H5TRACE1("i","i",attr_id);
/* check arguments */
if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
/* Copy the attribute's dataspace */
- if (NULL==(dst=H5S_copy (attr->ds))) {
- HRETURN_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL,
- "unable to copy dataspace");
- }
+ if (NULL==(dst=H5S_copy (attr->ds)))
+ HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy dataspace");
/* Atomize */
- if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register dataspace atom");
- }
+ if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0)
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom");
+done:
FUNC_LEAVE(ret_value);
} /* H5Aget_space() */
@@ -895,43 +875,40 @@ H5Aget_space(hid_t attr_id)
hid_t
H5Aget_type(hid_t attr_id)
{
- H5A_t *attr = NULL;
+ H5A_t *attr = NULL;
H5T_t *dst = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Aget_type, FAIL);
H5TRACE1("i","i",attr_id);
/* check arguments */
if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
/*
* Copy the attribute's data type. If the type is a named type then
* reopen the type before returning it to the user. Make the type
* read-only.
*/
- if (NULL==(dst=H5T_copy(attr->dt, H5T_COPY_REOPEN))) {
- HRETURN_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL,
- "unable to copy datatype");
- }
+ if (NULL==(dst=H5T_copy(attr->dt, H5T_COPY_REOPEN)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy datatype");
+
/* Mark any VL datatypes as being in memory now */
- if (H5T_vlen_mark(dst, NULL, H5T_VLEN_MEMORY)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "invalid VL location");
- }
- if (H5T_lock(dst, FALSE)<0) {
- H5T_close(dst);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to lock transient data type");
- }
+ if (H5T_vlen_mark(dst, NULL, H5T_VLEN_MEMORY)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
+ if (H5T_lock(dst, FALSE)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type");
/* Atomize */
- if ((ret_value=H5I_register(H5I_DATATYPE, dst))<0) {
- H5T_close(dst);
- HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register datatype atom");
- }
+ if ((ret_value=H5I_register(H5I_DATATYPE, dst))<0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
+
+done:
+ if(ret_value<0) {
+ if(dst!=NULL)
+ H5T_close(dst);
+ } /* end if */
FUNC_LEAVE(ret_value);
} /* H5Aget_type() */
@@ -965,17 +942,16 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf)
{
H5A_t *attr = NULL;
size_t copy_len, nbytes;
- ssize_t ret_value = FAIL;
+ ssize_t ret_value;
FUNC_ENTER_API(H5Aget_name, FAIL);
H5TRACE3("Zs","izs",attr_id,buf_size,buf);
/* check arguments */
if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
- if (!buf || buf_size<1) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
+ if (!buf || buf_size<1)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer");
/* get the real attribute length */
nbytes = HDstrlen(attr->name);
@@ -990,7 +966,10 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf)
/* Terminate the string */
buf[copy_len]='\0';
+ /* Set return value */
ret_value = (ssize_t)nbytes;
+
+done:
FUNC_LEAVE(ret_value);
} /* H5Aget_type() */
@@ -1021,41 +1000,35 @@ H5Aget_num_attrs(hid_t loc_id)
{
H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */
void *obj = NULL;
- int ret_value = 0;
+ int ret_value;
FUNC_ENTER_API(H5Aget_num_attrs, FAIL);
H5TRACE1("Is","i",loc_id);
/* check arguments */
- if (H5I_FILE==H5I_get_type(loc_id) ||
- H5I_ATTR==H5I_get_type(loc_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "location is not valid for an attribute");
- }
- if(NULL == (obj = H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
- }
+ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute");
+ if(NULL == (obj = H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom");
switch (H5I_get_type (loc_id)) {
- case H5I_DATASET:
- ent = H5D_entof ((H5D_t*)obj);
- break;
- case H5I_DATATYPE:
- if (NULL==(ent=H5T_entof ((H5T_t*)obj))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "target data type is not committed");
- }
- break;
- case H5I_GROUP:
- ent = H5G_entof ((H5G_t*)obj);
- break;
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "inappropriate attribute target");
+ case H5I_DATASET:
+ ent = H5D_entof ((H5D_t*)obj);
+ break;
+ case H5I_DATATYPE:
+ if (NULL==(ent=H5T_entof ((H5T_t*)obj)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "target data type is not committed");
+ break;
+ case H5I_GROUP:
+ ent = H5G_entof ((H5G_t*)obj);
+ break;
+ default:
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "inappropriate attribute target");
}
/* Look up the attribute for the object */
ret_value=H5O_count(ent, H5O_ATTR);
+done:
FUNC_LEAVE(ret_value);
} /* H5Aget_num_attrs() */
@@ -1111,21 +1084,17 @@ H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data)
{
H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */
H5A_t found_attr;
- herr_t ret_value = 0;
+ herr_t ret_value = FAIL;
int idx;
FUNC_ENTER_API(H5Aiterate, FAIL);
H5TRACE4("e","i*Iuxx",loc_id,attr_num,op,op_data);
/* check arguments */
- if (H5I_FILE==H5I_get_type(loc_id) ||
- H5I_ATTR==H5I_get_type(loc_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "location is not valid for an attribute");
- }
- if (NULL==(ent=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
+ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute");
+ if (NULL==(ent=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
/*
* Look up the attribute for the object. Make certain the start point is
@@ -1147,7 +1116,10 @@ H5Aiterate(hid_t loc_id, unsigned *attr_num, H5A_operator_t op, void *op_data)
H5E_clear ();
}
- if (attr_num) *attr_num = (unsigned)idx;
+ if (attr_num)
+ *attr_num = (unsigned)idx;
+
+done:
FUNC_LEAVE(ret_value);
} /* H5Aiterate() */
@@ -1183,23 +1155,18 @@ H5Adelete(hid_t loc_id, const char *name)
H5A_t found_attr;
H5G_entry_t *ent = NULL; /*symtab ent of object to attribute */
int idx=0, found=-1;
- herr_t ret_value = FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Aopen_name, FAIL);
H5TRACE2("e","is",loc_id,name);
/* check arguments */
- if (H5I_FILE==H5I_get_type(loc_id) ||
- H5I_ATTR==H5I_get_type(loc_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "location is not valid for an attribute");
- }
- if (NULL==(ent=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (H5I_FILE==H5I_get_type(loc_id) || H5I_ATTR==H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute");
+ if (NULL==(ent=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
/* Look up the attribute for the object */
idx=0;
@@ -1217,16 +1184,14 @@ H5Adelete(hid_t loc_id, const char *name)
idx++;
}
H5E_clear ();
- if (found<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found");
- }
+ if (found<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "attribute not found");
/* Delete the attribute from the location */
- if ((ret_value=H5O_remove(ent, H5O_ATTR, found)) < 0) {
- HRETURN_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL,
- "unable to delete attribute header message");
- }
+ if ((ret_value=H5O_remove(ent, H5O_ATTR, found)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute header message");
+done:
FUNC_LEAVE(ret_value);
} /* H5Adelete() */
@@ -1251,17 +1216,20 @@ H5Adelete(hid_t loc_id, const char *name)
herr_t
H5Aclose(hid_t attr_id)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5Aclose, FAIL);
H5TRACE1("e","i",attr_id);
/* check arguments */
if (NULL == H5I_object_verify(attr_id, H5I_ATTR))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute");
/* Decrement references to that atom (and close it) */
H5I_dec_ref (attr_id);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* H5Aclose() */
@@ -1285,6 +1253,7 @@ H5A_t *
H5A_copy(const H5A_t *old_attr)
{
H5A_t *new_attr=NULL;
+ H5A_t *ret_value=NULL; /* Return value */
FUNC_ENTER_NOAPI(H5A_copy, NULL);
@@ -1292,10 +1261,8 @@ H5A_copy(const H5A_t *old_attr)
assert(old_attr);
/* get space */
- if (NULL==(new_attr = H5MM_calloc(sizeof(H5A_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(new_attr = H5MM_calloc(sizeof(H5A_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Copy the top level of the attribute */
*new_attr = *old_attr;
@@ -1308,18 +1275,25 @@ H5A_copy(const H5A_t *old_attr)
new_attr->dt=H5T_copy(old_attr->dt, H5T_COPY_ALL);
new_attr->ds=H5S_copy(old_attr->ds);
if(old_attr->data) {
- if (NULL==(new_attr->data=H5MM_malloc(old_attr->data_size))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(new_attr->data=H5MM_malloc(old_attr->data_size)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy(new_attr->data,old_attr->data,old_attr->data_size);
} /* end if */
#ifndef LATER
/* Copy the share info? */
#endif
+
+ /* Set the return value */
+ ret_value=new_attr;
- FUNC_LEAVE(new_attr);
+done:
+ if(ret_value==NULL) {
+ if(new_attr!=NULL)
+ H5A_close(new_attr);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -1340,6 +1314,8 @@ H5A_copy(const H5A_t *old_attr)
herr_t
H5A_close(H5A_t *attr)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5A_close, FAIL);
assert(attr);
@@ -1347,16 +1323,12 @@ H5A_close(H5A_t *attr)
/* Check if the attribute has any data yet, if not, fill with zeroes */
if(attr->ent_opened && !attr->initialized) {
uint8_t *tmp_buf=H5MM_calloc(attr->data_size);
- if (NULL == tmp_buf) {
- HRETURN_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL,
- "memory allocation failed for attribute fill-value");
- }
+ if (NULL == tmp_buf)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOSPACE, FAIL, "memory allocation failed for attribute fill-value");
/* Go write the fill data to the attribute */
- if (H5A_write(attr,attr->dt,tmp_buf)<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL,
- "unable to write attribute");
- }
+ if (H5A_write(attr,attr->dt,tmp_buf)<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute");
/* Free temporary buffer */
H5MM_xfree(tmp_buf);
@@ -1365,12 +1337,16 @@ H5A_close(H5A_t *attr)
/* Free dynamicly allocated items */
if(attr->name)
H5MM_xfree(attr->name);
- if(attr->dt) H5T_close(attr->dt);
- if(attr->ds) H5S_close(attr->ds);
- if(attr->data) H5MM_xfree(attr->data);
+ if(attr->dt)
+ H5T_close(attr->dt);
+ if(attr->ds)
+ H5S_close(attr->ds);
+ if(attr->data)
+ H5MM_xfree(attr->data);
/* Close the object's symbol-table entry */
- if(attr->ent_opened) H5O_close(&(attr->ent));
+ if(attr->ent_opened)
+ H5O_close(&(attr->ent));
#ifndef LATER
/* Do something with the shared information? */
@@ -1378,7 +1354,8 @@ H5A_close(H5A_t *attr)
H5MM_xfree(attr);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5AC.c b/src/H5AC.c
index bb4b43e..9a0f7f6 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -95,6 +95,7 @@ H5AC_init_interface(void)
H5P_genplist_t *xfer_plist; /* Dataset transfer property list object */
unsigned block_before_meta_write=1; /* Custom value for "block before meta write" property */
#endif /* H5_HAVE_PARALLEL */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5AC_init_interface);
@@ -103,23 +104,24 @@ H5AC_init_interface(void)
/* Get the dataset transfer property list class object */
if (NULL == (xfer_pclass = H5I_object_verify(H5P_CLS_DATASET_XFER_g, H5I_GENPROP_CLS)))
- HRETURN_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list class");
+ HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list class");
/* Create a new dataset transfer property list */
if ((H5AC_dxpl_id=H5P_create_id(xfer_pclass)) < 0)
- HRETURN_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list");
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list");
#ifdef H5_HAVE_PARALLEL
/* Get the property list object */
if (NULL == (xfer_plist = H5I_object(H5AC_dxpl_id)))
- HRETURN_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object");
+ HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object");
/* Insert 'block before metadata write' property */
if(H5P_insert(xfer_plist,H5AC_BLOCK_BEFORE_META_WRITE_NAME,H5AC_BLOCK_BEFORE_META_WRITE_SIZE,&block_before_meta_write,NULL,NULL,NULL,NULL,NULL)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property");
#endif /* H5_HAVE_PARALLEL */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5AC_init_interface() */
@@ -196,6 +198,7 @@ int
H5AC_create(H5F_t *f, int size_hint)
{
H5AC_t *cache = NULL;
+ int ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5AC_create, FAIL);
@@ -203,26 +206,36 @@ H5AC_create(H5F_t *f, int size_hint)
assert(NULL == f->shared->cache);
if (size_hint < 1) size_hint = H5AC_NSLOTS;
- if (NULL==(f->shared->cache = cache = H5FL_ALLOC(H5AC_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(f->shared->cache = cache = H5FL_ALLOC(H5AC_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
cache->nslots = size_hint;
cache->slot = H5FL_ARR_ALLOC(H5AC_info_ptr_t,cache->nslots,1);
- if (NULL==cache->slot) {
- f->shared->cache = H5FL_FREE (H5AC_t,f->shared->cache);
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- }
+ if (NULL==cache->slot)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
#ifdef H5AC_DEBUG
- if ((cache->prot = H5FL_ARR_ALLOC(H5AC_prot_t,cache->nslots,1))==NULL) {
- cache->slot = H5FL_ARR_FREE (H5AC_info_ptr_t,cache->slot);
- f->shared->cache = H5FL_FREE (H5AC_t,f->shared->cache);
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
- }
+ if ((cache->prot = H5FL_ARR_ALLOC(H5AC_prot_t,cache->nslots,1))==NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
#endif /* H5AC_DEBUG */
- FUNC_LEAVE(size_hint);
+ /* Set return value */
+ ret_value=size_hint;
+
+done:
+ if(ret_value<0) {
+ if(cache!=NULL) {
+ if(cache->slot !=NULL)
+ cache->slot = H5FL_ARR_FREE (H5AC_info_ptr_t,cache->slot);
+#ifdef H5AC_DEBUG
+ if(cache->prot !=NULL)
+ cache->prot = H5FL_ARR_FREE (H5AC_prot_t,cache->prot);
+#endif /* H5AC_DEBUG */
+ f->shared->cache = H5FL_FREE (H5AC_t,f->shared->cache);
+ } /* end if */
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_dest
@@ -244,7 +257,8 @@ H5AC_create(H5F_t *f, int size_hint)
herr_t
H5AC_dest(H5F_t *f)
{
- H5AC_t *cache = NULL;
+ H5AC_t *cache = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5AC_dest, FAIL);
@@ -252,10 +266,9 @@ H5AC_dest(H5F_t *f)
assert(f->shared->cache);
cache = f->shared->cache;
- if (H5AC_flush(f, NULL, HADDR_UNDEF, TRUE) < 0) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "unable to flush cache");
- }
+ if (H5AC_flush(f, NULL, HADDR_UNDEF, TRUE) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache");
+
#ifdef H5AC_DEBUG
{
unsigned i;
@@ -271,8 +284,11 @@ H5AC_dest(H5F_t *f)
cache->slot = H5FL_ARR_FREE(H5AC_info_ptr_t,cache->slot);
cache->nslots = 0;
f->shared->cache = cache = H5FL_FREE(H5AC_t,cache);
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_find_f
@@ -329,6 +345,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
H5AC_flush_func_t flush;
H5AC_info_t **info = NULL;
H5AC_t *cache = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5AC_find, NULL);
@@ -347,7 +364,7 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
*/
if ((*info) && (*info)->type == type && H5F_addr_eq((*info)->addr, addr)) {
cache->diagnostics[type->id].nhits++;
- HRETURN(*info);
+ HGOTO_DONE(*info);
}
cache->diagnostics[type->id].nmisses++;
@@ -355,10 +372,9 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
* Fail if the item in the cache is at the correct address but is
* of the wrong type.
*/
- if ((*info) && (*info)->type && (*info)->type != type && H5F_addr_eq((*info)->addr, addr)) {
- HRETURN_ERROR(H5E_CACHE, H5E_BADTYPE, NULL,
- "internal error (correct address, wrong type)");
- }
+ if ((*info) && (*info)->type && (*info)->type != type && H5F_addr_eq((*info)->addr, addr))
+ HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "internal error (correct address, wrong type)");
+
#ifdef H5AC_DEBUG
/*
* Check that the requested thing isn't protected, for protected things
@@ -380,9 +396,9 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
* Load a new thing. If it can't be loaded, then return an error
* without preempting anything.
*/
- if (NULL == (thing = (type->load)(f, H5P_DATASET_XFER_DEFAULT, addr, udata1, udata2))) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load object");
- }
+ if (NULL == (thing = (type->load)(f, H5P_DATASET_XFER_DEFAULT, addr, udata1, udata2)))
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load object");
+
/*
* Free the previous cache entry if there is one.
*/
@@ -396,15 +412,13 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
* The old thing could not be removed from the stack.
* Release the new thing and fail.
*/
- if ((type->flush)(f, H5AC_dxpl_id, TRUE, addr, thing) < 0) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL,
- "unable to flush just-loaded object");
- }
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL,
- "unable to flush existing cached object");
+ if ((type->flush)(f, H5AC_dxpl_id, TRUE, addr, thing) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "unable to flush just-loaded object");
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "unable to flush existing cached object");
}
cache->diagnostics[type_id].nflushes++;
}
+
/*
* Make the cache point to the new thing.
*/
@@ -412,8 +426,13 @@ H5AC_find_f(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
(*info)->type = type;
(*info)->addr = addr;
- FUNC_LEAVE(thing);
+ /* Set the return value */
+ ret_value=thing;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_compare
@@ -439,6 +458,7 @@ H5AC_compare(const void *_a, const void *_b)
{
int a = *((const int *) _a);
int b = *((const int *) _b);
+ int ret_value=0;
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5AC_compare);
@@ -448,31 +468,32 @@ H5AC_compare(const void *_a, const void *_b)
if(NULL==current_cache_g->slot[a] || NULL == current_cache_g->slot[b]) {
if(NULL==current_cache_g->slot[a]) {
if (NULL == current_cache_g->slot[b]) {
- HRETURN(0);
- } else {
- HRETURN(-1);
- }
+ HGOTO_DONE(0);
+ } else
+ HGOTO_DONE(-1);
}
else {
- HRETURN(1);
+ HGOTO_DONE(1);
}
}
else if (NULL == current_cache_g->slot[a]->type) {
if (NULL == current_cache_g->slot[b]->type) {
- HRETURN(0);
- } else {
- HRETURN(-1);
- }
+ HGOTO_DONE(0);
+ } else
+ HGOTO_DONE(-1);
} else if (NULL == current_cache_g->slot[b]->type) {
- HRETURN(1);
+ HGOTO_DONE(1);
} else if (current_cache_g->slot[a]->addr < current_cache_g->slot[b]->addr) {
- HRETURN(-1);
+ HGOTO_DONE(-1);
} else if (current_cache_g->slot[a]->addr > current_cache_g->slot[b]->addr) {
- HRETURN(1);
+ HGOTO_DONE(1);
}
- FUNC_LEAVE(0);
+
+done:
+ FUNC_LEAVE(ret_value);
}
#endif
+
/*-------------------------------------------------------------------------
* Function: H5AC_flush
@@ -512,6 +533,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
#endif /* H5AC_SORT_BY_ADDR */
unsigned nslots;
H5AC_t *cache = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5AC_flush, FAIL);
@@ -527,10 +549,8 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
* Sort the cache entries by address since flushing them in
* ascending order by address may be much more efficient.
*/
- if (NULL==(map=H5FL_ARR_ALLOC(int,cache->nslots,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(map=H5FL_ARR_ALLOC(int,cache->nslots,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
for (i = nslots = 0; i < cache->nslots; i++) {
if (cache->slot[i]!=NULL)
map[nslots++] = i;
@@ -540,9 +560,8 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
HDqsort(map, nslots, sizeof(int), H5AC_compare);
current_cache_g = NULL;
#ifdef NDEBUG
- for (i = 1; i < nslots; i++) {
+ for (i = 1; i < nslots; i++)
assert(H5F_addr_lt(cache->slot[i - 1]->addr, cache->slot[i]->addr));
- }
#endif
#else /* H5AC_SORT_BY_ADDR */
nslots = cache->nslots;
@@ -577,8 +596,7 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
#ifdef H5AC_SORT_BY_ADDR
map = H5FL_ARR_FREE(int,map);
#endif /* H5AC_SORT_BY_ADDR */
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "unable to flush cache");
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache");
}
cache->diagnostics[type_id].nflushes++;
if (destroy)
@@ -593,10 +611,8 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
* If there are protected object then fail. However, everything
* else should have been flushed.
*/
- if (cache->nprots > 0) {
- HRETURN_ERROR(H5E_CACHE, H5E_PROTECT, FAIL,
- "cache has protected items");
- }
+ if (cache->nprots > 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_PROTECT, FAIL, "cache has protected items");
} else {
i = H5AC_HASH(f, addr);
if (cache->slot[i] && (!type || cache->slot[i]->type == type) &&
@@ -608,20 +624,19 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
* Flush just this entry.
*/
flush = cache->slot[i]->type->flush;
- status = (flush)(f, H5AC_dxpl_id, destroy, cache->slot[i]->addr,
- cache->slot[i]);
- if (status < 0) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "unable to flush object");
- }
+ if ((flush)(f, H5AC_dxpl_id, destroy, cache->slot[i]->addr,
+ cache->slot[i]) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush object");
cache->diagnostics[type_id].nflushes++;
if (destroy)
cache->slot[i]= NULL;
}
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_set
@@ -647,11 +662,11 @@ H5AC_flush(H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy)
herr_t
H5AC_set(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
{
- herr_t status;
unsigned idx;
H5AC_flush_func_t flush=NULL;
H5AC_info_t **info = NULL;
H5AC_t *cache = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5AC_set, FAIL);
@@ -661,6 +676,7 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
assert(type->flush);
assert(H5F_addr_defined(addr));
assert(thing);
+
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
info = cache->slot + idx;
@@ -671,9 +687,8 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
int i;
prot = cache->prot + idx;
- for (i = 0; i < prot->nprots; i++) {
+ for (i = 0; i < prot->nprots; i++)
assert(H5F_addr_ne(addr, prot->slot[i]->addr));
- }
}
#endif
@@ -682,20 +697,20 @@ H5AC_set(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
H5AC_subid_t type_id=(*info)->type->id; /* Remember this for later */
flush = (*info)->type->flush;
- status = (flush)(f, H5AC_dxpl_id, TRUE, (*info)->addr, (*info));
- if (status < 0) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "unable to flush object");
- }
+ if ((flush)(f, H5AC_dxpl_id, TRUE, (*info)->addr, (*info)) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush object");
cache->diagnostics[type_id].nflushes++;
}
+
(*info)=thing;
(*info)->type = type;
(*info)->addr = addr;
cache->diagnostics[type->id].ninits++;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_rename
@@ -724,14 +739,15 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
{
unsigned old_idx, new_idx;
H5AC_flush_func_t flush=NULL;
- herr_t status;
H5AC_t *cache = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5AC_rename, FAIL);
assert(f);
assert(f->shared->cache);
assert(type);
+
old_idx = H5AC_HASH(f, old_addr);
new_idx = H5AC_HASH(f, new_addr);
cache = f->shared->cache;
@@ -742,13 +758,11 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
int i;
prot = cache->prot + old_idx;
- for (i = 0; i < prot->nprots; i++) {
+ for (i = 0; i < prot->nprots; i++)
assert(H5F_addr_ne(old_addr, prot->slot[i]->addr));
- }
prot = cache->prot + new_idx;
- for (i = 0; i < prot->nprots; i++) {
+ for (i = 0; i < prot->nprots; i++)
assert(H5F_addr_ne(new_addr, prot->slot[i]->addr));
- }
}
#endif
@@ -758,11 +772,11 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
*/
if (cache->slot[old_idx]->type != type ||
H5F_addr_ne(cache->slot[old_idx]->addr, old_addr)) {
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
if (old_idx == new_idx) {
cache->slot[old_idx]->addr = new_addr;
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
/*
* Free the item from the destination cache line.
@@ -771,14 +785,12 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
H5AC_subid_t type_id=cache->slot[new_idx]->type->id; /* Remember this for later */
flush = cache->slot[new_idx]->type->flush;
- status = (flush)(f, H5AC_dxpl_id, TRUE, cache->slot[new_idx]->addr,
- cache->slot[new_idx]);
- if (status < 0) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "unable to flush object");
- }
+ if ((flush)(f, H5AC_dxpl_id, TRUE, cache->slot[new_idx]->addr,
+ cache->slot[new_idx]) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush object");
cache->diagnostics[type_id].nflushes++;
}
+
/*
* Move the source to the destination (it might not be cached)
*/
@@ -787,8 +799,10 @@ H5AC_rename(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
cache->slot[new_idx]->addr = new_addr;
cache->slot[old_idx]= NULL;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_protect
@@ -825,6 +839,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
void *thing = NULL;
H5AC_t *cache = NULL;
H5AC_info_t **info = NULL;
+ void *ret_value; /* Return value */
#ifdef H5AC_DEBUG
H5AC_prot_t *prot = NULL;
@@ -846,6 +861,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
assert(type->load);
assert(type->flush);
assert(H5F_addr_defined(addr));
+
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
info = cache->slot + idx;
@@ -867,8 +883,7 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
/*
* Right address but wrong object type.
*/
- HRETURN_ERROR(H5E_CACHE, H5E_BADTYPE, NULL,
- "internal error");
+ HGOTO_ERROR(H5E_CACHE, H5E_BADTYPE, NULL, "internal error");
} else {
#ifdef H5AC_DEBUG
@@ -879,9 +894,8 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
*/
int i;
- for (i = 0; i < prot->nprots; i++) {
+ for (i = 0; i < prot->nprots; i++)
assert(H5F_addr_ne(addr, prot->slot[i]->addr));
- }
#endif /* H5AC_DEBUG */
/*
@@ -889,10 +903,8 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
* without preempting anything.
*/
cache->diagnostics[type->id].nmisses++;
- if (NULL == (thing = (type->load)(f, H5P_DATASET_XFER_DEFAULT, addr, udata1, udata2))) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL,
- "unable to load object");
- }
+ if (NULL == (thing = (type->load)(f, H5P_DATASET_XFER_DEFAULT, addr, udata1, udata2)))
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load object");
}
#ifdef H5AC_DEBUG
@@ -904,10 +916,8 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
size_t na = prot->aprots + 10;
H5AC_info_t **x = H5MM_realloc(prot->slot,
na * sizeof(H5AC_info_t *));
- if (NULL==x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
prot->aprots = (int)na;
prot->slot = x;
}
@@ -918,8 +928,14 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
#endif /* H5AC_DEBUG */
cache->nprots += 1;
- FUNC_LEAVE(thing);
+
+ /* Set return value */
+ ret_value=thing;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_unprotect
@@ -947,11 +963,11 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr,
herr_t
H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
{
- herr_t status;
unsigned idx;
H5AC_flush_func_t flush=NULL;
H5AC_t *cache = NULL;
H5AC_info_t **info = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5AC_unprotect, FAIL);
@@ -962,6 +978,7 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
assert(type->flush);
assert(H5F_addr_defined(addr));
assert(thing);
+
idx = H5AC_HASH(f, addr);
cache = f->shared->cache;
info = cache->slot + idx;
@@ -975,11 +992,8 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
assert(H5F_addr_ne((*info)->addr, addr));
flush = (*info)->type->flush;
- status = (flush)(f, H5AC_dxpl_id, TRUE, (*info)->addr, (*info));
- if (status < 0) {
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "unable to flush object");
- }
+ if ((flush)(f, H5AC_dxpl_id, TRUE, (*info)->addr, (*info)) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush object");
cache->diagnostics[type_id].nflushes++;
}
#ifdef H5AC_DEBUG
@@ -1013,8 +1027,10 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing)
(*info)->addr = addr;
cache->nprots -= 1;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5AC_debug
diff --git a/src/H5B.c b/src/H5B.c
index a17004f..c850f28 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -194,7 +194,7 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
size_t total_native_keysize;
size_t offset;
int i;
- herr_t ret_value = FAIL;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5B_create, FAIL);
@@ -210,14 +210,10 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
*/
sizeof_rkey = (type->get_sizeof_rkey) (f, udata);
size = H5B_nodesize(f, type, &total_native_keysize, sizeof_rkey);
- if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)size))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "file allocation failed for B-tree root node");
- }
- if (NULL==(bt = H5FL_ALLOC(H5B_t,1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for B-tree root node");
- }
+ if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, (hsize_t)size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree root node");
+ if (NULL==(bt = H5FL_ALLOC(H5B_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node");
bt->type = type;
bt->sizeof_rkey = sizeof_rkey;
bt->dirty = TRUE;
@@ -227,12 +223,10 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
bt->right = HADDR_UNDEF;
bt->nchildren = 0;
if (NULL==(bt->page=H5FL_BLK_ALLOC(page,size,1)) ||
- NULL==(bt->native=H5FL_BLK_ALLOC(native_block,total_native_keysize,0)) ||
- NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,(size_t)(2*H5B_Kvalue(f,type)),0)) ||
- NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(size_t)(2*H5B_Kvalue(f,type)+1),0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for B-tree root node");
- }
+ NULL==(bt->native=H5FL_BLK_ALLOC(native_block,total_native_keysize,0)) ||
+ NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,(size_t)(2*H5B_Kvalue(f,type)),0)) ||
+ NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(size_t)(2*H5B_Kvalue(f,type)+1),0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node");
/*
* Initialize each entry's raw child and key pointers to point into the
@@ -259,16 +253,13 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata,
/*
* Cache the new B-tree node.
*/
- if (H5AC_set(f, H5AC_BT, *addr_p, bt) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
- "can't add B-tree root node to cache");
- }
+ if (H5AC_set(f, H5AC_BT, *addr_p, bt) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "can't add B-tree root node to cache");
#ifdef H5B_DEBUG
H5B_assert(f, *addr_p, type, udata);
#endif
- ret_value = SUCCEED;
- done:
+done:
if (ret_value<0) {
H5MF_xfree(f, H5FD_MEM_BTREE, *addr_p, (hsize_t)size);
if (bt) {
@@ -310,6 +301,7 @@ H5B_Kvalue(H5F_t *f, const H5B_class_t *type)
{
int btree_k[H5B_NUM_BTREE_ID];
H5P_genplist_t *plist;
+ int ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5B_Kvalue, FAIL);
@@ -318,12 +310,16 @@ H5B_Kvalue(H5F_t *f, const H5B_class_t *type)
/* Check arguments */
if (NULL == (plist = H5I_object(f->shared->fcpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list");
if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes");
- FUNC_LEAVE(btree_k[type->id]);
+ /* Set return value */
+ ret_value=btree_k[type->id];
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5B_Kvalue() */
@@ -358,7 +354,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
H5B_t *bt = NULL;
int i;
uint8_t *p;
- H5B_t *ret_value = NULL;
+ H5B_t *ret_value;
FUNC_ENTER_NOAPI(H5B_load, NULL);
@@ -368,40 +364,30 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
assert(type);
assert(type->get_sizeof_rkey);
- if (NULL==(bt = H5FL_ALLOC(H5B_t,1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(bt = H5FL_ALLOC(H5B_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
bt->sizeof_rkey = (type->get_sizeof_rkey) (f, udata);
size = H5B_nodesize(f, type, &total_nkey_size, bt->sizeof_rkey);
bt->type = type;
bt->dirty = FALSE;
bt->ndirty = 0;
if (NULL==(bt->page=H5FL_BLK_ALLOC(page,size,0)) ||
- NULL==(bt->native=H5FL_BLK_ALLOC(native_block,total_nkey_size,0)) ||
- NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(size_t)(2*H5B_Kvalue(f,type)+1),0)) ||
- NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,(size_t)(2*H5B_Kvalue(f,type)),0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL,
- "can't read B-tree node");
- }
+ NULL==(bt->native=H5FL_BLK_ALLOC(native_block,total_nkey_size,0)) ||
+ NULL==(bt->key=H5FL_ARR_ALLOC(H5B_key_t,(size_t)(2*H5B_Kvalue(f,type)+1),0)) ||
+ NULL==(bt->child=H5FL_ARR_ALLOC(haddr_t,(size_t)(2*H5B_Kvalue(f,type)),0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_READERROR, NULL, "can't read B-tree node");
p = bt->page;
/* magic number */
- if (HDmemcmp(p, H5B_MAGIC, H5B_SIZEOF_MAGIC)) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL,
- "wrong B-tree signature");
- }
+ if (HDmemcmp(p, H5B_MAGIC, H5B_SIZEOF_MAGIC))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature");
p += 4;
/* node type and level */
- if (*p++ != type->id) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL,
- "incorrect B-tree node level");
- }
+ if (*p++ != type->id)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "incorrect B-tree node level");
bt->level = *p++;
/* entries used */
@@ -430,9 +416,11 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
bt->key[2 * H5B_Kvalue(f, type)].dirty = FALSE;
bt->key[2 * H5B_Kvalue(f, type)].rkey = p;
bt->key[2 * H5B_Kvalue(f, type)].nkey = NULL;
+
+ /* Set return value */
ret_value = bt;
- done:
+done:
if (!ret_value && bt) {
H5FL_ARR_FREE(haddr_t,bt->child);
H5FL_ARR_FREE(H5B_key_t,bt->key);
@@ -442,6 +430,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata)
}
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_flush
@@ -472,6 +461,7 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt)
int i;
size_t size = 0;
uint8_t *p = bt->page;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B_flush, FAIL);
@@ -511,10 +501,8 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt)
if (bt->key[i].dirty) {
if (bt->key[i].nkey) {
if ((bt->type->encode) (f, bt, bt->key[i].rkey,
- bt->key[i].nkey) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL,
- "unable to encode B-tree key");
- }
+ bt->key[i].nkey) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL, "unable to encode B-tree key");
}
bt->key[i].dirty = FALSE;
}
@@ -533,10 +521,8 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt)
* bother writing data for the child entries that don't exist or
* for the final unchanged children.
*/
- if (H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL,
- "unable to save B-tree node to disk");
- }
+ if (H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, bt->page)<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to save B-tree node to disk");
bt->dirty = FALSE;
bt->ndirty = 0;
}
@@ -547,7 +533,9 @@ H5B_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5B_t *bt)
H5FL_BLK_FREE(native_block,bt->native);
H5FL_FREE(H5B_t,bt);
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -582,7 +570,7 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
{
H5B_t *bt = NULL;
int idx = -1, lt = 0, rt, cmp = 1;
- int ret_value = FAIL;
+ int ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5B_find, FAIL);
@@ -600,18 +588,14 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
* Perform a binary search to locate the child which contains
* the thing for which we're searching.
*/
- if (NULL == (bt = H5AC_protect(f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree node");
- }
+ if (NULL == (bt = H5AC_protect(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node");
rt = bt->nchildren;
while (lt < rt && cmp) {
idx = (lt + rt) / 2;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode B-tree key(s)");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode B-tree key(s)");
/* compare */
if ((cmp = (type->cmp3) (f, bt->key[idx].nkey, udata,
bt->key[idx+1].nkey)) < 0) {
@@ -620,36 +604,28 @@ H5B_find(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
lt = idx+1;
}
}
- if (cmp) {
- HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
- "B-tree key not found");
- }
+ if (cmp)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "B-tree key not found");
/*
* Follow the link to the subtree or to the data node.
*/
assert(idx >= 0 && idx < bt->nchildren);
if (bt->level > 0) {
- if ((ret_value = H5B_find(f, type, bt->child[idx], udata)) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
- "key not found in subtree");
- }
+ if (H5B_find(f, type, bt->child[idx], udata) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in subtree");
} else {
- ret_value = (type->found) (f, bt->child[idx], bt->key[idx].nkey,
- udata, bt->key[idx+1].nkey);
- if (ret_value < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
- "key not found in leaf node");
- }
+ if ((type->found) (f, bt->child[idx], bt->key[idx].nkey, udata, bt->key[idx+1].nkey) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "key not found in leaf node");
}
- done:
- if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, FAIL,
- "unable to release node");
- }
+done:
+ if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0 && ret_value>=0)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release node");
+
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_split
@@ -683,7 +659,7 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr,
haddr_t *new_addr_p/*out*/)
{
H5B_t *new_bt = NULL, *tmp_bt = NULL;
- herr_t ret_value = FAIL;
+ herr_t ret_value = SUCCEED;
int i, k, nleft, nright;
size_t recsize = 0;
@@ -745,22 +721,17 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr,
}
nright = 2*k - nleft;
#ifdef H5B_DEBUG
- if (H5DEBUG(B)) {
+ if (H5DEBUG(B))
fprintf(H5DEBUG(B), " split %3d/%-3d\n", nleft, nright);
- }
#endif
/*
* Create the new B-tree node.
*/
- if (H5B_create(f, type, udata, new_addr_p/*out*/) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
- "unable to create B-tree");
- }
- if (NULL==(new_bt=H5AC_protect(f, H5AC_BT, *new_addr_p, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to protect B-tree");
- }
+ if (H5B_create(f, type, udata, new_addr_p/*out*/) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to create B-tree");
+ if (NULL==(new_bt=H5AC_protect(f, H5AC_BT, *new_addr_p, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to protect B-tree");
new_bt->level = old_bt->level;
/*
@@ -776,13 +747,12 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr,
for (i=0; i<=nright; i++) {
/* key */
new_bt->key[i].dirty = old_bt->key[nleft+i].dirty;
- if (old_bt->key[nleft+i].nkey) {
+ if (old_bt->key[nleft+i].nkey)
new_bt->key[i].nkey = new_bt->native + i * type->sizeof_nkey;
- }
+
/* child */
- if (i < nright) {
+ if (i < nright)
new_bt->child[i] = old_bt->child[nleft+i];
- }
}
new_bt->ndirty = new_bt->nchildren = nright;
@@ -800,27 +770,20 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr,
new_bt->right = old_bt->right;
if (H5F_addr_defined(old_bt->right)) {
- if (NULL == (tmp_bt = H5AC_find(f, H5AC_BT, old_bt->right, type,
- udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load right sibling");
- }
+ if (NULL == (tmp_bt = H5AC_find(f, H5AC_BT, old_bt->right, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load right sibling");
tmp_bt->dirty = TRUE;
tmp_bt->left = *new_addr_p;
}
old_bt->right = *new_addr_p;
- HGOTO_DONE(SUCCEED);
+done:
+ if (new_bt && H5AC_unprotect(f, H5AC_BT, *new_addr_p, new_bt) < 0 && ret_value>=0)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, FAIL, "unable to release B-tree node");
- done:
- {
- if (new_bt && H5AC_unprotect(f, H5AC_BT, *new_addr_p, new_bt) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, FAIL,
- "unable to release B-tree node");
- }
- }
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_decode_key
@@ -842,16 +805,18 @@ H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr,
static herr_t
H5B_decode_key(H5F_t *f, H5B_t *bt, int idx)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5B_decode_key);
bt->key[idx].nkey = bt->native + idx * bt->type->sizeof_nkey;
- if ((bt->type->decode) (f, bt, bt->key[idx].rkey,
- bt->key[idx].nkey) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
- FUNC_LEAVE(SUCCEED);
+ if ((bt->type->decode) (f, bt, bt->key[idx].rkey, bt->key[idx].nkey) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key");
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_decode_keys
@@ -870,22 +835,23 @@ H5B_decode_key(H5F_t *f, H5B_t *bt, int idx)
static herr_t
H5B_decode_keys(H5F_t *f, H5B_t *bt, int idx)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5B_decode_keys);
assert(f);
assert(bt);
assert(idx >= 0 && idx < bt->nchildren);
- if (!bt->key[idx].nkey && H5B_decode_key(f, bt, idx) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
- if (!bt->key[idx+1].nkey && H5B_decode_key(f, bt, idx+1) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
- FUNC_LEAVE(SUCCEED);
+ if (!bt->key[idx].nkey && H5B_decode_key(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key");
+ if (!bt->key[idx+1].nkey && H5B_decode_key(f, bt, idx+1) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key");
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_insert
@@ -932,7 +898,7 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr,
H5B_t *bt;
hsize_t size;
H5B_ins_t my_ins = H5B_INS_ERROR;
- herr_t ret_value = FAIL;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5B_insert, FAIL);
@@ -945,40 +911,30 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr,
assert(H5F_addr_defined(addr));
if ((my_ins = H5B_insert_helper(f, addr, type, split_ratios, lt_key,
- &lt_key_changed, md_key, udata, rt_key,
- &rt_key_changed, &child/*out*/))<0 ||
- my_ins<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
- "unable to insert key");
- }
- if (H5B_INS_NOOP == my_ins) HRETURN(SUCCEED);
+ &lt_key_changed, md_key, udata, rt_key, &rt_key_changed, &child/*out*/))<0 ||
+ my_ins<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to insert key");
+ if (H5B_INS_NOOP == my_ins)
+ HGOTO_DONE(SUCCEED);
assert(H5B_INS_RIGHT == my_ins);
/* the current root */
- if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to locate root of B-tree");
- }
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to locate root of B-tree");
level = bt->level;
if (!lt_key_changed) {
- if (!bt->key[0].nkey && H5B_decode_key(f, bt, 0) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
+ if (!bt->key[0].nkey && H5B_decode_key(f, bt, 0) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key");
HDmemcpy(lt_key, bt->key[0].nkey, type->sizeof_nkey);
}
/* the new node */
- if (NULL == (bt = H5AC_find(f, H5AC_BT, child, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new node");
- }
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, child, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new node");
if (!rt_key_changed) {
if (!bt->key[bt->nchildren].nkey &&
- H5B_decode_key(f, bt, bt->nchildren) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
+ H5B_decode_key(f, bt, bt->nchildren) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL, "unable to decode key");
HDmemcpy(rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey);
}
@@ -988,16 +944,12 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr,
* from "moving".
*/
size = H5B_nodesize(f, type, NULL, bt->sizeof_rkey);
- if (HADDR_UNDEF==(old_root=H5MF_alloc(f, H5FD_MEM_BTREE, size))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file space to move root");
- }
+ if (HADDR_UNDEF==(old_root=H5MF_alloc(f, H5FD_MEM_BTREE, size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space to move root");
/* update the new child's left pointer */
- if (NULL == (bt = H5AC_find(f, H5AC_BT, child, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new child");
- }
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, child, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child");
bt->dirty = TRUE;
bt->left = old_root;
@@ -1006,32 +958,24 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr,
* at the new location -QAK
*/
/* Bring the old root into the cache if it's not already */
- if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new child");
- }
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load new child");
/* Make certain the old root info is marked as dirty before moving it, */
/* so it is certain to be written out at the new location */
bt->dirty = TRUE;
/* Make a copy of the old root information */
- if (NULL == (bt = H5B_copy(f, bt))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to copy old root");
- }
+ if (NULL == (bt = H5B_copy(f, bt)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to copy old root");
/* Move the location on the disk */
- if (H5AC_rename(f, H5AC_BT, addr, old_root) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL,
- "unable to move B-tree root node");
- }
+ if (H5AC_rename(f, H5AC_BT, addr, old_root) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL, "unable to move B-tree root node");
/* Insert the copy of the old root into the file again */
- if (H5AC_set(f, H5AC_BT, addr, bt) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL,
- "unable to flush old B-tree root node");
- }
+ if (H5AC_set(f, H5AC_BT, addr, bt) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL, "unable to flush old B-tree root node");
/* clear the old root info at the old address (we already copied it) */
bt->dirty = TRUE;
@@ -1060,9 +1004,8 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, haddr_t addr,
#ifdef H5B_DEBUG
H5B_assert(f, addr, type, udata);
#endif
- ret_value = SUCCEED;
- done:
+done:
FUNC_LEAVE(ret_value);
}
@@ -1163,6 +1106,7 @@ H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt,
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_insert_helper
@@ -1248,18 +1192,14 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* data. When the search completes IDX points to the child that
* should get the new data.
*/
- if (NULL == (bt = H5AC_protect(f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to load node");
- }
+ if (NULL == (bt = H5AC_protect(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node");
rt = bt->nchildren;
while (lt < rt && cmp) {
idx = (lt + rt) / 2;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
if ((cmp = (type->cmp3) (f, bt->key[idx].nkey, udata,
bt->key[idx+1].nkey)) < 0) {
rt = idx;
@@ -1279,8 +1219,7 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
if ((type->new_node)(f, H5B_INS_FIRST, bt->key[0].nkey, udata,
bt->key[1].nkey, bt->child + 0/*out*/) < 0) {
bt->key[0].nkey = bt->key[1].nkey = NULL;
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR,
- "unable to create leaf node");
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR, "unable to create leaf node");
}
bt->nchildren = 1;
bt->dirty = TRUE;
@@ -1291,12 +1230,9 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
if (type->follow_min) {
if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
- lt_key_changed, md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "unable to insert first leaf node");
- }
+ lt_key_changed, md_key, udata, bt->key[idx+1].nkey,
+ rt_key_changed, &child_addr/*out*/)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert first leaf node");
} else {
my_ins = H5B_INS_NOOP;
}
@@ -1307,18 +1243,13 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* Follow the minimum branch out of this node to a subtree.
*/
idx = 0;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
if ((my_ins = H5B_insert_helper(f, bt->child[idx], type, split_ratios,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata, bt->key[idx+1].nkey,
- rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert minimum subtree");
- }
+ bt->key[idx].nkey, lt_key_changed, md_key,
+ udata, bt->key[idx+1].nkey, rt_key_changed,
+ &child_addr/*out*/))<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum subtree");
} else if (cmp < 0 && idx <= 0 && type->follow_min) {
/*
* The value being inserted is less than any leaf node out of this
@@ -1326,17 +1257,12 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* subclass handle the problem.
*/
idx = 0;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
- lt_key_changed, md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert minimum leaf node");
- }
+ lt_key_changed, md_key, udata, bt->key[idx+1].nkey,
+ rt_key_changed, &child_addr/*out*/)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node");
} else if (cmp < 0 && idx <= 0) {
/*
* The value being inserted is less than any leaf node out of the
@@ -1344,17 +1270,13 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* node. This node is not empty (handled above).
*/
idx = 0;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
my_ins = H5B_INS_LEFT;
HDmemcpy(md_key, bt->key[idx].nkey, type->sizeof_nkey);
if ((type->new_node)(f, H5B_INS_LEFT, bt->key[idx].nkey, udata,
- md_key, &child_addr/*out*/) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert minimum leaf node");
- }
+ md_key, &child_addr/*out*/) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert minimum leaf node");
*lt_key_changed = TRUE;
} else if (cmp > 0 && idx + 1 >= bt->nchildren && bt->level > 0) {
@@ -1363,18 +1285,12 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* Follow the maximum branch out of this node to a subtree.
*/
idx = bt->nchildren - 1;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
if ((my_ins = H5B_insert_helper(f, bt->child[idx], type, split_ratios,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata, bt->key[idx+1].nkey,
- rt_key_changed,
- &child_addr/*out*/)) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert maximum subtree");
- }
+ bt->key[idx].nkey, lt_key_changed, md_key, udata,
+ bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum subtree");
} else if (cmp > 0 && idx + 1 >= bt->nchildren && type->follow_max) {
/*
* The value being inserted is larger than any leaf node out of the
@@ -1382,17 +1298,12 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* subclass handle the problem.
*/
idx = bt->nchildren - 1;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
- lt_key_changed, md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert maximum leaf node");
- }
+ lt_key_changed, md_key, udata, bt->key[idx+1].nkey,
+ rt_key_changed, &child_addr/*out*/)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node");
} else if (cmp > 0 && idx + 1 >= bt->nchildren) {
/*
* The value being inserted is larger than any leaf node out of the
@@ -1400,17 +1311,13 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* node.
*/
idx = bt->nchildren - 1;
- if (H5B_decode_keys(f, bt, idx) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (H5B_decode_keys(f, bt, idx) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
my_ins = H5B_INS_RIGHT;
HDmemcpy(md_key, bt->key[idx+1].nkey, type->sizeof_nkey);
if ((type->new_node)(f, H5B_INS_RIGHT, md_key, udata,
- bt->key[idx+1].nkey, &child_addr/*out*/) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert maximum leaf node");
- }
+ bt->key[idx+1].nkey, &child_addr/*out*/) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert maximum leaf node");
*rt_key_changed = TRUE;
} else if (cmp) {
@@ -1427,25 +1334,18 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
*/
assert(idx >= 0 && idx < bt->nchildren);
if ((my_ins = H5B_insert_helper(f, bt->child[idx], type, split_ratios,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert subtree");
- }
+ bt->key[idx].nkey, lt_key_changed, md_key, udata,
+ bt->key[idx+1].nkey, rt_key_changed, &child_addr/*out*/)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert subtree");
} else {
/*
* Follow a branch out of this node to a leaf node of some other type.
*/
assert(idx >= 0 && idx < bt->nchildren);
if ((my_ins = (type->insert)(f, bt->child[idx], bt->key[idx].nkey,
- lt_key_changed, md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/)) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert leaf node");
- }
+ lt_key_changed, md_key, udata, bt->key[idx+1].nkey,
+ rt_key_changed, &child_addr/*out*/)) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert leaf node");
}
assert(my_ins >= 0);
@@ -1485,15 +1385,10 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
*/
if (bt->nchildren == 2 * H5B_Kvalue(f, type)) {
if (H5B_split(f, type, bt, addr, idx, split_ratios, udata,
- new_node_p/*out*/)<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR,
- "unable to split node");
- }
- if (NULL == (twin = H5AC_protect(f, H5AC_BT, *new_node_p, type,
- udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to load node");
- }
+ new_node_p/*out*/)<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR, "unable to split node");
+ if (NULL == (twin = H5AC_protect(f, H5AC_BT, *new_node_p, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load node");
if (idx<bt->nchildren) {
tmp_bt = bt;
} else {
@@ -1505,11 +1400,8 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
}
/* Insert the child */
- if (H5B_insert_child(f, type, tmp_bt, idx, child_addr, my_ins,
- md_key) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert child");
- }
+ if (H5B_insert_child(f, type, tmp_bt, idx, child_addr, my_ins, md_key) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR, "can't insert child");
}
/*
@@ -1517,10 +1409,8 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* by the left and right node).
*/
if (twin) {
- if (!twin->key[0].nkey && H5B_decode_key(f, twin, 0) < 0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
+ if (!twin->key[0].nkey && H5B_decode_key(f, twin, 0) < 0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode key");
HDmemcpy(md_key, twin->key[0].nkey, type->sizeof_nkey);
ret_value = H5B_INS_RIGHT;
#ifdef H5B_DEBUG
@@ -1540,18 +1430,17 @@ H5B_insert_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
ret_value = H5B_INS_NOOP;
}
- done:
+done:
{
herr_t e1 = (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0);
herr_t e2 = (twin && H5AC_unprotect(f, H5AC_BT, *new_node_p, twin)<0);
- if (e1 || e2) { /*use vars to prevent short-circuit of side effects */
- HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR,
- "unable to release node(s)");
- }
+ if (e1 || e2) /*use vars to prevent short-circuit of side effects */
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node(s)");
}
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5B_iterate
@@ -1585,7 +1474,7 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, H5B_operator_t op, haddr_t addr,
haddr_t *child = NULL;
uint8_t *key = NULL;
int i, nchildren;
- herr_t ret_value = FAIL;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(H5B_iterate, FAIL);
@@ -1598,43 +1487,36 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, H5B_operator_t op, haddr_t addr,
assert(H5F_addr_defined(addr));
assert(udata);
- if (NULL == (bt=H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree node");
- }
+ if (NULL == (bt=H5AC_find(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node");
if (bt->level > 0) {
/* Keep following the left-most child until we reach a leaf node. */
- if ((ret_value=H5B_iterate(f, type, op, bt->child[0], udata))<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL,
- "unable to list B-tree node");
- }
+ if (H5B_iterate(f, type, op, bt->child[0], udata)<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, "unable to list B-tree node");
} else {
/*
* We've reached the left-most leaf. Now follow the right-sibling
* pointer from leaf to leaf until we've processed all leaves.
*/
if (NULL==(child=H5FL_ARR_ALLOC(haddr_t,(size_t)(2*H5B_Kvalue(f,type)),0)) ||
- NULL==(key=H5MM_malloc((2*H5B_Kvalue(f, type)+1)*type->sizeof_nkey))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ NULL==(key=H5MM_malloc((2*H5B_Kvalue(f, type)+1)*type->sizeof_nkey)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
for (cur_addr=addr, ret_value=0;
- H5F_addr_defined(cur_addr) && !ret_value;
- cur_addr=next_addr) {
+ H5F_addr_defined(cur_addr);
+ cur_addr=next_addr) {
/*
* Save all the child addresses and native keys since we can't
* leave the B-tree node protected during an application
* callback.
*/
- if (NULL==(bt=H5AC_find (f, H5AC_BT, cur_addr, type, udata))) {
+ if (NULL==(bt=H5AC_find (f, H5AC_BT, cur_addr, type, udata)))
HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL, "B-tree node");
- }
- for (i=0; i<bt->nchildren; i++) {
+ for (i=0; i<bt->nchildren; i++)
child[i] = bt->child[i];
- }
for (i=0; i<bt->nchildren+1; i++) {
- if (!bt->key[i].nkey) H5B_decode_key(f, bt, i);
+ if (!bt->key[i].nkey)
+ H5B_decode_key(f, bt, i);
HDmemcpy(key+i*type->sizeof_nkey, bt->key[i].nkey,
type->sizeof_nkey);
}
@@ -1646,14 +1528,11 @@ H5B_iterate (H5F_t *f, const H5B_class_t *type, H5B_operator_t op, haddr_t addr,
* Perform the iteration operator, which might invoke an
* application callback.
*/
- for (i=0, ret_value=0; i<nchildren && !ret_value; i++) {
+ for (i=0; i<nchildren && !ret_value; i++) {
ret_value = (*op)(f, key+i*type->sizeof_nkey,
- child[i], key+(i+1)*type->sizeof_nkey,
- udata);
- if (ret_value<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
- "iterator function failed");
- }
+ child[i], key+(i+1)*type->sizeof_nkey, udata);
+ if (ret_value<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "iterator function failed");
}
}
}
@@ -1722,17 +1601,13 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* Perform a binary search to locate the child which contains the thing
* for which we're searching.
*/
- if (NULL==(bt=H5AC_protect(f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to load B-tree node");
- }
+ if (NULL==(bt=H5AC_protect(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to load B-tree node");
rt = bt->nchildren;
while (lt<rt && cmp) {
idx = (lt+rt)/2;
- if (H5B_decode_keys(f, bt, idx)<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode B-tree key(s)");
- }
+ if (H5B_decode_keys(f, bt, idx)<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR, "unable to decode B-tree key(s)");
if ((cmp=(type->cmp3)(f, bt->key[idx].nkey, udata,
bt->key[idx+1].nkey))<0) {
rt = idx;
@@ -1740,10 +1615,8 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
lt = idx+1;
}
}
- if (cmp) {
- HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR,
- "B-tree key not found");
- }
+ if (cmp)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "B-tree key not found");
/*
* Follow the link to the subtree or to the data node. The return value
@@ -1753,17 +1626,10 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
if (bt->level>0) {
/* We're at an internal node -- call recursively */
if ((ret_value=H5B_remove_helper(f,
- bt->child[idx],
- type,
- level+1,
- bt->key[idx].nkey/*out*/,
- lt_key_changed/*out*/,
- udata,
- bt->key[idx+1].nkey/*out*/,
- rt_key_changed/*out*/))<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR,
- "key not found in subtree");
- }
+ bt->child[idx], type, level+1, bt->key[idx].nkey/*out*/,
+ lt_key_changed/*out*/, udata, bt->key[idx+1].nkey/*out*/,
+ rt_key_changed/*out*/))<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in subtree");
} else if (type->remove) {
/*
* We're at a leaf node but the leaf node points to an object that
@@ -1771,15 +1637,9 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
* object and let it decide how to progress.
*/
if ((ret_value=(type->remove)(f,
- bt->child[idx],
- bt->key[idx].nkey,
- lt_key_changed,
- udata,
- bt->key[idx+1].nkey,
- rt_key_changed))<0) {
- HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR,
- "key not found in leaf node");
- }
+ bt->child[idx], bt->key[idx].nkey, lt_key_changed, udata,
+ bt->key[idx+1].nkey, rt_key_changed))<0)
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, H5B_INS_ERROR, "key not found in leaf node");
} else {
/*
* We're at a leaf node which points to an object that has no removal
@@ -1834,20 +1694,14 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
bt->ndirty = 0;
if (level>0) {
if (H5F_addr_defined(bt->left)) {
- if (NULL==(sibling=H5AC_find(f, H5AC_BT, bt->left, type,
- udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to unlink node from tree");
- }
+ if (NULL==(sibling=H5AC_find(f, H5AC_BT, bt->left, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree");
sibling->right = bt->right;
sibling->dirty = TRUE;
}
if (H5F_addr_defined(bt->right)) {
- if (NULL==(sibling=H5AC_find(f, H5AC_BT, bt->right, type,
- udata))) {
- HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to unlink node from tree");
- }
+ if (NULL==(sibling=H5AC_find(f, H5AC_BT, bt->right, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR, "unable to unlink node from tree");
sibling->left = bt->left;
sibling->dirty = TRUE;
}
@@ -1856,11 +1710,10 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
sizeof_rkey = (type->get_sizeof_rkey)(f, udata);
sizeof_node = H5B_nodesize(f, type, NULL, sizeof_rkey);
if (H5AC_unprotect(f, H5AC_BT, addr, bt)<0 ||
- H5AC_flush(f, H5AC_BT, addr, TRUE)<0 ||
- H5MF_xfree(f, H5FD_MEM_BTREE, addr, sizeof_node)<0) {
+ H5AC_flush(f, H5AC_BT, addr, TRUE)<0 ||
+ H5MF_xfree(f, H5FD_MEM_BTREE, addr, sizeof_node)<0) {
bt = NULL;
- HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR,
- "unable to free B-tree node");
+ HGOTO_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to free B-tree node");
}
bt = NULL;
}
@@ -1950,15 +1803,13 @@ H5B_remove_helper(H5F_t *f, haddr_t addr, const H5B_class_t *type,
}
- done:
- if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt)<0) {
- HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR,
- "unable to release node");
- }
+done:
+ if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt)<0 && ret_value>=0)
+ HDONE_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR, "unable to release node");
+
FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
* Function: H5B_remove
@@ -1988,6 +1839,7 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
hbool_t lt_key_changed = FALSE; /*left key changed?*/
hbool_t rt_key_changed = FALSE; /*right key changed?*/
H5B_t *bt = NULL; /*btree node */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B_remove, FAIL);
@@ -1999,29 +1851,25 @@ H5B_remove(H5F_t *f, const H5B_class_t *type, haddr_t addr, void *udata)
/* The actual removal */
if (H5B_remove_helper(f, addr, type, 0, lt_key, &lt_key_changed,
- udata, rt_key, &rt_key_changed)==H5B_INS_ERROR) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
- "unable to remove entry from B-tree");
- }
+ udata, rt_key, &rt_key_changed)==H5B_INS_ERROR)
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL, "unable to remove entry from B-tree");
/*
* If the B-tree is now empty then make sure we mark the root node as
* being at level zero
*/
- if (NULL==(bt=H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree root node");
- }
+ if (NULL==(bt=H5AC_find(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree root node");
if (0==bt->nchildren && 0!=bt->level) {
bt->level = 0;
bt->dirty = TRUE;
}
-
#ifdef H5B_DEBUG
H5B_assert(f, addr, type, udata);
#endif
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2067,9 +1915,9 @@ H5B_nodesize(H5F_t *f, const H5B_class_t *type,
/*
* Total native key size.
*/
- if (total_nkey_size) {
+ if (total_nkey_size)
*total_nkey_size = (2 * H5B_Kvalue(f, type) + 1) * type->sizeof_nkey;
- }
+
/*
* Total node size.
*/
@@ -2101,11 +1949,12 @@ H5B_nodesize(H5F_t *f, const H5B_class_t *type,
static H5B_t *
H5B_copy(H5F_t *f, const H5B_t *old_bt)
{
- H5B_t *ret_value = NULL;
+ H5B_t *new_node = NULL;
size_t total_native_keysize;
size_t size;
size_t nkeys;
size_t u;
+ H5B_t *ret_value;
FUNC_ENTER_NOAPI(H5B_copy, NULL);
@@ -2121,39 +1970,48 @@ H5B_copy(H5F_t *f, const H5B_t *old_bt)
size = H5B_nodesize(f, old_bt->type, &total_native_keysize, old_bt->sizeof_rkey);
/* Allocate memory for the new H5B_t object */
- if (NULL==(ret_value = H5FL_ALLOC(H5B_t,0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for B-tree root node");
- }
+ if (NULL==(new_node = H5FL_ALLOC(H5B_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node");
/* Copy the main structure */
- HDmemcpy(ret_value,old_bt,sizeof(H5B_t));
+ HDmemcpy(new_node,old_bt,sizeof(H5B_t));
/* Compute the number of keys in this node */
nkeys=2*H5B_Kvalue(f,old_bt->type);
- if (NULL==(ret_value->page=H5FL_BLK_ALLOC(page,size,0)) ||
- NULL==(ret_value->native=H5FL_BLK_ALLOC(native_block,total_native_keysize,0)) ||
- NULL==(ret_value->child=H5FL_ARR_ALLOC(haddr_t,nkeys,0)) ||
- NULL==(ret_value->key=H5FL_ARR_ALLOC(H5B_key_t,(nkeys+1),0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for B-tree root node");
- }
+ if (NULL==(new_node->page=H5FL_BLK_ALLOC(page,size,0)) ||
+ NULL==(new_node->native=H5FL_BLK_ALLOC(native_block,total_native_keysize,0)) ||
+ NULL==(new_node->child=H5FL_ARR_ALLOC(haddr_t,nkeys,0)) ||
+ NULL==(new_node->key=H5FL_ARR_ALLOC(H5B_key_t,(nkeys+1),0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node");
/* Copy the other structures */
- HDmemcpy(ret_value->page,old_bt->page,(size_t)size);
- HDmemcpy(ret_value->native,old_bt->native,(size_t)total_native_keysize);
- HDmemcpy(ret_value->child,old_bt->child,(size_t)(sizeof(haddr_t)*nkeys));
- HDmemcpy(ret_value->key,old_bt->key,(size_t)(sizeof(H5B_key_t)*(nkeys+1)));
+ HDmemcpy(new_node->page,old_bt->page,(size_t)size);
+ HDmemcpy(new_node->native,old_bt->native,(size_t)total_native_keysize);
+ HDmemcpy(new_node->child,old_bt->child,(size_t)(sizeof(haddr_t)*nkeys));
+ HDmemcpy(new_node->key,old_bt->key,(size_t)(sizeof(H5B_key_t)*(nkeys+1)));
/*
* Translate the keys from pointers into the old 'page' buffer into
* pointers into the new 'page' buffer.
*/
for (u = 0; u < (nkeys+1); u++)
- ret_value->key[u].rkey = (old_bt->key[u].rkey - old_bt->page) + ret_value->page;
+ new_node->key[u].rkey = (old_bt->key[u].rkey - old_bt->page) + new_node->page;
+
+ /* Set return value */
+ ret_value=new_node;
done:
+ if(ret_value==NULL) {
+ if(new_node) {
+ H5FL_BLK_FREE (page,new_node->page);
+ H5FL_BLK_FREE (native_block,new_node->native);
+ H5FL_ARR_FREE (haddr_t,new_node->child);
+ H5FL_ARR_FREE (H5B_key_t,new_node->key);
+ H5FL_FREE (H5B_t,new_node);
+ } /* end if */
+ } /* end if */
+
FUNC_LEAVE(ret_value);
} /* H5B_copy */
@@ -2180,6 +2038,7 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth,
{
H5B_t *bt = NULL;
int i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5B_debug, FAIL);
@@ -2196,10 +2055,9 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth,
/*
* Load the tree node.
*/
- if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree node");
- }
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata)))
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL, "unable to load B-tree node");
+
/*
* Print the values.
*/
@@ -2245,13 +2103,13 @@ H5B_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth,
"Address:", bt->child[i]);
H5B_decode_key(f, bt, i);
- if (type->debug_key) {
+ if (type->debug_key)
(type->debug_key)(stream, indent+3, MAX (0, fwidth-3),
bt->key[i].nkey, udata);
- }
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5D.c b/src/H5D.c
index 6d82625..d8a618a 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -901,15 +901,20 @@ done:
H5S_t *
H5D_get_space(H5D_t *dset)
{
- H5S_t *space = NULL;
+ H5S_t *space;
+ H5S_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5D_get_space, NULL);
assert(dset);
if (NULL==(space=H5S_read(&(dset->ent))))
- HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header");
+
+ /* Set return value */
+ ret_value=space;
- FUNC_LEAVE(space);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1823,14 +1828,14 @@ H5D_isa(H5G_entry_t *ent)
if ((exists=H5O_exists(ent, H5O_DTYPE, 0))<0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header");
} else if (!exists) {
- HRETURN(FALSE);
+ HGOTO_DONE(FALSE);
}
/* Layout */
if ((exists=H5O_exists(ent, H5O_LAYOUT, 0))<0) {
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header");
} else if (!exists) {
- HRETURN(FALSE);
+ HGOTO_DONE(FALSE);
}
@@ -2103,6 +2108,7 @@ herr_t
H5D_close(H5D_t *dataset)
{
unsigned free_failed;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5D_close, FAIL);
@@ -2129,9 +2135,10 @@ H5D_close(H5D_t *dataset)
H5FL_FREE(H5D_t,dataset);
if (free_failed)
- HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free the type or creation property list, but the dataset was freed anyway.");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "couldn't free the type or creation property list, but the dataset was freed anyway.");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3297,18 +3304,20 @@ hsize_t
H5Dget_storage_size(hid_t dset_id)
{
H5D_t *dset=NULL;
- hsize_t size;
+ hsize_t ret_value; /* Return value */
FUNC_ENTER_API(H5Dget_storage_size, 0);
H5TRACE1("h","i",dset_id);
/* Check args */
if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset");
- size = H5D_get_storage_size(dset);
+ /* Set return value */
+ ret_value = H5D_get_storage_size(dset);
- FUNC_LEAVE(size);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3996,13 +4005,14 @@ herr_t
H5Ddebug(hid_t dset_id, unsigned UNUSED flags)
{
H5D_t *dset=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Ddebug, FAIL);
H5TRACE2("e","iIu",dset_id,flags);
/* Check args */
if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
/* Print B-tree information */
if (H5D_CHUNKED==dset->layout.type) {
@@ -4011,6 +4021,7 @@ H5Ddebug(hid_t dset_id, unsigned UNUSED flags)
HDfprintf(stdout, " %-10s %a\n", "Address:", dset->layout.addr);
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 461a068..89f9fc5 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -51,6 +51,7 @@ H5F_contig_read(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr,
size_t size, hid_t dxpl_id, void *buf/*out*/)
{
hsize_t offset=0; /* Offset for vector call */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_read, FAIL);
@@ -59,9 +60,10 @@ H5F_contig_read(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr,
assert(buf);
if (H5F_contig_readv(f, max_data, type, addr, 1, &size, &offset, dxpl_id, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_read() */
@@ -87,6 +89,7 @@ H5F_contig_write(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr, size
hid_t dxpl_id, const void *buf)
{
hsize_t offset=0; /* Offset for vector call */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_write, FAIL);
@@ -94,9 +97,10 @@ H5F_contig_write(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr, size
assert (buf);
if (H5F_contig_writev(f, max_data, type, addr, 1, &size, &offset, dxpl_id, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_write() */
@@ -141,6 +145,7 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size_t *size_arr_p; /* Pointer into the size array */
hsize_t *offset_arr_p; /* Pointer into the offset array */
#endif /* SLOW_WAY */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_readv, FAIL);
@@ -388,10 +393,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Flush the sieve buffer, if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -399,20 +402,16 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
} /* end if */
/* Read directly into the user's buffer */
- if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
/* Element size fits within the buffer size */
else {
/* Flush the sieve buffer if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -422,10 +421,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -443,10 +440,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
sieve_end=sieve_start+sieve_size;
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -472,26 +467,20 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if we can actually hold the I/O request in the sieve buffer */
if(size>f->shared->sieve_buf_size) {
- if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
else {
/* Allocate room for the data sieve buffer */
- if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Determine the new sieve buffer size & location */
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -500,10 +489,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
H5_ASSIGN_OVERFLOW(f->shared->sieve_size,MIN(rel_eoa-f->shared->sieve_loc,MIN(max_data,f->shared->sieve_buf_size)),hsize_t,size_t);
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -526,17 +513,16 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size=size_arr[u];
addr=_addr+offset_arr[u];
- if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
/* Increment offset in buffer */
buf += size_arr[u];
} /* end for */
} /* end else */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_readv() */
@@ -581,6 +567,7 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size_t *size_arr_p; /* Pointer into the size array */
hsize_t *offset_arr_p; /* Pointer into the offset array */
#endif /* SLOW_WAY */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_writev, FAIL);
@@ -831,10 +818,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Flush the sieve buffer, if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -846,10 +831,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
} /* end if */
/* Write directly from the user's buffer */
- if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
} /* end if */
/* Element size fits within the buffer size */
else {
@@ -889,10 +872,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Flush the sieve buffer if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -902,10 +883,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -925,10 +904,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if there is any point in reading the data from the file */
if(f->shared->sieve_size>size) {
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- } /* end if */
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
@@ -957,26 +934,20 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if we can actually hold the I/O request in the sieve buffer */
if(size>f->shared->sieve_buf_size) {
- if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
} /* end if */
else {
/* Allocate room for the data sieve buffer */
- if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Determine the new sieve buffer size & location */
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -987,10 +958,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if there is any point in reading the data from the file */
if(f->shared->sieve_size>size) {
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- } /* end if */
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
@@ -1014,16 +983,15 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size=size_arr[u];
addr=_addr+offset_arr[u];
- if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Increment offset in buffer */
buf += size_arr[u];
} /* end for */
} /* end else */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_writev() */
diff --git a/src/H5Distore.c b/src/H5Distore.c
index bac14c2..7780b2d 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -490,6 +490,7 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
unsigned u;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_new_node, FAIL);
#ifdef AKC
@@ -505,13 +506,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
/* Allocate new storage */
assert (udata->key.nbytes > 0);
-#ifdef AKC
- printf("calling H5MF_alloc for new chunk\n");
-#endif
- if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes))) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
- "couldn't allocate new file storage");
- }
+ if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes)))
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "couldn't allocate new file storage");
udata->addr = *addr_p;
/*
@@ -520,9 +516,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
*/
lt_key->nbytes = udata->key.nbytes;
lt_key->filter_mask = udata->key.filter_mask;
- for (u=0; u<udata->mesg.ndims; u++) {
+ for (u=0; u<udata->mesg.ndims; u++)
lt_key->offset[u] = udata->key.offset[u];
- }
/*
* The right key might already be present. If not, then add a zero-width
@@ -540,7 +535,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
}
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -578,6 +574,7 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key,
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key;
unsigned u;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_found, FAIL);
@@ -589,9 +586,8 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key,
/* Is this *really* the requested chunk? */
for (u=0; u<udata->mesg.ndims; u++) {
- if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg.dim[u])) {
- HRETURN(FAIL);
- }
+ if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg.dim[u]))
+ HGOTO_DONE(FAIL);
}
/* Initialize return values */
@@ -599,11 +595,11 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key,
udata->key.nbytes = lt_key->nbytes;
udata->key.filter_mask = lt_key->filter_mask;
assert (lt_key->nbytes>0);
- for (u = 0; u < udata->mesg.ndims; u++) {
+ for (u = 0; u < udata->mesg.ndims; u++)
udata->key.offset[u] = lt_key->offset[u];
- }
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -676,8 +672,7 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key,
if (cmp < 0) {
/* Negative indices not supported yet */
assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR,
- "internal error");
+ HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error");
} else if (H5V_vector_eq_s (udata->mesg.ndims,
udata->key.offset, lt_key->offset) &&
@@ -691,11 +686,8 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key,
printf("calling H5MF_realloc for new chunk\n");
#endif
if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr,
- (hsize_t)lt_key->nbytes,
- (hsize_t)udata->key.nbytes))) {
- HRETURN_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR,
- "unable to reallocate chunk storage");
- }
+ (hsize_t)lt_key->nbytes, (hsize_t)udata->key.nbytes)))
+ HGOTO_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR, "unable to reallocate chunk storage");
lt_key->nbytes = udata->key.nbytes;
lt_key->filter_mask = udata->key.filter_mask;
*lt_key_changed = TRUE;
@@ -729,20 +721,17 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key,
#ifdef AKC
printf("calling H5MF_alloc for new chunk\n");
#endif
- if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW,
- (hsize_t)udata->key.nbytes))) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR,
- "file allocation failed");
- }
+ if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes)))
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR, "file allocation failed");
udata->addr = *new_node_p;
ret_value = H5B_INS_RIGHT;
} else {
assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR,
- "internal error");
+ HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error");
}
+done:
FUNC_LEAVE(ret_value);
}
@@ -853,6 +842,7 @@ herr_t
H5F_istore_init (H5F_t *f)
{
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_init, FAIL);
@@ -860,13 +850,12 @@ H5F_istore_init (H5F_t *f)
if (f->shared->rdcc_nbytes>0 && f->shared->rdcc_nelmts>0) {
rdcc->nslots = f->shared->rdcc_nelmts;
rdcc->slot = H5FL_ARR_ALLOC (H5F_rdcc_ent_ptr_t,rdcc->nslots,1);
- if (NULL==rdcc->slot) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==rdcc->slot)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1015,6 +1004,7 @@ static herr_t
H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
{
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5F_istore_preempt);
@@ -1024,37 +1014,27 @@ H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
assert(ent->idx < rdcc->nslots);
if(flush) {
-
/* Flush */
- if(H5F_istore_flush_entry(f, ent, TRUE) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "cannot flush indexed storage buffer");
- }
+ if(H5F_istore_flush_entry(f, ent, TRUE) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer");
}
-
else {
-
/* Reset, but do not free or remove from list */
ent->layout = H5O_free(H5O_LAYOUT, ent->layout);
ent->pline = H5O_free(H5O_PLINE, ent->pline);
if(ent->chunk != NULL)
ent->chunk = H5MM_xfree(ent->chunk);
-
}
/* Unlink from list */
- if(ent->prev) {
+ if(ent->prev)
ent->prev->next = ent->next;
- }
- else {
+ else
rdcc->head = ent->next;
- }
- if(ent->next) {
+ if(ent->next)
ent->next->prev = ent->prev;
- }
- else {
+ else
rdcc->tail = ent->prev;
- }
ent->prev = ent->next = NULL;
/* Remove from cache */
@@ -1066,7 +1046,8 @@ H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
/* Free */
H5FL_FREE(H5F_rdcc_ent_t, ent);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1093,27 +1074,26 @@ H5F_istore_flush (H5F_t *f, hbool_t preempt)
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
int nerrors=0;
H5F_rdcc_ent_t *ent=NULL, *next=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_flush, FAIL);
for (ent=rdcc->head; ent; ent=next) {
next = ent->next;
if (preempt) {
- if (H5F_istore_preempt(f, ent, TRUE )<0) {
+ if (H5F_istore_preempt(f, ent, TRUE )<0)
nerrors++;
- }
} else {
- if (H5F_istore_flush_entry(f, ent, FALSE)<0) {
+ if (H5F_istore_flush_entry(f, ent, FALSE)<0)
nerrors++;
- }
}
}
- if (nerrors) {
- HRETURN_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL,
- "unable to flush one or more raw data chunks");
- }
- FUNC_LEAVE (SUCCEED);
+ if (nerrors)
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks");
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1140,6 +1120,7 @@ H5F_istore_dest (H5F_t *f)
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
int nerrors=0;
H5F_rdcc_ent_t *ent=NULL, *next=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_dest, FAIL);
@@ -1149,18 +1130,17 @@ H5F_istore_dest (H5F_t *f)
HDfflush(stderr);
#endif
next = ent->next;
- if (H5F_istore_preempt(f, ent, TRUE )<0) {
+ if (H5F_istore_preempt(f, ent, TRUE )<0)
nerrors++;
- }
- }
- if (nerrors) {
- HRETURN_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL,
- "unable to flush one or more raw data chunks");
}
+ if (nerrors)
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks");
H5FL_ARR_FREE (H5F_rdcc_ent_ptr_t,rdcc->slot);
HDmemset (rdcc, 0, sizeof(H5F_rdcc_t));
- FUNC_LEAVE (SUCCEED);
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1192,6 +1172,7 @@ H5F_istore_prune (H5F_t *f, size_t size)
int w[1]; /*weighting as an interval */
H5F_rdcc_ent_t *p[2], *cur; /*list pointers */
H5F_rdcc_ent_t *n[2]; /*list next pointers */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5F_istore_prune);
@@ -1212,17 +1193,20 @@ H5F_istore_prune (H5F_t *f, size_t size)
while ((p[0] || p[1]) && rdcc->nbytes+size>total) {
/* Introduce new pointers */
- for (i=0; i<nmeth-1; i++) if (0==w[i]) p[i+1] = rdcc->head;
+ for (i=0; i<nmeth-1; i++)
+ if (0==w[i])
+ p[i+1] = rdcc->head;
/* Compute next value for each pointer */
- for (i=0; i<nmeth; i++) n[i] = p[i] ? p[i]->next : NULL;
+ for (i=0; i<nmeth; i++)
+ n[i] = p[i] ? p[i]->next : NULL;
/* Give each method a chance */
for (i=0; i<nmeth && rdcc->nbytes+size>total; i++) {
if (0==i && p[0] && !p[0]->locked &&
- ((0==p[0]->rd_count && 0==p[0]->wr_count) ||
- (0==p[0]->rd_count && p[0]->chunk_size==p[0]->wr_count) ||
- (p[0]->chunk_size==p[0]->rd_count && 0==p[0]->wr_count))) {
+ ((0==p[0]->rd_count && 0==p[0]->wr_count) ||
+ (0==p[0]->rd_count && p[0]->chunk_size==p[0]->wr_count) ||
+ (p[0]->chunk_size==p[0]->rd_count && 0==p[0]->wr_count))) {
/*
* Method 0: Preempt entries that have been completely written
* and/or completely read but not entries that are partially
@@ -1253,23 +1237,28 @@ H5F_istore_prune (H5F_t *f, size_t size)
if (cur) {
for (j=0; j<nmeth; j++) {
- if (p[j]==cur) p[j] = NULL;
- if (n[j]==cur) n[j] = cur->next;
+ if (p[j]==cur)
+ p[j] = NULL;
+ if (n[j]==cur)
+ n[j] = cur->next;
}
- if (H5F_istore_preempt(f, cur, TRUE)<0) nerrors++;
+ if (H5F_istore_preempt(f, cur, TRUE)<0)
+ nerrors++;
}
}
/* Advance pointers */
- for (i=0; i<nmeth; i++) p[i] = n[i];
- for (i=0; i<nmeth-1; i++) w[i] -= 1;
+ for (i=0; i<nmeth; i++)
+ p[i] = n[i];
+ for (i=0; i<nmeth-1; i++)
+ w[i] -= 1;
}
- if (nerrors) {
- HRETURN_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL,
- "unable to preempt one or more raw data cache entry");
- }
- FUNC_LEAVE (SUCCEED);
+ if (nerrors)
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to preempt one or more raw data cache entry");
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1369,15 +1358,12 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
HDfflush(stderr);
#endif
rdcc->nhits++;
- for (u=0, tempchunk_size=1; u<layout->ndims; u++) {
+ for (u=0, tempchunk_size=1; u<layout->ndims; u++)
tempchunk_size *= layout->dim[u];
- }
H5_ASSIGN_OVERFLOW(chunk_size,tempchunk_size,hsize_t,size_t);
chunk_alloc = chunk_size;
- if (NULL==(chunk=H5MM_malloc (chunk_alloc))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for raw data chunk");
- }
+ if (NULL==(chunk=H5MM_malloc (chunk_alloc)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk");
} else {
/*
@@ -1394,25 +1380,18 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
udata.addr = HADDR_UNDEF;
status = H5B_find (f, H5B_ISTORE, layout->addr, &udata);
H5E_clear ();
- if (NULL==(chunk = H5MM_malloc (chunk_alloc))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for raw data chunk");
- }
+ if (NULL==(chunk = H5MM_malloc (chunk_alloc)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk");
if (status>=0 && H5F_addr_defined(udata.addr)) {
/*
* The chunk exists on disk.
*/
- if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DATASET_XFER_DEFAULT,
- chunk)<0) {
- HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL,
- "unable to read raw data chunk");
- }
+ if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DATASET_XFER_DEFAULT, chunk)<0)
+ HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk");
if (H5Z_pipeline(f, pline, H5Z_FLAG_REVERSE,
&(udata.key.filter_mask), &(udata.key.nbytes),
- &chunk_alloc, &chunk)<0 || udata.key.nbytes!=chunk_size) {
- HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL,
- "data pipeline read failed");
- }
+ &chunk_alloc, &chunk)<0 || udata.key.nbytes!=chunk_size)
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, "data pipeline read failed");
rdcc->nmisses++;
} else if (fill && fill->buf) {
/*
@@ -1456,15 +1435,11 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
}
fprintf(stderr, "}\n");
#endif
- if (H5F_istore_preempt(f, ent, TRUE)<0) {
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL,
- "unable to preempt chunk from cache");
- }
- }
- if (H5F_istore_prune(f, chunk_size)<0) {
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL,
- "unable to preempt chunk(s) from cache");
+ if (H5F_istore_preempt(f, ent, TRUE)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk from cache");
}
+ if (H5F_istore_prune(f, chunk_size)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache");
/* Create a new entry */
ent = H5FL_ALLOC(H5F_rdcc_ent_t,0);
@@ -1474,9 +1449,8 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
ent->alloc_size = chunk_size;
ent->layout = H5O_copy(H5O_LAYOUT, layout, NULL);
ent->pline = H5O_copy(H5O_PLINE, pline, NULL);
- for (u=0; u<layout->ndims; u++) {
+ for (u=0; u<layout->ndims; u++)
ent->offset[u] = offset[u];
- }
ent->rd_count = chunk_size;
ent->wr_count = chunk_size;
ent->chunk = chunk;
@@ -1522,17 +1496,15 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
* algorithm.
*/
if (ent->next) {
- if (ent->next->next) {
+ if (ent->next->next)
ent->next->next->prev = ent;
- } else {
+ else
rdcc->tail = ent;
- }
ent->next->prev = ent->prev;
- if (ent->prev) {
+ if (ent->prev)
ent->prev->next = ent->next;
- } else {
+ else
rdcc->head = ent->next;
- }
ent->prev = ent->next;
ent->next = ent->next->next;
ent->prev->next = ent;
@@ -1548,9 +1520,11 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
if (idx_hint)
*idx_hint = idx;
+
+ /* Set return value */
ret_value = chunk;
- done:
+done:
if (!ret_value)
H5MM_xfree (chunk);
FUNC_LEAVE (ret_value);
@@ -2052,6 +2026,7 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ )
#ifndef NDEBUG
unsigned u;
#endif
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_create, FAIL);
@@ -2060,17 +2035,16 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ )
assert(layout && H5D_CHUNKED == layout->type);
assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
#ifndef NDEBUG
- for (u = 0; u < layout->ndims; u++) {
+ for (u = 0; u < layout->ndims; u++)
assert(layout->dim[u] > 0);
- }
#endif
udata.mesg.ndims = layout->ndims;
- if (H5B_create(f, H5B_ISTORE, &udata, &(layout->addr)/*out*/) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
- }
+ if (H5B_create(f, H5B_ISTORE, &udata, &(layout->addr)/*out*/) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2097,16 +2071,20 @@ hsize_t
H5F_istore_allocated(H5F_t *f, unsigned ndims, haddr_t addr)
{
H5F_istore_ud1_t udata;
+ hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_nchunks, 0);
HDmemset(&udata, 0, sizeof udata);
udata.mesg.ndims = ndims;
- if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_allocated, addr, &udata)<0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
- "unable to iterate over chunk B-tree");
- }
- FUNC_LEAVE(udata.total_storage);
+ if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_allocated, addr, &udata)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree");
+
+ /* Set return value */
+ ret_value=udata.total_storage;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2132,17 +2110,18 @@ herr_t
H5F_istore_dump_btree(H5F_t *f, FILE *stream, unsigned ndims, haddr_t addr)
{
H5F_istore_ud1_t udata;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_dump_btree, FAIL);
HDmemset(&udata, 0, sizeof udata);
udata.mesg.ndims = ndims;
udata.stream = stream;
- if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_dump, addr, &udata)<0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
- "unable to iterate over chunk B-tree");
- }
- FUNC_LEAVE(SUCCEED);
+ if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_dump, addr, &udata)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2168,10 +2147,12 @@ H5F_istore_stats (H5F_t *f, hbool_t headers)
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
double miss_rate;
char ascii[32];
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_stats, FAIL);
- if (!H5DEBUG(AC)) HRETURN(SUCCEED);
+ if (!H5DEBUG(AC))
+ HGOTO_DONE(SUCCEED);
if (headers) {
fprintf(H5DEBUG(AC), "H5F: raw data cache statistics for file %s\n",
@@ -2204,7 +2185,8 @@ H5F_istore_stats (H5F_t *f, hbool_t headers)
rdcc->ninits, (long)(rdcc->nflushes)-(long)(rdcc->ninits));
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2349,6 +2331,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
int mpi_rank; /* This process's rank */
int mpi_size; /* Total # of processes */
int mpi_round=0; /* Current process responsible for I/O */
+ int mpi_code; /* MPI return code */
unsigned blocks_written=0; /* Flag to indicate that chunk was actually written */
int carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */
int i; /* Local index variable */
@@ -2468,11 +2451,10 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
/* Increment indices */
for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) {
chunk_offset[i] += layout->dim[i];
- if (chunk_offset[i] >= (hssize_t)(space_dim[i])) {
+ if (chunk_offset[i] >= (hssize_t)(space_dim[i]))
chunk_offset[i] = 0;
- } else {
+ else
carry = 0;
- }
} /* end for */
} /* end while */
@@ -2483,15 +2465,15 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
* them in, getting bogus data.
*/
if(IS_H5FD_MPIO(f)) {
- if (MPI_Barrier(H5FD_mpio_communicator(f->shared->lf)))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_Barrier(H5FD_mpio_communicator(f->shared->lf))))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code);
} /* end if */
else {
/* Sanity Check */
assert(IS_H5FD_MPIPOSIX(f));
- if (MPI_Barrier(H5FD_mpiposix_communicator(f->shared->lf)))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed");
+ if (MPI_SUCCESS!=(mpi_code=MPI_Barrier(H5FD_mpiposix_communicator(f->shared->lf))))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code);
} /* end else */
} /* end if */
@@ -2614,6 +2596,7 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
int found = 0; /*remove this entry */
H5F_istore_ud1_t udata; /*B-tree pass-through */
hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_prune_by_extent, FAIL);
@@ -2626,7 +2609,7 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
/* Go get the rank & dimensions */
if(H5S_get_simple_extent_dims(space, curr_dims, NULL) < 0)
- HRETURN_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
/*-------------------------------------------------------------------------
* Figure out what chunks are no longer in use for the specified extent
@@ -2654,13 +2637,9 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
#endif
/* Preempt the entry from the cache, but do not flush it to disk */
- if(H5F_istore_preempt(f, ent, FALSE) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
- "unable to preempt chunk");
- }
-
+ if(H5F_istore_preempt(f, ent, FALSE) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk");
}
-
}
/*-------------------------------------------------------------------------
@@ -2677,9 +2656,10 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
udata.dims = curr_dims;
if(H5B_iterate(f, H5B_ISTORE, H5F_istore_prune_extent, layout->addr, &udata) < 0)
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2708,6 +2688,7 @@ H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t UNUSED addr,
H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
unsigned u;
H5F_istore_ud1_t udata;
+ herr_t ret_value=SUCCEED; /* Return value */
/* The LT_KEY is the left key (the one that describes the chunk). It points to a chunk of
* storage that contains the beginning of the logical address space represented by UDATA.
@@ -2718,7 +2699,6 @@ H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t UNUSED addr,
/* Figure out what chunks are no longer in use for the specified extent and release them */
for(u = 0; u < bt_udata->mesg.ndims - 1; u++)
if((hsize_t)lt_key->offset[u] > bt_udata->dims[u]) {
-
#if defined (H5F_ISTORE_DEBUG)
HDfputs("b-tree:remove:[", bt_udata->stream);
for(u = 0; u < bt_udata->mesg.ndims - 1; u++) {
@@ -2734,11 +2714,12 @@ H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t UNUSED addr,
/* Remove */
if(H5B_remove(f, H5B_ISTORE, bt_udata->mesg.addr, &udata) < 0)
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
break;
} /* end if */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2881,7 +2862,6 @@ H5F_istore_initialize_by_extent(H5F_t *f, const H5O_layout_t *layout,
/* Loop over all chunks */
carry=0;
while(carry==0) {
-
for(u = 0, naccessed = 1; u < layout->ndims; u++) {
/* The location and size of the chunk being accessed */
chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]);
@@ -2940,7 +2920,6 @@ H5F_istore_initialize_by_extent(H5F_t *f, const H5O_layout_t *layout,
if(H5F_istore_unlock(f, dxpl_id, layout, &pline, TRUE,
chunk_offset, &idx_hint, chunk, (size_t)naccessed) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk");
-
} /*found */
/* Increment indices */
diff --git a/src/H5Dseq.c b/src/H5Dseq.c
index 8f988ff..d753dba 100644
--- a/src/H5Dseq.c
+++ b/src/H5Dseq.c
@@ -63,6 +63,8 @@ H5F_seq_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
const H5S_t *file_space, size_t elmt_size,
size_t seq_len, hsize_t file_offset, void *buf/*out*/)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5F_seq_read, FAIL);
/* Check args */
@@ -71,9 +73,10 @@ H5F_seq_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
assert(buf);
if (H5F_seq_readv(f, dxpl_id, layout, dc_plist, file_space, elmt_size, 1, &seq_len, &file_offset, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* H5F_seq_read() */
@@ -104,6 +107,8 @@ H5F_seq_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
const H5S_t *file_space, size_t elmt_size,
size_t seq_len, hsize_t file_offset, const void *buf)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5F_seq_write, FAIL);
/* Check args */
@@ -112,9 +117,10 @@ H5F_seq_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
assert(buf);
if (H5F_seq_writev(f, dxpl_id, layout, dc_plist, file_space, elmt_size, 1, &seq_len, &file_offset, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* H5F_seq_write() */
@@ -594,10 +600,8 @@ H5F_seq_writev(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
}
/* Collective MPIO access is unsupported for non-contiguous datasets */
- if (H5D_CONTIGUOUS!=layout->type && H5FD_MPIO_COLLECTIVE==xfer_mode) {
- HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL,
- "collective access on non-contiguous datasets not supported yet");
- }
+ if (H5D_CONTIGUOUS!=layout->type && H5FD_MPIO_COLLECTIVE==xfer_mode)
+ HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "collective access on non-contiguous datasets not supported yet");
#endif /* H5_HAVE_PARALLEL */
/* Get necessary properties from property list */
diff --git a/src/H5E.c b/src/H5E.c
index aa3201e..4067b40 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -533,6 +533,7 @@ const char *
H5Eget_major (H5E_major_t n)
{
unsigned i;
+ const char *ret_value="Invalid major error number";
/*
* WARNING: Do not call the FUNC_ENTER() or FUNC_LEAVE() macros since
@@ -545,10 +546,11 @@ H5Eget_major (H5E_major_t n)
for (i=0; i<NELMTS (H5E_major_mesg_g); i++) {
if (H5E_major_mesg_g[i].error_code==n)
- HRETURN(H5E_major_mesg_g[i].str);
+ HGOTO_DONE(H5E_major_mesg_g[i].str);
}
- FUNC_LEAVE("Invalid major error number");
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -573,6 +575,7 @@ const char *
H5Eget_minor (H5E_minor_t n)
{
unsigned i;
+ const char *ret_value="Invalid minor error number";
/*
* WARNING: Do not call the FUNC_ENTER() or FUNC_LEAVE() macros since
@@ -585,10 +588,11 @@ H5Eget_minor (H5E_minor_t n)
for (i=0; i<NELMTS (H5E_minor_mesg_g); i++) {
if (H5E_minor_mesg_g[i].error_code==n)
- HRETURN(H5E_minor_mesg_g[i].str);
+ HGOTO_DONE(H5E_minor_mesg_g[i].str);
}
- FUNC_LEAVE("Invalid minor error number");
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h
index d6466b7..424456e 100644
--- a/src/H5Eprivate.h
+++ b/src/H5Eprivate.h
@@ -51,6 +51,18 @@
}
/*
+ * HDONE_ERROR macro, used to facilitate error reporting between a
+ * FUNC_ENTER() and a FUNC_LEAVE() within a function body, but _AFTER_ the
+ * "done:" label. The arguments are
+ * the major error number, the minor error number, a return value, and a
+ * description of the error.
+ */
+#define HDONE_ERROR(maj, min, ret_val, str) { \
+ HCOMMON_ERROR (maj, min, str); \
+ ret_value = ret_val; \
+}
+
+/*
* HRETURN macro, used to facilitate returning from a function between a
* FUNC_ENTER() and a FUNC_LEAVE() within a function body. The argument is
* the return value.
@@ -128,6 +140,10 @@ extern int H5E_mpi_error_str_len;
MPI_Error_string(mpierr, H5E_mpi_error_str, &H5E_mpi_error_str_len); \
HERROR(H5E_INTERNAL, H5E_MPIERRSTR, H5E_mpi_error_str); \
}
+#define HMPI_DONE_ERROR(retcode, str, mpierr){ \
+ HMPI_ERROR(mpierr); \
+ HDONE_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \
+}
#define HMPI_GOTO_ERROR(retcode, str, mpierr){ \
HMPI_ERROR(mpierr); \
HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, retcode, str); \
diff --git a/src/H5F.c b/src/H5F.c
index 21683a4..5f70972 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -234,7 +234,7 @@ H5F_init_interface(void)
*/
if (H5I_init_group(H5I_FILE, H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)<0 ||
H5I_init_group(H5I_FILE_CLOSING, H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)<0)
- HRETURN_ERROR (H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface");
+ HGOTO_ERROR (H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface");
/* ========== File Creation Property Class Initialization ============*/
assert(H5P_CLS_FILE_CREATE_g!=-1);
@@ -317,7 +317,7 @@ H5F_init_interface(void)
} H5E_END_TRY;
if (status<0)
- HRETURN_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver registration failed");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver registration failed");
/* ========== File Access Property Class Initialization ============*/
assert(H5P_CLS_FILE_ACCESS_g!=-1);
@@ -701,12 +701,15 @@ H5F_flush_all(hbool_t invalidate)
herr_t
H5F_close_all(void)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5F_close_all, FAIL);
if (H5I_clear_group(H5I_FILE, FALSE)<0)
- HRETURN_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to close one or more files");
+ HGOTO_ERROR(H5E_FILE, H5E_CLOSEERROR, FAIL, "unable to close one or more files");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -774,7 +777,7 @@ H5Fget_create_plist(hid_t file_id)
{
H5F_t *file = NULL;
H5P_genplist_t *plist; /* Property list */
- hid_t ret_value = SUCCEED;
+ hid_t ret_value;
FUNC_ENTER_API(H5Fget_create_plist, FAIL);
H5TRACE1("i","i",file_id);
@@ -900,7 +903,7 @@ herr_t
H5Fget_obj_count(hid_t file_id, unsigned types, unsigned *obj_id_count)
{
H5F_t *f=NULL;
- herr_t ret_value = SUCCEED;
+ herr_t ret_value;
FUNC_ENTER_API(H5Fget_obj_counts, FAIL);
H5TRACE3("e","iIu*Iu",file_id,types,obj_id_count);
@@ -967,11 +970,12 @@ done:
herr_t
H5Fget_obj_ids(hid_t file_id, unsigned types, hid_t *oid_list)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value;
H5F_t *f=NULL;
FUNC_ENTER_API(H5Fget_obj_ids, FAIL);
H5TRACE3("e","iIu*i",file_id,types,oid_list);
+
if( file_id != H5F_OBJ_ALL && (NULL==(f=H5I_object_verify(file_id,H5I_FILE))) )
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id");
if( (types&H5F_OBJ_ALL)==0)
@@ -1213,16 +1217,16 @@ H5F_locate_signature(H5FD_t *file)
haddr_t addr, eoa;
uint8_t buf[H5F_SIGNATURE_LEN];
unsigned n, maxpow;
+ haddr_t ret_value; /* Return value */
FUNC_ENTER_NOINIT(H5F_locate_signature);
/* Find the least N such that 2^N is larger than the file size */
if (HADDR_UNDEF==(addr=H5FD_get_eof(file)) ||
- HADDR_UNDEF==(eoa=H5FD_get_eoa(file))) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF,
- "unable to obtain EOF/EOA value");
- }
- for (maxpow=0; addr; maxpow++) addr>>=1;
+ HADDR_UNDEF==(eoa=H5FD_get_eoa(file)))
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to obtain EOF/EOA value");
+ for (maxpow=0; addr; maxpow++)
+ addr>>=1;
maxpow = MAX(maxpow, 9);
/*
@@ -1231,15 +1235,12 @@ H5F_locate_signature(H5FD_t *file)
*/
for (n=8; n<maxpow; n++) {
addr = (8==n) ? 0 : (haddr_t)1 << n;
- if (H5FD_set_eoa(file, addr+H5F_SIGNATURE_LEN)<0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF,
- "unable to set EOA value for file signature");
- }
- if (H5FD_read(file, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, addr, H5F_SIGNATURE_LEN, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF,
- "unable to read file signature");
- }
- if (!HDmemcmp(buf, H5F_SIGNATURE, H5F_SIGNATURE_LEN)) break;
+ if (H5FD_set_eoa(file, addr+H5F_SIGNATURE_LEN)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to set EOA value for file signature");
+ if (H5FD_read(file, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, addr, H5F_SIGNATURE_LEN, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to read file signature");
+ if (!HDmemcmp(buf, H5F_SIGNATURE, H5F_SIGNATURE_LEN))
+ break;
}
/*
@@ -1248,12 +1249,14 @@ H5F_locate_signature(H5FD_t *file)
*/
if (n>=maxpow) {
H5FD_set_eoa(file, eoa);
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF,
- "unable to find a valid file signature");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, HADDR_UNDEF, "unable to find a valid file signature");
}
- /* Success */
- FUNC_LEAVE(addr);
+ /* Set return value */
+ ret_value=addr;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1281,28 +1284,28 @@ htri_t
H5Fis_hdf5(const char *name)
{
H5FD_t *file = NULL;
- htri_t ret_value = FAIL;
+ htri_t ret_value;
FUNC_ENTER_API(H5Fis_hdf5, FAIL);
H5TRACE1("b","s",name);
/* Check args and all the boring stuff. */
- if (!name || !*name) {
+ if (!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified");
- }
/* Open the file at the virtual file layer */
- if (NULL==(file=H5FD_open(name, H5F_ACC_RDONLY, H5P_DEFAULT,
- HADDR_UNDEF))) {
+ if (NULL==(file=H5FD_open(name, H5F_ACC_RDONLY, H5P_DEFAULT, HADDR_UNDEF)))
HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file");
- }
/* The file is an hdf5 file if the hdf5 file signature can be found */
ret_value = (HADDR_UNDEF!=H5F_locate_signature(file));
- done:
+done:
/* Close the file */
- if (file) H5FD_close(file);
+ if (file)
+ if(H5FD_close(file)<0 && ret_value>=0)
+ HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
+
FUNC_LEAVE(ret_value);
}
@@ -1338,7 +1341,7 @@ H5Fis_hdf5(const char *name)
static H5F_t *
H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id)
{
- H5F_t *f=NULL, *ret_value=NULL;
+ H5F_t *f=NULL, *ret_value;
int n;
H5P_genplist_t *plist; /* Property list */
@@ -1406,6 +1409,8 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id)
f->shared->nrefs++;
f->nrefs = 1;
+
+ /* Set return value */
ret_value = f;
done:
@@ -1601,7 +1606,7 @@ H5F_t *
H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
{
H5F_t *file=NULL; /*the success return value */
- H5F_t *ret_value=NULL;/*actual return value */
+ H5F_t *ret_value; /*actual return value */
H5F_file_t *shared=NULL; /*shared part of `file' */
H5FD_t *lf=NULL; /*file driver part of `shared' */
uint8_t buf[256]; /*temporary I/O buffer */
@@ -1934,35 +1939,35 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to set end-of-address marker for file");
}
- /* Decide the file close degree. If it's the first time to open the
- * file, set the degree to access property list value; if it's the
- * second time or later, verify the access property list value matches
- * the degree in shared file structure.
- */
- if(H5P_DEFAULT == fapl_id)
- fapl_id = H5P_FILE_ACCESS_DEFAULT;
- if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS) ||
- NULL == (a_plist = H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list");
- if(H5P_get(a_plist, H5F_CLOSE_DEGREE_NAME, &fc_degree) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree");
-
- if(shared->nrefs == 1) {
- if(fc_degree == H5F_CLOSE_DEFAULT)
- shared->fc_degree = H5F_CLOSE_DEFAULT;
- else
- shared->fc_degree = fc_degree;
- } else if(shared->nrefs > 1) {
- if(fc_degree != shared->fc_degree)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match");
- }
+ /* Decide the file close degree. If it's the first time to open the
+ * file, set the degree to access property list value; if it's the
+ * second time or later, verify the access property list value matches
+ * the degree in shared file structure.
+ */
+ if(H5P_DEFAULT == fapl_id)
+ fapl_id = H5P_FILE_ACCESS_DEFAULT;
+ if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS) ||
+ NULL == (a_plist = H5I_object(fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list");
+ if(H5P_get(a_plist, H5F_CLOSE_DEGREE_NAME, &fc_degree) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree");
+
+ if(shared->nrefs == 1) {
+ if(fc_degree == H5F_CLOSE_DEFAULT)
+ shared->fc_degree = H5F_CLOSE_DEFAULT;
+ else
+ shared->fc_degree = fc_degree;
+ } else if(shared->nrefs > 1) {
+ if(fc_degree != shared->fc_degree)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match");
+ }
/* Success */
ret_value = file;
done:
if (!ret_value && file)
- H5F_dest(file);
+ H5F_dest(file); /* Don't indicate error here, to leave the error stack with the correct error */
FUNC_LEAVE(ret_value);
}
@@ -2027,7 +2032,7 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id,
{
H5F_t *new_file = NULL; /*file struct for new file */
- hid_t ret_value = FAIL; /*return value */
+ hid_t ret_value; /*return value */
FUNC_ENTER_API(H5Fcreate, FAIL);
H5TRACE4("i","sIuii",filename,flags,fcpl_id,fapl_id);
@@ -2057,9 +2062,8 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id,
* the EXCL or TRUNC bit is set. All newly-created files are opened for
* reading and writing.
*/
- if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) {
+ if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC)))
flags |= H5F_ACC_EXCL; /*default*/
- }
flags |= H5F_ACC_RDWR | H5F_ACC_CREAT;
/*
@@ -2123,7 +2127,7 @@ hid_t
H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
{
H5F_t *new_file = NULL; /*file struct for new file */
- hid_t ret_value = FAIL; /*return value */
+ hid_t ret_value; /*return value */
FUNC_ENTER_API(H5Fopen, FAIL);
H5TRACE3("i","sIui",filename,flags,fapl_id);
@@ -2182,74 +2186,59 @@ H5Fflush(hid_t object_id, H5F_scope_t scope)
H5D_t *dset = NULL;
H5A_t *attr = NULL;
H5G_entry_t *ent = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Fflush, FAIL);
H5TRACE2("e","iFs",object_id,scope);
switch (H5I_get_type(object_id)) {
- case H5I_FILE:
- if (NULL==(f=H5I_object(object_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "invalid file identifier");
- }
- break;
+ case H5I_FILE:
+ if (NULL==(f=H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier");
+ break;
- case H5I_GROUP:
- if (NULL==(grp=H5I_object(object_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "invalid group identifier");
- }
- ent = H5G_entof(grp);
- break;
+ case H5I_GROUP:
+ if (NULL==(grp=H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier");
+ ent = H5G_entof(grp);
+ break;
- case H5I_DATATYPE:
- if (NULL==(type=H5I_object(object_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "invalid type identifier");
- }
- ent = H5T_entof(type);
- break;
+ case H5I_DATATYPE:
+ if (NULL==(type=H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier");
+ ent = H5T_entof(type);
+ break;
- case H5I_DATASET:
- if (NULL==(dset=H5I_object(object_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "invalid dataset identifier");
- }
- ent = H5D_entof(dset);
- break;
+ case H5I_DATASET:
+ if (NULL==(dset=H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier");
+ ent = H5D_entof(dset);
+ break;
- case H5I_ATTR:
- if (NULL==(attr=H5I_object(object_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "invalid attribute identifier");
- }
- ent = H5A_entof(attr);
- break;
+ case H5I_ATTR:
+ if (NULL==(attr=H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier");
+ ent = H5A_entof(attr);
+ break;
- default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file or file object");
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object");
}
if (!f) {
- if (!ent) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "object is not assocated with a file");
- }
+ if (!ent)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file");
f = ent->file;
}
- if (!f) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "object is not associated with a file");
- }
+ if (!f)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file");
/* Flush the file */
- if (H5F_flush(f, scope, FALSE, FALSE, FALSE)<0) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTINIT, FAIL,
- "flush failed");
- }
+ if (H5F_flush(f, scope, FALSE, FALSE, FALSE)<0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "flush failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2323,6 +2312,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
int btree_k[H5B_NUM_BTREE_ID]; /* B-tree size info */
unsigned sym_leaf_k; /* Number of symbols in B-tree leafs */
H5P_genplist_t *plist; /* Property list */
+ herr_t ret_value; /* Return value */
FUNC_ENTER_NOINIT(H5F_flush);
@@ -2333,7 +2323,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
* H5F_flush() with the read-only handle, still causes data to be flushed.
*/
if (0 == (H5F_ACC_RDWR & f->shared->flags))
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
/* Flush other stuff depending on scope */
if (H5F_SCOPE_GLOBAL==scope) {
@@ -2359,7 +2349,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
/* Return the unused portion of the metadata block to a free list */
if(f->shared->lf->eoma!=0)
if(H5FD_free(f->shared->lf,H5FD_MEM_DEFAULT,f->shared->lf->eoma,f->shared->lf->cur_meta_block_size)<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free metadata block");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free metadata block");
/* Reset metadata block information, just in case */
f->shared->lf->eoma=0;
@@ -2369,7 +2359,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
/* Return the unused portion of the "small data" block to a free list */
if(f->shared->lf->eosda!=0)
if(H5FD_free(f->shared->lf,H5FD_MEM_DRAW,f->shared->lf->eosda,f->shared->lf->cur_sdata_block_size)<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free 'small data' block");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "can't free 'small data' block");
/* Reset "small data" block information, just in case */
f->shared->lf->eosda=0;
@@ -2381,7 +2371,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
if(f->shared->sieve_buf && f->shared->sieve_dirty) {
/* Write dirty data sieve buffer to file */
if (H5F_block_write(f, H5FD_MEM_DRAW, f->shared->sieve_loc, f->shared->sieve_size, H5P_DATASET_XFER_DEFAULT, f->shared->sieve_buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -2389,29 +2379,29 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
/* flush the entire raw data cache */
if (H5F_istore_flush (f, invalidate)<0)
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush raw data cache");
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush raw data cache");
/* flush (and invalidate) the entire meta data cache */
if (H5AC_flush(f, NULL, HADDR_UNDEF, invalidate)<0)
- HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush meta data cache");
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush meta data cache");
} /* end if */
/* Get the shared file creation property list */
if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, &boot_vers) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get boot block version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get boot block version");
if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get free space version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get free space version");
if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get object directory version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get object directory version");
if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get shared-header format version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get shared-header format version");
if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for symbol table leaf nodes");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for symbol table leaf nodes");
if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes");
/* encode the file boot block */
p = sbuf;
@@ -2460,7 +2450,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
/* Encode driver-specific data */
if (H5FD_sb_encode(f->shared->lf, driver_name, dbuf+16)<0)
- HRETURN_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to encode driver information");
/* Driver name */
HDmemcpy(dbuf+8, driver_name, 8);
@@ -2482,9 +2472,9 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
superblock_size +
driver_size));
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate file space for userblock and/or superblock");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to allocate file space for userblock and/or superblock");
if (0!=addr)
- HRETURN_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver failed to allocate userblock and/or superblock at address zero");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "file driver failed to allocate userblock and/or superblock at address zero");
/*
* The file driver information block begins immediately after the
@@ -2503,7 +2493,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
if(chksum!=f->shared->boot_chksum) {
/* Write superblock */
if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, f->shared->boot_addr, superblock_size, sbuf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write superblock");
/* Update checksum information if different */
f->shared->boot_chksum=chksum;
@@ -2520,7 +2510,7 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
if(chksum!=f->shared->boot_chksum) {
/* Write driver information block */
if (H5FD_write(f->shared->lf, H5FD_MEM_SUPER, H5P_DATASET_XFER_DEFAULT, f->shared->base_addr+superblock_size, driver_size, dbuf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write driver information block");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to write driver information block");
/* Update checksum information if different */
f->shared->drvr_chksum=chksum;
@@ -2530,10 +2520,13 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate,
/* Flush file buffers to disk */
if (!alloc_only && H5FD_flush(f->shared->lf,closing)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed");
/* Check flush errors for children - errors are already on the stack */
- FUNC_LEAVE(nerrors ? FAIL : SUCCEED);
+ ret_value= (nerrors ? FAIL : SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_flush() */
@@ -2655,9 +2648,8 @@ H5F_close(H5F_t *f)
if (f->closing) {
#ifdef H5F_DEBUG
- if (H5DEBUG(F)) {
+ if (H5DEBUG(F))
fprintf(H5DEBUG(F), "H5F: H5F_close: operation completing\n");
- }
#endif
} /* end if */
@@ -2785,7 +2777,7 @@ H5Fclose(hid_t file_id)
HGOTO_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL, "problems closing file");
done:
- FUNC_LEAVE(ret_value < 0 ? FAIL : SUCCEED);
+ FUNC_LEAVE(ret_value);
}
@@ -2818,7 +2810,7 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child,
H5F_t *parent = NULL; /*file containing mount point */
int lt, rt, md, cmp; /*binary search indices */
H5G_entry_t *ent = NULL; /*temporary symbol table entry */
- herr_t ret_value = FAIL; /*return value */
+ herr_t ret_value = SUCCEED; /*return value */
FUNC_ENTER_NOINIT(H5F_mount);
@@ -2863,21 +2855,18 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child,
lt = md+1;
}
}
- if (cmp>0) md++;
- if (!cmp) {
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL,
- "mount point is already in use");
- }
+ if (cmp>0)
+ md++;
+ if (!cmp)
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use");
/* Make room in the table */
if (parent->mtab.nmounts>=parent->mtab.nalloc) {
unsigned n = MAX(16, 2*parent->mtab.nalloc);
H5F_mount_t *x = H5MM_realloc(parent->mtab.child,
n*sizeof(parent->mtab.child[0]));
- if (!x) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for mount table");
- }
+ if (!x)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table");
parent->mtab.child = x;
parent->mtab.nalloc = n;
}
@@ -2891,12 +2880,11 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child,
parent->mtab.child[md].file = child;
child->mtab.parent = parent;
child->nrefs++;
- ret_value = SUCCEED;
- done:
- if (ret_value<0 && mount_point) {
+done:
+ if (ret_value<0 && mount_point)
H5G_close(mount_point);
- }
+
FUNC_LEAVE(ret_value);
}
@@ -2946,9 +2934,8 @@ H5F_unmount(H5G_entry_t *loc, const char *name)
* If we get the root group and the file has a parent in the mount tree,
* then we must have found the mount point.
*/
- if (NULL==(mounted=H5G_open(loc, name))) {
+ if (NULL==(mounted=H5G_open(loc, name)))
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found");
- }
child = H5G_fileof(mounted);
mnt_ent = H5G_entof(mounted);
ent = H5G_entof(child->shared->root_grp);
@@ -2995,9 +2982,8 @@ H5F_unmount(H5G_entry_t *loc, const char *name)
lt = md+1;
}
}
- if (cmp) {
+ if (cmp)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point");
- }
/* Unmount the child */
parent->mtab.nmounts -= 1;
@@ -3010,8 +2996,11 @@ H5F_unmount(H5G_entry_t *loc, const char *name)
ret_value = SUCCEED;
}
- done:
- if (mounted) H5G_close(mounted);
+done:
+ if (mounted)
+ if(H5G_close(mounted)<0 && ret_value>=0)
+ HDONE_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "can't close group");
+
FUNC_LEAVE(ret_value);
}
@@ -3097,27 +3086,29 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id)
{
H5G_entry_t *loc = NULL;
H5F_t *child = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Fmount, FAIL);
H5TRACE4("e","isii",loc_id,name,child_id,plist_id);
/* Check arguments */
if (NULL==(loc=H5G_loc(loc_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
if (!name || !*name)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
if (NULL==(child=H5I_object_verify(child_id,H5I_FILE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
if(H5P_DEFAULT == plist_id)
plist_id = H5P_MOUNT_DEFAULT;
if(TRUE != H5P_isa_class(plist_id, H5P_MOUNT))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list");
/* Do the mount */
if (H5F_mount(loc, name, child, plist_id)<0)
- HRETURN_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file");
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3146,25 +3137,23 @@ herr_t
H5Funmount(hid_t loc_id, const char *name)
{
H5G_entry_t *loc = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Funmount, FAIL);
H5TRACE2("e","is",loc_id,name);
/* Check args */
- if (NULL==(loc=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (NULL==(loc=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
/* Unmount */
- if (H5F_unmount(loc, name)<0) {
- HRETURN_ERROR(H5E_FILE, H5E_MOUNT, FAIL,
- "unable to unmount file");
- }
+ if (H5F_unmount(loc, name)<0)
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3195,7 +3184,7 @@ H5Freopen(hid_t file_id)
{
H5F_t *old_file=NULL;
H5F_t *new_file=NULL;
- hid_t ret_value = -1;
+ hid_t ret_value;
FUNC_ENTER_API(H5Freopen, FAIL);
H5TRACE1("i","i",file_id);
@@ -3272,6 +3261,7 @@ H5F_sizeof_addr(const H5F_t *f)
{
size_t sizeof_addr = 0;
H5P_genplist_t *plist; /* Property list */
+ size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5F_sizeof_addr, 0);
@@ -3280,12 +3270,16 @@ H5F_sizeof_addr(const H5F_t *f)
/* Get property list */
if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a property list");
if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get byte number for address");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get byte number for address");
+
+ /* Set return value */
+ ret_value=sizeof_addr;
- FUNC_LEAVE(sizeof_addr);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3313,6 +3307,7 @@ H5F_sizeof_size(const H5F_t *f)
{
size_t sizeof_size = 0;
H5P_genplist_t *plist; /* Property list */
+ size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5F_sizeof_size, 0);
@@ -3321,12 +3316,16 @@ H5F_sizeof_size(const H5F_t *f)
/* Get property list */
if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a property list");
if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get byte number for object size");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get byte number for object size");
- FUNC_LEAVE(sizeof_size);
+ /* Set return value */
+ ret_value=sizeof_size;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3431,6 +3430,7 @@ H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_
void *buf/*out*/)
{
haddr_t abs_addr;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_block_read, FAIL);
@@ -3443,12 +3443,13 @@ H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, hid_t dxpl_
abs_addr = f->shared->base_addr + addr;
/* Read the data */
- if (H5FD_read(f->shared->lf, type, dxpl_id, abs_addr, size, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
- }
-
- FUNC_LEAVE(SUCCEED);
+ if (H5FD_read(f->shared->lf, type, dxpl_id, abs_addr, size, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5F_block_write
@@ -3485,6 +3486,7 @@ H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size,
hid_t dxpl_id, const void *buf)
{
haddr_t abs_addr;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_block_write, FAIL);
@@ -3493,19 +3495,18 @@ H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size,
assert (size<SIZET_MAX);
assert (buf);
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "no write intent");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "no write intent");
/* Convert the relative address to an absolute address */
abs_addr = f->shared->base_addr + addr;
/* Write the data */
- if (H5FD_write(f->shared->lf, type, dxpl_id, abs_addr, size, buf)) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
- }
+ if (H5FD_write(f->shared->lf, type, dxpl_id, abs_addr, size, buf))
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3544,9 +3545,8 @@ H5F_addr_encode(H5F_t *f, uint8_t **pp/*in,out*/, haddr_t addr)
assert("overflow" && 0 == tmp);
} else {
- for (i=0; i<H5F_SIZEOF_ADDR(f); i++) {
+ for (i=0; i<H5F_SIZEOF_ADDR(f); i++)
*(*pp)++ = 0xff;
- }
}
}
@@ -3586,7 +3586,8 @@ H5F_addr_decode(H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/)
for (i=0; i<H5F_SIZEOF_ADDR(f); i++) {
c = *(*pp)++;
- if (c != 0xff) all_zero = FALSE;
+ if (c != 0xff)
+ all_zero = FALSE;
if (i<sizeof(*addr_p)) {
tmp = c;
@@ -3596,7 +3597,8 @@ H5F_addr_decode(H5F_t *f, const uint8_t **pp/*in,out*/, haddr_t *addr_p/*out*/)
assert(0 == **pp); /*overflow */
}
}
- if (all_zero) *addr_p = HADDR_UNDEF;
+ if (all_zero)
+ *addr_p = HADDR_UNDEF;
}
@@ -3671,6 +3673,7 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent,
size_t sizeof_addr, sizeof_size;
int boot_vers, freespace_vers, obj_dir_vers, share_head_vers;
H5P_genplist_t *plist; /* Property list */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_debug, FAIL);
@@ -3683,28 +3686,28 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent,
/* Get property list */
if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
if(H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, &userblock_size)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block size");
if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes");
if(H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes");
if(H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &sizeof_addr)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address");
if(H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object size");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object size");
if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, &boot_vers)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get boot block version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get boot block version");
if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, &freespace_vers)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get boot block version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get boot block version");
if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, &obj_dir_vers)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version");
if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, &share_head_vers)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header format version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header format version");
/* debug */
HDfprintf(stream, "%*sFile Boot Block...\n", indent, "");
@@ -3757,5 +3760,7 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent,
H5G_ent_debug(f, H5G_entof(f->shared->root_grp), stream,
indent+3, MAX(0, fwidth-3), HADDR_UNDEF);
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5FD.c b/src/H5FD.c
index 49e7789..6047e5f 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -76,18 +76,19 @@ static unsigned long file_serial_no[2];
static herr_t
H5FD_init_interface(void)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5FD_init_interface);
if (H5I_init_group(H5I_VFL, H5I_VFL_HASHSIZE, 0,
- (H5I_free_t)H5FD_free_cls)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "unable to initialize interface");
- }
+ (H5I_free_t)H5FD_free_cls)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to initialize interface");
/* Reset the file serial numbers */
HDmemset(file_serial_no,0,sizeof(file_serial_no));
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -184,60 +185,48 @@ H5FD_free_cls(H5FD_class_t *cls)
hid_t
H5FDregister(const H5FD_class_t *cls)
{
- hid_t retval;
- H5FD_class_t *saved;
+ hid_t ret_value;
+ H5FD_class_t *saved=NULL;
H5FD_mem_t type;
FUNC_ENTER_API(H5FDregister, FAIL);
H5TRACE1("i","x",cls);
/* Check arguments */
- if (!cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL,
- "null class pointer is disallowed");
- }
+ if (!cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed");
- if (!cls->open || !cls->close) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL,
- "`open' and/or `close' methods are not defined");
- }
+ if (!cls->open || !cls->close)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`open' and/or `close' methods are not defined");
- if (!cls->get_eoa || !cls->set_eoa) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL,
- "`get_eoa' and/or `set_eoa' methods are not defined");
- }
+ if (!cls->get_eoa || !cls->set_eoa)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eoa' and/or `set_eoa' methods are not defined");
- if (!cls->get_eof) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL,
- "`get_eof' method is not defined");
- }
- if (!cls->read || !cls->write) {
- HRETURN_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL,
- "`read' and/or `write' method is not defined");
- }
+ if (!cls->get_eof)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eof' method is not defined");
+ if (!cls->read || !cls->write)
+ HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`read' and/or `write' method is not defined");
for (type=H5FD_MEM_DEFAULT; type<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,type)) {
if (cls->fl_map[type]<H5FD_MEM_NOLIST ||
- cls->fl_map[type]>=H5FD_MEM_NTYPES) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid free-list mapping");
- }
+ cls->fl_map[type]>=H5FD_MEM_NTYPES)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid free-list mapping");
}
/* Copy the class structure so the caller can reuse or free it */
- if (NULL==(saved=H5MM_malloc(sizeof(H5FD_class_t)))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for file driver class struct");
- }
+ if (NULL==(saved=H5MM_malloc(sizeof(H5FD_class_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for file driver class struct");
*saved = *cls;
/* Create the new class ID */
- if ((retval=H5I_register(H5I_VFL, saved))<0) {
- H5MM_xfree(saved);
- HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register file driver ID");
- }
+ if ((ret_value=H5I_register(H5I_VFL, saved))<0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register file driver ID");
+
+done:
+ if(ret_value<0)
+ if(saved)
+ H5MM_xfree(saved);
- FUNC_LEAVE(retval);
+ FUNC_LEAVE(ret_value);
}
@@ -263,18 +252,21 @@ H5FDregister(const H5FD_class_t *cls)
herr_t
H5FDunregister(hid_t driver_id)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5FDunregister, FAIL);
H5TRACE1("e","i",driver_id);
/* Check arguments */
if (NULL==H5I_object_verify(driver_id,H5I_VFL))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver");
/* The H5FD_class_t struct will be freed by this function */
if (H5I_dec_ref(driver_id)<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to unregister file driver");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to unregister file driver");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -319,21 +311,22 @@ H5FD_get_class(hid_t id)
} else {
/* Get the plist structure */
if(NULL == (plist = H5I_object(id)))
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID");
if (TRUE==H5P_isa_class(id,H5P_FILE_ACCESS)) {
if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID");
ret_value = H5FD_get_class(driver_id);
} else if (TRUE==H5P_isa_class(id,H5P_DATASET_XFER)) {
if(H5P_get(plist, H5D_XFER_VFL_ID_NAME, &driver_id) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID");
ret_value = H5FD_get_class(driver_id);
} else {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver id, file access property list or data transfer property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver id, file access property list or data transfer property list");
}
} /* end if */
+done:
FUNC_LEAVE(ret_value);
}
@@ -364,9 +357,9 @@ H5FD_sb_size(H5FD_t *file)
FUNC_ENTER_NOAPI(H5FD_sb_size, 0);
assert(file && file->cls);
- if (file->cls->sb_size) {
+
+ if (file->cls->sb_size)
ret_value = (file->cls->sb_size)(file);
- }
FUNC_LEAVE(ret_value);
}
@@ -396,16 +389,17 @@ H5FD_sb_size(H5FD_t *file)
herr_t
H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5FD_sb_encode, FAIL);
assert(file && file->cls);
if (file->cls->sb_encode &&
- (file->cls->sb_encode)(file, name/*out*/, buf/*out*/)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "driver sb_encode request failed");
- }
+ (file->cls->sb_encode)(file, name/*out*/, buf/*out*/)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -428,16 +422,17 @@ H5FD_sb_encode(H5FD_t *file, char *name/*out*/, uint8_t *buf)
herr_t
H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5FD_sb_decode, FAIL);
assert(file && file->cls);
if (file->cls->sb_decode &&
- (file->cls->sb_decode)(file, name, buf)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "driver sb_decode request failed");
- }
+ (file->cls->sb_decode)(file, name, buf)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -476,9 +471,8 @@ H5FD_fapl_get(H5FD_t *file)
assert(file);
- if (file->cls->fapl_get) {
+ if (file->cls->fapl_get)
ret_value = (file->cls->fapl_get)(file);
- }
FUNC_LEAVE(ret_value);
}
@@ -509,14 +503,15 @@ H5FD_fapl_copy(hid_t driver_id, const void *old_fapl)
{
void *new_fapl = NULL;
H5FD_class_t *driver=NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_fapl_copy, NULL);
/* Check args */
if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver ID");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver ID");
if (!old_fapl)
- HRETURN(NULL); /*but no error*/
+ HGOTO_DONE(NULL); /*but no error*/
/* Allow the driver to copy or do it ourselves */
if (driver->fapl_copy) {
@@ -524,12 +519,14 @@ H5FD_fapl_copy(hid_t driver_id, const void *old_fapl)
} else if (driver->fapl_size>0) {
new_fapl = H5MM_malloc(driver->fapl_size);
HDmemcpy(new_fapl, old_fapl, driver->fapl_size);
- } else {
- HRETURN_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL,
- "no way to copy driver file access property list");
- }
+ } else
+ HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "no way to copy driver file access property list");
+
+ /* Set return value */
+ ret_value=new_fapl;
- FUNC_LEAVE(new_fapl);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -553,24 +550,24 @@ herr_t
H5FD_fapl_free(hid_t driver_id, void *fapl)
{
H5FD_class_t *driver=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_fapl_free, FAIL);
/* Check args */
if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID");
/* Allow driver to free or do it ourselves */
if (fapl && driver->fapl_free) {
- if ((driver->fapl_free)(fapl)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "driver fapl_free request failed");
- }
+ if ((driver->fapl_free)(fapl)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver fapl_free request failed");
} else {
H5MM_xfree(fapl);
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -599,14 +596,15 @@ H5FD_dxpl_copy(hid_t driver_id, const void *old_dxpl)
{
void *new_dxpl = NULL;
H5FD_class_t *driver=NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_dxpl_copy, NULL);
/* Check args */
if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver ID");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver ID");
if (!old_dxpl)
- HRETURN(NULL); /*but no error*/
+ HGOTO_DONE(NULL); /*but no error*/
/* Allow the driver to copy or do it ourselves */
if (driver->dxpl_copy) {
@@ -614,12 +612,14 @@ H5FD_dxpl_copy(hid_t driver_id, const void *old_dxpl)
} else if (driver->dxpl_size>0) {
new_dxpl = H5MM_malloc(driver->dxpl_size);
HDmemcpy(new_dxpl, old_dxpl, driver->dxpl_size);
- } else {
- HRETURN_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL,
- "no way to copy driver file access property list");
- }
+ } else
+ HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "no way to copy driver file access property list");
- FUNC_LEAVE(new_dxpl);
+ /* Set return value */
+ ret_value=new_dxpl;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -643,24 +643,24 @@ herr_t
H5FD_dxpl_free(hid_t driver_id, void *dxpl)
{
H5FD_class_t *driver=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_dxpl_free, FAIL);
/* Check args */
if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID");
/* Allow driver to free or do it ourselves */
if (dxpl && driver->dxpl_free) {
- if ((driver->dxpl_free)(dxpl)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "driver dxpl_free request failed");
- }
+ if ((driver->dxpl_free)(dxpl)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver dxpl_free request failed");
} else {
H5MM_xfree(dxpl);
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -726,11 +726,10 @@ H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
FUNC_ENTER_API(H5FDopen, NULL);
- if (NULL==(ret_value=H5FD_open(name, flags, fapl_id, maxaddr))) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, NULL,
- "unable to open file");
- }
+ if (NULL==(ret_value=H5FD_open(name, flags, fapl_id, maxaddr)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to open file");
+done:
FUNC_LEAVE(ret_value);
}
@@ -765,6 +764,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
hsize_t meta_block_size=0;
hsize_t sdata_block_size=0;
H5P_genplist_t *plist; /* Property list pointer */
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_open, NULL);
@@ -772,25 +772,25 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
if(H5P_DEFAULT == fapl_id)
fapl_id = H5P_FILE_ACCESS_DEFAULT;
if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
if (0==maxaddr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range");
if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID");
/* Get driver info */
if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL)))
- HRETURN_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list");
+ HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list");
if (NULL==driver->open)
- HRETURN_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method");
+ HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method");
/* Dispatch to file driver */
if (HADDR_UNDEF==maxaddr)
maxaddr = driver->maxaddr;
if (NULL==(file=(driver->open)(name, flags, fapl_id, maxaddr)))
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "open failed");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "open failed");
/*
* Fill in public fields. We must increment the reference count on the
@@ -802,30 +802,35 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
file->maxaddr = maxaddr;
HDmemset(file->fl, 0, sizeof(file->fl));
if(H5P_get(plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(meta_block_size)) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get meta data block size");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get meta data block size");
file->def_meta_block_size = meta_block_size;
if(H5P_get(plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(sdata_block_size)) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'small data' block size");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get 'small data' block size");
file->def_sdata_block_size = sdata_block_size;
file->accum_loc = HADDR_UNDEF;
if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(file->threshold)) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment threshold");
if(H5P_get(plist, H5F_ACS_ALIGN_NAME, &(file->alignment)) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get alignment");
/* Retrieve the VFL driver feature flags */
if (H5FD_query(file, &(file->feature_flags))<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to query file driver");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to query file driver");
/* Increment the global serial number & assign it to this H5FD_t object */
if(++file_serial_no[0]==0) {
/* (Just error out if we wrap both numbers around for now...) */
if(++file_serial_no[1]==0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to get file serial number");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to get file serial number");
} /* end if */
HDmemcpy(file->fileno,file_serial_no,sizeof(file_serial_no));
- FUNC_LEAVE(file);
+ /* Set return value */
+ ret_value=file;
+
+done:
+ /* Can't cleanup 'file' information, since we don't know what type it is */
+ FUNC_LEAVE(ret_value);
}
@@ -852,18 +857,19 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
herr_t
H5FDclose(H5FD_t *file)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5FDclose, FAIL);
H5TRACE1("e","x",file);
- if (!file || !file->cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
- }
+ if (!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
- if (H5FD_close(file)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to close file");
- }
+ if (H5FD_close(file)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to close file");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -896,6 +902,7 @@ H5FD_close(H5FD_t *file)
unsigned nblocks=0;
hsize_t nbytes=0;
#endif
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_close, FAIL);
@@ -944,10 +951,11 @@ H5FD_close(H5FD_t *file)
* close the file then the file will be in an unusable state.
*/
assert(driver->close);
- if ((driver->close)(file)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "close failed");
- }
- FUNC_LEAVE(SUCCEED);
+ if ((driver->close)(file)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "close failed");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -984,6 +992,7 @@ H5FDcmp(const H5FD_t *f1, const H5FD_t *f2)
H5TRACE2("Is","xx",f1,f2);
ret_value = H5FD_cmp(f1, f2);
+
FUNC_LEAVE(ret_value);
}
@@ -1011,21 +1020,29 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2)
FUNC_ENTER_NOAPI(H5FD_cmp, -1); /*return value is arbitrary*/
- if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HRETURN(0);
- if (!f1 || !f1->cls) HRETURN(-1);
- if (!f2 || !f2->cls) HRETURN(1);
- if (f1->cls < f2->cls) HRETURN(-1);
- if (f1->cls > f2->cls) HRETURN(1);
+ if ((!f1 || !f1->cls) && (!f2 || !f2->cls))
+ HGOTO_DONE(0);
+ if (!f1 || !f1->cls)
+ HGOTO_DONE(-1);
+ if (!f2 || !f2->cls)
+ HGOTO_DONE(1);
+ if (f1->cls < f2->cls)
+ HGOTO_DONE(-1);
+ if (f1->cls > f2->cls)
+ HGOTO_DONE(1);
/* Files are same driver; no cmp callback */
if (!f1->cls->cmp) {
- if (f1<f2) HRETURN(-1);
- if (f1>f2) HRETURN(1);
- HRETURN(0);
+ if (f1<f2)
+ HGOTO_DONE(-1);
+ if (f1>f2)
+ HGOTO_DONE(1);
+ HGOTO_DONE(0);
}
ret_value = (f1->cls->cmp)(f1, f2);
+done:
FUNC_LEAVE(ret_value);
}
@@ -1149,25 +1166,18 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
H5TRACE3("a","xMth",file,type,size);
/* Check args */
- if (!file || !file->cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF,
- "invalid file pointer");
- }
- if (type<0 || type>=H5FD_MEM_NTYPES) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF,
- "invalid request type");
- }
- if (size<=0) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF,
- "zero-size request");
- }
+ if (!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer");
+ if (type<0 || type>=H5FD_MEM_NTYPES)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid request type");
+ if (size<=0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "zero-size request");
/* Do the real work */
- if (HADDR_UNDEF==(ret_value=H5FD_alloc(file, type, size))) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF,
- "unable to allocate file memory");
- }
+ if (HADDR_UNDEF==(ret_value=H5FD_alloc(file, type, size)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory");
+done:
FUNC_LEAVE(ret_value);
}
@@ -1457,7 +1467,7 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
/* Return the unused portion of the metadata block to a free list */
if(file->eoma!=0)
if(H5FD_free(file,H5FD_MEM_DEFAULT,file->eoma,file->cur_meta_block_size)<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free metadata block");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free metadata block");
/* Point the metadata block at the newly allocated block */
file->eoma=new_meta;
@@ -1526,7 +1536,7 @@ H5FD_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
/* Return the unused portion of the "small data" block to a free list */
if(file->eosda!=0)
if(H5FD_free(file,H5FD_MEM_DRAW,file->eosda,file->cur_sdata_block_size)<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free 'small data' block");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, HADDR_UNDEF, "can't free 'small data' block");
/* Point the "small data" block at the newly allocated block */
file->eosda=new_data;
@@ -1593,10 +1603,8 @@ H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
*/
if (file->cls->alloc) {
ret_value = (file->cls->alloc)(file, type, size);
- if (HADDR_UNDEF==ret_value) {
- HRETURN_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF,
- "driver allocation request failed");
- }
+ if (HADDR_UNDEF==ret_value)
+ HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "driver allocation request failed");
} else {
hsize_t wasted;
haddr_t oldeoa=0;
@@ -1615,28 +1623,20 @@ H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
wasted = file->alignment - wasted; /* actual waste */
oldeoa = eoa; /* save it for later freeing */
/* advance eoa to the next alignment by allocating the wasted */
- if (H5F_addr_overflow(eoa, wasted) || eoa+wasted>file->maxaddr) {
- HRETURN_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation request failed");
- }
+ if (H5F_addr_overflow(eoa, wasted) || eoa+wasted>file->maxaddr)
+ HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed");
eoa += wasted;
- if ((file->cls->set_eoa)(file, eoa)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation request failed");
- }
+ if ((file->cls->set_eoa)(file, eoa)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed");
}
/* allocate the aligned memory */
- if (H5F_addr_overflow(eoa, size) || eoa+size>file->maxaddr) {
- HRETURN_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation request failed");
- }
+ if (H5F_addr_overflow(eoa, size) || eoa+size>file->maxaddr)
+ HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed");
ret_value = eoa;
eoa += size;
- if ((file->cls->set_eoa)(file, eoa)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation request failed");
- }
+ if ((file->cls->set_eoa)(file, eoa)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, HADDR_UNDEF, "file allocation request failed");
/* Free the wasted memory */
if (wasted)
@@ -1651,6 +1651,7 @@ H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
#endif
}
+done:
FUNC_LEAVE(ret_value);
} /* end H5FD_real_alloc() */
@@ -1680,24 +1681,23 @@ H5FD_real_alloc(H5FD_t *file, H5FD_mem_t type, hsize_t size)
herr_t
H5FDfree(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5FDfree, FAIL);
H5TRACE4("e","xMtah",file,type,addr,size);
/* Check args */
- if (!file || !file->cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
- }
- if (type<0 || type>=H5FD_MEM_NTYPES) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request type");
- }
+ if (!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
+ if (type<0 || type>=H5FD_MEM_NTYPES)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request type");
/* Do the real work */
- if (H5FD_free(file, type, addr, size)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "file deallocation request failed");
- }
+ if (H5FD_free(file, type, addr, size)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file deallocation request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1721,6 +1721,7 @@ herr_t
H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
{
H5FD_mem_t mapped_type;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_free, FAIL);
@@ -1728,13 +1729,12 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
assert(file && file->cls);
assert(type>=0 && type<H5FD_MEM_NTYPES);
if (!H5F_addr_defined(addr) || addr>file->maxaddr ||
- H5F_addr_overflow(addr, size) || addr+size>file->maxaddr) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid region");
- }
+ H5F_addr_overflow(addr, size) || addr+size>file->maxaddr)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid region");
/* Allow 0-sized free's to occur without penalty */
if(0==size)
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
/* Map request type to free list */
if (H5FD_MEM_DEFAULT==file->cls->fl_map[type]) {
@@ -1757,15 +1757,14 @@ H5FD_free(H5FD_t *file, H5FD_mem_t type, haddr_t addr, hsize_t size)
file->fl[mapped_type] = cur;
file->maxsize = MAX(file->maxsize, size);
} else if (file->cls->free) {
- if ((file->cls->free)(file, type, addr, size)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "driver free request failed");
- }
+ if ((file->cls->free)(file, type, addr, size)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver free request failed");
} else {
/* leak memory */
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1796,12 +1795,10 @@ H5FDrealloc(H5FD_t *file, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
FUNC_ENTER_API(H5FDrealloc, HADDR_UNDEF);
H5TRACE5("a","xMtahh",file,type,old_addr,old_size,new_size);
- if (HADDR_UNDEF==(ret_value=H5FD_realloc(file, type, old_addr, old_size,
- new_size))) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF,
- "file reallocation request failed");
- }
+ if (HADDR_UNDEF==(ret_value=H5FD_realloc(file, type, old_addr, old_size, new_size)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file reallocation request failed");
+done:
FUNC_LEAVE(ret_value);
}
@@ -1830,6 +1827,7 @@ H5FD_realloc(H5FD_t *file, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
haddr_t new_addr=old_addr;
uint8_t _buf[8192];
uint8_t *buf=_buf;
+ haddr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_realloc, HADDR_UNDEF);
@@ -1839,10 +1837,8 @@ H5FD_realloc(H5FD_t *file, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
} else if (0==old_size) {
/* allocate memory */
assert(!H5F_addr_defined(old_addr));
- if (HADDR_UNDEF==(new_addr=H5FDalloc(file, type, new_size))) {
- HRETURN_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation failed");
- }
+ if (HADDR_UNDEF==(new_addr=H5FDalloc(file, type, new_size)))
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed");
} else if (0==new_size) {
/* free memory */
assert(H5F_addr_defined(old_addr));
@@ -1860,22 +1856,18 @@ H5FD_realloc(H5FD_t *file, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
* to move pieces of the realloced data through a fixed size buffer, etc.
* -QAK, 6/20/01
*/
- if (HADDR_UNDEF==(new_addr=H5FDalloc(file, type, new_size))) {
- HRETURN_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation failed");
- }
+ if (HADDR_UNDEF==(new_addr=H5FDalloc(file, type, new_size)))
+ HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed");
H5_CHECK_OVERFLOW(old_size,hsize_t,size_t);
if (old_size>sizeof(_buf) && NULL==(buf=H5MM_malloc((size_t)old_size))) {
H5FDfree(file, type, new_addr, new_size);
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF,
- "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "memory allocation failed");
}
if (H5FDread(file, type, H5P_DEFAULT, old_addr, (size_t)old_size, buf)<0 ||
H5FDwrite(file, type, H5P_DEFAULT, new_addr, (size_t)old_size, buf)<0) {
H5FDfree(file, type, new_addr, new_size);
H5MM_xfree(buf);
- HRETURN_ERROR(H5E_FILE, H5E_READERROR, HADDR_UNDEF,
- "unable to move file block");
+ HGOTO_ERROR(H5E_FILE, H5E_READERROR, HADDR_UNDEF, "unable to move file block");
}
if (buf!=_buf)
@@ -1883,7 +1875,11 @@ H5FD_realloc(H5FD_t *file, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
H5FDfree(file, type, old_addr, old_size);
}
- FUNC_LEAVE(new_addr);
+ /* Set return value */
+ ret_value=new_addr;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1907,24 +1903,21 @@ H5FD_realloc(H5FD_t *file, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
haddr_t
H5FDget_eoa(H5FD_t *file)
{
- haddr_t addr;
+ haddr_t ret_value;
FUNC_ENTER_API(H5FDget_eoa, HADDR_UNDEF);
H5TRACE1("a","x",file);
/* Check args */
- if (!file || !file->cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF,
- "invalid file pointer");
- }
+ if (!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer");
/* The real work */
- if (HADDR_UNDEF==(addr=H5FD_get_eoa(file))) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF,
- "file get eoa request failed");
- }
+ if (HADDR_UNDEF==(ret_value=H5FD_get_eoa(file)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eoa request failed");
- FUNC_LEAVE(addr);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1947,18 +1940,17 @@ H5FDget_eoa(H5FD_t *file)
haddr_t
H5FD_get_eoa(H5FD_t *file)
{
- haddr_t addr;
+ haddr_t ret_value;
FUNC_ENTER_NOAPI(H5FD_get_eoa, HADDR_UNDEF);
assert(file && file->cls);
/* Dispatch to driver */
- if (HADDR_UNDEF==(addr=(file->cls->get_eoa)(file))) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF,
- "driver get_eoa request failed");
- }
+ if (HADDR_UNDEF==(ret_value=(file->cls->get_eoa)(file)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed");
- FUNC_LEAVE(addr);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1992,25 +1984,23 @@ H5FD_get_eoa(H5FD_t *file)
herr_t
H5FDset_eoa(H5FD_t *file, haddr_t addr)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5FDset_eoa, FAIL);
H5TRACE2("e","xa",file,addr);
/* Check args */
- if (!file || !file->cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
- }
- if (!H5F_addr_defined(addr) || addr>file->maxaddr) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid end-of-address value");
- }
+ if (!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
+ if (!H5F_addr_defined(addr) || addr>file->maxaddr)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid end-of-address value");
/* The real work */
- if (H5FD_set_eoa(file, addr)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "file set eoa request failed");
- }
+ if (H5FD_set_eoa(file, addr)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file set eoa request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2033,18 +2023,19 @@ H5FDset_eoa(H5FD_t *file, haddr_t addr)
herr_t
H5FD_set_eoa(H5FD_t *file, haddr_t addr)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5FD_set_eoa, FAIL);
assert(file && file->cls);
assert(H5F_addr_defined(addr) && addr<=file->maxaddr);
/* Dispatch to driver */
- if ((file->cls->set_eoa)(file, addr)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "driver set_eoa request failed");
- }
+ if ((file->cls->set_eoa)(file, addr)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver set_eoa request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2077,24 +2068,21 @@ H5FD_set_eoa(H5FD_t *file, haddr_t addr)
haddr_t
H5FDget_eof(H5FD_t *file)
{
- haddr_t addr;
+ haddr_t ret_value;
FUNC_ENTER_API(H5FDget_eof, HADDR_UNDEF);
H5TRACE1("a","x",file);
/* Check arguments */
- if (!file || !file->cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF,
- "invalid file pointer");
- }
+ if (!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer");
/* The real work */
- if (HADDR_UNDEF==(addr=H5FD_get_eof(file))) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF,
- "file get eof request failed");
- }
+ if (HADDR_UNDEF==(ret_value=H5FD_get_eof(file)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eof request failed");
- FUNC_LEAVE(addr);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2117,7 +2105,7 @@ H5FDget_eof(H5FD_t *file)
haddr_t
H5FD_get_eof(H5FD_t *file)
{
- haddr_t addr=HADDR_UNDEF;
+ haddr_t ret_value;
FUNC_ENTER_NOAPI(H5FD_get_eof, HADDR_UNDEF);
@@ -2125,15 +2113,14 @@ H5FD_get_eof(H5FD_t *file)
/* Dispatch to driver */
if (file->cls->get_eof) {
- if (HADDR_UNDEF==(addr=(file->cls->get_eof)(file))) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF,
- "driver get_eof request failed");
- }
+ if (HADDR_UNDEF==(ret_value=(file->cls->get_eof)(file)))
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eof request failed");
} else {
- addr = file->maxaddr;
+ ret_value = file->maxaddr;
}
- FUNC_LEAVE(addr);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2162,26 +2149,30 @@ herr_t
H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
void *buf/*out*/)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5FDread, FAIL);
H5TRACE6("e","xMtiazx",file,type,dxpl_id,addr,size,buf);
/* Check args */
if (!file || !file->cls)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
+
/* Get the default dataset transfer property list if the user didn't provide one */
if (H5P_DEFAULT == dxpl_id)
dxpl_id= H5P_DATASET_XFER_DEFAULT;
if (H5I_GENPROP_LST != H5I_get_type(dxpl_id) ||
TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list");
if (!buf)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer");
/* Do the real work */
if (H5FD_read(file, type, dxpl_id, addr, size, buf)<0)
- HRETURN_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2209,6 +2200,8 @@ herr_t
H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
void *buf/*out*/)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5FD_read, FAIL);
assert(file && file->cls);
@@ -2220,7 +2213,8 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
/* Do not return early for Parallel mode since the I/O could be a */
/* collective transfer. */
/* The no-op case */
- if (0==size) HRETURN(SUCCEED);
+ if (0==size)
+ HGOTO_DONE(SUCCEED);
#endif /* H5_HAVE_PARALLEL */
/* Check if this information is in the metadata accumulator */
@@ -2244,7 +2238,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
/* Dispatch to driver */
if ((file->cls->read)(file, type, dxpl_id, addr, amount_read, read_buf)<0)
- HRETURN_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
/* Adjust the buffer, address & size */
read_buf+=amount_read;
@@ -2279,7 +2273,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
if(size>0 && addr>=(file->accum_loc+file->accum_size)) {
/* Dispatch to driver */
if ((file->cls->read)(file, type, dxpl_id, addr, size, read_buf)<0)
- HRETURN_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
/* Adjust the buffer, address & size */
read_buf+=size;
@@ -2300,7 +2294,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
/* Flush current contents, if dirty */
if(file->accum_dirty) {
if ((file->cls->write)(file, H5FD_MEM_DEFAULT, dxpl_id, file->accum_loc, file->accum_size, file->meta_accum)<0)
- HRETURN_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed");
/* Reset accumulator dirty flag */
file->accum_dirty=FALSE;
@@ -2311,7 +2305,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
if(size>file->accum_buf_size) {
/* Grow the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=size;
@@ -2324,7 +2318,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
/* Shrink the accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,new_size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=new_size;
@@ -2338,7 +2332,7 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
/* Read into accumulator */
if ((file->cls->read)(file, H5FD_MEM_DEFAULT, dxpl_id, file->accum_loc, file->accum_size, file->meta_accum)<0)
- HRETURN_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
/* Copy into buffer */
HDmemcpy(buf,file->meta_accum,size);
@@ -2346,17 +2340,18 @@ H5FD_read(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz
else {
/* Dispatch to driver */
if ((file->cls->read)(file, type, dxpl_id, addr, size, buf)<0)
- HRETURN_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
} /* end else */
} /* end else */
} /* end if */
else {
/* Dispatch to driver */
if ((file->cls->read)(file, type, dxpl_id, addr, size, buf)<0)
- HRETURN_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "driver read request failed");
} /* end else */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2383,26 +2378,29 @@ herr_t
H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size,
const void *buf)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5FDwrite, FAIL);
H5TRACE6("e","xMtiazx",file,type,dxpl_id,addr,size,buf);
/* Check args */
if (!file || !file->cls)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
/* Get the default dataset transfer property list if the user didn't provide one */
if (H5P_DEFAULT == dxpl_id)
dxpl_id= H5P_DATASET_XFER_DEFAULT;
if (H5I_GENPROP_LST != H5I_get_type(dxpl_id) ||
TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list");
if (!buf)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer");
/* The real work */
if (H5FD_write(file, type, dxpl_id, addr, size, buf)<0)
- HRETURN_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2432,6 +2430,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
{
size_t new_size; /* New size of the accumulator buffer */
size_t old_offset; /* Offset of old data within the accumulator buffer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_write, FAIL);
@@ -2444,7 +2443,8 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
/* Do not return early for Parallel mode since the I/O could be a */
/* collective transfer. */
/* The no-op case */
- if (0==size) HRETURN(SUCCEED);
+ if (0==size)
+ HGOTO_DONE(SUCCEED);
#endif /* H5_HAVE_PARALLEL */
/* Check for accumulating metadata */
@@ -2462,7 +2462,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
if((size+file->accum_size)>file->accum_buf_size) {
/* Reallocate the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size+file->accum_size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=size+file->accum_size;
@@ -2487,7 +2487,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
if((size+file->accum_size)>file->accum_buf_size) {
/* Reallocate the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size+file->accum_size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=size+file->accum_size;
@@ -2519,7 +2519,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
if(new_size>file->accum_buf_size) {
/* Reallocate the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,new_size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=new_size;
@@ -2550,7 +2550,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
if(new_size>file->accum_buf_size) {
/* Reallocate the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,new_size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=new_size;
@@ -2575,7 +2575,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
/* Write out the existing metadata accumulator, with dispatch to driver */
if(file->accum_dirty) {
if ((file->cls->write)(file, H5FD_MEM_DEFAULT, dxpl_id, file->accum_loc, file->accum_size, file->meta_accum)<0)
- HRETURN_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed");
/* Reset accumulator dirty flag */
file->accum_dirty=FALSE;
} /* end if */
@@ -2585,7 +2585,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
if(size>file->accum_buf_size) {
/* Grow the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=size;
@@ -2598,7 +2598,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
/* Shrink the accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,tmp_size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=tmp_size;
@@ -2620,7 +2620,7 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
if(size>file->accum_buf_size) {
/* Reallocate the metadata accumulator buffer */
if ((file->meta_accum=H5FL_BLK_REALLOC(meta_accum,file->meta_accum,size))==NULL)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate metadata accumulator buffer");
/* Note the new buffer size */
file->accum_buf_size=size;
@@ -2638,10 +2638,11 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
else {
/* Dispatch to driver */
if ((file->cls->write)(file, type, dxpl_id, addr, size, buf)<0)
- HRETURN_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "driver write request failed");
} /* end else */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2667,21 +2668,21 @@ H5FD_write(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t si
herr_t
H5FDflush(H5FD_t *file, unsigned closing)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5FDflush, FAIL);
H5TRACE2("e","xIu",file,closing);
/* Check args */
- if (!file || !file->cls) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
- }
+ if (!file || !file->cls)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer");
/* Do the real work */
- if (H5FD_flush(file,closing)<0) {
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL,
- "file flush request failed");
- }
+ if (H5FD_flush(file,closing)<0)
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file flush request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2706,6 +2707,8 @@ H5FDflush(H5FD_t *file, unsigned closing)
herr_t
H5FD_flush(H5FD_t *file, unsigned closing)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5FD_flush, FAIL);
assert(file && file->cls);
@@ -2715,16 +2718,17 @@ H5FD_flush(H5FD_t *file, unsigned closing)
/* Flush the metadata contents */
/* Not certain if the type and dxpl should be the way they are... -QAK */
if ((file->cls->write)(file, H5FD_MEM_DEFAULT, H5P_DATASET_XFER_DEFAULT, file->accum_loc, file->accum_size, file->meta_accum)<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver write request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver write request failed");
/* Reset the dirty flag */
file->accum_dirty=FALSE;
} /* end if */
if (file->cls->flush && (file->cls->flush)(file,closing)<0)
- HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed");
+ HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5FDcore.c b/src/H5FDcore.c
index 7980b0b..2f79dd0 100644
--- a/src/H5FDcore.c
+++ b/src/H5FDcore.c
@@ -181,20 +181,21 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store)
{
H5FD_core_fapl_t fa;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5FD_set_fapl_core, FAIL);
H5TRACE3("e","izb",fapl_id,increment,backing_store);
/* Check argument */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
fa.increment = increment;
fa.backing_store = backing_store;
ret_value= H5P_set_driver(plist, H5FD_CORE, &fa);
+done:
FUNC_LEAVE(ret_value);
}
@@ -227,24 +228,26 @@ H5Pget_fapl_core(hid_t fapl_id, size_t *increment/*out*/,
{
H5FD_core_fapl_t *fa;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_fapl_core, FAIL);
H5TRACE3("e","ixx",fapl_id,increment,backing_store);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
"not a file access property list");
if (H5FD_CORE!=H5P_get_driver(plist))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if (NULL==(fa=H5P_get_driver_info(plist)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (increment)
*increment = fa->increment;
if (backing_store)
*backing_store = fa->backing_store;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -269,17 +272,21 @@ H5FD_core_fapl_get(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
H5FD_core_fapl_t *fa = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(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");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
fa->increment = file->increment;
fa->backing_store = (file->fd>=0);
- FUNC_LEAVE(fa);
+ /* Set return value */
+ ret_value=fa;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -310,28 +317,29 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
H5FD_core_fapl_t *fa=NULL;
H5P_genplist_t *plist; /* Property list pointer */
int fd=-1;
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_core_open, NULL);
/* Check arguments */
if (0==maxaddr || HADDR_UNDEF==maxaddr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow");
if (H5P_DEFAULT!=fapl_id) {
if(NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
fa = H5P_get_driver_info(plist);
} /* end if */
/* Open backing store */
if (fa && fa->backing_store && name &&
(fd=HDopen(name, O_CREAT|O_TRUNC|O_RDWR, 0666))<0)
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open backing store");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open backing store");
/* Create the new file struct */
if (NULL==(file=H5MM_calloc(sizeof(H5FD_core_t))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct");
file->fd = fd;
if (name && *name)
file->name = HDstrdup(name);
@@ -343,7 +351,11 @@ H5FD_core_open(const char *name, unsigned UNUSED flags, hid_t fapl_id,
*/
file->increment = (fa && fa->increment>0) ? fa->increment : H5FD_CORE_INCREMENT;
- FUNC_LEAVE((H5FD_t*)file);
+ /* Set return value */
+ ret_value=(H5FD_t *)file;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -368,6 +380,7 @@ static herr_t
H5FD_core_flush(H5FD_t *_file, unsigned UNUSED closing)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_core_flush, FAIL);
@@ -377,25 +390,25 @@ H5FD_core_flush(H5FD_t *_file, unsigned UNUSED closing)
unsigned char *ptr = file->mem;
if (0!=HDlseek(file->fd, (off_t)0, SEEK_SET))
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL,
- "error seeking in backing store");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "error seeking in backing store");
while (size) {
ssize_t n;
H5_CHECK_OVERFLOW(size,hsize_t,size_t);
n = HDwrite(file->fd, ptr, (size_t)size);
- if (n<0 && EINTR==errno) continue;
+ if (n<0 && EINTR==errno)
+ continue;
if (n<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "error writing backing store");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "error writing backing store");
ptr += (size_t)n;
size -= (size_t)n;
}
file->dirty = FALSE;
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -421,20 +434,26 @@ static herr_t
H5FD_core_close(H5FD_t *_file)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_core_close, FAIL);
/* Flush */
if (H5FD_core_flush(_file,TRUE)<0)
- HRETURN_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file");
/* Release resources */
- if (file->fd>=0) HDclose(file->fd);
- if (file->name) H5MM_xfree(file->name);
- if (file->mem) H5MM_xfree(file->mem);
+ if (file->fd>=0)
+ HDclose(file->fd);
+ if (file->name)
+ H5MM_xfree(file->name);
+ if (file->mem)
+ H5MM_xfree(file->mem);
HDmemset(file, 0, sizeof(H5FD_core_t));
H5MM_xfree(file);
- FUNC_LEAVE(0);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -468,15 +487,21 @@ H5FD_core_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
FUNC_ENTER_NOAPI(H5FD_core_cmp, FAIL);
if (NULL==f1->name && NULL==f2->name) {
- if (f1<f2) HRETURN(-1);
- if (f1>f2) HRETURN(1);
- HRETURN(0);
+ if (f1<f2)
+ HGOTO_DONE(-1);
+ if (f1>f2)
+ HGOTO_DONE(1);
+ HGOTO_DONE(0);
}
- if (NULL==f1->name) HRETURN(-1);
- if (NULL==f2->name) HRETURN(1);
+ if (NULL==f1->name)
+ HGOTO_DONE(-1);
+ if (NULL==f2->name)
+ HGOTO_DONE(1);
ret_value = HDstrcmp(f1->name, f2->name);
+
+done:
FUNC_LEAVE(ret_value);
}
@@ -532,14 +557,17 @@ static herr_t
H5FD_core_set_eoa(H5FD_t *_file, haddr_t addr)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_core_set_eoa, FAIL);
if (ADDR_OVERFLOW(addr))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow");
file->eoa = addr;
- FUNC_LEAVE(0);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -598,6 +626,7 @@ H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
size_t size, void *buf/*out*/)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_core_read, FAIL);
@@ -606,11 +635,11 @@ H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
/* Check for overflow conditions */
if (HADDR_UNDEF == addr)
- HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
if (addr + size > file->eoa)
- HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
/* Read the part which is before the EOF marker */
if (addr < file->eof) {
@@ -632,11 +661,11 @@ H5FD_core_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
}
/* Read zeros for the part which is after the EOF markers */
- if (size > 0) {
+ if (size > 0)
HDmemset(buf, 0, size);
- }
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -663,6 +692,7 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
size_t size, const void *buf)
{
H5FD_core_t *file = (H5FD_core_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_core_write, FAIL);
@@ -671,9 +701,9 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
/* Check for overflow conditions */
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
+ HGOTO_ERROR(H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
/*
* Allocate more memory if necessary, careful of overflow. Also, if the
@@ -694,8 +724,7 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
else
x = H5MM_realloc(file->mem, new_eof);
if (!x)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate memory block");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block");
file->mem = x;
file->eof = new_eof;
}
@@ -704,5 +733,6 @@ H5FD_core_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
HDmemcpy(file->mem+addr, buf, size);
file->dirty = TRUE;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c
index 24a244d..bd7e621 100644
--- a/src/H5FDfamily.c
+++ b/src/H5FDfamily.c
@@ -176,7 +176,7 @@ 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;
+ herr_t ret_value;
H5FD_family_fapl_t fa;
H5P_genplist_t *plist; /* Property list pointer */
@@ -185,9 +185,9 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id)
/* Check arguments */
if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
if(memb_fapl_id!=H5P_DEFAULT && TRUE != H5P_isa_class(memb_fapl_id, H5P_FILE_ACCESS))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list");
/*
* Initialize driver specific information. No need to copy it into the FA
@@ -197,9 +197,10 @@ H5Pset_fapl_family(hid_t fapl_id, hsize_t memb_size, hid_t memb_fapl_id)
fa.memb_fapl_id = memb_fapl_id;
if(NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
ret_value= H5P_set_driver(plist, H5FD_FAMILY, &fa);
+done:
FUNC_LEAVE(ret_value);
}
@@ -232,25 +233,27 @@ H5Pget_fapl_family(hid_t fapl_id, hsize_t *memb_size/*out*/,
{
H5FD_family_fapl_t *fa;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_fapl_family, FAIL);
H5TRACE3("e","ixx",fapl_id,memb_size,memb_fapl_id);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list");
if (H5FD_FAMILY!=H5P_get_driver(plist))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if (NULL==(fa=H5P_get_driver_info(plist)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (memb_size)
*memb_size = fa->memb_size;
if (memb_fapl_id) {
if(NULL == (plist = H5I_object(fa->memb_fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access list");
*memb_fapl_id = H5P_copy_plist(plist);
} /* end if */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -277,18 +280,27 @@ H5FD_family_fapl_get(H5FD_t *_file)
H5FD_family_t *file = (H5FD_family_t*)_file;
H5FD_family_fapl_t *fa = NULL;
H5P_genplist_t *plist; /* Property list pointer */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(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");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
fa->memb_size = file->memb_size;
if(NULL == (plist = H5I_object(file->memb_fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
fa->memb_fapl_id = H5P_copy_plist(plist);
- FUNC_LEAVE(fa);
+ /* Set return value */
+ ret_value=fa;
+
+done:
+ if(ret_value==NULL) {
+ if(fa!=NULL)
+ H5MM_xfree(fa);
+ } /* end if */
+ FUNC_LEAVE(ret_value);
}
@@ -314,11 +326,12 @@ 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 = NULL;
H5P_genplist_t *plist; /* Property list pointer */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(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");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Copy the fields of the structure */
memcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t));
@@ -328,11 +341,19 @@ H5FD_family_fapl_copy(const void *_old_fa)
new_fa->memb_fapl_id = H5P_DEFAULT;
else {
if(NULL == (plist = H5I_object(old_fa->memb_fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
new_fa->memb_fapl_id = H5P_copy_plist(plist);
} /* end else */
- FUNC_LEAVE(new_fa);
+ /* Set return value */
+ ret_value=new_fa;
+
+done:
+ if(ret_value==NULL) {
+ if(new_fa!=NULL)
+ H5MM_xfree(new_fa);
+ } /* end if */
+ FUNC_LEAVE(ret_value);
}
@@ -388,18 +409,27 @@ 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 = NULL;
H5P_genplist_t *plist; /* Property list pointer */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(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");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
memcpy(new_dx, old_dx, sizeof(H5FD_family_dxpl_t));
if(NULL == (plist = H5I_object(old_dx->memb_dxpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
new_dx->memb_dxpl_id = H5P_copy_plist(plist);
- FUNC_LEAVE(new_dx);
+ /* Set return value */
+ ret_value=new_dx;
+
+done:
+ if(ret_value==NULL) {
+ if(new_dx!=NULL)
+ H5MM_xfree(new_dx);
+ } /* end if */
+ FUNC_LEAVE(ret_value);
}
@@ -587,6 +617,7 @@ H5FD_family_close(H5FD_t *_file)
{
H5FD_family_t *file = (H5FD_family_t*)_file;
int i, nerrors=0;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_family_close, FAIL);
@@ -601,8 +632,7 @@ H5FD_family_close(H5FD_t *_file)
}
}
if (nerrors)
- HRETURN_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL,
- "unable to close member files");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close member files");
/* Clean up other stuff */
H5I_dec_ref(file->memb_fapl_id);
@@ -612,7 +642,8 @@ H5FD_family_close(H5FD_t *_file)
H5MM_xfree(file->name);
H5MM_xfree(file);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -741,6 +772,7 @@ H5FD_family_set_eoa(H5FD_t *_file, haddr_t eoa)
haddr_t addr=eoa;
int i;
char memb_name[4096];
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_family_set_eoa, FAIL);
@@ -751,8 +783,7 @@ H5FD_family_set_eoa(H5FD_t *_file, haddr_t eoa)
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,
- "unable to allocate memory block");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block");
file->amembs = n;
file->memb = x;
file->nmembs = i;
@@ -767,8 +798,7 @@ H5FD_family_set_eoa(H5FD_t *_file, haddr_t eoa)
file->memb_fapl_id, file->memb_size);
} H5E_END_TRY;
if (NULL==file->memb[i])
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to open member file");
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open member file");
}
/* Set the EOA marker for the member */
@@ -782,7 +812,9 @@ H5FD_family_set_eoa(H5FD_t *_file, haddr_t eoa)
}
file->eoa = eoa;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -867,6 +899,7 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si
size_t req;
hsize_t tempreq;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_family_read, FAIL);
@@ -875,7 +908,7 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si
* list does not belong to this driver then assume defaults
*/
if(NULL == (plist = H5I_object(dxpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
if (H5P_DEFAULT!=dxpl_id && H5FD_FAMILY==H5P_get_driver(plist)) {
H5FD_family_dxpl_t *dx = H5P_get_driver_info(plist);
@@ -901,15 +934,15 @@ H5FD_family_read(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, si
assert(i<file->nmembs);
if (H5FDread(file->memb[i], type, memb_dxpl_id, sub, req, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "member file read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "member file read failed");
addr += req;
buf += req;
size -= req;
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -943,6 +976,7 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s
size_t req;
hsize_t tempreq;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_family_write, FAIL);
@@ -951,7 +985,7 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s
* list does not belong to this driver then assume defaults.
*/
if(NULL == (plist = H5I_object(dxpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
if (H5P_DEFAULT!=dxpl_id && H5FD_FAMILY==H5P_get_driver(plist)) {
H5FD_family_dxpl_t *dx = H5P_get_driver_info(plist);
@@ -977,15 +1011,15 @@ H5FD_family_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, s
assert(i<file->nmembs);
if (H5FDwrite(file->memb[i], type, memb_dxpl_id, sub, req, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "member file write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "member file write failed");
addr += req;
buf += req;
size -= req;
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1010,6 +1044,7 @@ H5FD_family_flush(H5FD_t *_file, unsigned closing)
{
H5FD_family_t *file = (H5FD_family_t*)_file;
int i, nerrors=0;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_family_flush, FAIL);
@@ -1018,8 +1053,8 @@ H5FD_family_flush(H5FD_t *_file, unsigned closing)
nerrors++;
if (nerrors)
- HRETURN_ERROR(H5E_IO, H5E_BADVALUE, FAIL,
- "unable to flush member files");
+ HGOTO_ERROR(H5E_IO, H5E_BADVALUE, FAIL, "unable to flush member files");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5FDgass.c b/src/H5FDgass.c
index 42b46b2..0133daf 100644
--- a/src/H5FDgass.c
+++ b/src/H5FDgass.c
@@ -229,14 +229,14 @@ H5Pset_fapl_gass(hid_t fapl_id, GASS_Info info)
{
H5FD_gass_fapl_t fa;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_gass, FAIL);
/*NO TRACE*/
/* Check arguments */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
#ifdef LATER
#warning "We need to verify that INFO contain sensible information."
@@ -247,6 +247,7 @@ H5Pset_fapl_gass(hid_t fapl_id, GASS_Info info)
ret_value= H5P_set_driver(plist, H5FD_GASS, &fa);
+done:
FUNC_LEAVE(ret_value);
}
@@ -281,21 +282,23 @@ H5Pget_fapl_gass(hid_t fapl_id, GASS_Info *info/*out*/)
{
H5FD_gass_fapl_t *fa;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_fapl_gass, FAIL);
H5TRACE2("e","ix",fapl_id,info);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
if (H5FD_GASS!=H5P_get_driver(plist))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if (NULL==(fa=H5P_get_driver_info(plist)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (info)
*info = fa->info;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -333,6 +336,7 @@ H5FD_gass_open(const char *name, unsigned flags, hid_t fapl_id,
char *filename = (char *) H5MM_malloc(80 * sizeof(char));
H5P_genplist_t *plist; /* Property list pointer */
h5_stat_t sb;
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_gass_open, NULL);
@@ -340,17 +344,17 @@ H5FD_gass_open(const char *name, unsigned flags, hid_t fapl_id,
/* Check arguments */
if (!name || !*name)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0==maxaddr || HADDR_UNDEF==maxaddr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
strcpy (filename, name);
/* Obtain a pointer to gass-specific file access properties */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
if (H5P_DEFAULT==fapl_id || H5FD_GASS!=H5P_get_driver(plist)) {
GASS_INFO_NULL (_fa.info);
/* _fa.info = GASS_INFO_NULL; */
@@ -382,47 +386,49 @@ H5FD_gass_open(const char *name, unsigned flags, hid_t fapl_id,
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, NULL, "open failed");
+ if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "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");
+ if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0)
+ HGOTO_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");
+ if ((fd = globus_gass_open (filename, O_RDWR|O_TRUNC)) < 0)
+ HGOTO_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");
+ if ((fd = globus_gass_open (filename, O_RDWR)) < 0)
+ HGOTO_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");
+ if ((fd = globus_gass_open (filename, O_RDONLY)) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
}
- if (HDfstat(fd, &sb)<0) {
+ if (HDfstat(fd, &sb)<0) {
close(fd);
- HRETURN_ERROR(H5E_IO, H5E_BADFILE, NULL, "fstat failed");
+ HGOTO_ERROR(H5E_IO, H5E_BADFILE, NULL, "fstat failed");
}
/* Create the new file struct */
if (NULL==(file=H5MM_calloc(sizeof(H5FD_gass_t))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct");
+ HGOTO_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;
+
+ /* Set return value */
+ ret_value=(H5FD_t*)file;
- FUNC_LEAVE((H5FD_t*)file);
+done:
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
@@ -445,17 +451,19 @@ static herr_t
H5FD_gass_close (H5FD_t *_file)
{
H5FD_gass_t *file = (H5FD_gass_t *)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_gass_close, FAIL);
if (file == NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle");
if (globus_gass_close (file->fd) < 0)
- HRETURN_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "can't close GASS file");
+ HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "can't close GASS file");
H5MM_xfree(file);
+done:
FUNC_LEAVE(SUCCEED);
}
@@ -584,6 +592,7 @@ H5FD_gass_get_eof(H5FD_t *_file)
FUNC_LEAVE(MAX(file->eof, file->eoa));
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_gass_read
*
@@ -608,6 +617,7 @@ H5FD_gass_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id/*unused*/, h
{
H5FD_gass_t *file = (H5FD_gass_t*)_file;
ssize_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_gass_read, FAIL);
@@ -616,18 +626,18 @@ H5FD_gass_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id/*unused*/, h
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_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->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "gass file seek failed");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "gass file seek failed");
}
/*
@@ -643,7 +653,7 @@ H5FD_gass_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id/*unused*/, h
/* error */
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "gass file read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "gass file read failed");
}
if (0==nbytes) {
/* end of file but not end of format address space */
@@ -660,9 +670,12 @@ H5FD_gass_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id/*unused*/, h
/* Update current position */
file->pos = addr;
file->op = OP_READ;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_gass_write
*
@@ -686,6 +699,7 @@ H5FD_gass_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id/*unused*/, haddr_t
{
H5FD_gass_t *file = (H5FD_gass_t*)_file;
ssize_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_gass_write, FAIL);
@@ -694,18 +708,18 @@ H5FD_gass_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id/*unused*/, haddr_t
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_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_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, "gass file seek failed");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "gass file seek failed");
}
/*
@@ -721,7 +735,7 @@ H5FD_gass_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id/*unused*/, haddr_t
/* error */
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "gass file write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "gass file write failed");
}
assert(nbytes>0);
assert(nbytes<=size);
@@ -736,7 +750,8 @@ H5FD_gass_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id/*unused*/, haddr_t
if (file->pos>file->eof)
file->eof = file->pos;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
#endif /* H5_HAVE_GASS */
diff --git a/src/H5FDlog.c b/src/H5FDlog.c
index 4036f9b..c3837b3 100644
--- a/src/H5FDlog.c
+++ b/src/H5FDlog.c
@@ -279,13 +279,13 @@ H5Pset_fapl_log(hid_t fapl_id, char *logfile, int verbosity)
{
H5FD_log_fapl_t fa; /* File access property list information */
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_log, FAIL);
H5TRACE3("e","isIs",fapl_id,logfile,verbosity);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
fa.logfile=logfile;
if(verbosity>0) {
@@ -296,6 +296,7 @@ H5Pset_fapl_log(hid_t fapl_id, char *logfile, int verbosity)
fa.buf_size=32*(1024*1024);
ret_value= H5P_set_driver(plist, H5FD_LOG, &fa);
+done:
FUNC_LEAVE(ret_value);
}
#else /* H5_WANT_H5_V1_4_COMPAT */
@@ -325,19 +326,20 @@ H5Pset_fapl_log(hid_t fapl_id, char *logfile, unsigned flags, size_t buf_size)
{
H5FD_log_fapl_t fa; /* File access property list information */
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_log, FAIL);
H5TRACE4("e","isIuz",fapl_id,logfile,flags,buf_size);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
fa.logfile=logfile;
fa.flags=flags;
fa.buf_size=buf_size;
ret_value= H5P_set_driver(plist, H5FD_LOG, &fa);
+done:
FUNC_LEAVE(ret_value);
}
#endif /* H5_WANT_H5_V1_4_COMPAT */
@@ -394,6 +396,7 @@ H5FD_log_fapl_copy(const void *_old_fa)
{
const H5FD_log_fapl_t *old_fa = (const H5FD_log_fapl_t*)_old_fa;
H5FD_log_fapl_t *new_fa = H5MM_malloc(sizeof(H5FD_log_fapl_t));
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_log_fapl_copy, NULL);
@@ -405,10 +408,13 @@ H5FD_log_fapl_copy(const void *_old_fa)
/* Deep copy the log file name */
if(old_fa->logfile!=NULL)
if (NULL==(new_fa->logfile=HDstrdup(old_fa->logfile)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "unable to allocate log file name");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate log file name");
- FUNC_LEAVE(new_fa);
+ /* Set return value */
+ ret_value=new_fa;
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5FD_log_fapl_copy() */
@@ -467,7 +473,7 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id,
haddr_t maxaddr)
{
int o_flags;
- int fd;
+ int fd=(-1);
H5FD_log_t *file=NULL;
H5FD_log_fapl_t *fa; /* File access property list information */
#ifdef WIN32
@@ -477,16 +483,17 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id,
#endif
h5_stat_t sb;
H5P_genplist_t *plist; /* Property list */
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_log_open, NULL);
/* Check arguments */
if (!name || !*name)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0==maxaddr || HADDR_UNDEF==maxaddr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");
/* Build the open flags */
o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
@@ -496,19 +503,17 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id,
/* Open the file */
if ((fd=HDopen(name, o_flags, 0666))<0)
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file");
- if (HDfstat(fd, &sb)<0) {
- HDclose(fd);
- HRETURN_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file");
- }
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file");
+ if (HDfstat(fd, &sb)<0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file");
/* Create the new file struct */
if (NULL==(file=H5MM_calloc(sizeof(H5FD_log_t))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct");
/* Get the driver specific information */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
fa = H5P_get_driver_info(plist);
file->fd = fd;
@@ -549,7 +554,16 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id,
file->logfp=stderr;
} /* end if */
- FUNC_LEAVE((H5FD_t*)file);
+ /* Set return value */
+ ret_value=(H5FD_t*)file;
+
+done:
+ if(ret_value==NULL) {
+ if(fd>=0)
+ HDclose(fd);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
} /* end H5FD_log_open() */
@@ -577,18 +591,19 @@ H5FD_log_close(H5FD_t *_file)
struct timeval timeval_start,timeval_stop;
struct timeval timeval_diff;
#endif /* H5_HAVE_GETTIMEOFDAY */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_log_close, FAIL);
if (H5FD_log_flush(_file,TRUE)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to flush file");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to flush file");
#ifdef H5_HAVE_GETTIMEOFDAY
if(file->fa.flags&H5FD_LOG_TIME_CLOSE)
HDgettimeofday(&timeval_start,NULL);
#endif /* H5_HAVE_GETTIMEOFDAY */
if (close(file->fd)<0)
- HRETURN_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
+ HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
#ifdef H5_HAVE_GETTIMEOFDAY
if(file->fa.flags&H5FD_LOG_TIME_CLOSE)
HDgettimeofday(&timeval_stop,NULL);
@@ -677,7 +692,8 @@ H5FD_log_close(H5FD_t *_file)
H5MM_xfree(file);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -709,29 +725,30 @@ H5FD_log_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
FUNC_ENTER_NOAPI(H5FD_log_cmp, H5FD_VFD_DEFAULT);
#ifdef WIN32
- if (f1->fileindexhi < f2->fileindexhi) ret_value= -1;
- if (f1->fileindexhi > f2->fileindexhi) ret_value= 1;
+ if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1);
+ if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1);
- if (f1->fileindexlo < f2->fileindexlo) ret_value= -1;
- if (f1->fileindexlo > f2->fileindexlo) ret_value= 1;
+ if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1);
+ if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1);
#else
#ifdef H5_DEV_T_IS_SCALAR
- if (f1->device < f2->device) ret_value= -1;
- if (f1->device > f2->device) ret_value= 1;
+ if (f1->device < f2->device) HGOTO_DONE(-1);
+ if (f1->device > f2->device) HGOTO_DONE(1);
#else /* H5_DEV_T_IS_SCALAR */
/* If dev_t isn't a scalar value on this system, just use memcmp to
* determine if the values are the same or not. The actual return value
* shouldn't really matter...
*/
- if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) ret_value= -1;
- if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) ret_value= 1;
+ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1);
+ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1);
#endif /* H5_DEV_T_IS_SCALAR */
- if (f1->inode < f2->inode) ret_value= -1;
- if (f1->inode > f2->inode) ret_value= 1;
+ if (f1->inode < f2->inode) HGOTO_DONE(-1);
+ if (f1->inode > f2->inode) HGOTO_DONE(1);
#endif
+done:
FUNC_LEAVE(ret_value);
}
@@ -941,6 +958,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr
{
H5FD_log_t *file = (H5FD_log_t*)_file;
ssize_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_log_read, FAIL);
@@ -949,11 +967,11 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
/* Log the I/O information about the read */
if(file->fa.flags!=0) {
@@ -988,7 +1006,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr
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, "unable to seek to proper position");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position");
}
/*
@@ -1003,7 +1021,7 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr
/* error */
file->pos = HADDR_UNDEF;
file->op = OP_UNKNOWN;
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
}
if (0==nbytes) {
/* end of file but not end of format address space */
@@ -1020,7 +1038,9 @@ H5FD_log_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr
/* Update current position */
file->pos = addr;
file->op = OP_READ;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1054,6 +1074,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
struct timeval timeval_start,timeval_stop;
struct timeval timeval_diff;
#endif /* H5_HAVE_GETTIMEOFDAY */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_log_write, FAIL);
@@ -1067,11 +1088,11 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
/* Log the I/O information about the write */
if(file->fa.flags&H5FD_LOG_FILE_WRITE) {
@@ -1092,7 +1113,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
if(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, "unable to seek to proper position");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position");
} /* end if */
#ifdef H5_HAVE_GETTIMEOFDAY
if(file->fa.flags&H5FD_LOG_TIME_SEEK)
@@ -1139,7 +1160,7 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
file->op = OP_UNKNOWN;
if(file->fa.flags&H5FD_LOG_LOC_WRITE)
HDfprintf(file->logfp,"Error! Writing: %10a-%10a (%10Zu bytes)\n",orig_addr,orig_addr+orig_size-1,orig_size);
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
}
assert(nbytes>0);
assert((size_t)nbytes<=size);
@@ -1190,7 +1211,8 @@ H5FD_log_write(H5FD_t *_file, H5FD_mem_t type, hid_t UNUSED dxpl_id, haddr_t add
if (file->pos>file->eof)
file->eof = file->pos;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1215,19 +1237,20 @@ static herr_t
H5FD_log_flush(H5FD_t *_file, unsigned UNUSED closing)
{
H5FD_log_t *file = (H5FD_log_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_log_flush, FAIL);
if (file->eoa>file->eof) {
if (-1==file_seek(file->fd, (file_offset_t)(file->eoa-1), SEEK_SET))
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL,
- "unable to seek to proper position");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position");
if (write(file->fd, "", 1)!=1)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
file->eof = file->eoa;
file->pos = file->eoa;
file->op = OP_WRITE;
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c
index 023057f..6c25caa 100644
--- a/src/H5FDmpio.c
+++ b/src/H5FDmpio.c
@@ -242,15 +242,14 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info)
{
H5FD_mpio_fapl_t fa;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_mpio, FAIL);
H5TRACE3("e","iMcMi",fapl_id,comm,info);
/* Check arguments */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
-
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
#ifdef LATER
#warning "We need to verify that COMM and INFO contain sensible information."
@@ -262,6 +261,7 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info)
ret_value= H5P_set_driver(plist, H5FD_MPIO, &fa);
+done:
FUNC_LEAVE(ret_value);
}
@@ -304,23 +304,25 @@ H5Pget_fapl_mpio(hid_t fapl_id, MPI_Comm *comm/*out*/, MPI_Info *info/*out*/)
{
H5FD_mpio_fapl_t *fa;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_fapl_mpio, FAIL);
H5TRACE3("e","ixx",fapl_id,comm,info);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
if (H5FD_MPIO!=H5P_get_driver(plist))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if (NULL==(fa=H5P_get_driver_info(plist)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (comm)
*comm = fa->comm;
if (info)
*info = fa->info;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -355,22 +357,23 @@ H5Pset_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t xfer_mode)
{
H5FD_mpio_dxpl_t dx;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_dxpl_mpio, FAIL);
H5TRACE2("e","iDt",dxpl_id,xfer_mode);
/* Check arguments */
if(TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(dxpl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
if (H5FD_MPIO_INDEPENDENT!=xfer_mode && H5FD_MPIO_COLLECTIVE!=xfer_mode)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "incorrect xfer_mode");
/* Initialize driver-specific properties */
dx.xfer_mode = xfer_mode;
ret_value= H5P_set_driver(plist, H5FD_MPIO, &dx);
+done:
FUNC_LEAVE(ret_value);
}
@@ -400,20 +403,22 @@ H5Pget_dxpl_mpio(hid_t dxpl_id, H5FD_mpio_xfer_t *xfer_mode/*out*/)
{
H5FD_mpio_dxpl_t *dx;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_dxpl_mpio, FAIL);
H5TRACE2("e","ix",dxpl_id,xfer_mode);
if(TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(dxpl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
if (H5FD_MPIO!=H5P_get_driver(plist))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if (NULL==(dx=H5P_get_driver_info(plist)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (xfer_mode)
*xfer_mode = dx->xfer_mode;
+done:
FUNC_LEAVE(SUCCEED);
}
@@ -535,26 +540,28 @@ herr_t
H5FD_mpio_setup(hid_t dxpl_id, MPI_Datatype btype, MPI_Datatype ftype, unsigned use_view)
{
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpio_setup, FAIL);
/* Check arguments */
if(TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(dxpl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list");
/* Set buffer MPI type */
if(H5P_insert(plist,H5FD_MPIO_XFER_MEM_MPI_TYPE_NAME,H5FD_MPIO_XFER_MEM_MPI_TYPE_SIZE,&btype,NULL,NULL,NULL,NULL,NULL)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
/* Set file MPI type */
if(H5P_insert(plist,H5FD_MPIO_XFER_FILE_MPI_TYPE_NAME,H5FD_MPIO_XFER_FILE_MPI_TYPE_SIZE,&ftype,NULL,NULL,NULL,NULL,NULL)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
/* Set 'use view' property */
if(H5P_insert(plist,H5FD_MPIO_XFER_USE_VIEW_NAME,H5FD_MPIO_XFER_USE_VIEW_SIZE,&use_view,NULL,NULL,NULL,NULL,NULL)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't insert MPI-I/O property");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -577,26 +584,28 @@ herr_t
H5FD_mpio_teardown(hid_t dxpl_id)
{
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpio_teardown, FAIL);
/* Check arguments */
if(TRUE!=H5P_isa_class(dxpl_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(dxpl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dataset transfer list");
/* Remove buffer MPI type */
if(H5P_remove(dxpl_id,plist,H5FD_MPIO_XFER_MEM_MPI_TYPE_NAME)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
/* Remove file MPI type */
if(H5P_remove(dxpl_id,plist,H5FD_MPIO_XFER_FILE_MPI_TYPE_NAME)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
/* Remove 'use view' property */
if(H5P_remove(dxpl_id,plist,H5FD_MPIO_XFER_USE_VIEW_NAME)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTDELETE, FAIL, "can't remove MPI-I/O property");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -632,6 +641,7 @@ H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file)
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
char msgbuf[1];
MPI_Status rcvstat;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpio_wait_for_left_neighbor, FAIL);
@@ -644,10 +654,11 @@ H5FD_mpio_wait_for_left_neighbor(H5FD_t *_file)
/* p0 has no left neighbor; all other procs wait for msg */
if (file->mpi_rank != 0) {
if (MPI_SUCCESS!= MPI_Recv( &msgbuf, 1, MPI_CHAR, file->mpi_rank-1, MPI_ANY_TAG, file->comm, &rcvstat ))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Recv failed");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Recv failed");
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -682,6 +693,7 @@ H5FD_mpio_signal_right_neighbor(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
char msgbuf[1];
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpio_signal_right_neighbor, FAIL);
@@ -690,9 +702,11 @@ H5FD_mpio_signal_right_neighbor(H5FD_t *_file)
if (file->mpi_rank != (file->mpi_size-1)) {
if (MPI_SUCCESS!= MPI_Send(&msgbuf, 0/*empty msg*/, MPI_CHAR, file->mpi_rank+1, 0, file->comm))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Send failed");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Send failed");
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -719,6 +733,7 @@ H5FD_mpio_fapl_get(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
H5FD_mpio_fapl_t *fa = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpio_fapl_get, NULL);
@@ -726,13 +741,17 @@ H5FD_mpio_fapl_get(H5FD_t *_file)
assert(H5FD_MPIO==file->pub.driver_id);
if (NULL==(fa=H5MM_calloc(sizeof(H5FD_mpio_fapl_t))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_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;
- FUNC_LEAVE(fa);
+ /* Set return value */
+ ret_value=fa;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -783,6 +802,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
{
H5FD_mpio_t *file=NULL;
MPI_File fh;
+ unsigned file_opened=0; /* Flag to indicate that the file was successfully opened */
int mpi_amode;
int mpi_rank; /* MPI rank of this process */
int mpi_size; /* Total number of MPI processes */
@@ -791,6 +811,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
const H5FD_mpio_fapl_t *fa=NULL;
H5FD_mpio_fapl_t _fa;
H5P_genplist_t *plist; /* Property list pointer */
+ H5FD_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpio_open, NULL);
@@ -803,7 +824,7 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
/* Obtain a pointer to mpio-specific file access properties */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
if (H5P_DEFAULT==fapl_id || H5FD_MPIO!=H5P_get_driver(plist)) {
_fa.comm = MPI_COMM_SELF; /*default*/
_fa.info = MPI_INFO_NULL; /*default*/
@@ -856,49 +877,44 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
#endif
/*OKAY: CAST DISCARDS CONST*/
- if (MPI_SUCCESS !=
- (mpi_code=MPI_File_open(fa->comm, (char*)name, mpi_amode, fa->info, &fh)))
- HMPI_RETURN_ERROR(NULL, "MPI_File_open failed", mpi_code);
+ if (MPI_SUCCESS != (mpi_code=MPI_File_open(fa->comm, (char*)name,
+ mpi_amode, fa->info, &fh)))
+ HMPI_GOTO_ERROR(NULL, "MPI_File_open failed", mpi_code);
+ file_opened=1;
/* Get the MPI rank of this process and the total number of processes */
- if (MPI_SUCCESS != MPI_Comm_rank (fa->comm, &mpi_rank))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_Comm_rank failed");
- if (MPI_SUCCESS != MPI_Comm_size (fa->comm, &mpi_size))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_Comm_size failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_Comm_rank (fa->comm, &mpi_rank)))
+ HMPI_GOTO_ERROR(NULL, "MPI_Comm_rank failed", mpi_code);
+ if (MPI_SUCCESS != (mpi_code=MPI_Comm_size (fa->comm, &mpi_size)))
+ HMPI_GOTO_ERROR(NULL, "MPI_Comm_size failed", mpi_code);
/* Following changes in handling file-truncation made be rkyates and ppweidhaas, sep 99 */
/* Only processor p0 will get the filesize and broadcast it. */
if (mpi_rank == 0) {
- /* Get current file size */
- if (MPI_SUCCESS != MPI_File_get_size(fh, &size)) {
- MPI_File_close(&fh);
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_File_get_size failed");
- }
+ /* Get current file size */
+ if (MPI_SUCCESS != (mpi_code=MPI_File_get_size(fh, &size)))
+ HMPI_GOTO_ERROR(NULL, "MPI_File_get_size failed", mpi_code);
}
/* Broadcast file-size */
- if (MPI_SUCCESS != MPI_Bcast(&size, sizeof(MPI_Offset), MPI_BYTE, 0, fa->comm))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, NULL, "MPI_Bcast failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_Bcast(&size, sizeof(MPI_Offset), MPI_BYTE, 0, fa->comm)))
+ HMPI_GOTO_ERROR(NULL, "MPI_Bcast failed", mpi_code);
/* Only if size > 0, truncate the file - if requested */
if (size && (flags & H5F_ACC_TRUNC)) {
- 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");
- }
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_size(fh, (MPI_Offset)0)))
+ HMPI_GOTO_ERROR(NULL, "MPI_File_set_size failed", mpi_code);
/* 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");
- }
+ if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(fa->comm)))
+ HMPI_GOTO_ERROR(NULL, "MPI_Barrier failed", mpi_code);
size = 0;
}
/* Build the return value and initialize it */
if (NULL==(file=H5MM_calloc(sizeof(H5FD_mpio_t))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
file->f = fh;
file->comm = fa->comm;
@@ -907,13 +923,20 @@ H5FD_mpio_open(const char *name, unsigned flags, hid_t fapl_id,
file->mpi_size = mpi_size;
file->eof = H5FD_mpio_MPIOff_to_haddr(size);
+ /* Set return value */
+ ret_value=(H5FD_t*)file;
+
+done:
+ if(ret_value==NULL) {
+ if(file_opened)
+ MPI_File_close(&fh);
+ } /* end if */
+
#ifdef H5FDmpio_DEBUG
- if (H5FD_mpio_Debug[(int)'t']) {
- fprintf(stdout, "Leaving H5FD_mpio_open\n" );
- }
+ if (H5FD_mpio_Debug[(int)'t'])
+ fprintf(stdout, "Leaving H5FD_mpio_open\n" );
#endif
-
- FUNC_LEAVE((H5FD_t*)file);
+ FUNC_LEAVE(ret_value);
}
@@ -941,6 +964,8 @@ static herr_t
H5FD_mpio_close(H5FD_t *_file)
{
H5FD_mpio_t *file = (H5FD_mpio_t*)_file;
+ int mpi_code; /* mpi return code */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpio_close, FAIL);
@@ -952,18 +977,18 @@ H5FD_mpio_close(H5FD_t *_file)
assert(H5FD_MPIO==file->pub.driver_id);
/* MPI_File_close sets argument to MPI_FILE_NULL */
- if (MPI_SUCCESS != MPI_File_close(&(file->f)/*in,out*/))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_close failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_close(&(file->f)/*in,out*/)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_close failed", mpi_code);
/* Clean up other stuff */
H5MM_xfree(file);
+done:
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "Leaving H5FD_mpio_close\n");
#endif
-
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE(ret_value);
}
@@ -1189,6 +1214,7 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
H5FD_mpio_dxpl_t _dx;
MPI_Offset mpi_off, mpi_disp;
MPI_Status mpi_stat;
+ int mpi_code; /* mpi return code */
MPI_Datatype buf_type, file_type;
int size_i, bytes_read, n;
unsigned use_view_this_time=0;
@@ -1273,22 +1299,22 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
*/
if (use_view_this_time) {
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type, (char*)"native", file->info))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_view failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type, (char*)"native", file->info)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code);
} /* end if */
/* Read the data. */
assert(H5FD_MPIO_INDEPENDENT==dx->xfer_mode || H5FD_MPIO_COLLECTIVE==dx->xfer_mode);
if (H5FD_MPIO_INDEPENDENT==dx->xfer_mode) {
- if (MPI_SUCCESS!= MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_read_at failed");
+ if (MPI_SUCCESS!= (mpi_code=MPI_File_read_at(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code);
} else {
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "H5FD_mpio_read: using MPIO collective mode\n");
#endif
- if (MPI_SUCCESS!= MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat ))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_read_at_all failed");
+ if (MPI_SUCCESS!= (mpi_code=MPI_File_read_at_all(file->f, mpi_off, buf, size_i, buf_type, &mpi_stat )))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at_all failed", mpi_code);
}
/* KLUDGE, Robb Matzke, 2000-12-29
@@ -1315,8 +1341,8 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
} /* end if */
else {
/* How many bytes were actually read? */
- if (MPI_SUCCESS != MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_read))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Get_count failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_read)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Get_count failed", mpi_code);
} /* end else */
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'c'])
@@ -1342,8 +1368,8 @@ H5FD_mpio_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t dxpl_id, haddr_t add
*/
if (use_view_this_time) {
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, (char*)"native", file->info))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_view failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, (char*)"native", file->info)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code);
} /* end if */
/*
@@ -1584,8 +1610,8 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
*/
if (use_view_this_time) {
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type, (char*)"native", file->info))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_view failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, mpi_disp, MPI_BYTE, file_type, (char*)"native", file->info)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code);
} /* end if */
/* Metadata specific actions */
@@ -1623,16 +1649,16 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
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*/
- if (MPI_SUCCESS != MPI_File_write_at(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_write_at failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_write_at(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code);
} else {
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'t'])
fprintf(stdout, "H5FD_mpio_write: using MPIO collective mode\n");
#endif
/*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))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_write_at_all failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_write_at_all(file->f, mpi_off, (void*)buf, size_i, buf_type, &mpi_stat)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at_all failed", mpi_code);
}
/* KLUDGE, Robb Matzke, 2000-12-29
@@ -1659,8 +1685,8 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
} /* end if */
else {
/* How many bytes were actually written? */
- if (MPI_SUCCESS!= MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_written))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Get_count failed");
+ if (MPI_SUCCESS!= (mpi_code=MPI_Get_count(&mpi_stat, MPI_BYTE, &bytes_written)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Get_count failed", mpi_code);
} /* end else */
#ifdef H5FDmpio_DEBUG
if (H5FD_mpio_Debug[(int)'c'])
@@ -1686,8 +1712,8 @@ H5FD_mpio_write(H5FD_t *_file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr,
*/
if (use_view_this_time) {
/*OKAY: CAST DISCARDS CONST QUALIFIER*/
- if (MPI_SUCCESS != MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, (char*)"native", file->info))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_view failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_view(file->f, 0, MPI_BYTE, MPI_BYTE, (char*)"native", file->info)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_set_view failed", mpi_code);
} /* end if */
/* Forget the EOF value (see H5FD_mpio_get_eof()) --rpm 1999-08-06 */
@@ -1698,9 +1724,8 @@ done:
if(ret_value!=FAIL) {
/* if only p<round> writes, need to broadcast the ret_value to other processes */
if ((type!=H5FD_MEM_DRAW) && H5_mpi_1_metawrite_g) {
- if (MPI_SUCCESS !=
- MPI_Bcast(&ret_value, sizeof(ret_value), MPI_BYTE, file->mpi_round, file->comm))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Bcast failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_Bcast(&ret_value, sizeof(ret_value), MPI_BYTE, file->mpi_round, file->comm)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_code);
/* Round-robin rotate to the next process */
file->mpi_round = (++file->mpi_round)%file->mpi_size;
@@ -1779,19 +1804,19 @@ H5FD_mpio_flush(H5FD_t *_file, unsigned closing)
#ifdef OLD_WAY
if (0==file->mpi_rank) {
if (H5FD_mpio_haddr_to_MPIOff(file->eoa-1, &mpi_off)<0)
- HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset");
- if (MPI_SUCCESS != MPI_File_read_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_read_at() failed");
- if (MPI_SUCCESS != MPI_File_write_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_write_at() failed");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_read_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_read_at failed", mpi_code);
+ if (MPI_SUCCESS != (mpi_code=MPI_File_write_at(file->f, mpi_off, &byte, 1, MPI_BYTE, &mpi_stat)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_write_at failed", mpi_code);
} /* end if */
#else /* OLD_WAY */
if (H5FD_mpio_haddr_to_MPIOff(file->eoa, &mpi_off)<0)
- HRETURN_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADRANGE, FAIL, "cannot convert from haddr_t to MPI_Offset");
/* Extend the file's size */
- if (MPI_SUCCESS != MPI_File_set_size(file->f, mpi_off))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_File_set_size failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_File_set_size(file->f, mpi_off)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_File_set_size failed", mpi_code);
/* Don't let any proc return until all have extended the file.
* (Prevents race condition where some processes go ahead and write
@@ -1799,8 +1824,8 @@ H5FD_mpio_flush(H5FD_t *_file, unsigned closing)
* it the shorter length, potentially truncating the file and dropping
* the new data written)
*/
- if (MPI_SUCCESS!= MPI_Barrier(file->comm))
- HRETURN_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed");
+ if (MPI_SUCCESS!= (mpi_code=MPI_Barrier(file->comm)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code);
#endif /* OLD_WAY */
/* Update the 'last' eoa value */
diff --git a/src/H5FDmpiposix.c b/src/H5FDmpiposix.c
index 32e5535..117fea7 100644
--- a/src/H5FDmpiposix.c
+++ b/src/H5FDmpiposix.c
@@ -17,7 +17,7 @@
* Thursday, July 11, 2002
*
* Purpose: This is a "combination" MPI-2 and posix I/O driver.
- * It uses MPI for coodinating the actions of several processes
+ * It uses MPI for coordinating the actions of several processes
* and posix I/O calls to do the actual I/O to the disk.
*
* This driver was derived from the H5FDmpio.c driver and may
@@ -275,14 +275,14 @@ H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm)
{
H5FD_mpiposix_fapl_t fa;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_mpiposix, FAIL);
H5TRACE2("e","iMc",fapl_id,comm);
/* Check arguments */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
#ifdef LATER
#warning "We need to verify that COMM contains sensible information."
#endif
@@ -292,6 +292,7 @@ H5Pset_fapl_mpiposix(hid_t fapl_id, MPI_Comm comm)
ret_value= H5P_set_driver(plist, H5FD_MPIPOSIX, &fa);
+done:
FUNC_LEAVE(ret_value);
} /* end H5Pset_fapl_mpiposix() */
@@ -324,22 +325,24 @@ H5Pget_fapl_mpiposix(hid_t fapl_id, MPI_Comm *comm/*out*/)
{
H5FD_mpiposix_fapl_t *fa;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_fapl_mpiposix, FAIL);
H5TRACE2("e","ix",fapl_id,comm);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a file access list");
if (H5FD_MPIPOSIX!=H5P_get_driver(plist))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if (NULL==(fa=H5P_get_driver_info(plist)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
/* Get MPI Communicator */
if (comm)
*comm = fa->comm;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5Pget_fapl_mpiposix() */
@@ -454,6 +457,7 @@ H5FD_mpiposix_fapl_get(H5FD_t *_file)
{
H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file;
H5FD_mpiposix_fapl_t *fa = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpiposix_fapl_get, NULL);
@@ -461,12 +465,16 @@ H5FD_mpiposix_fapl_get(H5FD_t *_file)
assert(H5FD_MPIPOSIX==file->pub.driver_id);
if (NULL==(fa=H5MM_calloc(sizeof(H5FD_mpiposix_fapl_t))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* These should be copied. --QAK, 2002-07-11 */
fa->comm = file->comm;
+
+ /* Set return value */
+ ret_value=fa;
- FUNC_LEAVE(fa);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5FD_mpiposix_fapl_get() */
@@ -523,7 +531,7 @@ H5FD_mpiposix_open(const char *name, unsigned flags, hid_t fapl_id,
/* Obtain a pointer to mpiposix-specific file access properties */
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
if (H5P_DEFAULT==fapl_id || H5FD_MPIPOSIX!=H5P_get_driver(plist)) {
_fa.comm = MPI_COMM_SELF; /*default*/
fa = &_fa;
@@ -659,6 +667,7 @@ static herr_t
H5FD_mpiposix_close(H5FD_t *_file)
{
H5FD_mpiposix_t *file = (H5FD_mpiposix_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_mpiposix_close, FAIL);
@@ -667,11 +676,12 @@ H5FD_mpiposix_close(H5FD_t *_file)
/* Close the unix file */
if (HDclose(file->fd)<0)
- HRETURN_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
+ HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
H5MM_xfree(file);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5FD_mpiposix_close() */
@@ -702,20 +712,30 @@ H5FD_mpiposix_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
FUNC_ENTER_NOAPI(H5FD_mpiposix_cmp, H5FD_VFD_DEFAULT);
#ifdef WIN32
- if (f1->fileindexhi < f2->fileindexhi) ret_value= -1;
- if (f1->fileindexhi > f2->fileindexhi) ret_value= 1;
+ if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1);
+ if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1);
- if (f1->fileindexlo < f2->fileindexlo) ret_value= -1;
- if (f1->fileindexlo > f2->fileindexlo) ret_value= 1;
+ if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1);
+ if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1);
#else
- if (f1->device < f2->device) ret_value= -1;
- if (f1->device > f2->device) ret_value= 1;
+#ifdef H5_DEV_T_IS_SCALAR
+ if (f1->device < f2->device) HGOTO_DONE(-1);
+ if (f1->device > f2->device) HGOTO_DONE(1);
+#else /* H5_DEV_T_IS_SCALAR */
+ /* If dev_t isn't a scalar value on this system, just use memcmp to
+ * determine if the values are the same or not. The actual return value
+ * shouldn't really matter...
+ */
+ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1);
+ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1);
+#endif /* H5_DEV_T_IS_SCALAR */
- if (f1->inode < f2->inode) ret_value= -1;
- if (f1->inode > f2->inode) ret_value= 1;
+ if (f1->inode < f2->inode) HGOTO_DONE(-1);
+ if (f1->inode > f2->inode) HGOTO_DONE(1);
#endif
+done:
FUNC_LEAVE(ret_value);
} /* end H5FD_mpiposix_cmp() */
diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c
index f888852..bd2ca96 100644
--- a/src/H5FDsec2.c
+++ b/src/H5FDsec2.c
@@ -231,16 +231,17 @@ herr_t
H5Pset_fapl_sec2(hid_t fapl_id)
{
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_sec2, FAIL);
H5TRACE1("e","i",fapl_id);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
ret_value= H5P_set_driver(plist, H5FD_SEC2, NULL);
+done:
FUNC_LEAVE(ret_value);
}
@@ -268,7 +269,7 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id,
haddr_t maxaddr)
{
int o_flags;
- int fd;
+ int fd=(-1);
H5FD_sec2_t *file=NULL;
#ifdef WIN32
HFILE filehandle;
@@ -276,16 +277,17 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id,
int results;
#endif
h5_stat_t sb;
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_sec2_open, NULL);
/* Check arguments */
if (!name || !*name)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0==maxaddr || HADDR_UNDEF==maxaddr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, NULL, "bogus maxaddr");
/* Build the open flags */
o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
@@ -295,16 +297,14 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id,
/* Open the file */
if ((fd=HDopen(name, o_flags, 0666))<0)
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file");
- if (HDfstat(fd, &sb)<0) {
- HDclose(fd);
- HRETURN_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file");
- }
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file");
+ if (HDfstat(fd, &sb)<0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADFILE, NULL, "unable to fstat file");
/* Create the new file struct */
if (NULL==(file=H5FL_ALLOC(H5FD_sec2_t,1)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "unable to allocate file struct");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct");
+
file->fd = fd;
file->eof = sb.st_size;
file->pos = HADDR_UNDEF;
@@ -318,7 +318,17 @@ H5FD_sec2_open(const char *name, unsigned flags, hid_t UNUSED fapl_id,
file->device = sb.st_dev;
file->inode = sb.st_ino;
#endif
- FUNC_LEAVE((H5FD_t*)file);
+
+ /* Set return value */
+ ret_value=(H5FD_t*)file;
+
+done:
+ if(ret_value==NULL) {
+ if(fd>=0)
+ HDclose(fd);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -342,15 +352,17 @@ static herr_t
H5FD_sec2_close(H5FD_t *_file)
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_sec2_close, FAIL);
if (HDclose(file->fd)<0)
- HRETURN_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
+ HGOTO_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file");
H5FL_FREE(H5FD_sec2_t,file);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -382,29 +394,30 @@ H5FD_sec2_cmp(const H5FD_t *_f1, const H5FD_t *_f2)
FUNC_ENTER_NOAPI(H5FD_sec2_cmp, H5FD_VFD_DEFAULT);
#ifdef WIN32
- if (f1->fileindexhi < f2->fileindexhi) ret_value= -1;
- if (f1->fileindexhi > f2->fileindexhi) ret_value= 1;
+ if (f1->fileindexhi < f2->fileindexhi) HGOTO_DONE(-1);
+ if (f1->fileindexhi > f2->fileindexhi) HGOTO_DONE(1);
- if (f1->fileindexlo < f2->fileindexlo) ret_value= -1;
- if (f1->fileindexlo > f2->fileindexlo) ret_value= 1;
+ if (f1->fileindexlo < f2->fileindexlo) HGOTO_DONE(-1);
+ if (f1->fileindexlo > f2->fileindexlo) HGOTO_DONE(1);
#else
#ifdef H5_DEV_T_IS_SCALAR
- if (f1->device < f2->device) ret_value= -1;
- if (f1->device > f2->device) ret_value= 1;
+ if (f1->device < f2->device) HGOTO_DONE(-1);
+ if (f1->device > f2->device) HGOTO_DONE(1);
#else /* H5_DEV_T_IS_SCALAR */
/* If dev_t isn't a scalar value on this system, just use memcmp to
* determine if the values are the same or not. The actual return value
* shouldn't really matter...
*/
- if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) ret_value= -1;
- if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) ret_value= 1;
+ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))<0) HGOTO_DONE(-1);
+ if(HDmemcmp(&(f1->device),&(f2->device),sizeof(dev_t))>0) HGOTO_DONE(1);
#endif /* H5_DEV_T_IS_SCALAR */
- if (f1->inode < f2->inode) ret_value= -1;
- if (f1->inode > f2->inode) ret_value= 1;
+ if (f1->inode < f2->inode) HGOTO_DONE(-1);
+ if (f1->inode > f2->inode) HGOTO_DONE(1);
#endif
+done:
FUNC_LEAVE(ret_value);
}
@@ -562,6 +575,7 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
ssize_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_sec2_read, FAIL);
@@ -570,20 +584,16 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_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;
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL,
- "unable to seek to proper position");
- }
+ file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0)
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position");
/*
* Read data, being careful of interrupted system calls, partial results,
@@ -593,12 +603,8 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
do {
nbytes = HDread(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 (-1==nbytes) /* error */
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "file read failed");
if (0==nbytes) {
/* end of file but not end of format address space */
HDmemset(buf, 0, size);
@@ -614,7 +620,15 @@ H5FD_sec2_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
/* Update current position */
file->pos = addr;
file->op = OP_READ;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ if(ret_value<0) {
+ /* Reset last file I/O information */
+ file->pos = HADDR_UNDEF;
+ file->op = OP_UNKNOWN;
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -642,6 +656,7 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
{
H5FD_sec2_t *file = (H5FD_sec2_t*)_file;
ssize_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_sec2_write, FAIL);
@@ -650,20 +665,16 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr overflow");
+ HGOTO_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;
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL,
- "unable to seek to proper position");
- }
+ file_seek(file->fd, (file_offset_t)addr, SEEK_SET)<0)
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to seek to proper position");
/*
* Write the data, being careful of interrupted system calls and partial
@@ -673,12 +684,8 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
do {
nbytes = HDwrite(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");
- }
+ if (-1==nbytes) /* error */
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "file write failed");
assert(nbytes>0);
assert((size_t)nbytes<=size);
size -= nbytes;
@@ -692,7 +699,14 @@ H5FD_sec2_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, had
if (file->pos>file->eof)
file->eof = file->pos;
- FUNC_LEAVE(SUCCEED);
+done:
+ if(ret_value<0) {
+ /* Reset last file I/O information */
+ file->pos = HADDR_UNDEF;
+ file->op = OP_UNKNOWN;
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -721,6 +735,7 @@ H5FD_sec2_flush(H5FD_t *_file, unsigned UNUSED closing)
HFILE filehandle; /* Windows file handle */
LARGE_INTEGER li; /* 64-bit integer for SetFilePointer() call */
#endif /* WIN32 */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_sec2_flush, FAIL);
@@ -737,10 +752,10 @@ H5FD_sec2_flush(H5FD_t *_file, unsigned UNUSED closing)
li.QuadPart = file->eoa;
SetFilePointer((HANDLE)filehandle,li.LowPart,&li.HighPart,FILE_BEGIN);
if(SetEndOfFile((HANDLE)filehandle)==0)
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly");
#else /* WIN32 */
if (-1==file_truncate(file->fd, (file_offset_t)file->eoa))
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly");
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "unable to extend file properly");
#endif /* WIN32 */
/* Update the eof value */
@@ -751,5 +766,6 @@ H5FD_sec2_flush(H5FD_t *_file, unsigned UNUSED closing)
file->op = OP_UNKNOWN;
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5FDsrb.c b/src/H5FDsrb.c
index 1579af0..c9a33eb 100644
--- a/src/H5FDsrb.c
+++ b/src/H5FDsrb.c
@@ -142,6 +142,7 @@ static const H5FD_class_t H5FD_srb_g = {
#define INTERFACE_INIT H5FD_srb_init
static int interface_initialize_g = 0;
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_init
*
@@ -169,6 +170,7 @@ H5FD_srb_init(void)
FUNC_LEAVE(H5FD_SRB_g);
}
+
/*-------------------------------------------------------------------------
* Function: H5Pset_fapl_srb
*
@@ -197,13 +199,13 @@ H5Pset_fapl_srb(hid_t fapl_id, SRB_Info info)
H5FD_srb_fapl_t fa;
int srb_status;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value = FAIL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Pset_fapl_srb, FAIL);
/*NO TRACE*/
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
/*connect to SRB server */
fa.srb_conn = clConnect(info.srbHost, info.srbPort, info.srbAuth);
@@ -212,15 +214,17 @@ H5Pset_fapl_srb(hid_t fapl_id, SRB_Info info)
clFinish(fa.srb_conn);
/*not sure about first 2 parameters. */
- HRETURN_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "Connection to srbMaster failed.");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "Connection to srbMaster failed.");
}
fa.info = info;
ret_value = H5P_set_driver(plist, H5FD_SRB, &fa);
+done:
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5Pget_fapl_srb
*
@@ -246,23 +250,26 @@ H5Pget_fapl_srb(hid_t fapl_id, SRB_Info *info/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
H5FD_srb_fapl_t *fa;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_fapl_srb, FAIL);
H5TRACE2("e","ix",fapl_id,info);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
if(H5FD_SRB != H5P_get_driver(plist))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if(NULL==(fa=H5P_get_driver_info(plist)))
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if(info)
*info = fa->info;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_open
*
@@ -291,21 +298,22 @@ H5FD_srb_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
H5FD_srb_t *file;
int srb_fid;
H5P_genplist_t *plist; /* Property list pointer */
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_srb_open, FAIL);
/* Check arguments */
if (!name || !*name)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid file name");
if (0==maxaddr || HADDR_UNDEF==maxaddr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if (ADDR_OVERFLOW(maxaddr))
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
if(H5P_DEFAULT==fapl_id || H5FD_SRB!=H5P_get_driver(plist)) {
- memset((void*)&_fa, 0, sizeof(H5FD_srb_fapl_t));
+ HDmemset((void*)&_fa, 0, sizeof(H5FD_srb_fapl_t));
fa = &_fa;
}
else {
@@ -353,22 +361,29 @@ H5FD_srb_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
if(srb_fid < 0) {
+#ifdef OLD_WAY
fprintf(stderr, "cannot open file %s\n", name);
fprintf(stderr,"%s",clErrorMessage(fa->srb_conn));
clFinish(fa->srb_conn);
- HRETURN_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "cannot open file");
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, "cannot open file");
+#else /* OLD_WAY */
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, NULL, clErrorMessage(fa->srb_conn));
+#endif /* OLD_WAY */
}
if(srbFileStat(fa->srb_conn, fa->info.storSysType, fa->info.srbHost, name,
- &srb_stat)!=0) {
+ &srb_stat)!=0) {
+#ifdef OLD_WAY
srbFileClose(fa->srb_conn, srb_fid);
clFinish(fa->srb_conn);
- HRETURN_ERROR(H5E_IO, H5E_BADFILE, NULL, "SRB file stat failed");
+ HGOTO_ERROR(H5E_IO, H5E_BADFILE, NULL, "SRB file stat failed");
+#else /* OLD_WAY */
+ HGOTO_ERROR(H5E_IO, H5E_BADFILE, NULL, "SRB file stat failed");
+#endif /* OLD_WAY */
}
if (NULL==(file=H5MM_calloc(sizeof(H5FD_srb_t))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "can't allocate file struct");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate file struct");
file->fd = srb_fid;
file->eof = srb_stat.st_size;
@@ -376,9 +391,20 @@ H5FD_srb_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
file->srb_conn = fa->srb_conn;
file->info = fa->info;
- FUNC_LEAVE((H5FD_t*)file);
+ /* Set return value */
+ ret_value=(H5FD_t*)file;
+
+done:
+ if(ret_value==NULL) {
+ if(fa!=NULL)
+ clFinish(fa->srb_conn);
+ if(srb_fid>=0)
+ srbFileClose(fa->srb_conn, srb_fid);
+ } /* end if */
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_close
*
@@ -428,8 +454,6 @@ H5FD_srb_close(H5FD_t *_file)
static herr_t
H5FD_srb_query(const UNUSED H5FD_t *_f, unsigned long *flags /* out */)
{
- herr_t ret_value=SUCCEED;
-
FUNC_ENTER_NOAPI(H5FD_srb_query, FAIL);
/* Set the VFL feature flags that this driver supports */
@@ -439,9 +463,10 @@ H5FD_srb_query(const UNUSED H5FD_t *_f, unsigned long *flags /* out */)
*flags|=H5FD_FEAT_AGGREGATE_SMALLDATA; /* OK to aggregate "small" raw data allocations */
}
- FUNC_LEAVE(ret_value);
+ FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_get_eoa
*
@@ -469,6 +494,7 @@ H5FD_srb_get_eoa(H5FD_t *_file)
FUNC_LEAVE(file->eoa);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_set_eoa
*
@@ -499,6 +525,7 @@ H5FD_srb_set_eoa(H5FD_t *_file, haddr_t addr)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_get_eof
*
@@ -525,6 +552,7 @@ H5FD_srb_get_eof(H5FD_t *_file)
FUNC_LEAVE(file->eof);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_read
*
@@ -545,38 +573,29 @@ H5FD_srb_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr
{
H5FD_srb_t *file = (H5FD_srb_t*)_file;
ssize_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_srb_read, FAIL);
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
if( addr!=file->pos &&
- srbFileSeek(file->srb_conn, (int)file->fd, (int)addr, SEEK_SET)<0 ) {
- file->pos = HADDR_UNDEF;
- srbFileClose(file->srb_conn, file->fd);
- clFinish(file->srb_conn);
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file seek failed");
- }
+ srbFileSeek(file->srb_conn, (int)file->fd, (int)addr, SEEK_SET)<0 )
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file seek failed");
/*
* Read data, being careful of interrupted system calls, partial results,
* and the end of the file.
*/
while(size>0) {
- if((nbytes=srbFileRead(file->srb_conn, (int)file->fd, (char*)buf,
- size))<0) {
- file->pos = HADDR_UNDEF;
- srbFileClose(file->srb_conn, file->fd);
- clFinish(file->srb_conn);
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "srb file write failed");
- }
+ if((nbytes=srbFileRead(file->srb_conn, (int)file->fd, (char*)buf, size))<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "srb file write failed");
if (0==nbytes) {
/*end of file but not end of format address space*/
@@ -591,9 +610,20 @@ H5FD_srb_read(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, haddr
/* Update current position */
file->pos = addr;
- FUNC_LEAVE(SUCCEED);
+done:
+ if(ret_value<0) {
+ /* Reset file position */
+ file->pos = HADDR_UNDEF;
+
+ /* Close connection, etc. */
+ srbFileClose(file->srb_conn, file->fd);
+ clFinish(file->srb_conn);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_write
*
@@ -615,34 +645,25 @@ H5FD_srb_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
{
H5FD_srb_t *file = (H5FD_srb_t*)_file;
ssize_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_srb_write, FAIL);
/* Check for overflow conditions */
if (HADDR_UNDEF==addr)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "addr undefined");
if (REGION_OVERFLOW(addr, size))
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
if (addr+size>file->eoa)
- HRETURN_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
+ HGOTO_ERROR(H5E_ARGS, H5E_OVERFLOW, FAIL, "addr too large");
if( addr!=file->pos &&
- srbFileSeek(file->srb_conn, (int)file->fd, (int)addr, SEEK_SET)<0 ) {
- file->pos = HADDR_UNDEF;
- srbObjClose(file->srb_conn, file->fd);
- clFinish(file->srb_conn);
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file seek failed");
- }
+ srbFileSeek(file->srb_conn, (int)file->fd, (int)addr, SEEK_SET)<0 )
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file seek failed");
while(size>0) {
- if( (nbytes=srbFileWrite(file->srb_conn, (int)file->fd, (char*)buf,
- size)) < 0 ) {
- file->pos = HADDR_UNDEF;
- srbObjClose(file->srb_conn, file->fd);
- clFinish(file->srb_conn);
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "srb file write failed");
- }
+ if( (nbytes=srbFileWrite(file->srb_conn, (int)file->fd, (char*)buf, size)) < 0 )
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "srb file write failed");
size -= nbytes;
addr += (haddr_t)nbytes;
@@ -654,9 +675,20 @@ H5FD_srb_write(H5FD_t *_file, H5FD_mem_t UNUSED type, hid_t UNUSED dxpl_id, hadd
if(file->pos > file->eof)
file->eof = file->pos;
- FUNC_LEAVE(SUCCEED);
+done:
+ if(ret_value<0) {
+ /* Reset file position */
+ file->pos = HADDR_UNDEF;
+
+ /* Close connection, etc. */
+ srbFileClose(file->srb_conn, file->fd);
+ clFinish(file->srb_conn);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5FD_srb_flush
*
@@ -674,16 +706,20 @@ static herr_t
H5FD_srb_flush(H5FD_t *_file, unsigned UNUSED closing)
{
H5FD_srb_t *file = (H5FD_srb_t*)_file;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_srb_flush, FAIL);
- if(srbFileSync(file->srb_conn, file->fd) != 0) {
+ if(srbFileSync(file->srb_conn, file->fd) != 0)
+ HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file sync failed");
+
+done:
+ if(ret_value<0) {
srbFileClose(file->srb_conn, file->fd);
clFinish(file->srb_conn);
- HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "srb file sync failed");
- }
+ } /* end if */
- FUNC_LEAVE(SUCCEED);
+ FUNC_LEAVE(ret_value);
}
#endif /* H5_HAVE_SRB */
diff --git a/src/H5FDstream.c b/src/H5FDstream.c
index 72cb7b8..60907f6 100644
--- a/src/H5FDstream.c
+++ b/src/H5FDstream.c
@@ -221,18 +221,15 @@ hid_t H5FD_stream_init (void)
{
FUNC_ENTER_NOAPI(H5FD_stream_init, FAIL);
- if (H5I_VFL != H5Iget_type (H5FD_STREAM_g))
- {
+ if (H5I_VFL != H5Iget_type (H5FD_STREAM_g)) {
H5FD_STREAM_g = H5FDregister (&H5FD_stream_g);
/* set the process signal mask to ignore SIGPIPE signals */
/* NOTE: Windows doesn't know SIGPIPE signals that's why the #ifdef */
#ifdef SIGPIPE
if (signal (SIGPIPE, SIG_IGN) == SIG_ERR)
- {
fprintf (stderr, "Stream VFD warning: failed to set the process signal "
"mask to ignore SIGPIPE signals\n");
- }
#endif
}
@@ -264,36 +261,29 @@ herr_t H5Pset_fapl_stream (hid_t fapl_id, H5FD_stream_fapl_t *fapl)
{
H5FD_stream_fapl_t user_fapl;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t result;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pset_fapl_stream, FAIL);
H5TRACE2 ("e", "ix", fapl_id, fapl);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- HRETURN_ERROR (H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
+ HGOTO_ERROR (H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
- if (fapl)
- {
+ if (fapl) {
if (! fapl->do_socket_io && fapl->broadcast_fn == NULL)
- {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "read broadcast function pointer is NULL");
- }
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "read broadcast function pointer is NULL");
user_fapl = *fapl;
if (fapl->increment == 0)
- {
user_fapl.increment = H5FD_STREAM_INCREMENT;
- }
user_fapl.port = 0;
- result = H5P_set_driver (plist, H5FD_STREAM, &user_fapl);
+ ret_value = H5P_set_driver (plist, H5FD_STREAM, &user_fapl);
}
else
- {
- result = H5P_set_driver (plist, H5FD_STREAM, &default_fapl);
- }
+ ret_value = H5P_set_driver (plist, H5FD_STREAM, &default_fapl);
- FUNC_LEAVE (result);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -316,29 +306,23 @@ herr_t H5Pget_fapl_stream(hid_t fapl_id, H5FD_stream_fapl_t *fapl /* out */)
{
H5FD_stream_fapl_t *this_fapl;
H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_fapl_stream, FAIL);
H5TRACE2("e","ix",fapl_id,fapl);
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
- {
- HRETURN_ERROR (H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
- }
+ HGOTO_ERROR (H5E_PLIST, H5E_BADTYPE, FAIL, "not a fapl");
if (H5FD_STREAM != H5P_get_driver (plist))
- {
- HRETURN_ERROR (H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
- }
+ HGOTO_ERROR (H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver");
if (NULL == (this_fapl = H5P_get_driver_info (plist)))
- {
- HRETURN_ERROR (H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
- }
+ HGOTO_ERROR (H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info");
if (fapl)
- {
*fapl = *this_fapl;
- }
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -362,18 +346,20 @@ H5FD_stream_fapl_get (H5FD_t *_stream)
{
H5FD_stream_t *stream = (H5FD_stream_t *) _stream;
H5FD_stream_fapl_t *fapl;
-
+ H5FD_t *ret_value;
FUNC_ENTER_NOAPI(H5FD_stream_fapl_get, NULL);
if ((fapl = H5MM_calloc (sizeof (H5FD_stream_fapl_t))) == NULL)
- {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- }
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
*fapl = stream->fapl;
- FUNC_LEAVE (fapl);
+ /* Set return value */
+ ret_value=fapl;
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -396,22 +382,14 @@ H5FD_stream_open_socket (const char *filename, int o_flags,
for (separator = filename; *separator != ':' && *separator; separator++)
;
if (separator == filename || !*separator)
- {
HGOTO_ERROR(H5E_ARGS,H5E_BADVALUE,H5FD_STREAM_INVALID_SOCKET,"invalid host address");
- }
- else
- {
+ else {
tmp = separator;
if (! tmp[1])
- {
HGOTO_ERROR(H5E_ARGS,H5E_BADVALUE,H5FD_STREAM_INVALID_SOCKET,"no port number");
- }
- while (*++tmp)
- {
+ while (*++tmp) {
if (! isdigit (*tmp))
- {
HGOTO_ERROR(H5E_ARGS,H5E_BADVALUE,H5FD_STREAM_INVALID_SOCKET,"invalid port number");
- }
}
}
@@ -419,9 +397,7 @@ H5FD_stream_open_socket (const char *filename, int o_flags,
/* Return if out of memory */
if (hostname == NULL)
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"memory allocation failed");
- }
HDstrncpy (hostname, filename, (size_t)(separator - filename));
hostname[separator - filename] = 0;
@@ -432,72 +408,49 @@ H5FD_stream_open_socket (const char *filename, int o_flags,
server.sin_port = htons (fapl->port);
if (! (he = gethostbyname (hostname)))
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to get host address");
- }
else if (H5FD_STREAM_ERROR_CHECK (sock = socket (AF_INET, SOCK_STREAM, 0)))
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to open socket");
- }
- if (O_RDONLY == o_flags)
- {
+ if (O_RDONLY == o_flags) {
HDmemcpy (&server.sin_addr, he->h_addr, (size_t)he->h_length);
#ifdef DEBUG
fprintf (stderr, "Stream VFD: connecting to host '%s' port %d\n",
hostname, fapl->port);
#endif
if (connect (sock, (struct sockaddr *) &server, sizeof (server)) < 0)
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to connect");
- }
}
- else
- {
+ else {
server.sin_addr.s_addr = INADDR_ANY;
if (H5FD_STREAM_IOCTL_SOCKET (sock, FIONBIO, &on) < 0)
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to set non-blocking mode for socket");
- }
else if (setsockopt (sock, IPPROTO_TCP, TCP_NODELAY, (const char *) &on,
sizeof(on)) < 0)
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to set socket option TCP_NODELAY");
- }
else if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, (const char *) &on,
sizeof(on)) < 0)
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to set socket option SO_REUSEADDR");
- }
- else
- {
+ else {
/* Try to bind the socket to the given port.
If maxhunt is given try some successive ports also. */
first_port = fapl->port;
- while (fapl->port <= first_port + fapl->maxhunt)
- {
+ while (fapl->port <= first_port + fapl->maxhunt) {
#ifdef DEBUG
fprintf (stderr, "Stream VFD: binding to port %d\n", fapl->port);
#endif
server.sin_port = htons (fapl->port);
if (bind (sock, (struct sockaddr *) &server, sizeof (server)) < 0)
- {
fapl->port++;
- }
else
- {
break;
- }
}
- if (fapl->port > first_port + fapl->maxhunt)
- {
+ if (fapl->port > first_port + fapl->maxhunt) {
fapl->port = 0;
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to bind socket");
}
else if (listen (sock, fapl->backlog) < 0)
- {
HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,H5FD_STREAM_INVALID_SOCKET,"unable to listen on socket");
- }
}
}
@@ -514,6 +467,7 @@ done:
if (!H5FD_STREAM_ERROR_CHECK(sock))
H5FD_STREAM_CLOSE_SOCKET(sock);
} /* end if */
+
FUNC_LEAVE(ret_value);
}
@@ -531,10 +485,8 @@ H5FD_stream_read_from_socket (H5FD_stream_t *stream)
stream->eof = 0;
stream->mem = NULL;
- while (1)
- {
- if (max_size <= 0)
- {
+ while (1) {
+ if (max_size <= 0) {
/*
* Allocate initial buffer as increment + 1
* to prevent unnecessary reallocation
@@ -542,14 +494,10 @@ H5FD_stream_read_from_socket (H5FD_stream_t *stream)
*/
max_size = stream->fapl.increment;
if (! stream->mem)
- {
max_size++;
- }
ptr = H5MM_realloc (stream->mem, (size_t) (stream->eof + max_size));
if (! ptr)
- {
- HRETURN_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"unable to allocate file space buffer");
- }
+ HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,FAIL,"unable to allocate file space buffer");
stream->mem = ptr;
ptr += stream->eof;
}
@@ -558,17 +506,11 @@ H5FD_stream_read_from_socket (H5FD_stream_t *stream)
size = recv (stream->socket, ptr, max_size, 0);
if (size < 0 && (EINTR == errno || EAGAIN == errno || EWOULDBLOCK))
- {
continue;
- }
if (size < 0)
- {
- HRETURN_ERROR(H5E_IO,H5E_READERROR,FAIL,"error reading from file from socket");
- }
+ HGOTO_ERROR(H5E_IO,H5E_READERROR,FAIL,"error reading from file from socket");
if (! size)
- {
break;
- }
max_size -= (size_t) size;
stream->eof += (haddr_t) size;
ptr += size;
@@ -582,6 +524,7 @@ H5FD_stream_read_from_socket (H5FD_stream_t *stream)
fprintf (stderr, "Stream VFD: read total of %d bytes from socket\n",
(int) stream->eof);
#endif
+done:
FUNC_LEAVE(ret_value);
}
@@ -616,23 +559,17 @@ H5FD_stream_open (const char *filename,
WSADATA wsadata;
#endif
H5P_genplist_t *plist; /* Property list pointer */
- H5FD_t *ret_value=NULL; /* Function return value */
+ H5FD_t *ret_value; /* Function return value */
FUNC_ENTER_NOAPI(H5FD_stream_open, NULL);
/* Check arguments */
if (filename == NULL|| *filename == '\0')
- {
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL,"invalid file name");
- }
if (maxaddr == 0 || HADDR_UNDEF == maxaddr)
- {
HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, NULL, "bogus maxaddr");
- }
if (ADDR_OVERFLOW (maxaddr))
- {
HGOTO_ERROR (H5E_ARGS, H5E_OVERFLOW, NULL, "maxaddr overflow");
- }
/* Build the open flags */
o_flags = (H5F_ACC_RDWR & flags) ? O_RDWR : O_RDONLY;
@@ -641,54 +578,41 @@ H5FD_stream_open (const char *filename,
if (H5F_ACC_EXCL & flags) o_flags |= O_EXCL;
if ((O_RDWR & o_flags) && ! (O_CREAT & o_flags))
- {
HGOTO_ERROR (H5E_ARGS, H5E_UNSUPPORTED, NULL, "open stream for read/write not supported");
- }
#ifdef WIN32
if (WSAStartup (MAKEWORD (2, 0), &wsadata))
- {
HGOTO_ERROR (H5E_IO, H5E_CANTINIT, NULL, "Couldn't start Win32 socket layer");
- }
#endif
fapl = NULL;
- if (H5P_DEFAULT != fapl_id)
- {
+ if (H5P_DEFAULT != fapl_id) {
if(TRUE!=H5P_isa_class(fapl_id,H5P_FILE_ACCESS) || NULL == (plist = H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
fapl = H5P_get_driver_info (plist);
}
if (fapl == NULL)
- {
fapl = &default_fapl;
- }
/* Create the new file struct */
stream = (H5FD_stream_t *) H5MM_calloc (sizeof (H5FD_stream_t));
if (stream == NULL)
- {
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "unable to allocate file struct");
- }
stream->fapl = *fapl;
stream->socket = H5FD_STREAM_INVALID_SOCKET;
/* if an external socket is provided with the file access property list
we use that, otherwise the filename argument is parsed and a socket
is opened internally */
- if (fapl->do_socket_io)
- {
- if (! H5FD_STREAM_ERROR_CHECK (fapl->socket))
- {
+ if (fapl->do_socket_io) {
+ if (! H5FD_STREAM_ERROR_CHECK (fapl->socket)) {
stream->internal_socket = FALSE;
stream->socket = fapl->socket;
}
- else
- {
+ else {
stream->internal_socket = TRUE;
stream->socket = H5FD_stream_open_socket (filename, o_flags, &stream->fapl);
- if (stream->socket != H5FD_STREAM_INVALID_SOCKET)
- {
+ if (stream->socket != H5FD_STREAM_INVALID_SOCKET) {
/* update the port ID in the file access property
so that it can be queried via H5P_get_fapl_stream() later on */
H5P_set_driver (plist, H5FD_STREAM, &stream->fapl);
@@ -699,10 +623,8 @@ H5FD_stream_open (const char *filename,
}
/* read the data from socket into memory */
- if (O_RDONLY == o_flags)
- {
- if (fapl->do_socket_io)
- {
+ if (O_RDONLY == o_flags) {
+ if (fapl->do_socket_io) {
#ifdef DEBUG
fprintf (stderr, "Stream VFD: reading file from socket\n");
#endif
@@ -711,27 +633,20 @@ H5FD_stream_open (const char *filename,
}
/* Now call the user's broadcast routine if given */
- if (fapl->broadcast_fn)
- {
+ if (fapl->broadcast_fn) {
if ((fapl->broadcast_fn) (&stream->mem, &stream->eof,
fapl->broadcast_arg) < 0)
- {
HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "broadcast error");
- }
/* check for filesize of zero bytes */
if (stream->eof == 0)
- {
HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "zero filesize");
- }
}
/* For files which are read from a socket:
the opened socket is not needed anymore */
if (stream->internal_socket && ! H5FD_STREAM_ERROR_CHECK (stream->socket))
- {
H5FD_STREAM_CLOSE_SOCKET (stream->socket);
- }
stream->socket = H5FD_STREAM_INVALID_SOCKET;
}
@@ -742,13 +657,9 @@ done:
if(ret_value==NULL) {
if(stream!=NULL) {
if (stream->mem)
- {
- H5MM_xfree (stream->mem);
- }
+ H5MM_xfree (stream->mem);
if (stream->internal_socket && ! H5FD_STREAM_ERROR_CHECK (stream->socket))
- {
- H5FD_STREAM_CLOSE_SOCKET (stream->socket);
- }
+ H5FD_STREAM_CLOSE_SOCKET (stream->socket);
H5MM_xfree(stream);
} /* end if */
}
@@ -788,17 +699,14 @@ H5FD_stream_flush (H5FD_t *_stream, unsigned UNUSED closing)
FUNC_ENTER_NOAPI(H5FD_stream_flush, FAIL);
/* Write to backing store */
- if (stream->dirty && ! H5FD_STREAM_ERROR_CHECK (stream->socket))
- {
+ if (stream->dirty && ! H5FD_STREAM_ERROR_CHECK (stream->socket)) {
#ifdef DEBUG
fprintf (stderr, "Stream VFD: accepting client connections\n");
#endif
fromlen = sizeof (from);
while (! H5FD_STREAM_ERROR_CHECK (sock = accept (stream->socket,
- &from, &fromlen)))
- {
- if (H5FD_STREAM_IOCTL_SOCKET (sock, FIONBIO, &on) < 0)
- {
+ &from, &fromlen))) {
+ if (H5FD_STREAM_IOCTL_SOCKET (sock, FIONBIO, &on) < 0) {
H5FD_STREAM_CLOSE_SOCKET (sock);
continue; /* continue the loop for other clients to connect */
}
@@ -806,15 +714,11 @@ H5FD_stream_flush (H5FD_t *_stream, unsigned UNUSED closing)
size = stream->eof;
ptr = stream->mem;
- while (size)
- {
+ while (size) {
bytes_send = send (sock, ptr, size, 0);
- if (bytes_send < 0)
- {
+ if (bytes_send < 0) {
if (EINTR == errno || EAGAIN == errno || EWOULDBLOCK == errno)
- {
continue;
- }
/* continue the outermost loop for other clients to connect */
break;
@@ -854,28 +758,24 @@ static herr_t
H5FD_stream_close (H5FD_t *_stream)
{
H5FD_stream_t *stream = (H5FD_stream_t *) _stream;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_stream_close, FAIL);
/* Flush */
if (H5FD_stream_flush (_stream,TRUE) != SUCCEED)
- {
- HRETURN_ERROR (H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file");
- }
+ HGOTO_ERROR (H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file");
/* Release resources */
if (! H5FD_STREAM_ERROR_CHECK (stream->socket) && stream->internal_socket)
- {
H5FD_STREAM_CLOSE_SOCKET (stream->socket);
- }
if (stream->mem)
- {
H5MM_xfree (stream->mem);
- }
HDmemset (stream, 0, sizeof (H5FD_stream_t));
H5MM_xfree (stream);
- FUNC_LEAVE (0);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -963,17 +863,17 @@ static herr_t
H5FD_stream_set_eoa (H5FD_t *_stream, haddr_t addr)
{
H5FD_stream_t *stream = (H5FD_stream_t *) _stream;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_stream_set_eoa, FAIL);
if (ADDR_OVERFLOW (addr))
- {
- HRETURN_ERROR (H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow");
- }
+ HGOTO_ERROR (H5E_ARGS, H5E_OVERFLOW, FAIL, "address overflow");
stream->eoa = addr;
- FUNC_LEAVE (0);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1036,6 +936,7 @@ H5FD_stream_read (H5FD_t *_stream,
{
H5FD_stream_t *stream = (H5FD_stream_t *) _stream;
size_t nbytes;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_stream_read, FAIL);
@@ -1044,21 +945,14 @@ H5FD_stream_read (H5FD_t *_stream,
/* Check for overflow conditions */
if (HADDR_UNDEF == addr)
- {
- HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
- }
+ HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
if (REGION_OVERFLOW (addr, size))
- {
- HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
- }
+ HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
if (addr + size > stream->eoa)
- {
- HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
- }
+ HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
/* Read the part which is before the EOF marker */
- if (addr < stream->eof)
- {
+ if (addr < stream->eof) {
nbytes = MIN (size, stream->eof - addr);
HDmemcpy (buf, stream->mem + addr, nbytes);
size -= nbytes;
@@ -1068,11 +962,10 @@ H5FD_stream_read (H5FD_t *_stream,
/* Read zeros for the part which is after the EOF markers */
if (size > 0)
- {
HDmemset (buf, 0, size);
- }
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1102,6 +995,7 @@ H5FD_stream_write (H5FD_t *_stream,
const void *buf)
{
H5FD_stream_t *stream = (H5FD_stream_t *) _stream;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5FD_stream_write, FAIL);
@@ -1110,13 +1004,9 @@ H5FD_stream_write (H5FD_t *_stream,
/* Check for overflow conditions */
if (REGION_OVERFLOW (addr, size))
- {
- HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
- }
+ HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
if (addr + size > stream->eoa)
- {
- HRETURN_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
- }
+ HGOTO_ERROR (H5E_IO, H5E_OVERFLOW, FAIL, "file address overflowed");
/*
* Allocate more memory if necessary, careful of overflow. Also, if the
@@ -1124,30 +1014,19 @@ H5FD_stream_write (H5FD_t *_stream,
* careful of non-Posix realloc() that doesn't understand what to do when
* the first argument is null.
*/
- if (addr + size > stream->eof)
- {
+ if (addr + size > stream->eof) {
unsigned char *x;
haddr_t new_eof = stream->fapl.increment *
((addr+size) / stream->fapl.increment);
-
if ((addr+size) % stream->fapl.increment)
- {
new_eof += stream->fapl.increment;
- }
if (stream->mem == NULL)
- {
x = H5MM_malloc ((size_t) new_eof);
- }
else
- {
x = H5MM_realloc (stream->mem, (size_t) new_eof);
- }
if (x == NULL)
- {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate memory block");
- }
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate memory block");
stream->mem = x;
stream->eof = new_eof;
}
@@ -1156,7 +1035,8 @@ H5FD_stream_write (H5FD_t *_stream,
HDmemcpy (stream->mem + addr, buf, size);
stream->dirty = TRUE;
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
#endif /* H5_HAVE_STREAM */
diff --git a/src/H5FL.c b/src/H5FL.c
index cf14880..4045079 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -162,7 +162,7 @@ H5FL_reg_init(H5FL_reg_head_t *head)
/* Allocate a new garbage collection node */
if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_reg_gc_node_t))))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Initialize the new garbage collection node */
new_node->list=head;
@@ -178,6 +178,7 @@ H5FL_reg_init(H5FL_reg_head_t *head)
if(head->size<sizeof(void *))
head->size=sizeof(void *);
+done:
FUNC_LEAVE (ret_value);
} /* end H5FL_reg_init() */
@@ -292,17 +293,17 @@ H5FL_reg_alloc(H5FL_reg_head_t *head, unsigned clear)
/* Otherwise allocate a node */
else {
if (NULL==(ret_value = H5FL_malloc(head->size)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Increment the number of blocks allocated in list */
head->allocated++;
} /* end else */
/* Clear to zeros, if asked */
- if(clear) {
+ if(clear)
HDmemset(ret_value,0,head->size);
- } /* end if */
+done:
FUNC_LEAVE (ret_value);
} /* end H5FL_reg_alloc() */
@@ -500,7 +501,7 @@ static H5FL_blk_node_t *
H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size)
{
H5FL_blk_node_t *temp; /* Temp. pointer to node in the native list */
- H5FL_blk_node_t *ret_value=NULL;
+ H5FL_blk_node_t *ret_value;
FUNC_ENTER_NOINIT(H5FL_blk_find_list);
@@ -554,7 +555,7 @@ static H5FL_blk_node_t *
H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size)
{
H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */
- H5FL_blk_node_t *ret_value=NULL;
+ H5FL_blk_node_t *ret_value;
FUNC_ENTER_NOINIT(H5FL_blk_create_list);
@@ -611,7 +612,7 @@ H5FL_blk_init(H5FL_blk_head_t *head)
/* Allocate a new garbage collection node */
if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_blk_gc_node_t))))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Initialize the new garbage collection node */
new_node->pq=head;
@@ -623,6 +624,7 @@ H5FL_blk_init(H5FL_blk_head_t *head)
/* Indicate that the PQ is initialized */
head->init=1;
+done:
FUNC_LEAVE (ret_value);
} /* end H5FL_blk_init() */
@@ -699,9 +701,8 @@ H5FL_blk_alloc(H5FL_blk_head_t *head, size_t size, unsigned clear)
} /* end else */
/* Clear the block to zeros, if requested */
- if(clear) {
+ if(clear)
HDmemset(ret_value,0,size);
- } /* end if */
done:
FUNC_LEAVE(ret_value);
@@ -1021,7 +1022,7 @@ H5FL_arr_init(H5FL_arr_head_t *head)
/* Allocate a new garbage collection node */
if (NULL==(new_node = H5MM_malloc(sizeof(H5FL_gc_arr_node_t))))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Initialize the new garbage collection node */
new_node->list=head;
@@ -1033,9 +1034,9 @@ H5FL_arr_init(H5FL_arr_head_t *head)
/* Allocate room for the free lists, if the arrays have a maximum size */
if(head->maxelem>0) {
if (NULL==(head->u.list_arr = H5MM_calloc(head->maxelem*sizeof(H5FL_arr_node_t *))))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
if (NULL==(head->onlist = H5MM_calloc(head->maxelem*sizeof(unsigned))))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
} /* end if */
else {
head->u.queue.init=0;
@@ -1049,6 +1050,7 @@ H5FL_arr_init(H5FL_arr_head_t *head)
/* Indicate that the free list is initialized */
head->init=1;
+done:
FUNC_LEAVE (ret_value);
} /* end H5FL_arr_init() */
@@ -1074,12 +1076,13 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
H5FL_arr_node_t *temp; /* Temp. ptr to the new free list node allocated */
size_t mem_size; /* Size of memory being freed */
size_t free_nelem; /* Number of elements in node being free'd */
+ void *ret_value=NULL; /* Return value */
FUNC_ENTER_NOAPI(H5FL_arr_free, NULL);
/* The H5MM_xfree code allows obj to null */
if (!obj)
- HRETURN (NULL);
+ HGOTO_DONE (NULL);
/* Double check parameters */
assert(head);
@@ -1125,11 +1128,11 @@ H5FL_arr_free(H5FL_arr_head_t *head, void *obj)
} /* end if */
/* No maximum number of elements, use block routine */
- else {
+ else
H5FL_blk_free(&(head->u.queue),obj);
- } /* end else */
- FUNC_LEAVE(NULL);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5FL_arr_free() */
@@ -1194,7 +1197,7 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, size_t elem, unsigned clear)
/* Otherwise allocate a node */
else {
if (NULL==(new_obj = H5FL_malloc(sizeof(H5FL_arr_node_t)+mem_size)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Increment the number of blocks allocated in list */
head->allocated++;
@@ -1211,10 +1214,10 @@ H5FL_arr_alloc(H5FL_arr_head_t *head, size_t elem, unsigned clear)
HDmemset(ret_value,0,mem_size);
} /* end if */
/* No fixed number of elements, use PQ routine */
- else {
+ else
ret_value=H5FL_blk_alloc(&(head->u.queue),mem_size,clear);
- } /* end else */
+done:
FUNC_LEAVE (ret_value);
} /* end H5FL_arr_alloc() */
@@ -1272,9 +1275,8 @@ H5FL_arr_realloc(H5FL_arr_head_t *head, void * obj, size_t new_elem)
ret_value=obj;
} /* end if */
/* No fixed number of elements, use block routine */
- else {
+ else
ret_value=H5FL_blk_realloc(&(head->u.queue),obj,head->size*new_elem);
- } /* end else */
} /* end else */
FUNC_LEAVE (ret_value);
@@ -1344,9 +1346,8 @@ H5FL_arr_gc_list(H5FL_arr_head_t *head)
} /* end if */
/* No maximum number of elements, use the block call to garbage collect */
- else {
+ else
H5FL_blk_gc_list(&(head->u.queue));
- } /* end else */
FUNC_LEAVE(SUCCEED);
} /* end H5FL_arr_gc_list() */
diff --git a/src/H5Fcontig.c b/src/H5Fcontig.c
index 461a068..89f9fc5 100644
--- a/src/H5Fcontig.c
+++ b/src/H5Fcontig.c
@@ -51,6 +51,7 @@ H5F_contig_read(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr,
size_t size, hid_t dxpl_id, void *buf/*out*/)
{
hsize_t offset=0; /* Offset for vector call */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_read, FAIL);
@@ -59,9 +60,10 @@ H5F_contig_read(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr,
assert(buf);
if (H5F_contig_readv(f, max_data, type, addr, 1, &size, &offset, dxpl_id, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_read() */
@@ -87,6 +89,7 @@ H5F_contig_write(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr, size
hid_t dxpl_id, const void *buf)
{
hsize_t offset=0; /* Offset for vector call */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_write, FAIL);
@@ -94,9 +97,10 @@ H5F_contig_write(H5F_t *f, hsize_t max_data, H5FD_mem_t type, haddr_t addr, size
assert (buf);
if (H5F_contig_writev(f, max_data, type, addr, 1, &size, &offset, dxpl_id, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_write() */
@@ -141,6 +145,7 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size_t *size_arr_p; /* Pointer into the size array */
hsize_t *offset_arr_p; /* Pointer into the offset array */
#endif /* SLOW_WAY */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_readv, FAIL);
@@ -388,10 +393,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Flush the sieve buffer, if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -399,20 +402,16 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
} /* end if */
/* Read directly into the user's buffer */
- if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
/* Element size fits within the buffer size */
else {
/* Flush the sieve buffer if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -422,10 +421,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -443,10 +440,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
sieve_end=sieve_start+sieve_size;
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -472,26 +467,20 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if we can actually hold the I/O request in the sieve buffer */
if(size>f->shared->sieve_buf_size) {
- if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
else {
/* Allocate room for the data sieve buffer */
- if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Determine the new sieve buffer size & location */
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -500,10 +489,8 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
H5_ASSIGN_OVERFLOW(f->shared->sieve_size,MIN(rel_eoa-f->shared->sieve_loc,MIN(max_data,f->shared->sieve_buf_size)),hsize_t,size_t);
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -526,17 +513,16 @@ H5F_contig_readv(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size=size_arr[u];
addr=_addr+offset_arr[u];
- if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- }
+ if (H5F_block_read(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
/* Increment offset in buffer */
buf += size_arr[u];
} /* end for */
} /* end else */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_readv() */
@@ -581,6 +567,7 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size_t *size_arr_p; /* Pointer into the size array */
hsize_t *offset_arr_p; /* Pointer into the offset array */
#endif /* SLOW_WAY */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_contig_writev, FAIL);
@@ -831,10 +818,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Flush the sieve buffer, if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -846,10 +831,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
} /* end if */
/* Write directly from the user's buffer */
- if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
} /* end if */
/* Element size fits within the buffer size */
else {
@@ -889,10 +872,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Flush the sieve buffer if it's dirty */
if(f->shared->sieve_dirty) {
/* Write to file */
- if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, H5FD_MEM_DRAW, sieve_start, sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Reset sieve buffer dirty flag */
f->shared->sieve_dirty=0;
@@ -902,10 +883,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -925,10 +904,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if there is any point in reading the data from the file */
if(f->shared->sieve_size>size) {
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- } /* end if */
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
@@ -957,26 +934,20 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if we can actually hold the I/O request in the sieve buffer */
if(size>f->shared->sieve_buf_size) {
- if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
} /* end if */
else {
/* Allocate room for the data sieve buffer */
- if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(f->shared->sieve_buf=H5FL_BLK_ALLOC(sieve_buf,f->shared->sieve_buf_size,0)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Determine the new sieve buffer size & location */
f->shared->sieve_loc=addr;
/* Make certain we don't read off the end of the file */
- if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf))) {
- HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL,
- "unable to determine file size");
- }
+ if (HADDR_UNDEF==(abs_eoa=H5FD_get_eoa(f->shared->lf)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to determine file size");
/* Adjust absolute EOA address to relative EOA address */
rel_eoa=abs_eoa-f->shared->base_addr;
@@ -987,10 +958,8 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
/* Check if there is any point in reading the data from the file */
if(f->shared->sieve_size>size) {
/* Read the new sieve buffer */
- if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
- "block read failed");
- } /* end if */
+ if (H5F_block_read(f, type, f->shared->sieve_loc, f->shared->sieve_size, dxpl_id, f->shared->sieve_buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
} /* end if */
/* Grab the data out of the buffer (must be first piece of data in buffer ) */
@@ -1014,16 +983,15 @@ H5F_contig_writev(H5F_t *f, hsize_t _max_data, H5FD_mem_t type, haddr_t _addr,
size=size_arr[u];
addr=_addr+offset_arr[u];
- if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "block write failed");
- }
+ if (H5F_block_write(f, type, addr, size, dxpl_id, buf)<0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
/* Increment offset in buffer */
buf += size_arr[u];
} /* end for */
} /* end else */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5F_contig_writev() */
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index bac14c2..7780b2d 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -490,6 +490,7 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
unsigned u;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_new_node, FAIL);
#ifdef AKC
@@ -505,13 +506,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
/* Allocate new storage */
assert (udata->key.nbytes > 0);
-#ifdef AKC
- printf("calling H5MF_alloc for new chunk\n");
-#endif
- if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes))) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
- "couldn't allocate new file storage");
- }
+ if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes)))
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "couldn't allocate new file storage");
udata->addr = *addr_p;
/*
@@ -520,9 +516,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
*/
lt_key->nbytes = udata->key.nbytes;
lt_key->filter_mask = udata->key.filter_mask;
- for (u=0; u<udata->mesg.ndims; u++) {
+ for (u=0; u<udata->mesg.ndims; u++)
lt_key->offset[u] = udata->key.offset[u];
- }
/*
* The right key might already be present. If not, then add a zero-width
@@ -540,7 +535,8 @@ H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
}
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -578,6 +574,7 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key,
H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key;
unsigned u;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_found, FAIL);
@@ -589,9 +586,8 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key,
/* Is this *really* the requested chunk? */
for (u=0; u<udata->mesg.ndims; u++) {
- if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg.dim[u])) {
- HRETURN(FAIL);
- }
+ if (udata->key.offset[u] >= lt_key->offset[u]+(hssize_t)(udata->mesg.dim[u]))
+ HGOTO_DONE(FAIL);
}
/* Initialize return values */
@@ -599,11 +595,11 @@ H5F_istore_found(H5F_t UNUSED *f, haddr_t addr, const void *_lt_key,
udata->key.nbytes = lt_key->nbytes;
udata->key.filter_mask = lt_key->filter_mask;
assert (lt_key->nbytes>0);
- for (u = 0; u < udata->mesg.ndims; u++) {
+ for (u = 0; u < udata->mesg.ndims; u++)
udata->key.offset[u] = lt_key->offset[u];
- }
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -676,8 +672,7 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key,
if (cmp < 0) {
/* Negative indices not supported yet */
assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR,
- "internal error");
+ HGOTO_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error");
} else if (H5V_vector_eq_s (udata->mesg.ndims,
udata->key.offset, lt_key->offset) &&
@@ -691,11 +686,8 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key,
printf("calling H5MF_realloc for new chunk\n");
#endif
if (HADDR_UNDEF==(*new_node_p=H5MF_realloc(f, H5FD_MEM_DRAW, addr,
- (hsize_t)lt_key->nbytes,
- (hsize_t)udata->key.nbytes))) {
- HRETURN_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR,
- "unable to reallocate chunk storage");
- }
+ (hsize_t)lt_key->nbytes, (hsize_t)udata->key.nbytes)))
+ HGOTO_ERROR (H5E_STORAGE, H5E_WRITEERROR, H5B_INS_ERROR, "unable to reallocate chunk storage");
lt_key->nbytes = udata->key.nbytes;
lt_key->filter_mask = udata->key.filter_mask;
*lt_key_changed = TRUE;
@@ -729,20 +721,17 @@ H5F_istore_insert(H5F_t *f, haddr_t addr, void *_lt_key,
#ifdef AKC
printf("calling H5MF_alloc for new chunk\n");
#endif
- if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW,
- (hsize_t)udata->key.nbytes))) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR,
- "file allocation failed");
- }
+ if (HADDR_UNDEF==(*new_node_p=H5MF_alloc(f, H5FD_MEM_DRAW, (hsize_t)udata->key.nbytes)))
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, H5B_INS_ERROR, "file allocation failed");
udata->addr = *new_node_p;
ret_value = H5B_INS_RIGHT;
} else {
assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR,
- "internal error");
+ HGOTO_ERROR(H5E_IO, H5E_UNSUPPORTED, H5B_INS_ERROR, "internal error");
}
+done:
FUNC_LEAVE(ret_value);
}
@@ -853,6 +842,7 @@ herr_t
H5F_istore_init (H5F_t *f)
{
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_init, FAIL);
@@ -860,13 +850,12 @@ H5F_istore_init (H5F_t *f)
if (f->shared->rdcc_nbytes>0 && f->shared->rdcc_nelmts>0) {
rdcc->nslots = f->shared->rdcc_nelmts;
rdcc->slot = H5FL_ARR_ALLOC (H5F_rdcc_ent_ptr_t,rdcc->nslots,1);
- if (NULL==rdcc->slot) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==rdcc->slot)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1015,6 +1004,7 @@ static herr_t
H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
{
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5F_istore_preempt);
@@ -1024,37 +1014,27 @@ H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
assert(ent->idx < rdcc->nslots);
if(flush) {
-
/* Flush */
- if(H5F_istore_flush_entry(f, ent, TRUE) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
- "cannot flush indexed storage buffer");
- }
+ if(H5F_istore_flush_entry(f, ent, TRUE) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer");
}
-
else {
-
/* Reset, but do not free or remove from list */
ent->layout = H5O_free(H5O_LAYOUT, ent->layout);
ent->pline = H5O_free(H5O_PLINE, ent->pline);
if(ent->chunk != NULL)
ent->chunk = H5MM_xfree(ent->chunk);
-
}
/* Unlink from list */
- if(ent->prev) {
+ if(ent->prev)
ent->prev->next = ent->next;
- }
- else {
+ else
rdcc->head = ent->next;
- }
- if(ent->next) {
+ if(ent->next)
ent->next->prev = ent->prev;
- }
- else {
+ else
rdcc->tail = ent->prev;
- }
ent->prev = ent->next = NULL;
/* Remove from cache */
@@ -1066,7 +1046,8 @@ H5F_istore_preempt(H5F_t *f, H5F_rdcc_ent_t * ent, hbool_t flush)
/* Free */
H5FL_FREE(H5F_rdcc_ent_t, ent);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1093,27 +1074,26 @@ H5F_istore_flush (H5F_t *f, hbool_t preempt)
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
int nerrors=0;
H5F_rdcc_ent_t *ent=NULL, *next=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_flush, FAIL);
for (ent=rdcc->head; ent; ent=next) {
next = ent->next;
if (preempt) {
- if (H5F_istore_preempt(f, ent, TRUE )<0) {
+ if (H5F_istore_preempt(f, ent, TRUE )<0)
nerrors++;
- }
} else {
- if (H5F_istore_flush_entry(f, ent, FALSE)<0) {
+ if (H5F_istore_flush_entry(f, ent, FALSE)<0)
nerrors++;
- }
}
}
- if (nerrors) {
- HRETURN_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL,
- "unable to flush one or more raw data chunks");
- }
- FUNC_LEAVE (SUCCEED);
+ if (nerrors)
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks");
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1140,6 +1120,7 @@ H5F_istore_dest (H5F_t *f)
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
int nerrors=0;
H5F_rdcc_ent_t *ent=NULL, *next=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_dest, FAIL);
@@ -1149,18 +1130,17 @@ H5F_istore_dest (H5F_t *f)
HDfflush(stderr);
#endif
next = ent->next;
- if (H5F_istore_preempt(f, ent, TRUE )<0) {
+ if (H5F_istore_preempt(f, ent, TRUE )<0)
nerrors++;
- }
- }
- if (nerrors) {
- HRETURN_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL,
- "unable to flush one or more raw data chunks");
}
+ if (nerrors)
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to flush one or more raw data chunks");
H5FL_ARR_FREE (H5F_rdcc_ent_ptr_t,rdcc->slot);
HDmemset (rdcc, 0, sizeof(H5F_rdcc_t));
- FUNC_LEAVE (SUCCEED);
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1192,6 +1172,7 @@ H5F_istore_prune (H5F_t *f, size_t size)
int w[1]; /*weighting as an interval */
H5F_rdcc_ent_t *p[2], *cur; /*list pointers */
H5F_rdcc_ent_t *n[2]; /*list next pointers */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5F_istore_prune);
@@ -1212,17 +1193,20 @@ H5F_istore_prune (H5F_t *f, size_t size)
while ((p[0] || p[1]) && rdcc->nbytes+size>total) {
/* Introduce new pointers */
- for (i=0; i<nmeth-1; i++) if (0==w[i]) p[i+1] = rdcc->head;
+ for (i=0; i<nmeth-1; i++)
+ if (0==w[i])
+ p[i+1] = rdcc->head;
/* Compute next value for each pointer */
- for (i=0; i<nmeth; i++) n[i] = p[i] ? p[i]->next : NULL;
+ for (i=0; i<nmeth; i++)
+ n[i] = p[i] ? p[i]->next : NULL;
/* Give each method a chance */
for (i=0; i<nmeth && rdcc->nbytes+size>total; i++) {
if (0==i && p[0] && !p[0]->locked &&
- ((0==p[0]->rd_count && 0==p[0]->wr_count) ||
- (0==p[0]->rd_count && p[0]->chunk_size==p[0]->wr_count) ||
- (p[0]->chunk_size==p[0]->rd_count && 0==p[0]->wr_count))) {
+ ((0==p[0]->rd_count && 0==p[0]->wr_count) ||
+ (0==p[0]->rd_count && p[0]->chunk_size==p[0]->wr_count) ||
+ (p[0]->chunk_size==p[0]->rd_count && 0==p[0]->wr_count))) {
/*
* Method 0: Preempt entries that have been completely written
* and/or completely read but not entries that are partially
@@ -1253,23 +1237,28 @@ H5F_istore_prune (H5F_t *f, size_t size)
if (cur) {
for (j=0; j<nmeth; j++) {
- if (p[j]==cur) p[j] = NULL;
- if (n[j]==cur) n[j] = cur->next;
+ if (p[j]==cur)
+ p[j] = NULL;
+ if (n[j]==cur)
+ n[j] = cur->next;
}
- if (H5F_istore_preempt(f, cur, TRUE)<0) nerrors++;
+ if (H5F_istore_preempt(f, cur, TRUE)<0)
+ nerrors++;
}
}
/* Advance pointers */
- for (i=0; i<nmeth; i++) p[i] = n[i];
- for (i=0; i<nmeth-1; i++) w[i] -= 1;
+ for (i=0; i<nmeth; i++)
+ p[i] = n[i];
+ for (i=0; i<nmeth-1; i++)
+ w[i] -= 1;
}
- if (nerrors) {
- HRETURN_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL,
- "unable to preempt one or more raw data cache entry");
- }
- FUNC_LEAVE (SUCCEED);
+ if (nerrors)
+ HGOTO_ERROR (H5E_IO, H5E_CANTFLUSH, FAIL, "unable to preempt one or more raw data cache entry");
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1369,15 +1358,12 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
HDfflush(stderr);
#endif
rdcc->nhits++;
- for (u=0, tempchunk_size=1; u<layout->ndims; u++) {
+ for (u=0, tempchunk_size=1; u<layout->ndims; u++)
tempchunk_size *= layout->dim[u];
- }
H5_ASSIGN_OVERFLOW(chunk_size,tempchunk_size,hsize_t,size_t);
chunk_alloc = chunk_size;
- if (NULL==(chunk=H5MM_malloc (chunk_alloc))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for raw data chunk");
- }
+ if (NULL==(chunk=H5MM_malloc (chunk_alloc)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk");
} else {
/*
@@ -1394,25 +1380,18 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
udata.addr = HADDR_UNDEF;
status = H5B_find (f, H5B_ISTORE, layout->addr, &udata);
H5E_clear ();
- if (NULL==(chunk = H5MM_malloc (chunk_alloc))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for raw data chunk");
- }
+ if (NULL==(chunk = H5MM_malloc (chunk_alloc)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for raw data chunk");
if (status>=0 && H5F_addr_defined(udata.addr)) {
/*
* The chunk exists on disk.
*/
- if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DATASET_XFER_DEFAULT,
- chunk)<0) {
- HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL,
- "unable to read raw data chunk");
- }
+ if (H5F_block_read(f, H5FD_MEM_DRAW, udata.addr, udata.key.nbytes, H5P_DATASET_XFER_DEFAULT, chunk)<0)
+ HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "unable to read raw data chunk");
if (H5Z_pipeline(f, pline, H5Z_FLAG_REVERSE,
&(udata.key.filter_mask), &(udata.key.nbytes),
- &chunk_alloc, &chunk)<0 || udata.key.nbytes!=chunk_size) {
- HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL,
- "data pipeline read failed");
- }
+ &chunk_alloc, &chunk)<0 || udata.key.nbytes!=chunk_size)
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, NULL, "data pipeline read failed");
rdcc->nmisses++;
} else if (fill && fill->buf) {
/*
@@ -1456,15 +1435,11 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
}
fprintf(stderr, "}\n");
#endif
- if (H5F_istore_preempt(f, ent, TRUE)<0) {
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL,
- "unable to preempt chunk from cache");
- }
- }
- if (H5F_istore_prune(f, chunk_size)<0) {
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL,
- "unable to preempt chunk(s) from cache");
+ if (H5F_istore_preempt(f, ent, TRUE)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk from cache");
}
+ if (H5F_istore_prune(f, chunk_size)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "unable to preempt chunk(s) from cache");
/* Create a new entry */
ent = H5FL_ALLOC(H5F_rdcc_ent_t,0);
@@ -1474,9 +1449,8 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
ent->alloc_size = chunk_size;
ent->layout = H5O_copy(H5O_LAYOUT, layout, NULL);
ent->pline = H5O_copy(H5O_PLINE, pline, NULL);
- for (u=0; u<layout->ndims; u++) {
+ for (u=0; u<layout->ndims; u++)
ent->offset[u] = offset[u];
- }
ent->rd_count = chunk_size;
ent->wr_count = chunk_size;
ent->chunk = chunk;
@@ -1522,17 +1496,15 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
* algorithm.
*/
if (ent->next) {
- if (ent->next->next) {
+ if (ent->next->next)
ent->next->next->prev = ent;
- } else {
+ else
rdcc->tail = ent;
- }
ent->next->prev = ent->prev;
- if (ent->prev) {
+ if (ent->prev)
ent->prev->next = ent->next;
- } else {
+ else
rdcc->head = ent->next;
- }
ent->prev = ent->next;
ent->next = ent->next->next;
ent->prev->next = ent;
@@ -1548,9 +1520,11 @@ H5F_istore_lock(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
if (idx_hint)
*idx_hint = idx;
+
+ /* Set return value */
ret_value = chunk;
- done:
+done:
if (!ret_value)
H5MM_xfree (chunk);
FUNC_LEAVE (ret_value);
@@ -2052,6 +2026,7 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ )
#ifndef NDEBUG
unsigned u;
#endif
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_create, FAIL);
@@ -2060,17 +2035,16 @@ H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ )
assert(layout && H5D_CHUNKED == layout->type);
assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
#ifndef NDEBUG
- for (u = 0; u < layout->ndims; u++) {
+ for (u = 0; u < layout->ndims; u++)
assert(layout->dim[u] > 0);
- }
#endif
udata.mesg.ndims = layout->ndims;
- if (H5B_create(f, H5B_ISTORE, &udata, &(layout->addr)/*out*/) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
- }
+ if (H5B_create(f, H5B_ISTORE, &udata, &(layout->addr)/*out*/) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2097,16 +2071,20 @@ hsize_t
H5F_istore_allocated(H5F_t *f, unsigned ndims, haddr_t addr)
{
H5F_istore_ud1_t udata;
+ hsize_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_nchunks, 0);
HDmemset(&udata, 0, sizeof udata);
udata.mesg.ndims = ndims;
- if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_allocated, addr, &udata)<0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
- "unable to iterate over chunk B-tree");
- }
- FUNC_LEAVE(udata.total_storage);
+ if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_allocated, addr, &udata)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree");
+
+ /* Set return value */
+ ret_value=udata.total_storage;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2132,17 +2110,18 @@ herr_t
H5F_istore_dump_btree(H5F_t *f, FILE *stream, unsigned ndims, haddr_t addr)
{
H5F_istore_ud1_t udata;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_dump_btree, FAIL);
HDmemset(&udata, 0, sizeof udata);
udata.mesg.ndims = ndims;
udata.stream = stream;
- if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_dump, addr, &udata)<0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
- "unable to iterate over chunk B-tree");
- }
- FUNC_LEAVE(SUCCEED);
+ if (H5B_iterate(f, H5B_ISTORE, H5F_istore_iter_dump, addr, &udata)<0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over chunk B-tree");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2168,10 +2147,12 @@ H5F_istore_stats (H5F_t *f, hbool_t headers)
H5F_rdcc_t *rdcc = &(f->shared->rdcc);
double miss_rate;
char ascii[32];
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_stats, FAIL);
- if (!H5DEBUG(AC)) HRETURN(SUCCEED);
+ if (!H5DEBUG(AC))
+ HGOTO_DONE(SUCCEED);
if (headers) {
fprintf(H5DEBUG(AC), "H5F: raw data cache statistics for file %s\n",
@@ -2204,7 +2185,8 @@ H5F_istore_stats (H5F_t *f, hbool_t headers)
rdcc->ninits, (long)(rdcc->nflushes)-(long)(rdcc->ninits));
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2349,6 +2331,7 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
int mpi_rank; /* This process's rank */
int mpi_size; /* Total # of processes */
int mpi_round=0; /* Current process responsible for I/O */
+ int mpi_code; /* MPI return code */
unsigned blocks_written=0; /* Flag to indicate that chunk was actually written */
int carry; /* Flag to indicate that chunk increment carrys to higher dimension (sorta) */
int i; /* Local index variable */
@@ -2468,11 +2451,10 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
/* Increment indices */
for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) {
chunk_offset[i] += layout->dim[i];
- if (chunk_offset[i] >= (hssize_t)(space_dim[i])) {
+ if (chunk_offset[i] >= (hssize_t)(space_dim[i]))
chunk_offset[i] = 0;
- } else {
+ else
carry = 0;
- }
} /* end for */
} /* end while */
@@ -2483,15 +2465,15 @@ H5F_istore_allocate(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
* them in, getting bogus data.
*/
if(IS_H5FD_MPIO(f)) {
- if (MPI_Barrier(H5FD_mpio_communicator(f->shared->lf)))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed");
+ if (MPI_SUCCESS != (mpi_code=MPI_Barrier(H5FD_mpio_communicator(f->shared->lf))))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code);
} /* end if */
else {
/* Sanity Check */
assert(IS_H5FD_MPIPOSIX(f));
- if (MPI_Barrier(H5FD_mpiposix_communicator(f->shared->lf)))
- HGOTO_ERROR(H5E_INTERNAL, H5E_MPI, FAIL, "MPI_Barrier failed");
+ if (MPI_SUCCESS!=(mpi_code=MPI_Barrier(H5FD_mpiposix_communicator(f->shared->lf))))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Barrier failed", mpi_code);
} /* end else */
} /* end if */
@@ -2614,6 +2596,7 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
int found = 0; /*remove this entry */
H5F_istore_ud1_t udata; /*B-tree pass-through */
hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /*current dataspace dimensions */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5F_istore_prune_by_extent, FAIL);
@@ -2626,7 +2609,7 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
/* Go get the rank & dimensions */
if(H5S_get_simple_extent_dims(space, curr_dims, NULL) < 0)
- HRETURN_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions");
/*-------------------------------------------------------------------------
* Figure out what chunks are no longer in use for the specified extent
@@ -2654,13 +2637,9 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
#endif
/* Preempt the entry from the cache, but do not flush it to disk */
- if(H5F_istore_preempt(f, ent, FALSE) < 0) {
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0,
- "unable to preempt chunk");
- }
-
+ if(H5F_istore_preempt(f, ent, FALSE) < 0)
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to preempt chunk");
}
-
}
/*-------------------------------------------------------------------------
@@ -2677,9 +2656,10 @@ H5F_istore_prune_by_extent(H5F_t *f, const H5O_layout_t *layout, const H5S_t * s
udata.dims = curr_dims;
if(H5B_iterate(f, H5B_ISTORE, H5F_istore_prune_extent, layout->addr, &udata) < 0)
- HRETURN_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree");
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, 0, "unable to iterate over B-tree");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2708,6 +2688,7 @@ H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t UNUSED addr,
H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
unsigned u;
H5F_istore_ud1_t udata;
+ herr_t ret_value=SUCCEED; /* Return value */
/* The LT_KEY is the left key (the one that describes the chunk). It points to a chunk of
* storage that contains the beginning of the logical address space represented by UDATA.
@@ -2718,7 +2699,6 @@ H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t UNUSED addr,
/* Figure out what chunks are no longer in use for the specified extent and release them */
for(u = 0; u < bt_udata->mesg.ndims - 1; u++)
if((hsize_t)lt_key->offset[u] > bt_udata->dims[u]) {
-
#if defined (H5F_ISTORE_DEBUG)
HDfputs("b-tree:remove:[", bt_udata->stream);
for(u = 0; u < bt_udata->mesg.ndims - 1; u++) {
@@ -2734,11 +2714,12 @@ H5F_istore_prune_extent(H5F_t *f, void *_lt_key, haddr_t UNUSED addr,
/* Remove */
if(H5B_remove(f, H5B_ISTORE, bt_udata->mesg.addr, &udata) < 0)
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
break;
} /* end if */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2881,7 +2862,6 @@ H5F_istore_initialize_by_extent(H5F_t *f, const H5O_layout_t *layout,
/* Loop over all chunks */
carry=0;
while(carry==0) {
-
for(u = 0, naccessed = 1; u < layout->ndims; u++) {
/* The location and size of the chunk being accessed */
chunk_offset[u] = idx_cur[u] * (hssize_t)(layout->dim[u]);
@@ -2940,7 +2920,6 @@ H5F_istore_initialize_by_extent(H5F_t *f, const H5O_layout_t *layout,
if(H5F_istore_unlock(f, dxpl_id, layout, &pline, TRUE,
chunk_offset, &idx_hint, chunk, (size_t)naccessed) < 0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "unable to unlock raw data chunk");
-
} /*found */
/* Increment indices */
diff --git a/src/H5Fseq.c b/src/H5Fseq.c
index 8f988ff..d753dba 100644
--- a/src/H5Fseq.c
+++ b/src/H5Fseq.c
@@ -63,6 +63,8 @@ H5F_seq_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
const H5S_t *file_space, size_t elmt_size,
size_t seq_len, hsize_t file_offset, void *buf/*out*/)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5F_seq_read, FAIL);
/* Check args */
@@ -71,9 +73,10 @@ H5F_seq_read(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
assert(buf);
if (H5F_seq_readv(f, dxpl_id, layout, dc_plist, file_space, elmt_size, 1, &seq_len, &file_offset, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "vector read failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* H5F_seq_read() */
@@ -104,6 +107,8 @@ H5F_seq_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
const H5S_t *file_space, size_t elmt_size,
size_t seq_len, hsize_t file_offset, const void *buf)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5F_seq_write, FAIL);
/* Check args */
@@ -112,9 +117,10 @@ H5F_seq_write(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
assert(buf);
if (H5F_seq_writev(f, dxpl_id, layout, dc_plist, file_space, elmt_size, 1, &seq_len, &file_offset, buf)<0)
- HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "vector write failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* H5F_seq_write() */
@@ -594,10 +600,8 @@ H5F_seq_writev(H5F_t *f, hid_t dxpl_id, const H5O_layout_t *layout,
}
/* Collective MPIO access is unsupported for non-contiguous datasets */
- if (H5D_CONTIGUOUS!=layout->type && H5FD_MPIO_COLLECTIVE==xfer_mode) {
- HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL,
- "collective access on non-contiguous datasets not supported yet");
- }
+ if (H5D_CONTIGUOUS!=layout->type && H5FD_MPIO_COLLECTIVE==xfer_mode)
+ HGOTO_ERROR (H5E_DATASET, H5E_WRITEERROR, FAIL, "collective access on non-contiguous datasets not supported yet");
#endif /* H5_HAVE_PARALLEL */
/* Get necessary properties from property list */
diff --git a/src/H5G.c b/src/H5G.c
index 688d104..fb30a3a 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -72,8 +72,8 @@
*-------------------------------------------------------------------------
*/
-#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */
-#define H5F_PACKAGE /*suppress error about including H5Fpkg */
+#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */
+#define H5F_PACKAGE /*suppress error about including H5Fpkg */
/* Packages needed by this file... */
@@ -142,28 +142,29 @@ H5Gcreate(hid_t loc_id, const char *name, size_t size_hint)
{
H5G_entry_t *loc = NULL;
H5G_t *grp = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Gcreate, FAIL);
H5TRACE3("i","isz",loc_id,name,size_hint);
/* Check arguments */
- if (NULL==(loc=H5G_loc (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
- }
+ if (NULL==(loc=H5G_loc (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
/* Create the group */
- if (NULL == (grp = H5G_create(loc, name, size_hint))) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group");
- }
- if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0) {
- H5G_close(grp);
- HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register group");
- }
+ if (NULL == (grp = H5G_create(loc, name, size_hint)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group");
+ if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group");
+
+done:
+ if(ret_value<0) {
+ if(grp!=NULL)
+ H5G_close(grp);
+ } /* end if */
+
FUNC_LEAVE(ret_value);
}
@@ -198,23 +199,24 @@ H5Gopen(hid_t loc_id, const char *name)
H5TRACE2("i","is",loc_id,name);
/* Check args */
- if (NULL==(loc=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (NULL==(loc=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
/* Open the group */
- if (NULL == (grp = H5G_open(loc, name))) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
- }
+ if (NULL == (grp = H5G_open(loc, name)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
/* Register an atom for the group */
- if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0) {
- H5G_close(grp);
- HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register group");
- }
+ if ((ret_value = H5I_register(H5I_GROUP, grp)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group");
+
+done:
+ if(ret_value<0) {
+ if(grp!=NULL)
+ H5G_close(grp);
+ } /* end if */
+
FUNC_LEAVE(ret_value);
}
@@ -237,22 +239,24 @@ H5Gopen(hid_t loc_id, const char *name)
herr_t
H5Gclose(hid_t group_id)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5Gclose, FAIL);
H5TRACE1("e","i",group_id);
/* Check args */
- if (H5I_GROUP != H5I_get_type(group_id) ||
- NULL == H5I_object(group_id)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
- }
+ if (NULL == H5I_object_verify(group_id,H5I_GROUP))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
+
/*
* Decrement the counter on the group atom. It will be freed if the count
* reaches zero.
*/
- if (H5I_dec_ref(group_id) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
- }
- FUNC_LEAVE(SUCCEED);
+ if (H5I_dec_ref(group_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -289,35 +293,31 @@ H5Giterate(hid_t loc_id, const char *name, int *idx,
{
int _idx = 0;
H5G_bt_ud2_t udata;
- herr_t ret_value = FAIL;
H5G_entry_t *loc = NULL;
+ herr_t ret_value;
FUNC_ENTER_API(H5Giterate, FAIL);
H5TRACE5("e","is*Isxx",loc_id,name,idx,op,op_data);
/* Check args */
- if (NULL==(loc=H5G_loc (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- }
- if (!idx) idx = &_idx;
- if (!op) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");
- }
+ if (NULL==(loc=H5G_loc (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
+ if (!idx)
+ idx = &_idx;
+ if (!op)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified");
/*
* Open the group on which to operate. We also create a group ID which
* we can pass to the application-defined operator.
*/
- if (NULL==(udata.group = H5G_open (loc, name))) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to open group");
- }
+ if (NULL==(udata.group = H5G_open (loc, name)))
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to open group");
if ((udata.group_id=H5I_register (H5I_GROUP, udata.group))<0) {
H5G_close(udata.group);
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to register group");
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to register group");
}
/* Build udata to pass through H5B_iterate() to H5G_node_iterate() */
@@ -330,14 +330,15 @@ H5Giterate(hid_t loc_id, const char *name, int *idx,
/* Iterate over the group members */
if ((ret_value = H5B_iterate (H5G_fileof(udata.group), H5B_SNODE,
- H5G_node_iterate, udata.group->ent.cache.stab.btree_addr, &udata))<0) {
+ H5G_node_iterate, udata.group->ent.cache.stab.btree_addr, &udata))<0)
HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
- }
/* Set the index we stopped at */
*idx=udata.final_ent;
H5I_dec_ref (udata.group_id); /*also closes udata.group*/
+
+done:
FUNC_LEAVE (ret_value);
}
@@ -369,46 +370,36 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
{
H5G_entry_t *src_loc=NULL;
H5G_entry_t *dst_loc=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Gmove2, FAIL);
H5TRACE4("e","isis",src_loc_id,src_name,dst_loc_id,dst_name);
- if (src_loc_id != H5G_SAME_LOC && NULL==(src_loc=H5G_loc(src_loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (dst_loc_id != H5G_SAME_LOC && NULL==(dst_loc=H5G_loc(dst_loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!src_name || !*src_name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "no current name specified");
- }
- if (!dst_name || !*dst_name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "no new name specified");
- }
+ if (src_loc_id != H5G_SAME_LOC && NULL==(src_loc=H5G_loc(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (dst_loc_id != H5G_SAME_LOC && NULL==(dst_loc=H5G_loc(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!src_name || !*src_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified");
+ if (!dst_name || !*dst_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified");
if(src_loc_id == H5G_SAME_LOC && dst_loc_id == H5G_SAME_LOC) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "source and destination should not be both H5G_SAME_LOC");
- }
- else if(src_loc_id == H5G_SAME_LOC) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC");
+ } else if(src_loc_id == H5G_SAME_LOC) {
src_loc = dst_loc;
}
else if(dst_loc_id == H5G_SAME_LOC) {
dst_loc = src_loc;
}
- else if(src_loc->file != dst_loc->file) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "source and destination should be in the same file.");
- }
+ else if(src_loc->file != dst_loc->file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.");
- if (H5G_move(src_loc, src_name, dst_loc, dst_name)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to change object name");
- }
+ if (H5G_move(src_loc, src_name, dst_loc, dst_name)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to change object name");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -445,32 +436,25 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
{
H5G_entry_t *cur_loc = NULL;
H5G_entry_t *new_loc = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Glink2, FAIL);
H5TRACE5("e","isGlis",cur_loc_id,cur_name,type,new_loc_id,new_name);
/* Check arguments */
- if (cur_loc_id != H5G_SAME_LOC && NULL==(cur_loc=H5G_loc(cur_loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (new_loc_id != H5G_SAME_LOC && NULL==(new_loc=H5G_loc(new_loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (type!=H5G_LINK_HARD && type!=H5G_LINK_SOFT) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unrecognized link type");
- }
- if (!cur_name || !*cur_name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "no current name specified");
- }
- if (!new_name || !*new_name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "no new name specified");
- }
+ if (cur_loc_id != H5G_SAME_LOC && NULL==(cur_loc=H5G_loc(cur_loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (new_loc_id != H5G_SAME_LOC && NULL==(new_loc=H5G_loc(new_loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (type!=H5G_LINK_HARD && type!=H5G_LINK_SOFT)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unrecognized link type");
+ if (!cur_name || !*cur_name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified");
+ if (!new_name || !*new_name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified");
if(cur_loc_id == H5G_SAME_LOC && new_loc_id == H5G_SAME_LOC) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "source and destination should not be both H5G_SAME_LOC");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5G_SAME_LOC");
}
else if(cur_loc_id == H5G_SAME_LOC) {
cur_loc = new_loc;
@@ -478,17 +462,14 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
else if(new_loc_id == H5G_SAME_LOC) {
new_loc = cur_loc;
}
- else if(cur_loc->file != new_loc->file) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "source and destination should be in the same file.");
- }
+ else if(cur_loc->file != new_loc->file)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.");
- if (H5G_link(cur_loc, cur_name, new_loc, new_name, type, H5G_TARGET_NORMAL)
- <0) {
- HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "unable to create link");
- }
+ if (H5G_link(cur_loc, cur_name, new_loc, new_name, type, H5G_TARGET_NORMAL) <0)
+ HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL, "unable to create link");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -515,24 +496,23 @@ herr_t
H5Gunlink(hid_t loc_id, const char *name)
{
H5G_entry_t *loc = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Gunlink, FAIL);
H5TRACE2("e","is",loc_id,name);
/* Check arguments */
- if (NULL==(loc=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (NULL==(loc=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
/* Unlink */
- if (H5G_unlink(loc, name)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink object");
- }
+ if (H5G_unlink(loc, name)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink object");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -558,24 +538,23 @@ H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link,
H5G_stat_t *statbuf/*out*/)
{
H5G_entry_t *loc = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Gget_objinfo, FAIL);
H5TRACE4("e","isbx",loc_id,name,follow_link,statbuf);
/* Check arguments */
- if (NULL==(loc=H5G_loc (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- }
+ if (NULL==(loc=H5G_loc (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
/* Get info */
- if (H5G_get_objinfo (loc, name, follow_link, statbuf)<0) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "cannot stat object");
- }
+ if (H5G_get_objinfo (loc, name, follow_link, statbuf)<0)
+ HGOTO_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "cannot stat object");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -601,25 +580,23 @@ herr_t
H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/)
{
H5G_entry_t *loc = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Gget_linkval, FAIL);
H5TRACE4("e","iszx",loc_id,name,size,buf);
/* Check arguments */
- if (NULL==(loc=H5G_loc (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- }
+ if (NULL==(loc=H5G_loc (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
/* Get the link value */
- if (H5G_linkval (loc, name, size, buf)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to get link value");
- }
+ if (H5G_linkval (loc, name, size, buf)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -644,23 +621,21 @@ herr_t
H5Gset_comment(hid_t loc_id, const char *name, const char *comment)
{
H5G_entry_t *loc = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Gset_comment, FAIL);
H5TRACE3("e","iss",loc_id,name,comment);
- if (NULL==(loc=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- }
+ if (NULL==(loc=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- if (H5G_set_comment(loc, name, comment)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to set comment value");
- }
+ if (H5G_set_comment(loc, name, comment)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -691,27 +666,23 @@ int
H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
{
H5G_entry_t *loc = NULL;
- int retval = FAIL;
+ int ret_value;
FUNC_ENTER_API(H5Gget_comment, FAIL);
H5TRACE4("Is","iszs",loc_id,name,bufsize,buf);
- if (NULL==(loc=H5G_loc(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- }
- if (bufsize>0 && !buf) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified");
- }
+ if (NULL==(loc=H5G_loc(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
+ if (bufsize>0 && !buf)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified");
- if ((retval=H5G_get_comment(loc, name, bufsize, buf))<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to get comment value");
- }
+ if ((ret_value=H5G_get_comment(loc, name, bufsize, buf))<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get comment value");
- FUNC_LEAVE(retval);
+done:
+ FUNC_LEAVE(ret_value);
}
/*
@@ -739,14 +710,14 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
static herr_t
H5G_init_interface(void)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5G_init_interface);
/* Initialize the atom group for the group IDs */
if (H5I_init_group(H5I_GROUP, H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
- (H5I_free_t)H5G_close) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to initialize interface");
- }
+ (H5I_free_t)H5G_close) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface");
/*
* Initialize the type info table. Begin with the most general types and
@@ -757,7 +728,8 @@ H5G_init_interface(void)
H5G_register_type(H5G_GROUP, H5G_isa, "group");
H5G_register_type(H5G_DATASET, H5D_isa, "dataset");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -792,9 +764,8 @@ H5G_term_interface(void)
H5I_clear_group(H5I_GROUP, FALSE);
} else {
/* Empty the object type table */
- for (i=0; i<H5G_ntypes_g; i++) {
+ for (i=0; i<H5G_ntypes_g; i++)
H5MM_xfree(H5G_type_g[i].desc);
- }
H5G_ntypes_g = H5G_atypes_g = 0;
H5G_type_g = H5MM_xfree(H5G_type_g);
@@ -840,7 +811,7 @@ H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*), const char *_desc)
{
char *desc = NULL;
size_t i;
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_register_type, FAIL);
@@ -849,10 +820,8 @@ H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*), const char *_desc)
assert(_desc);
/* Copy the description */
- if (NULL==(desc=H5MM_strdup(_desc))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for object type description");
- }
+ if (NULL==(desc=H5MM_strdup(_desc)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for object type description");
/*
* If the type is already registered then just update its entry without
@@ -872,10 +841,8 @@ H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*), const char *_desc)
size_t n = MAX(32, 2*H5G_atypes_g);
H5G_typeinfo_t *x = H5MM_realloc(H5G_type_g,
n*sizeof(H5G_typeinfo_t));
- if (!x) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for objec type table");
- }
+ if (!x)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for objec type table");
H5G_atypes_g = n;
H5G_type_g = x;
}
@@ -886,10 +853,9 @@ H5G_register_type(int type, htri_t(*isa)(H5G_entry_t*), const char *_desc)
H5G_type_g[H5G_ntypes_g].desc = desc; /*already copied*/
H5G_ntypes_g++;
- ret_value = SUCCEED;
-
- done:
- if (ret_value<0) H5MM_xfree(desc);
+done:
+ if (ret_value<0)
+ H5MM_xfree(desc);
FUNC_LEAVE(ret_value);
}
@@ -924,8 +890,10 @@ H5G_component(const char *name, size_t *size_p)
assert(name);
- while ('/' == *name) name++;
- if (size_p) *size_p = HDstrcspn(name, "/");
+ while ('/' == *name)
+ name++;
+ if (size_p)
+ *size_p = HDstrcspn(name, "/");
FUNC_LEAVE(name);
}
@@ -962,13 +930,16 @@ H5G_basename(const char *name, size_t *size_p)
/* Find the end of the base name */
i = HDstrlen(name);
- while (i>0 && '/'==name[i-1]) --i;
+ while (i>0 && '/'==name[i-1])
+ --i;
/* Skip backward over base name */
- while (i>0 && '/'!=name[i-1]) --i;
+ while (i>0 && '/'!=name[i-1])
+ --i;
/* Watch out for root special case */
- if ('/'==name[i] && size_p) *size_p = 1;
+ if ('/'==name[i] && size_p)
+ *size_p = 1;
FUNC_LEAVE(name+i);
}
@@ -1066,6 +1037,7 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
size_t nchars; /*component name length */
int _nlinks = H5G_NLINKS;
const char *s = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5G_namei);
@@ -1079,10 +1051,9 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
* root of the file; for relative names it starts at CWG.
*/
if (!name || !*name) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no name given");
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no name given");
} else if (!loc_ent) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "no current working group");
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group");
} else if ('/' == *name) {
*obj_ent = H5G_rootof(loc_ent->file)->ent;
} else {
@@ -1104,8 +1075,7 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
H5G_comp_g = H5MM_realloc(H5G_comp_g, H5G_comp_alloc_g);
if (!H5G_comp_g) {
H5G_comp_alloc_g = 0;
- HRETURN_ERROR(H5E_SYM, H5E_NOSPACE, FAIL,
- "unable to allocate component buffer");
+ HGOTO_ERROR(H5E_SYM, H5E_NOSPACE, FAIL, "unable to allocate component buffer");
}
}
HDmemcpy(H5G_comp_g, name, nchars);
@@ -1131,7 +1101,7 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
* Component was not found in the current symbol table, possibly
* because GRP_ENT isn't a symbol table.
*/
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
}
/*
@@ -1142,14 +1112,10 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
if (H5G_CACHED_SLINK==obj_ent->type &&
(0==(target & H5G_TARGET_SLINK) ||
((s=H5G_component(name+nchars, NULL)) && *s))) {
- if ((*nlinks)-- <= 0) {
- HRETURN_ERROR (H5E_SYM, H5E_SLINK, FAIL,
- "too many symbolic links");
- }
- if (H5G_traverse_slink (grp_ent, obj_ent, nlinks)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "symbolic link traversal failed");
- }
+ if ((*nlinks)-- <= 0)
+ HGOTO_ERROR (H5E_SYM, H5E_SLINK, FAIL, "too many symbolic links");
+ if (H5G_traverse_slink (grp_ent, obj_ent, nlinks)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "symbolic link traversal failed");
}
/*
@@ -1165,9 +1131,11 @@ H5G_namei(H5G_entry_t *loc_ent, const char *name, const char **rest/*out*/,
/* next component */
name += nchars;
}
- if (rest) *rest = name; /*final null */
+ if (rest)
+ *rest = name; /*final null */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1199,31 +1167,23 @@ H5G_traverse_slink (H5G_entry_t *grp_ent/*in,out*/,
H5O_stab_t stab_mesg; /*info about local heap */
const char *clv = NULL; /*cached link value */
char *linkval = NULL; /*the copied link value */
- herr_t ret_value = FAIL; /*return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_traverse_slink, FAIL);
/* Get the link value */
- if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab_mesg)) {
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to determine local heap address");
- }
+ if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab_mesg))
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to determine local heap address");
if (NULL==(clv=H5HL_peek (grp_ent->file, stab_mesg.heap_addr,
- obj_ent->cache.slink.lval_offset))) {
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbolic link value");
- }
+ obj_ent->cache.slink.lval_offset)))
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbolic link value");
linkval = H5MM_xstrdup (clv);
/* Traverse the link */
- if (H5G_namei (grp_ent, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL,
- nlinks)) {
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to follow symbolic link");
- }
- ret_value = SUCCEED;
+ if (H5G_namei (grp_ent, linkval, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, nlinks))
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to follow symbolic link");
- done:
+done:
H5MM_xfree (linkval);
FUNC_LEAVE (ret_value);
}
@@ -1254,12 +1214,14 @@ H5G_mkroot (H5F_t *f, H5G_entry_t *ent)
{
H5G_entry_t new_root; /*new root object */
H5O_stab_t stab; /*symbol table message */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_mkroot, FAIL);
/* check args */
assert(f);
- if (f->shared->root_grp) HRETURN(SUCCEED);
+ if (f->shared->root_grp)
+ HGOTO_DONE(SUCCEED);
/*
* If there is no root object then create one. The root group always has
@@ -1267,26 +1229,19 @@ H5G_mkroot (H5F_t *f, H5G_entry_t *ent)
*/
if (!ent) {
ent = &new_root;
- if (H5G_stab_create (f, 256, ent/*out*/)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to create root group");
- }
- if (1 != H5O_link (ent, 1)) {
- HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL,
- "internal error (wrong link count)");
- }
+ if (H5G_stab_create (f, 256, ent/*out*/)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create root group");
+ if (1 != H5O_link (ent, 1))
+ HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL, "internal error (wrong link count)");
} else {
/*
* Open the root object as a group.
*/
- if (H5O_open (ent)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL,
- "unable to open root group");
- }
+ if (H5O_open (ent)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open root group");
if (NULL==H5O_read (ent, H5O_STAB, 0, &stab)) {
H5O_close(ent);
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "root object is not a group");
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "root object is not a group");
}
H5O_reset (H5O_STAB, &stab);
}
@@ -1296,16 +1251,15 @@ H5G_mkroot (H5F_t *f, H5G_entry_t *ent)
* don't count the root group as an open object. The root group will
* never be closed.
*/
- if (NULL==(f->shared->root_grp = H5FL_ALLOC (H5G_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(f->shared->root_grp = H5FL_ALLOC (H5G_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
f->shared->root_grp->ent = *ent;
f->shared->root_grp->nref = 1;
assert (1==f->nopen_objs);
f->nopen_objs = 0;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1339,6 +1293,7 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint)
char _comp[1024]; /*name component */
size_t nchars; /*number of characters in compon*/
H5G_t *grp = NULL; /*new group */
+ H5G_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_create, NULL);
@@ -1347,10 +1302,8 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint)
assert(name && *name);
/* lookup name */
- if (0 == H5G_namei(loc, name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL,
- NULL)) {
- HRETURN_ERROR(H5E_SYM, H5E_EXISTS, NULL, "already exists");
- }
+ if (0 == H5G_namei(loc, name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL, NULL))
+ HGOTO_ERROR(H5E_SYM, H5E_EXISTS, NULL, "already exists");
H5E_clear(); /*it's OK that we didn't find it */
assert(H5F_addr_defined(grp_ent.header));
@@ -1360,9 +1313,9 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint)
if (rest[nchars]) {
const char *t = H5G_component(rest+nchars, NULL);
if (t && *t) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "missing component");
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "missing component");
} else if (nchars+1 > sizeof _comp) {
- HRETURN_ERROR(H5E_SYM, H5E_COMPLEN, NULL, "component is too long");
+ HGOTO_ERROR(H5E_SYM, H5E_COMPLEN, NULL, "component is too long");
} else {
/* null terminate */
HDmemcpy(_comp, rest, nchars);
@@ -1372,26 +1325,30 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint)
}
/* create an open group */
- if (NULL==(grp = H5FL_ALLOC(H5G_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- if (H5G_stab_create(grp_ent.file, size_hint, &(grp->ent)/*out*/) < 0) {
- grp = H5FL_FREE(H5G_t,grp);
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
- }
+ if (NULL==(grp = H5FL_ALLOC(H5G_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ if (H5G_stab_create(grp_ent.file, size_hint, &(grp->ent)/*out*/) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
/* insert child name into parent */
- if (1!=H5O_link(&(grp->ent), 1)) {
- HRETURN_ERROR(H5E_SYM, H5E_LINK, NULL, "link inc failure");
- }
+ if (1!=H5O_link(&(grp->ent), 1))
+ HGOTO_ERROR(H5E_SYM, H5E_LINK, NULL, "link inc failure");
if (H5G_stab_insert(&grp_ent, rest, &(grp->ent)) < 0) {
H5O_close(&(grp->ent));
- grp = H5FL_FREE(H5G_t,grp);
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't insert");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't insert");
}
grp->nref = 1;
- FUNC_LEAVE(grp);
+
+ /* Set return value */
+ ret_value=grp;
+
+done:
+ if(ret_value==NULL) {
+ if(grp!=NULL)
+ H5FL_FREE(H5G_t,grp);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -1417,17 +1374,17 @@ H5G_create(H5G_entry_t *loc, const char *name, size_t size_hint)
htri_t
H5G_isa(H5G_entry_t *ent)
{
- htri_t exists;
+ htri_t ret_value;
FUNC_ENTER_NOAPI(H5G_isa, FAIL);
assert(ent);
- if ((exists=H5O_exists(ent, H5O_STAB, 0))<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to read object header");
- }
- FUNC_LEAVE(exists);
+ if ((ret_value=H5O_exists(ent, H5O_STAB, 0))<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1463,19 +1420,20 @@ H5G_open(H5G_entry_t *loc, const char *name)
assert(name && *name);
/* Open the object, making sure it's a group */
- if (H5G_find(loc, name, NULL, &ent/*out*/) < 0) {
+ if (H5G_find(loc, name, NULL, &ent/*out*/) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
- }
+
/* Open the group object */
- if ((grp=H5G_open_oid(&ent)) ==NULL) {
+ if ((grp=H5G_open_oid(&ent)) ==NULL)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "not found");
- }
+
+ /* Set return value */
ret_value = grp;
done:
- if (!ret_value && grp) {
+ if (!ret_value && grp)
H5FL_FREE(H5G_t,grp);
- }
+
FUNC_LEAVE(ret_value);
}
@@ -1510,29 +1468,28 @@ H5G_open_oid(H5G_entry_t *ent)
assert(ent);
/* Open the object, making sure it's a group */
- if (NULL==(grp = H5FL_ALLOC(H5G_t,1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(grp = H5FL_ALLOC(H5G_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Copy over the symbol table information if it's provided */
HDmemcpy(&(grp->ent),ent,sizeof(H5G_entry_t));
/* Grab the object header */
- if (H5O_open(&(grp->ent)) < 0) {
+ if (H5O_open(&(grp->ent)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
- }
if (NULL==H5O_read (&(grp->ent), H5O_STAB, 0, &mesg)) {
H5O_close(&(grp->ent));
HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "not a group");
}
grp->nref = 1;
+
+ /* Set return value */
ret_value = grp;
- done:
- if (!ret_value && grp) {
+done:
+ if (!ret_value && grp)
H5FL_FREE(H5G_t,grp);
- }
+
FUNC_LEAVE(ret_value);
}
@@ -1584,6 +1541,8 @@ H5G_reopen(H5G_t *grp)
herr_t
H5G_close(H5G_t *grp)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5G_close, FAIL);
/* Check args */
@@ -1592,16 +1551,16 @@ H5G_close(H5G_t *grp)
if (1 == grp->nref) {
assert (grp!=H5G_rootof(H5G_fileof(grp)));
- if (H5O_close(&(grp->ent)) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close");
- }
+ if (H5O_close(&(grp->ent)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close");
grp->nref = 0;
H5FL_FREE (H5G_t,grp);
} else {
--grp->nref;
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1629,7 +1588,8 @@ H5G_t *
H5G_rootof(H5F_t *f)
{
FUNC_ENTER_NOAPI(H5G_rootof, NULL);
- while (f->mtab.parent) f = f->mtab.parent;
+ while (f->mtab.parent)
+ f = f->mtab.parent;
FUNC_LEAVE(f->shared->root_grp);
}
@@ -1657,6 +1617,7 @@ H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent)
H5G_entry_t grp; /*entry for group to contain obj */
size_t nchars; /*number of characters in name */
char _comp[1024]; /*name component */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_insert, FAIL);
@@ -1668,9 +1629,8 @@ H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent)
/*
* Look up the name -- it shouldn't exist yet.
*/
- if (H5G_namei(loc, name, &rest, &grp, NULL, H5G_TARGET_NORMAL, NULL)>=0) {
- HRETURN_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists");
- }
+ if (H5G_namei(loc, name, &rest, &grp, NULL, H5G_TARGET_NORMAL, NULL)>=0)
+ HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists");
H5E_clear(); /*it's OK that we didn't find it */
rest = H5G_component(rest, &nchars);
@@ -1680,9 +1640,9 @@ H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent)
*/
if (rest[nchars]) {
if (H5G_component(rest + nchars, NULL)) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
} else if (nchars + 1 > sizeof _comp) {
- HRETURN_ERROR(H5E_SYM, H5E_COMPLEN, FAIL, "component is too long");
+ HGOTO_ERROR(H5E_SYM, H5E_COMPLEN, FAIL, "component is too long");
} else {
/* null terminate */
HDmemcpy(_comp, rest, nchars);
@@ -1694,15 +1654,15 @@ H5G_insert(H5G_entry_t *loc, const char *name, H5G_entry_t *ent)
/*
* Insert the object into a symbol table.
*/
- if (H5O_link(ent, 1) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_LINK, FAIL,
- "unable to increment hard link count");
- }
+ if (H5O_link(ent, 1) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "unable to increment hard link count");
if (H5G_stab_insert(&grp, rest, ent) < 0) {
H5O_link(ent, -1);
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to insert name");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to insert name");
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1737,17 +1697,19 @@ herr_t
H5G_find(H5G_entry_t *loc, const char *name,
H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5G_find, FAIL);
/* check args */
assert (loc);
assert (name && *name);
- if (H5G_namei(loc, name, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL,
- NULL)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
- }
- FUNC_LEAVE(SUCCEED);
+ if (H5G_namei(loc, name, NULL, grp_ent, obj_ent, H5G_TARGET_NORMAL, NULL)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1826,7 +1788,7 @@ H5G_entry_t *
H5G_loc (hid_t loc_id)
{
H5F_t *f;
- H5G_entry_t *ret_value = NULL;
+ H5G_entry_t *ret_value;
H5G_t *group=NULL;
H5T_t *dt=NULL;
H5D_t *dset=NULL;
@@ -1835,78 +1797,60 @@ H5G_loc (hid_t loc_id)
FUNC_ENTER_NOAPI(H5G_loc, NULL);
switch (H5I_get_type(loc_id)) {
- case H5I_FILE:
- if (NULL==(f=H5I_object (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "invalid file ID");
- }
- if (NULL==(ret_value=H5G_entof(H5G_rootof(f)))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry for root group");
- }
- break;
-
- case H5I_GENPROP_CLS:
- case H5I_GENPROP_LST:
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry of property list");
-
- case H5I_GROUP:
- if (NULL==(group=H5I_object (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "invalid group ID");
- }
- if (NULL==(ret_value=H5G_entof(group))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry of group");
- }
- break;
-
- case H5I_DATATYPE:
- if (NULL==(dt=H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid type ID");
- }
- if (NULL==(ret_value=H5T_entof(dt))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry of data type");
- }
- break;
-
- case H5I_DATASPACE:
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry of data space");
-
- case H5I_DATASET:
- if (NULL==(dset=H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid data ID");
- }
- if (NULL==(ret_value=H5D_entof(dset))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry of dataset");
- }
- break;
-
- case H5I_ATTR:
- if (NULL==(attr=H5I_object(loc_id))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "invalid attribute ID");
- }
- if (NULL==(ret_value=H5A_entof(attr))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry of attribute");
- }
- break;
-
- case H5I_TEMPBUF:
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "unable to get symbol table entry of buffer");
-
- case H5I_NGROUPS:
- case H5I_BADID:
- case H5I_FILE_CLOSING:
- case H5I_REFERENCE:
- case H5I_VFL:
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object ID");
+ case H5I_FILE:
+ if (NULL==(f=H5I_object (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "invalid file ID");
+ if (NULL==(ret_value=H5G_entof(H5G_rootof(f))))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry for root group");
+ break;
+
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of property list");
+
+ case H5I_GROUP:
+ if (NULL==(group=H5I_object (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "invalid group ID");
+ if (NULL==(ret_value=H5G_entof(group)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of group");
+ break;
+
+ case H5I_DATATYPE:
+ if (NULL==(dt=H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid type ID");
+ if (NULL==(ret_value=H5T_entof(dt)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of data type");
+ break;
+
+ case H5I_DATASPACE:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of data space");
+
+ case H5I_DATASET:
+ if (NULL==(dset=H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid data ID");
+ if (NULL==(ret_value=H5D_entof(dset)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of dataset");
+ break;
+
+ case H5I_ATTR:
+ if (NULL==(attr=H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid attribute ID");
+ if (NULL==(ret_value=H5A_entof(attr)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of attribute");
+ break;
+
+ case H5I_TEMPBUF:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "unable to get symbol table entry of buffer");
+
+ case H5I_NGROUPS:
+ case H5I_BADID:
+ case H5I_FILE_CLOSING:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object ID");
}
+done:
FUNC_LEAVE (ret_value);
}
@@ -1937,6 +1881,7 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
char _comp[1024]; /*name component */
size_t nchars; /*characters in component */
size_t offset; /*offset to sym-link value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_link, FAIL);
@@ -1947,94 +1892,78 @@ H5G_link (H5G_entry_t *cur_loc, const char *cur_name, H5G_entry_t *new_loc,
assert (new_name && *new_name);
switch (type) {
- case H5G_LINK_SOFT:
- /*
- * Lookup the the new_name so we can get the group which will contain
- * the new entry. The entry shouldn't exist yet.
- */
- if (H5G_namei (new_loc, new_name, &rest, &grp_ent, NULL,
- H5G_TARGET_NORMAL, NULL)>=0) {
- HRETURN_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "already exists");
- }
- H5E_clear (); /*it's okay that we didn't find it*/
- rest = H5G_component (rest, &nchars);
-
- /*
- * There should be one component left. Make sure it's null
- * terminated and that `rest' points to it.
- */
- if (rest[nchars]) {
- if (H5G_component (rest+nchars, NULL)) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "component not found");
- } else if (nchars+1 > sizeof _comp) {
- HRETURN_ERROR (H5E_SYM, H5E_COMPLEN, FAIL,
- "name component is too long");
- } else {
- HDmemcpy (_comp, rest, nchars);
- _comp[nchars] = '\0';
- rest = _comp;
- }
- }
-
- /*
- * Add the link-value to the local heap for the symbol table which
- * will contain the link.
- */
- if (NULL==H5O_read (&grp_ent, H5O_STAB, 0, &stab_mesg)) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to determine local heap address");
- }
- if ((size_t)(-1)==(offset=H5HL_insert (grp_ent.file,
- stab_mesg.heap_addr,
- HDstrlen(cur_name)+1,
- cur_name))) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to write link value to local heap");
- }
- H5O_reset (H5O_STAB, &stab_mesg);
-
- /*
- * Create a symbol table entry for the link. The object header is
- * undefined and the cache contains the link-value offset.
- */
- HDmemset (&cur_obj, 0, sizeof cur_obj);
- cur_obj.header = HADDR_UNDEF;
- cur_obj.file = grp_ent.file;
- cur_obj.type = H5G_CACHED_SLINK;
- cur_obj.cache.slink.lval_offset = offset;
-
- /*
- * Insert the link head in the symbol table. This shouldn't ever
- * fail because we've already checked that the link head doesn't
- * exist and the file is writable (because the local heap is
- * writable). But if it does, the only side effect is that the local
- * heap has some extra garbage in it.
- */
- if (H5G_stab_insert (&grp_ent, rest, &cur_obj)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to create new name/link for object");
- }
- break;
-
- case H5G_LINK_HARD:
- if (H5G_namei(cur_loc, cur_name, NULL, NULL, &cur_obj, namei_flags,
- NULL)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "source object not found");
- }
- if (H5G_insert (new_loc, new_name, &cur_obj)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to create new name/link for object");
- }
- break;
+ case H5G_LINK_SOFT:
+ /*
+ * Lookup the the new_name so we can get the group which will contain
+ * the new entry. The entry shouldn't exist yet.
+ */
+ if (H5G_namei (new_loc, new_name, &rest, &grp_ent, NULL,
+ H5G_TARGET_NORMAL, NULL)>=0)
+ HGOTO_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "already exists");
+ H5E_clear (); /*it's okay that we didn't find it*/
+ rest = H5G_component (rest, &nchars);
+
+ /*
+ * There should be one component left. Make sure it's null
+ * terminated and that `rest' points to it.
+ */
+ if (rest[nchars]) {
+ if (H5G_component (rest+nchars, NULL)) {
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
+ } else if (nchars+1 > sizeof _comp) {
+ HGOTO_ERROR (H5E_SYM, H5E_COMPLEN, FAIL, "name component is too long");
+ } else {
+ HDmemcpy (_comp, rest, nchars);
+ _comp[nchars] = '\0';
+ rest = _comp;
+ }
+ }
- default:
- HRETURN_ERROR (H5E_SYM, H5E_BADVALUE, FAIL,
- "unrecognized link type");
+ /*
+ * Add the link-value to the local heap for the symbol table which
+ * will contain the link.
+ */
+ if (NULL==H5O_read (&grp_ent, H5O_STAB, 0, &stab_mesg))
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to determine local heap address");
+ if ((size_t)(-1)==(offset=H5HL_insert (grp_ent.file,
+ stab_mesg.heap_addr, HDstrlen(cur_name)+1, cur_name)))
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to write link value to local heap");
+ H5O_reset (H5O_STAB, &stab_mesg);
+
+ /*
+ * Create a symbol table entry for the link. The object header is
+ * undefined and the cache contains the link-value offset.
+ */
+ HDmemset (&cur_obj, 0, sizeof cur_obj);
+ cur_obj.header = HADDR_UNDEF;
+ cur_obj.file = grp_ent.file;
+ cur_obj.type = H5G_CACHED_SLINK;
+ cur_obj.cache.slink.lval_offset = offset;
+
+ /*
+ * Insert the link head in the symbol table. This shouldn't ever
+ * fail because we've already checked that the link head doesn't
+ * exist and the file is writable (because the local heap is
+ * writable). But if it does, the only side effect is that the local
+ * heap has some extra garbage in it.
+ */
+ if (H5G_stab_insert (&grp_ent, rest, &cur_obj)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object");
+ break;
+
+ case H5G_LINK_HARD:
+ if (H5G_namei(cur_loc, cur_name, NULL, NULL, &cur_obj, namei_flags, NULL)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found");
+ if (H5G_insert (new_loc, new_name, &cur_obj)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create new name/link for object");
+ break;
+
+ default:
+ HGOTO_ERROR (H5E_SYM, H5E_BADVALUE, FAIL, "unrecognized link type");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2059,23 +1988,23 @@ H5G_get_type(H5G_entry_t *ent)
{
htri_t isa;
size_t i;
+ int ret_value=H5G_UNKNOWN; /* Return value */
FUNC_ENTER_NOAPI(H5G_get_type, H5G_UNKNOWN);
for (i=H5G_ntypes_g; i>0; --i) {
if ((isa=(H5G_type_g[i-1].isa)(ent))<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN,
- "unable to determine object type");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type");
} else if (isa) {
- HRETURN(H5G_type_g[i-1].type);
+ HGOTO_DONE(H5G_type_g[i-1].type);
}
}
- if (0==i) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN,
- "unable to determine object type");
- }
- FUNC_LEAVE(H5G_UNKNOWN);
+ if (0==i)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2104,6 +2033,7 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
H5O_stab_t stab_mesg;
H5G_entry_t grp_ent, obj_ent;
const char *s = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_get_objinfo, FAIL);
@@ -2113,9 +2043,8 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
/* Find the object's symbol table entry */
if (H5G_namei (loc, name, NULL, &grp_ent/*out*/, &obj_ent/*out*/,
- (unsigned)(follow_link?H5G_TARGET_NORMAL:H5G_TARGET_SLINK), NULL)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to stat object");
- }
+ (unsigned)(follow_link?H5G_TARGET_NORMAL:H5G_TARGET_SLINK), NULL)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "unable to stat object");
/*
* Initialize the stat buf. Symbolic links aren't normal objects and
@@ -2127,10 +2056,8 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
/* Named object is a symbolic link */
if (NULL==H5O_read (&grp_ent, H5O_STAB, 0, &stab_mesg) ||
NULL==(s=H5HL_peek (grp_ent.file, stab_mesg.heap_addr,
- obj_ent.cache.slink.lval_offset))) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to read symbolic link value");
- }
+ obj_ent.cache.slink.lval_offset)))
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value");
statbuf->linklen = HDstrlen(s)+1; /*count the null terminator*/
statbuf->objno[0] = statbuf->objno[1] = 0;
statbuf->nlink = 0;
@@ -2158,10 +2085,11 @@ H5G_get_objinfo (H5G_entry_t *loc, const char *name, hbool_t follow_link,
/* Common code to retrieve the file's fileno */
if(H5F_get_fileno(obj_ent.file,statbuf->fileno)<0)
- HRETURN_ERROR (H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno");
+ HGOTO_ERROR (H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2191,6 +2119,7 @@ H5G_linkval (H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/)
const char *s = NULL;
H5G_entry_t grp_ent, obj_ent;
H5O_stab_t stab_mesg;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_linkval, FAIL);
@@ -2199,35 +2128,27 @@ H5G_linkval (H5G_entry_t *loc, const char *name, size_t size, char *buf/*out*/)
* entry for the group in which the link head appears.
*/
if (H5G_namei (loc, name, NULL, &grp_ent/*out*/, &obj_ent/*out*/,
- H5G_TARGET_SLINK, NULL)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "symbolic link was not found");
- }
- if (H5G_CACHED_SLINK!=obj_ent.type) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "object is not a symbolic link");
- }
+ H5G_TARGET_SLINK, NULL)<0)
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "symbolic link was not found");
+ if (H5G_CACHED_SLINK!=obj_ent.type)
+ HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "object is not a symbolic link");
/*
* Get the address of the local heap for the link value and a pointer
* into that local heap.
*/
- if (NULL==H5O_read (&grp_ent, H5O_STAB, 0, &stab_mesg)) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to determine local heap address");
- }
+ if (NULL==H5O_read (&grp_ent, H5O_STAB, 0, &stab_mesg))
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to determine local heap address");
if (NULL==(s=H5HL_peek (grp_ent.file, stab_mesg.heap_addr,
- obj_ent.cache.slink.lval_offset))) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to read symbolic link value");
- }
+ obj_ent.cache.slink.lval_offset)))
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value");
/* Copy to output buffer */
- if (size>0 && buf) {
+ if (size>0 && buf)
HDstrncpy (buf, s, size);
- }
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2250,14 +2171,14 @@ H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf)
{
H5G_entry_t obj_ent;
H5O_name_t comment;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_set_comment, FAIL);
/* Get the symbol table entry for the object */
if (H5G_namei(loc, name, NULL, NULL, &obj_ent/*out*/, H5G_TARGET_NORMAL,
- NULL)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
- }
+ NULL)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
/* Remove the previous comment message if any */
if (H5O_remove(&obj_ent, H5O_NAME, 0)<0) H5E_clear();
@@ -2265,14 +2186,13 @@ H5G_set_comment(H5G_entry_t *loc, const char *name, const char *buf)
/* Add the new message */
if (buf && *buf) {
comment.s = H5MM_xstrdup(buf);
- if (H5O_modify(&obj_ent, H5O_NAME, H5O_NEW_MESG, 0, &comment)<0) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to set comment object header message");
- }
+ if (H5O_modify(&obj_ent, H5O_NAME, H5O_NEW_MESG, 0, &comment)<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to set comment object header message");
H5O_reset(H5O_NAME, &comment);
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2299,28 +2219,29 @@ H5G_get_comment(H5G_entry_t *loc, const char *name, size_t bufsize, char *buf)
{
H5O_name_t comment;
H5G_entry_t obj_ent;
- int retval = FAIL;
+ int ret_value;
FUNC_ENTER_NOAPI(H5G_get_comment, FAIL);
/* Get the symbol table entry for the object */
if (H5G_namei(loc, name, NULL, NULL, &obj_ent/*out*/, H5G_TARGET_NORMAL,
- NULL)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
- }
+ NULL)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
/* Get the message */
comment.s = NULL;
if (NULL==H5O_read(&obj_ent, H5O_NAME, 0, &comment)) {
- if (buf && bufsize>0) buf[0] = '\0';
- retval = 0;
+ if (buf && bufsize>0)
+ buf[0] = '\0';
+ ret_value = 0;
} else {
HDstrncpy(buf, comment.s, bufsize);
- retval = (int)HDstrlen(comment.s);
+ ret_value = (int)HDstrlen(comment.s);
H5O_reset(H5O_NAME, &comment);
}
- FUNC_LEAVE(retval);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2344,6 +2265,7 @@ H5G_unlink(H5G_entry_t *loc, const char *name)
H5G_entry_t grp_ent, obj_ent;
size_t len;
const char *base=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_unlink, FAIL);
assert(loc);
@@ -2351,25 +2273,19 @@ H5G_unlink(H5G_entry_t *loc, const char *name)
/* Get the entry for the group that contains the object to be unlinked */
if (H5G_namei(loc, name, NULL, &grp_ent, &obj_ent,
- H5G_TARGET_SLINK|H5G_TARGET_MOUNT, NULL)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
- }
- if (!H5F_addr_defined(grp_ent.header)) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "no containing group specified");
- }
- if (NULL==(base=H5G_basename(name, &len)) || '/'==*base) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "problems obtaining object base name");
- }
+ H5G_TARGET_SLINK|H5G_TARGET_MOUNT, NULL)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
+ if (!H5F_addr_defined(grp_ent.header))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no containing group specified");
+ if (NULL==(base=H5G_basename(name, &len)) || '/'==*base)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "problems obtaining object base name");
/* Remove the name from the symbol table */
- if (H5G_stab_remove(&grp_ent, base)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to unlink name from symbol table");
- }
+ if (H5G_stab_remove(&grp_ent, base)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to unlink name from symbol table");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2397,6 +2313,7 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc,
H5G_stat_t sb;
char *linkval=NULL;
size_t lv_size=32;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_move, FAIL);
assert(src_loc);
@@ -2404,31 +2321,23 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc,
assert(src_name && *src_name);
assert(dst_name && *dst_name);
- if (H5G_get_objinfo(src_loc, src_name, FALSE, &sb)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
- }
+ if (H5G_get_objinfo(src_loc, src_name, FALSE, &sb)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
if (H5G_LINK==sb.type) {
/*
* When renaming a symbolic link we rename the link but don't change
* the value of the link.
*/
do {
- if (NULL==(linkval=H5MM_realloc(linkval, 2*lv_size))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate space for symbolic link "
- "value");
- }
+ if (NULL==(linkval=H5MM_realloc(linkval, 2*lv_size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for symbolic link value");
linkval[lv_size-1] = '\0';
- if (H5G_linkval(src_loc, src_name, lv_size, linkval)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to read symbolic link value");
- }
+ if (H5G_linkval(src_loc, src_name, lv_size, linkval)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read symbolic link value");
} while (linkval[lv_size-1]);
if (H5G_link(src_loc, linkval, dst_loc, dst_name, H5G_LINK_SOFT,
- H5G_TARGET_NORMAL)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to rename symbolic link");
- }
+ H5G_TARGET_NORMAL)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to rename symbolic link");
H5MM_xfree(linkval);
} else {
@@ -2436,19 +2345,16 @@ H5G_move(H5G_entry_t *src_loc, const char *src_name, H5G_entry_t *dst_loc,
* Rename the object.
*/
if (H5G_link(src_loc, src_name, dst_loc, dst_name, H5G_LINK_HARD,
- H5G_TARGET_MOUNT)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to register new name for object");
- }
+ H5G_TARGET_MOUNT)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to register new name for object");
}
/* Remove the old name */
- if (H5G_unlink(src_loc, src_name)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to deregister old object name");
- }
+ if (H5G_unlink(src_loc, src_name)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to deregister old object name");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2476,6 +2382,7 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name)
const char *rest;
H5G_entry_t grp_ent;
size_t size;
+ H5F_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_insertion_file, NULL);
assert(loc);
@@ -2485,20 +2392,20 @@ H5G_insertion_file(H5G_entry_t *loc, const char *name)
* Look up the name to get the containing group and to make sure the name
* doesn't already exist.
*/
- if (H5G_namei(loc, name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL,
- NULL)>=0) {
- HRETURN_ERROR(H5E_SYM, H5E_EXISTS, NULL, "name already exists");
- }
+ if (H5G_namei(loc, name, &rest, &grp_ent, NULL, H5G_TARGET_NORMAL, NULL)>=0)
+ HGOTO_ERROR(H5E_SYM, H5E_EXISTS, NULL, "name already exists");
H5E_clear();
/* Make sure only the last component wasn't resolved */
rest = H5G_component(rest, &size);
assert(*rest && size>0);
rest = H5G_component(rest+size, NULL);
- if (*rest) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, NULL,
- "insertion point not found");
- }
+ if (*rest)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "insertion point not found");
- FUNC_LEAVE(grp_ent.file);
+ /* Set return value */
+ ret_value=grp_ent.file;
+
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Gent.c b/src/H5Gent.c
index 35fd0af..c973400 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -42,16 +42,22 @@ static int interface_initialize_g = 0;
H5G_cache_t *
H5G_ent_cache(H5G_entry_t *ent, H5G_type_t *cache_type)
{
+ H5G_cache_t *ret_value; /* Return value */
+
FUNC_ENTER_NOAPI(H5G_ent_cache, NULL);
- if (!ent) {
- HRETURN_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "no entry");
- }
+ if (!ent)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "no entry");
if (cache_type)
*cache_type = ent->type;
- FUNC_LEAVE(&(ent->cache));
+ /* Set return value */
+ ret_value=&(ent->cache);
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5G_ent_modified
@@ -78,11 +84,13 @@ H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type)
assert(ent);
- if (H5G_NO_CHANGE != ent->type) ent->type = cache_type;
+ if (H5G_NO_CHANGE != ent->type)
+ ent->type = cache_type;
ent->dirty = TRUE;
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5G_ent_decode_vec
@@ -110,6 +118,7 @@ herr_t
H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, int n)
{
int i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_ent_decode_vec, FAIL);
@@ -121,13 +130,14 @@ H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, H5G_entry_t *ent, int n)
/* decode entries */
for (i = 0; i < n; i++) {
- if (H5G_ent_decode(f, pp, ent + i) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode");
- }
+ if (H5G_ent_decode(f, pp, ent + i) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode");
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5G_ent_decode
@@ -222,6 +232,7 @@ herr_t
H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, int n)
{
int i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_ent_encode_vec, FAIL);
@@ -233,13 +244,14 @@ H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, int n)
/* encode entries */
for (i = 0; i < n; i++) {
- if (H5G_ent_encode(f, pp, ent + i) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode");
- }
+ if (H5G_ent_encode(f, pp, ent + i) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode");
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5G_ent_encode
@@ -286,21 +298,21 @@ H5G_ent_encode(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent)
/* encode scratch-pad */
switch (ent->type) {
- case H5G_NOTHING_CACHED:
- break;
+ case H5G_NOTHING_CACHED:
+ break;
- case H5G_CACHED_STAB:
- assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH);
- H5F_addr_encode(f, pp, ent->cache.stab.btree_addr);
- H5F_addr_encode(f, pp, ent->cache.stab.heap_addr);
- break;
+ case H5G_CACHED_STAB:
+ assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH);
+ H5F_addr_encode(f, pp, ent->cache.stab.btree_addr);
+ H5F_addr_encode(f, pp, ent->cache.stab.heap_addr);
+ break;
- case H5G_CACHED_SLINK:
- UINT32ENCODE (*pp, ent->cache.slink.lval_offset);
- break;
+ case H5G_CACHED_SLINK:
+ UINT32ENCODE (*pp, ent->cache.slink.lval_offset);
+ break;
- default:
- HDabort();
+ default:
+ HDabort();
}
} else {
H5F_ENCODE_LENGTH(f, *pp, 0);
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index efb38d0..3c76e28 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -253,6 +253,7 @@ H5G_node_create(H5F_t *f, H5B_ins_t UNUSED op, void *_lt_key,
H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
H5G_node_t *sym = NULL;
hsize_t size = 0;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_node_create, FAIL);
@@ -262,39 +263,38 @@ H5G_node_create(H5F_t *f, H5B_ins_t UNUSED op, void *_lt_key,
assert(f);
assert(H5B_INS_FIRST == op);
- if (NULL==(sym = H5FL_ALLOC(H5G_node_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(sym = H5FL_ALLOC(H5G_node_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
size = H5G_node_size(f);
- if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, size))) {
- H5FL_FREE(H5G_node_t,sym);
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to allocate file space");
- }
+ if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, size)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to allocate file space");
sym->dirty = TRUE;
sym->entry = H5FL_ARR_ALLOC(H5G_entry_t,(2*H5G_node_k(f)),1);
- if (NULL==sym->entry) {
- H5FL_FREE(H5G_node_t,sym);
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- if (H5AC_set(f, H5AC_SNODE, *addr_p, sym) < 0) {
- H5FL_ARR_FREE(H5G_entry_t,sym->entry);
- H5FL_FREE(H5G_node_t,sym);
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to cache symbol table leaf node");
- }
+ if (NULL==sym->entry)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if (H5AC_set(f, H5AC_SNODE, *addr_p, sym) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to cache symbol table leaf node");
/*
* The left and right symbols in an empty tree are both the
* empty string stored at offset zero by the H5G functions. This
* allows the comparison functions to work correctly without knowing
* that there are no symbols.
*/
- if (lt_key) lt_key->offset = 0;
- if (rt_key) rt_key->offset = 0;
+ if (lt_key)
+ lt_key->offset = 0;
+ if (rt_key)
+ rt_key->offset = 0;
- FUNC_LEAVE(SUCCEED);
+done:
+ if(ret_value<0) {
+ if(sym!=NULL) {
+ if(sym->entry!=NULL)
+ H5FL_ARR_FREE(H5G_entry_t,sym->entry);
+ H5FL_FREE(H5G_node_t,sym);
+ } /* end if */
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -326,8 +326,8 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_
{
uint8_t *buf = NULL, *p = NULL;
size_t size;
- herr_t status;
int i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_node_flush, FAIL);
@@ -359,8 +359,7 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_
/* Allocate temporary buffer */
if ((buf=H5FL_BLK_ALLOC(symbol_node,size, 0))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
p=buf;
/* magic number */
@@ -380,10 +379,8 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_
H5G_ent_encode_vec(f, &p, sym->entry, sym->nsyms);
HDmemset(p, 0, size - (p - buf));
- status = H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf);
- if (status < 0)
- HRETURN_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL,
- "unable to write symbol table node to the file");
+ if (H5F_block_write(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL, "unable to write symbol table node to the file");
if (buf)
H5FL_BLK_FREE(symbol_node,buf);
@@ -399,7 +396,9 @@ H5G_node_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5G_node_
sym->entry = H5FL_ARR_FREE(H5G_entry_t,sym->entry);
H5FL_FREE(H5G_node_t,sym);
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -433,7 +432,7 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1
size_t size = 0;
uint8_t *buf = NULL;
const uint8_t *p = NULL;
- H5G_node_t *ret_value = NULL; /*for error handling */
+ H5G_node_t *ret_value; /*for error handling */
FUNC_ENTER_NOAPI(H5G_node_load, NULL);
@@ -450,30 +449,21 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1
*/
size = H5G_node_size(f);
if ((buf=H5FL_BLK_ALLOC(symbol_node,size,0))==NULL)
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for symbol table node");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for symbol table node");
p=buf;
if (NULL==(sym = H5FL_ALLOC(H5G_node_t,1)) ||
- NULL==(sym->entry=H5FL_ARR_ALLOC(H5G_entry_t,(2*H5G_node_k(f)),1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0) {
- HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL,
- "unable to read symbol table node");
- }
+ NULL==(sym->entry=H5FL_ARR_ALLOC(H5G_entry_t,(2*H5G_node_k(f)),1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ if (H5F_block_read(f, H5FD_MEM_BTREE, addr, size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL, "unable to read symbol table node");
/* magic */
- if (HDmemcmp(p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC)) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL,
- "bad symbol table node signature");
- }
+ if (HDmemcmp(p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node signature");
p += 4;
/* version */
- if (H5G_NODE_VERS != *p++) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL,
- "bad symbol table node version");
- }
+ if (H5G_NODE_VERS != *p++)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "bad symbol table node version");
/* reserved */
p++;
@@ -481,22 +471,23 @@ H5G_node_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1
UINT16DECODE(p, sym->nsyms);
/* entries */
- if (H5G_ent_decode_vec(f, &p, sym->entry, sym->nsyms) < 0) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL,
- "unable to decode symbol table entries");
- }
+ if (H5G_ent_decode_vec(f, &p, sym->entry, sym->nsyms) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL, "unable to decode symbol table entries");
+ /* Set return value */
ret_value = sym;
- done:
+done:
if (buf)
H5FL_BLK_FREE(symbol_node,buf);
if (!ret_value) {
if (sym) {
- sym->entry = H5FL_ARR_FREE(H5G_entry_t,sym->entry);
- sym = H5FL_FREE(H5G_node_t,sym);
+ if(sym->entry)
+ H5FL_ARR_FREE(H5G_entry_t,sym->entry);
+ H5FL_FREE(H5G_node_t,sym);
}
}
+
FUNC_LEAVE(ret_value);
}
@@ -531,7 +522,7 @@ H5G_node_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
const char *s1, *s2;
- int cmp;
+ int ret_value;
FUNC_ENTER_NOAPI(H5G_node_cmp2, FAIL);
@@ -539,17 +530,16 @@ H5G_node_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
assert(lt_key);
assert(rt_key);
- if (NULL == (s1 = H5HL_peek(f, udata->heap_addr, lt_key->offset))) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
- if (NULL == (s2 = H5HL_peek(f, udata->heap_addr, rt_key->offset))) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
- cmp = HDstrcmp(s1, s2);
+ if (NULL == (s1 = H5HL_peek(f, udata->heap_addr, lt_key->offset)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol name");
+ if (NULL == (s2 = H5HL_peek(f, udata->heap_addr, rt_key->offset)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol name");
- FUNC_LEAVE(cmp);
+ /* Set return value */
+ ret_value = HDstrcmp(s1, s2);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -587,26 +577,24 @@ H5G_node_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
const char *s;
+ int ret_value=0; /* Return value */
FUNC_ENTER_NOAPI(H5G_node_cmp3, FAIL);
/* left side */
- if (NULL == (s = H5HL_peek(f, udata->heap_addr, lt_key->offset))) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
+ if (NULL == (s = H5HL_peek(f, udata->heap_addr, lt_key->offset)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol name");
if (HDstrcmp(udata->name, s) <= 0)
- HRETURN(-1);
+ HGOTO_DONE(-1);
/* right side */
- if (NULL == (s = H5HL_peek(f, udata->heap_addr, rt_key->offset))) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
+ if (NULL == (s = H5HL_peek(f, udata->heap_addr, rt_key->offset)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol name");
if (HDstrcmp(udata->name, s) > 0)
- HRETURN(1);
+ HGOTO_DONE(1);
- FUNC_LEAVE(0);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -647,7 +635,7 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void UNUSED *_lt_key,
H5G_node_t *sn = NULL;
int lt = 0, idx = 0, rt, cmp = 1;
const char *s;
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_node_found, FAIL);
@@ -661,10 +649,8 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void UNUSED *_lt_key,
/*
* Load the symbol table node for exclusive access.
*/
- if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
- "unable to protect symbol table node");
- }
+ if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to protect symbol table node");
/*
* Binary search.
@@ -672,11 +658,8 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void UNUSED *_lt_key,
rt = sn->nsyms;
while (lt < rt && cmp) {
idx = (lt + rt) / 2;
- if (NULL == (s = H5HL_peek(f, bt_udata->heap_addr,
- sn->entry[idx].name_off))) {
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
+ if (NULL == (s = H5HL_peek(f, bt_udata->heap_addr, sn->entry[idx].name_off)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to read symbol name");
cmp = HDstrcmp(bt_udata->name, s);
if (cmp < 0) {
@@ -685,28 +668,22 @@ H5G_node_found(H5F_t *f, haddr_t addr, const void UNUSED *_lt_key,
lt = idx + 1;
}
}
- if (cmp) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+ if (cmp)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+
+ if (bt_udata->operation==H5G_OPER_FIND)
+ /*
+ * The caller is querying the symbol entry. Return just a pointer to
+ * the entry. The pointer is valid until the next call to H5AC.
+ */
+ bt_udata->ent = sn->entry[idx];
+ else
+ HGOTO_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL, "internal erorr (unknown symbol find operation)");
- switch (bt_udata->operation) {
- case H5G_OPER_FIND:
- /*
- * The caller is querying the symbol entry. Return just a pointer to
- * the entry. The pointer is valid until the next call to H5AC.
- */
- bt_udata->ent = sn->entry[idx];
- break;
-
- default:
- HRETURN_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL,
- "internal erorr (unknown symbol find operation)");
- }
- ret_value = SUCCEED;
+done:
+ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0 && ret_value>=0)
+ HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node");
- done:
- if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_PROTECT, FAIL,
- "unable to release symbol table node");
- }
FUNC_LEAVE(ret_value);
}
@@ -781,10 +758,8 @@ H5G_node_insert(H5F_t *f, haddr_t addr, void UNUSED *_lt_key,
/*
* Load the symbol node.
*/
- if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to protect symbol table node");
- }
+ if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node");
/*
* Where does the new symbol get inserted? We use a binary search.
@@ -792,16 +767,10 @@ H5G_node_insert(H5F_t *f, haddr_t addr, void UNUSED *_lt_key,
rt = sn->nsyms;
while (lt < rt) {
idx = (lt + rt) / 2;
- if (NULL == (s = H5HL_peek(f, bt_udata->heap_addr,
- sn->entry[idx].name_off))) {
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR,
- "unable to read symbol name");
- }
- if (0 == (cmp = HDstrcmp(bt_udata->name, s))) {
- /*already present */
- HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR,
- "symbol is already present in symbol table");
- }
+ if (NULL == (s = H5HL_peek(f, bt_udata->heap_addr, sn->entry[idx].name_off)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to read symbol name");
+ if (0 == (cmp = HDstrcmp(bt_udata->name, s))) /*already present */
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "symbol is already present in symbol table");
if (cmp < 0) {
rt = idx;
} else {
@@ -816,10 +785,8 @@ H5G_node_insert(H5F_t *f, haddr_t addr, void UNUSED *_lt_key,
offset = H5HL_insert(f, bt_udata->heap_addr, HDstrlen(bt_udata->name)+1,
bt_udata->name);
bt_udata->ent.name_off = offset;
- if (0==offset || (size_t)(-1)==offset) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR,
- "unable to insert symbol name into heap");
- }
+ if (0==offset || (size_t)(-1)==offset)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR, "unable to insert symbol name into heap");
if ((size_t)(sn->nsyms) >= 2*H5G_node_k(f)) {
/*
* The node is full. Split it into a left and right
@@ -830,14 +797,10 @@ H5G_node_insert(H5F_t *f, haddr_t addr, void UNUSED *_lt_key,
/* The right node */
if (H5G_node_create(f, H5B_INS_FIRST, NULL, NULL, NULL,
- new_node_p/*out*/)<0) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR,
- "unable to split symbol table node");
- }
- if (NULL==(snrt=H5AC_find(f, H5AC_SNODE, *new_node_p, NULL, NULL))) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to split symbol table node");
- }
+ new_node_p/*out*/)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to split symbol table node");
+ if (NULL==(snrt=H5AC_find(f, H5AC_SNODE, *new_node_p, NULL, NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to split symbol table node");
HDmemcpy(snrt->entry, sn->entry + H5G_node_k(f),
H5G_node_k(f) * sizeof(H5G_entry_t));
snrt->nsyms = H5G_node_k(f);
@@ -885,11 +848,10 @@ H5G_node_insert(H5F_t *f, haddr_t addr, void UNUSED *_lt_key,
insert_into->entry[idx].dirty = TRUE;
insert_into->nsyms += 1;
- done:
- if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR,
- "unable to release symbol table node");
- }
+done:
+ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0 && ret_value!=H5B_INS_ERROR)
+ HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node");
+
FUNC_LEAVE(ret_value);
}
@@ -941,20 +903,16 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/,
assert(bt_udata);
/* Load the symbol table */
- if (NULL==(sn=H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to protect symbol table node");
- }
+ if (NULL==(sn=H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR, "unable to protect symbol table node");
/* Find the name with a binary search */
rt = sn->nsyms;
while (lt<rt && cmp) {
idx = (lt+rt)/2;
if (NULL==(s=H5HL_peek(f, bt_udata->heap_addr,
- sn->entry[idx].name_off))) {
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR,
- "unable to read symbol name");
- }
+ sn->entry[idx].name_off)))
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to read symbol name");
cmp = HDstrcmp(bt_udata->name, s);
if (cmp<0) {
rt = idx;
@@ -962,31 +920,25 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/,
lt = idx+1;
}
}
- if (cmp) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found");
+ if (cmp)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found");
if (H5G_CACHED_SLINK==sn->entry[idx].type) {
/* Remove the symbolic link value */
if ((s=H5HL_peek(f, bt_udata->heap_addr,
- sn->entry[idx].cache.slink.lval_offset))) {
- H5HL_remove(f, bt_udata->heap_addr,
- sn->entry[idx].cache.slink.lval_offset,
- HDstrlen(s)+1);
- }
+ sn->entry[idx].cache.slink.lval_offset)))
+ H5HL_remove(f, bt_udata->heap_addr, sn->entry[idx].cache.slink.lval_offset, HDstrlen(s)+1);
H5E_clear(); /*no big deal*/
} else {
/* Decrement the reference count */
assert(H5F_addr_defined(sn->entry[idx].header));
- if (H5O_link(sn->entry+idx, -1)<0) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR,
- "unable to decrement object link count");
- }
+ if (H5O_link(sn->entry+idx, -1)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count");
}
/* Remove the name from the local heap */
- if ((s=H5HL_peek(f, bt_udata->heap_addr, sn->entry[idx].name_off))) {
- H5HL_remove(f, bt_udata->heap_addr, sn->entry[idx].name_off,
- HDstrlen(s)+1);
- }
+ if ((s=H5HL_peek(f, bt_udata->heap_addr, sn->entry[idx].name_off)))
+ H5HL_remove(f, bt_udata->heap_addr, sn->entry[idx].name_off, HDstrlen(s)+1);
H5E_clear(); /*no big deal*/
/* Remove the entry from the symbol table node */
@@ -1003,11 +955,10 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/,
sn->nsyms = 0;
sn->dirty = TRUE;
if (H5AC_unprotect(f, H5AC_SNODE, addr, sn)<0 ||
- H5AC_flush(f, H5AC_SNODE, addr, TRUE)<0 ||
- H5MF_xfree(f, H5FD_MEM_BTREE, addr, (hsize_t)H5G_node_size(f))<0) {
+ H5AC_flush(f, H5AC_SNODE, addr, TRUE)<0 ||
+ H5MF_xfree(f, H5FD_MEM_BTREE, addr, (hsize_t)H5G_node_size(f))<0) {
sn = NULL;
- HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR,
- "unable to free symbol table node");
+ HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to free symbol table node");
}
sn = NULL;
ret_value = H5B_INS_REMOVE;
@@ -1048,11 +999,10 @@ H5G_node_remove(H5F_t *f, haddr_t addr, void *_lt_key/*in,out*/,
ret_value = H5B_INS_NOOP;
}
- done:
- if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR,
- "unable to release symbol table node");
- }
+done:
+ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn)<0 && ret_value!=H5B_INS_ERROR)
+ HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node");
+
FUNC_LEAVE(ret_value);
}
@@ -1101,15 +1051,11 @@ H5G_node_iterate (H5F_t *f, void UNUSED *_lt_key, haddr_t addr,
* Save information about the symbol table node since we can't lock it
* because we're about to call an application function.
*/
- if (NULL == (sn = H5AC_find(f, H5AC_SNODE, addr, NULL, NULL))) {
- HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
- "unable to load symbol table node");
- }
+ if (NULL == (sn = H5AC_find(f, H5AC_SNODE, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to load symbol table node");
nsyms = sn->nsyms;
- if (NULL==(name_off = H5MM_malloc (nsyms*sizeof(name_off[0])))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(name_off = H5MM_malloc (nsyms*sizeof(name_off[0]))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
for (i=0; i<nsyms; i++)
name_off[i] = sn->entry[i].name_off;
sn = NULL;
@@ -1126,10 +1072,8 @@ H5G_node_iterate (H5F_t *f, void UNUSED *_lt_key, haddr_t addr,
assert (name);
n = HDstrlen (name);
if (n+1>sizeof(buf)) {
- if (NULL==(s = H5MM_malloc (n+1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(s = H5MM_malloc (n+1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
} else {
s = buf;
}
@@ -1144,9 +1088,8 @@ H5G_node_iterate (H5F_t *f, void UNUSED *_lt_key, haddr_t addr,
/* (whether we skipped them or not) */
bt_udata->final_ent++;
}
- if (ret_value<0) {
+ if (ret_value<0)
HERROR (H5E_SYM, H5E_CANTINIT, "iteration operator failed");
- }
done:
name_off = H5MM_xfree (name_off);
@@ -1177,8 +1120,8 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent,
{
int i;
H5G_node_t *sn = NULL;
- herr_t status;
const char *s;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_node_debug, FAIL);
@@ -1197,12 +1140,9 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent,
*/
if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
H5E_clear(); /*discard that error */
- status = H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, NULL);
- if (status < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
- "unable to debug B-tree node");
- }
- HRETURN(SUCCEED);
+ if ( H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to debug B-tree node");
+ HGOTO_DONE(SUCCEED);
}
fprintf(stream, "%*sSymbol Table Node...\n", indent, "");
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
@@ -1228,7 +1168,9 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent,
}
H5AC_unprotect(f, H5AC_SNODE, addr, sn);
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1257,15 +1199,20 @@ unsigned H5G_node_k(const H5F_t *f)
{
unsigned sym_leaf_k;
H5P_genplist_t *plist; /* Property list pointer */
+ unsigned ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5G_node_k, UFAIL);
assert(f);
if(NULL == (plist = H5I_object(f->shared->fcpl_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a file access property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, UFAIL, "not a file access property list");
if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k) < 0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get rank for symbol table leaf node");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get rank for symbol table leaf node");
- FUNC_LEAVE(sym_leaf_k);
+ /* Set return value */
+ ret_value=sym_leaf_k;
+
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 9a23256..9c4311c 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -20,6 +20,7 @@
#define PABLO_MASK H5G_stab_mask
static int interface_initialize_g = 0;
#define INTERFACE_INIT NULL
+
/*-------------------------------------------------------------------------
* Function: H5G_stab_create
@@ -50,6 +51,7 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
{
size_t name; /*offset of "" name */
H5O_stab_t stab; /*symbol table message */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_create, FAIL);
@@ -61,13 +63,11 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
init = MAX(init, H5HL_SIZEOF_FREE(f) + 2);
/* Create symbol table private heap */
- if (H5HL_create(f, init, &(stab.heap_addr)/*out*/)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap");
- }
+ if (H5HL_create(f, init, &(stab.heap_addr)/*out*/)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap");
name = H5HL_insert(f, stab.heap_addr, 1, "");
- if ((size_t)(-1)==name) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap");
- }
+ if ((size_t)(-1)==name)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap");
/*
* B-tree's won't work if the first name isn't at the beginning
@@ -76,18 +76,16 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
assert(0 == name);
/* Create the B-tree */
- if (H5B_create(f, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree");
- }
+ if (H5B_create(f, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree");
/*
* Create symbol table object header. It has a zero link count
* since nothing refers to it yet. The link count will be
* incremented if the object is added to the group directed graph.
*/
- if (H5O_create(f, 4 + 2 * H5F_SIZEOF_ADDR(f), self/*out*/) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header");
- }
+ if (H5O_create(f, 4 + 2 * H5F_SIZEOF_ADDR(f), self/*out*/) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header");
/*
* Insert the symbol table message into the object header and the symbol
@@ -95,13 +93,14 @@ H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
*/
if (H5O_modify(self, H5O_STAB, H5O_NEW_MESG, H5O_FLAG_CONSTANT, &stab)<0) {
H5O_close(self);
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
}
self->cache.stab.btree_addr = stab.btree_addr;
self->cache.stab.heap_addr = stab.heap_addr;
self->type = H5G_CACHED_STAB;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -130,6 +129,7 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
{
H5G_bt_ud1_t udata; /*data to pass through B-tree */
H5O_stab_t stab; /*symbol table message */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_find, FAIL);
@@ -139,20 +139,22 @@ H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
assert(name && *name);
/* set up the udata */
- if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
- HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message");
- }
+ if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message");
udata.operation = H5G_OPER_FIND;
udata.name = name;
udata.heap_addr = stab.heap_addr;
/* search the B-tree */
- if (H5B_find(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
- }
- if (obj_ent) *obj_ent = udata.ent;
- FUNC_LEAVE(SUCCEED);
+ if (H5B_find(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+ if (obj_ent)
+ *obj_ent = udata.ent;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5G_stab_insert
@@ -179,6 +181,7 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
H5O_stab_t stab; /*symbol table message */
H5G_bt_ud1_t udata; /*data to pass through B-tree */
static double split_ratios[3] = {0.1, 0.5, 0.9};
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_insert, FAIL);
@@ -186,29 +189,26 @@ H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
assert(grp_ent && grp_ent->file);
assert(name && *name);
assert(obj_ent && obj_ent->file);
- if (grp_ent->file->shared != obj_ent->file->shared) {
- HRETURN_ERROR(H5E_SYM, H5E_LINK, FAIL,
- "interfile hard links are not allowed");
- }
+ if (grp_ent->file->shared != obj_ent->file->shared)
+ HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL, "interfile hard links are not allowed");
/* initialize data to pass through B-tree */
- if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
- HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
- }
+ if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
udata.operation = H5G_OPER_INSERT;
udata.name = name;
udata.heap_addr = stab.heap_addr;
udata.ent = *obj_ent;
/* insert */
- if (H5B_insert(grp_ent->file, H5B_SNODE, stab.btree_addr, split_ratios,
- &udata) < 0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry");
- }
+ if (H5B_insert(grp_ent->file, H5B_SNODE, stab.btree_addr, split_ratios, &udata) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "unable to insert entry");
/* update the name offset in the entry */
obj_ent->name_off = udata.ent.name_off;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -231,6 +231,7 @@ H5G_stab_remove(H5G_entry_t *grp_ent, const char *name)
{
H5O_stab_t stab; /*symbol table message */
H5G_bt_ud1_t udata; /*data to pass through B-tree */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5G_stab_remove, FAIL);
@@ -238,18 +239,18 @@ H5G_stab_remove(H5G_entry_t *grp_ent, const char *name)
assert(name && *name);
/* initialize data to pass through B-tree */
- if (NULL==H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
- HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
- }
+ if (NULL==H5O_read(grp_ent, H5O_STAB, 0, &stab))
+ HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
udata.operation = H5G_OPER_REMOVE;
udata.name = name;
udata.heap_addr = stab.heap_addr;
HDmemset(&(udata.ent), 0, sizeof(udata.ent));
/* remove */
- if (H5B_remove(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata)<0) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
- }
+ if (H5B_remove(grp_ent->file, H5B_SNODE, stab.btree_addr, &udata)<0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to remove entry");
+
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5HG.c b/src/H5HG.c
index 5920e15..bc4a6de 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -411,6 +411,7 @@ static herr_t
H5HG_flush (H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HG_heap_t *heap)
{
int i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HG_flush, FAIL);
@@ -422,10 +423,8 @@ H5HG_flush (H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HG_heap_t
if (heap->dirty) {
if (H5F_block_write (f, H5FD_MEM_GHEAP, addr, heap->size,
- dxpl_id, heap->chunk)<0) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "unable to write global heap collection to file");
- }
+ dxpl_id, heap->chunk)<0)
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write global heap collection to file");
heap->dirty = 0;
}
@@ -443,7 +442,8 @@ H5HG_flush (H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HG_heap_t
H5FL_FREE (H5HG_heap_t,heap);
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -574,6 +574,7 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
int cwfsno;
unsigned idx;
H5HG_heap_t *heap = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HG_insert, FAIL);
@@ -582,10 +583,8 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
assert (0==size || obj);
assert (hobj);
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file");
/* Find a large enough collection on the CWFS list */
need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size);
@@ -610,17 +609,11 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
* new collection large enough for the message plus the collection header.
*/
if (cwfsno>=f->shared->ncwfs) {
- if (NULL==(heap=H5HG_create (f, need+H5HG_SIZEOF_HDR (f)))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL,
- "unable to allocate a global heap collection");
- }
+ if (NULL==(heap=H5HG_create (f, need+H5HG_SIZEOF_HDR (f))))
+ HGOTO_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL, "unable to allocate a global heap collection");
assert (f->shared->ncwfs>0);
assert (f->shared->cwfs[0]==heap);
-#ifdef OLD_WAY
- assert (f->shared->cwfs[0]->obj[0].size >= need+H5HG_SIZEOF_HDR(f));
-#else /* OLD_WAY */
assert (f->shared->cwfs[0]->obj[0].size >= need);
-#endif /* OLD_WAY */
cwfsno = 0;
}
@@ -637,7 +630,9 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
/* Return value */
hobj->addr = heap->addr;
hobj->idx = idx;
- FUNC_LEAVE (SUCCEED);
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -666,7 +661,7 @@ void *
H5HG_peek (H5F_t *f, H5HG_t *hobj)
{
H5HG_heap_t *heap = NULL;
- void *retval = NULL;
+ void *ret_value;
int i;
FUNC_ENTER_NOAPI(H5HG_peek, NULL);
@@ -676,12 +671,11 @@ H5HG_peek (H5F_t *f, H5HG_t *hobj)
assert (hobj);
/* Load the heap and return a pointer to the object */
- if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
- }
+ if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL)))
+ HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
assert (hobj->idx>0 && hobj->idx<heap->nalloc);
- retval = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR (f);
- assert (retval);
+ ret_value = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR (f);
+ assert (ret_value);
/*
* Advance the heap in the CWFS list. We might have done this already
@@ -699,7 +693,8 @@ H5HG_peek (H5F_t *f, H5HG_t *hobj)
}
}
- FUNC_LEAVE (retval);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -729,6 +724,7 @@ H5HG_read (H5F_t *f, H5HG_t *hobj, void *object/*out*/)
int i;
size_t size;
uint8_t *p = NULL;
+ void *ret_value;
FUNC_ENTER_NOAPI(H5HG_read, NULL);
@@ -737,17 +733,14 @@ H5HG_read (H5F_t *f, H5HG_t *hobj, void *object/*out*/)
assert (hobj);
/* Load the heap */
- if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
- }
+ if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL)))
+ HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
assert (hobj->idx>0 && hobj->idx<heap->nalloc);
assert (heap->obj[hobj->idx].begin);
size = heap->obj[hobj->idx].size;
p = heap->obj[hobj->idx].begin + H5HG_SIZEOF_OBJHDR (f);
- if (!object && NULL==(object = H5MM_malloc (size))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!object && NULL==(object = H5MM_malloc (size)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy (object, p, size);
/*
@@ -766,7 +759,11 @@ H5HG_read (H5F_t *f, H5HG_t *hobj, void *object/*out*/)
}
}
- FUNC_LEAVE (object);
+ /* Set return value */
+ ret_value=object;
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -794,35 +791,34 @@ int
H5HG_link (H5F_t *f, H5HG_t *hobj, int adjust)
{
H5HG_heap_t *heap = NULL;
+ int ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5HG_link, FAIL);
/* Check args */
assert (f);
assert (hobj);
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file");
/* Load the heap */
- if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
- }
+ if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL)))
+ HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
assert (hobj->idx>0 && hobj->idx<heap->nalloc);
assert (heap->obj[hobj->idx].begin);
- if (heap->obj[hobj->idx].nrefs+adjust<0) {
- HRETURN_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL,
- "new link count would be out of range");
- }
- if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK) {
- HRETURN_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL,
- "new link count would be out of range");
- }
+ if (heap->obj[hobj->idx].nrefs+adjust<0)
+ HGOTO_ERROR (H5E_HEAP, H5E_BADRANGE, FAIL, "new link count would be out of range");
+ if (heap->obj[hobj->idx].nrefs+adjust>H5HG_MAXLINK)
+ HGOTO_ERROR (H5E_HEAP, H5E_BADVALUE, FAIL, "new link count would be out of range");
heap->obj[hobj->idx].nrefs += adjust;
- if (adjust) heap->dirty = TRUE;
+ if (adjust)
+ heap->dirty = TRUE;
+
+ /* Set return value */
+ ret_value=heap->obj[hobj->idx].nrefs;
- FUNC_LEAVE (heap->obj[hobj->idx].nrefs);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -848,21 +844,19 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj)
size_t need;
int i;
unsigned u;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HG_remove, FAIL);
/* Check args */
assert (f);
assert (hobj);
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file");
/* Load the heap */
- if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
- }
+ if (NULL==(heap=H5AC_find (f, H5AC_GHEAP, hobj->addr, NULL, NULL)))
+ HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
assert (hobj->idx>0 && hobj->idx<heap->nalloc);
assert (heap->obj[hobj->idx].begin);
obj_start = heap->obj[hobj->idx].begin;
@@ -871,9 +865,8 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj)
/* Move the new free space to the end of the heap */
for (u=0; u<heap->nalloc; u++) {
- if (heap->obj[u].begin > heap->obj[hobj->idx].begin) {
+ if (heap->obj[u].begin > heap->obj[hobj->idx].begin)
heap->obj[u].begin -= need;
- }
}
if (NULL==heap->obj[0].begin) {
heap->obj[0].begin = heap->chunk + (heap->size-need);
@@ -924,7 +917,8 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj)
}
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -954,6 +948,7 @@ H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent,
char buf[64];
size_t size;
uint8_t *p = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HG_debug, FAIL);
@@ -964,10 +959,8 @@ H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent,
assert(indent >= 0);
assert(fwidth >= 0);
- if (NULL == (h = H5AC_find(f, H5AC_GHEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load global heap collection");
- }
+ if (NULL == (h = H5AC_find(f, H5AC_GHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load global heap collection");
fprintf(stream, "%*sGlobal Heap Collection...\n", indent, "");
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
"Dirty:",
@@ -1024,5 +1017,6 @@ H5HG_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent,
}
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5HL.c b/src/H5HL.c
index 45d8f0f..d9e5d9c 100644
--- a/src/H5HL.c
+++ b/src/H5HL.c
@@ -210,7 +210,7 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED udata1,
H5HL_t *heap = NULL;
H5HL_free_t *fl = NULL, *tail = NULL;
size_t free_block = H5HL_FREE_NULL;
- H5HL_t *ret_value = NULL;
+ H5HL_t *ret_value;
FUNC_ENTER_NOAPI(H5HL_load, NULL);
@@ -221,22 +221,15 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED udata1,
assert(!udata1);
assert(!udata2);
- if (H5F_block_read(f, H5FD_MEM_LHEAP, addr, H5HL_SIZEOF_HDR(f), dxpl_id,
- hdr) < 0) {
- HRETURN_ERROR(H5E_HEAP, H5E_READERROR, NULL,
- "unable to read heap header");
- }
+ if (H5F_block_read(f, H5FD_MEM_LHEAP, addr, H5HL_SIZEOF_HDR(f), dxpl_id, hdr) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_READERROR, NULL, "unable to read heap header");
p = hdr;
- if (NULL==(heap = H5FL_ALLOC(H5HL_t,1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(heap = H5FL_ALLOC(H5HL_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* magic number */
- if (HDmemcmp(hdr, H5HL_MAGIC, H5HL_SIZEOF_MAGIC)) {
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap signature");
- }
+ if (HDmemcmp(hdr, H5HL_MAGIC, H5HL_SIZEOF_MAGIC))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap signature");
p += H5HL_SIZEOF_MAGIC;
/* Reserved */
@@ -248,35 +241,25 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED udata1,
/* free list head */
H5F_DECODE_LENGTH(f, p, free_block);
- if (free_block != H5HL_FREE_NULL && free_block >= heap->disk_alloc) {
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap free list");
- }
+ if (free_block != H5HL_FREE_NULL && free_block >= heap->disk_alloc)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list");
/* data */
H5F_addr_decode(f, &p, &(heap->addr));
heap->chunk = H5FL_BLK_ALLOC(heap_chunk,(H5HL_SIZEOF_HDR(f) + heap->mem_alloc),1);
- if (NULL==heap->chunk) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==heap->chunk)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
if (heap->disk_alloc &&
- H5F_block_read(f, H5FD_MEM_LHEAP, heap->addr, heap->disk_alloc,
- dxpl_id, heap->chunk + H5HL_SIZEOF_HDR(f)) < 0) {
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "unable to read heap data");
- }
+ H5F_block_read(f, H5FD_MEM_LHEAP, heap->addr, heap->disk_alloc,
+ dxpl_id, heap->chunk + H5HL_SIZEOF_HDR(f)) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to read heap data");
/* free list */
while (H5HL_FREE_NULL != free_block) {
- if (free_block >= heap->disk_alloc) {
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap free list");
- }
- if (NULL==(fl = H5FL_ALLOC(H5HL_free_t,0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (free_block >= heap->disk_alloc)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list");
+ if (NULL==(fl = H5FL_ALLOC(H5HL_free_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
fl->offset = free_block;
fl->prev = tail;
fl->next = NULL;
@@ -288,15 +271,14 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED udata1,
H5F_DECODE_LENGTH(f, p, free_block);
H5F_DECODE_LENGTH(f, p, fl->size);
- if (fl->offset + fl->size > heap->disk_alloc) {
- HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap free list");
- }
+ if (fl->offset + fl->size > heap->disk_alloc)
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad heap free list");
}
+ /* Set return value */
ret_value = heap;
- done:
+done:
if (!ret_value && heap) {
if(heap->chunk)
heap->chunk = H5FL_BLK_FREE(heap_chunk,heap->chunk);
@@ -306,8 +288,10 @@ H5HL_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED udata1,
}
H5FL_FREE(H5HL_t,heap);
}
+
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_flush
@@ -339,6 +323,7 @@ H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HL_t *heap)
uint8_t *p = heap->chunk;
H5HL_free_t *fl = heap->freelist;
haddr_t hdr_end_addr;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HL_flush, FAIL);
@@ -356,10 +341,8 @@ H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HL_t *heap)
if (heap->mem_alloc > heap->disk_alloc) {
haddr_t old_addr = heap->addr, new_addr;
if (HADDR_UNDEF==(new_addr=H5MF_alloc(f, H5FD_MEM_LHEAP,
- (hsize_t)heap->mem_alloc))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file space for heap");
- }
+ (hsize_t)heap->mem_alloc)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate file space for heap");
heap->addr = new_addr;
H5MF_xfree(f, H5FD_MEM_LHEAP, old_addr, (hsize_t)heap->disk_alloc);
H5E_clear(); /*don't really care if the free failed */
@@ -402,21 +385,15 @@ H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HL_t *heap)
/* The header and data are contiguous */
if (H5F_block_write(f, H5FD_MEM_LHEAP, addr,
(H5HL_SIZEOF_HDR(f)+heap->disk_alloc),
- dxpl_id, heap->chunk) < 0) {
- HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL,
- "unable to write heap header and data to file");
- }
+ dxpl_id, heap->chunk) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap header and data to file");
} else {
if (H5F_block_write(f, H5FD_MEM_LHEAP, addr, H5HL_SIZEOF_HDR(f),
- dxpl_id, heap->chunk)<0) {
- HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL,
- "unable to write heap header to file");
- }
+ dxpl_id, heap->chunk)<0)
+ HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap header to file");
if (H5F_block_write(f, H5FD_MEM_LHEAP, heap->addr, heap->disk_alloc,
- dxpl_id, heap->chunk + H5HL_SIZEOF_HDR(f)) < 0) {
- HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL,
- "unable to write heap data to file");
- }
+ dxpl_id, heap->chunk + H5HL_SIZEOF_HDR(f)) < 0)
+ HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "unable to write heap data to file");
}
heap->dirty = 0;
@@ -434,8 +411,11 @@ H5HL_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5HL_t *heap)
}
H5FL_FREE(H5HL_t,heap);
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_read
@@ -468,6 +448,7 @@ void *
H5HL_read(H5F_t *f, haddr_t addr, size_t offset, size_t size, void *buf)
{
H5HL_t *heap = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5HL_read, NULL);
@@ -475,21 +456,22 @@ H5HL_read(H5F_t *f, haddr_t addr, size_t offset, size_t size, void *buf)
assert(f);
assert (H5F_addr_defined(addr));
- if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "unable to load heap");
- }
+ if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
assert(offset < heap->mem_alloc);
assert(offset + size <= heap->mem_alloc);
- if (!buf && NULL==(buf = H5MM_malloc(size))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!buf && NULL==(buf = H5MM_malloc(size)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy(buf, heap->chunk + H5HL_SIZEOF_HDR(f) + offset, size);
- FUNC_LEAVE(buf);
+ /* Set return value */
+ ret_value=buf;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_peek
@@ -526,7 +508,7 @@ const void *
H5HL_peek(H5F_t *f, haddr_t addr, size_t offset)
{
H5HL_t *heap = NULL;
- const void *retval = NULL;
+ const void *ret_value = NULL;
FUNC_ENTER_NOAPI(H5HL_peek, NULL);
@@ -534,14 +516,17 @@ H5HL_peek(H5F_t *f, haddr_t addr, size_t offset)
assert(f);
assert(H5F_addr_defined(addr));
- if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
- }
+ if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap");
assert(offset < heap->mem_alloc);
- retval = heap->chunk + H5HL_SIZEOF_HDR(f) + offset;
- FUNC_LEAVE(retval);
+ /* Set return value */
+ ret_value = heap->chunk + H5HL_SIZEOF_HDR(f) + offset;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_remove_free
@@ -571,6 +556,7 @@ H5HL_remove_free(H5HL_t *heap, H5HL_free_t *fl)
FUNC_LEAVE(H5FL_FREE(H5HL_free_t,fl));
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_insert
@@ -598,6 +584,7 @@ H5HL_insert(H5F_t *f, haddr_t addr, size_t buf_size, const void *buf)
size_t offset = 0;
size_t need_size, old_size, need_more;
hbool_t found;
+ size_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5HL_insert, (size_t)(-1));
@@ -606,15 +593,11 @@ H5HL_insert(H5F_t *f, haddr_t addr, size_t buf_size, const void *buf)
assert(H5F_addr_defined(addr));
assert(buf_size > 0);
assert(buf);
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, (size_t)(-1),
- "no write intent on file");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, (size_t)(-1), "no write intent on file");
- if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, (size_t)(-1),
- "unable to load heap");
- }
+ if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, (size_t)(-1), "unable to load heap");
heap->dirty += 1;
/*
@@ -686,10 +669,8 @@ H5HL_insert(H5F_t *f, haddr_t addr, size_t buf_size, const void *buf)
*/
offset = heap->mem_alloc;
if (need_more - need_size >= H5HL_SIZEOF_FREE(f)) {
- if (NULL==(fl = H5FL_ALLOC(H5HL_free_t,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1),
- "memory allocation failed");
- }
+ if (NULL==(fl = H5FL_ALLOC(H5HL_free_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed");
fl->offset = heap->mem_alloc + need_size;
fl->size = need_more - need_size;
assert (fl->offset==H5HL_ALIGN (fl->offset));
@@ -719,10 +700,8 @@ H5HL_insert(H5F_t *f, haddr_t addr, size_t buf_size, const void *buf)
heap->mem_alloc += need_more;
heap->chunk = H5FL_BLK_REALLOC(heap_chunk,heap->chunk,
(H5HL_SIZEOF_HDR(f) + heap->mem_alloc));
- if (NULL==heap->chunk) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1),
- "memory allocation failed");
- }
+ if (NULL==heap->chunk)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, (size_t)(-1), "memory allocation failed");
/* clear new section so junk doesn't appear in the file */
HDmemset(heap->chunk + H5HL_SIZEOF_HDR(f) + old_size, 0, need_more);
@@ -731,8 +710,14 @@ H5HL_insert(H5F_t *f, haddr_t addr, size_t buf_size, const void *buf)
* Copy the data into the heap
*/
HDmemcpy(heap->chunk + H5HL_SIZEOF_HDR(f) + offset, buf, buf_size);
- FUNC_LEAVE(offset);
+
+ /* Set return value */
+ ret_value=offset;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_write
@@ -760,6 +745,7 @@ herr_t
H5HL_write(H5F_t *f, haddr_t addr, size_t offset, size_t size, const void *buf)
{
H5HL_t *heap = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HL_write, FAIL);
@@ -768,23 +754,21 @@ H5HL_write(H5F_t *f, haddr_t addr, size_t offset, size_t size, const void *buf)
assert(H5F_addr_defined(addr));
assert(buf);
assert (offset==H5HL_ALIGN (offset));
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file");
- if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
- }
+ if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
assert(offset < heap->mem_alloc);
assert(offset + size <= heap->mem_alloc);
heap->dirty += 1;
HDmemcpy(heap->chunk + H5HL_SIZEOF_HDR(f) + offset, buf, size);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_remove
@@ -818,6 +802,7 @@ H5HL_remove(H5F_t *f, haddr_t addr, size_t offset, size_t size)
{
H5HL_t *heap = NULL;
H5HL_free_t *fl = NULL, *fl2 = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HL_remove, FAIL);
@@ -826,16 +811,12 @@ H5HL_remove(H5F_t *f, haddr_t addr, size_t offset, size_t size)
assert(H5F_addr_defined(addr));
assert(size > 0);
assert (offset==H5HL_ALIGN (offset));
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file");
size = H5HL_ALIGN (size);
- if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
- }
+ if (NULL == (heap = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
assert(offset < heap->mem_alloc);
assert(offset + size <= heap->mem_alloc);
fl = heap->freelist;
@@ -861,11 +842,11 @@ H5HL_remove(H5F_t *f, haddr_t addr, size_t offset, size_t size)
assert (fl->offset==H5HL_ALIGN (fl->offset));
assert (fl->size==H5HL_ALIGN (fl->size));
fl2 = H5HL_remove_free(heap, fl2);
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
fl2 = fl2->next;
}
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
} else if (fl->offset + fl->size == offset) {
fl->size += size;
@@ -876,11 +857,11 @@ H5HL_remove(H5F_t *f, haddr_t addr, size_t offset, size_t size)
fl->size += fl2->size;
assert (fl->size==H5HL_ALIGN (fl->size));
fl2 = H5HL_remove_free(heap, fl2);
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
fl2 = fl2->next;
}
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
fl = fl->next;
}
@@ -897,26 +878,27 @@ H5HL_remove(H5F_t *f, haddr_t addr, size_t offset, size_t size)
(unsigned long) size);
}
#endif
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
/*
* Add an entry to the free list.
*/
- if (NULL==(fl = H5FL_ALLOC(H5HL_free_t,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(fl = H5FL_ALLOC(H5HL_free_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
fl->offset = offset;
fl->size = size;
assert (fl->offset==H5HL_ALIGN (fl->offset));
assert (fl->size==H5HL_ALIGN (fl->size));
fl->prev = NULL;
fl->next = heap->freelist;
- if (heap->freelist) heap->freelist->prev = fl;
+ if (heap->freelist)
+ heap->freelist->prev = fl;
heap->freelist = fl;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5HL_debug
@@ -943,6 +925,7 @@ H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)
H5HL_free_t *freelist = NULL;
uint8_t *marker = NULL;
size_t amount_free = 0;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5HL_debug, FAIL);
@@ -953,10 +936,8 @@ H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)
assert(indent >= 0);
assert(fwidth >= 0);
- if (NULL == (h = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
- }
+ if (NULL == (h = H5AC_find(f, H5AC_LHEAP, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL, "unable to load heap");
fprintf(stream, "%*sLocal Heap...\n", indent, "");
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
"Dirty:",
@@ -979,10 +960,8 @@ H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)
* the heap and that no two free blocks point to the same region of
* the heap.
*/
- if (NULL==(marker = H5MM_calloc(h->mem_alloc))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(marker = H5MM_calloc(h->mem_alloc)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
for (freelist = h->freelist; freelist; freelist = freelist->next) {
fprintf(stream, "%*s%-*s %8lu, %8lu\n", indent, "", fwidth,
"Free Block (offset,size):",
@@ -1051,5 +1030,7 @@ H5HL_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, int fwidth)
}
H5MM_xfree(marker);
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5I.c b/src/H5I.c
index bf85308..2d668ea 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -259,19 +259,24 @@ H5I_nmembers(H5I_type_t grp)
H5I_id_info_t *cur=NULL;
int n=0;
unsigned i;
+ int ret_value;
FUNC_ENTER_NOAPI(H5I_nmembers, FAIL);
if (grp<=H5I_BADID || grp>=H5I_NGROUPS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number");
if (NULL==(grp_ptr=H5I_id_group_list_g[grp]) || grp_ptr->count<=0)
- HRETURN(0);
+ HGOTO_DONE(0);
for (i=0; i<grp_ptr->hash_size; i++)
for (cur=grp_ptr->id_list[i]; cur; cur=cur->next)
n++;
- FUNC_LEAVE(n);
+ /* Set return value */
+ ret_value=n;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -874,14 +879,14 @@ H5I_dec_ref(hid_t id)
H5I_type_t grp = H5I_GROUP(id); /*group the object is in*/
H5I_id_group_t *grp_ptr = NULL; /*ptr to the group */
H5I_id_info_t *id_ptr = NULL; /*ptr to the new ID */
- int ret_value = FAIL; /*return value */
+ int ret_value; /*return value */
FUNC_ENTER_NOAPI(H5I_dec_ref, FAIL);
/* Check arguments */
grp_ptr = H5I_id_group_list_g[grp];
if (grp_ptr == NULL || grp_ptr->count <= 0)
- HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number");
/* General lookup of the ID */
if ((id_ptr=H5I_find_id(id))) {
@@ -907,6 +912,8 @@ H5I_dec_ref(hid_t id)
ret_value = --(id_ptr->count);
}
}
+
+done:
FUNC_LEAVE(ret_value);
}
@@ -933,22 +940,27 @@ H5I_inc_ref(hid_t id)
H5I_type_t grp = H5I_GROUP(id); /*group the object is in*/
H5I_id_group_t *grp_ptr = NULL; /*ptr to the group */
H5I_id_info_t *id_ptr = NULL; /*ptr to the ID */
+ int ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5I_inc_ref, FAIL);
/* Check arguments */
if (id<0)
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID");
grp_ptr = H5I_id_group_list_g[grp];
if (!grp_ptr || grp_ptr->count<=0)
- HRETURN_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group");
/* General lookup of the ID */
if (NULL==(id_ptr=H5I_find_id(id)))
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID");
id_ptr->count++;
- FUNC_LEAVE(id_ptr->count);
+ /* Set return value */
+ ret_value=id_ptr->count;
+
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5MF.c b/src/H5MF.c
index 91b8553..660f849 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -59,7 +59,7 @@ static int interface_initialize_g = 0;
haddr_t
H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size)
{
- haddr_t ret_value=HADDR_UNDEF;
+ haddr_t ret_value;
FUNC_ENTER_NOAPI(H5MF_alloc, HADDR_UNDEF);
@@ -68,20 +68,20 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size)
assert(size > 0);
/* Fail if we don't have write access */
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "file is read-only");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "file is read-only");
/* Allocate space from the virtual file layer */
- if (HADDR_UNDEF==(ret_value=H5FD_alloc(f->shared->lf, type, size))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation failed");
- }
+ if (HADDR_UNDEF==(ret_value=H5FD_alloc(f->shared->lf, type, size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed");
/* Convert absolute file address to relative file address */
assert(ret_value>=f->shared->base_addr);
+
+ /* Set return value */
ret_value -= f->shared->base_addr;
+done:
FUNC_LEAVE(ret_value);
}
@@ -109,13 +109,14 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size)
herr_t
H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5MF_xfree, FAIL);
/* check arguments */
assert(f);
- if (!H5F_addr_defined(addr) || 0 == size) {
- HRETURN(SUCCEED);
- }
+ if (!H5F_addr_defined(addr) || 0 == size)
+ HGOTO_DONE(SUCCEED);
assert(addr!=0);
/* Convert relative address to absolute address */
@@ -132,7 +133,8 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size)
#endif
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -175,7 +177,7 @@ haddr_t
H5MF_realloc(H5F_t *f, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
hsize_t new_size)
{
- haddr_t ret_value=HADDR_UNDEF;
+ haddr_t ret_value;
FUNC_ENTER_NOAPI(H5MF_realloc, HADDR_UNDEF);
@@ -185,14 +187,15 @@ H5MF_realloc(H5F_t *f, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
/* Reallocate memory from the virtual file layer */
ret_value = H5FD_realloc(f->shared->lf, type, old_addr, old_size,
new_size);
- if (HADDR_UNDEF==ret_value) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF,
- "unable to allocate new file memory");
- }
+ if (HADDR_UNDEF==ret_value)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "unable to allocate new file memory");
/* Convert return value to relative address */
assert(ret_value>=f->shared->base_addr);
+
+ /* Set return value */
ret_value -= f->shared->base_addr;
+done:
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5MM.c b/src/H5MM.c
index 3acc30b..fbd66f7 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -50,11 +50,14 @@ static int interface_initialize_g = 0;
void *
H5MM_realloc(void *mem, size_t size)
{
+ void *ret_value;
+
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5MM_realloc);
if (!mem) {
- if (0 == size) HRETURN(NULL);
+ if (0 == size)
+ HGOTO_DONE(NULL);
mem = H5MM_malloc(size);
} else if (0 == size) {
@@ -65,7 +68,11 @@ H5MM_realloc(void *mem, size_t size)
assert(mem);
}
- FUNC_LEAVE(mem);
+ /* Set return value */
+ ret_value=mem;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -91,17 +98,19 @@ H5MM_realloc(void *mem, size_t size)
char *
H5MM_xstrdup(const char *s)
{
- char *mem;
+ char *ret_value;
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5MM_xstrdup);
- if (!s) HRETURN(NULL);
- mem = H5MM_malloc(HDstrlen(s) + 1);
- assert (mem);
- HDstrcpy(mem, s);
+ if (!s)
+ HGOTO_DONE(NULL);
+ ret_value = H5MM_malloc(HDstrlen(s) + 1);
+ assert (ret_value);
+ HDstrcpy(ret_value, s);
- FUNC_LEAVE(mem);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -127,21 +136,18 @@ H5MM_xstrdup(const char *s)
char *
H5MM_strdup(const char *s)
{
- char *mem;
+ char *ret_value;
FUNC_ENTER_NOAPI(H5MM_strdup, NULL);
- if (!s) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL,
- "null string");
- }
- if (NULL==(mem = H5MM_malloc(HDstrlen(s) + 1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- HDstrcpy(mem, s);
+ if (!s)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "null string");
+ if (NULL==(ret_value = H5MM_malloc(HDstrlen(s) + 1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HDstrcpy(ret_value, s);
- FUNC_LEAVE (mem);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -172,7 +178,8 @@ H5MM_xfree(void *mem)
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5MM_xfree);
- if (mem) HDfree(mem);
+ if (mem)
+ HDfree(mem);
FUNC_LEAVE(NULL);
}
diff --git a/src/H5O.c b/src/H5O.c
index 827fdad..aede4d4 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -156,6 +156,7 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
hsize_t size; /*total size of object header */
H5O_t *oh = NULL;
haddr_t tmp_addr;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_create, FAIL);
@@ -168,16 +169,12 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
/* allocate disk space for header and first chunk */
size = H5O_SIZEOF_HDR(f) + size_hint;
ent->file = f;
- if (HADDR_UNDEF==(ent->header=H5MF_alloc(f, H5FD_MEM_OHDR, size))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "file allocation failed for object header header");
- }
+ if (HADDR_UNDEF==(ent->header=H5MF_alloc(f, H5FD_MEM_OHDR, size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header header");
/* allocate the object header and fill in header fields */
- if (NULL==(oh = H5FL_ALLOC(H5O_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(oh = H5FL_ALLOC(H5O_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
oh->dirty = TRUE;
oh->version = H5O_VERSION;
oh->nlink = 0;
@@ -185,26 +182,20 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
/* create the chunk list and initialize the first chunk */
oh->nchunks = 1;
oh->alloc_nchunks = H5O_NCHUNKS;
- if (NULL==(oh->chunk=H5FL_ARR_ALLOC(H5O_chunk_t,oh->alloc_nchunks,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(oh->chunk=H5FL_ARR_ALLOC(H5O_chunk_t,oh->alloc_nchunks,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
tmp_addr = ent->header + (hsize_t)H5O_SIZEOF_HDR(f);
oh->chunk[0].dirty = TRUE;
oh->chunk[0].addr = tmp_addr;
oh->chunk[0].size = size_hint;
- if (NULL==(oh->chunk[0].image = H5FL_BLK_ALLOC(chunk_image,size_hint,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(oh->chunk[0].image = H5FL_BLK_ALLOC(chunk_image,size_hint,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* create the message list and initialize the first message */
oh->nmesgs = 1;
oh->alloc_nmesgs = H5O_NMESGS;
- if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,oh->alloc_nmesgs,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,oh->alloc_nmesgs,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
oh->mesg[0].type = H5O_NULL;
oh->mesg[0].dirty = TRUE;
oh->mesg[0].native = NULL;
@@ -215,16 +206,15 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
/* cache it */
if (H5AC_set(f, H5AC_OHDR, ent->header, oh) < 0) {
H5FL_FREE(H5O_t,oh);
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to cache object header");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to cache object header");
}
/* open it */
- if (H5O_open(ent) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL,
- "unable to open object header");
- }
- FUNC_LEAVE(SUCCEED);
+ if (H5O_open(ent) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -253,13 +243,13 @@ H5O_open(H5G_entry_t *obj_ent)
assert(obj_ent->file);
#ifdef H5O_DEBUG
- if (H5DEBUG(O)) {
+ if (H5DEBUG(O))
HDfprintf(H5DEBUG(O), "> %a\n", obj_ent->header);
- }
#endif
/* Increment open-lock counters */
obj_ent->file->nopen_objs++;
+
FUNC_LEAVE(SUCCEED);
}
@@ -308,9 +298,8 @@ H5O_close(H5G_entry_t *obj_ent)
* pending then close the file and remove it from the H5I_FILE_CLOSING ID
* group.
*/
- if (0==obj_ent->file->nopen_objs && obj_ent->file->closing) {
+ if (0==obj_ent->file->nopen_objs && obj_ent->file->closing)
H5I_dec_ref(obj_ent->file->closing);
- }
FUNC_LEAVE(SUCCEED);
}
@@ -350,7 +339,7 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
void * UNUSED _udata2)
{
H5O_t *oh = NULL;
- H5O_t *ret_value = NULL;
+ H5O_t *ret_value;
uint8_t buf[16], *p;
size_t mesg_size;
size_t hdr_size;
@@ -372,26 +361,20 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
assert(!_udata2);
/* allocate ohdr and init chunk list */
- if (NULL==(oh = H5FL_ALLOC(H5O_t,1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(oh = H5FL_ALLOC(H5O_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* read fixed-lenth part of object header */
hdr_size = H5O_SIZEOF_HDR(f);
assert(hdr_size<=sizeof(buf));
- if (H5F_block_read(f, H5FD_MEM_OHDR, addr, hdr_size, dxpl_id, buf) < 0) {
- HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL,
- "unable to read object header");
- }
+ if (H5F_block_read(f, H5FD_MEM_OHDR, addr, hdr_size, dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header");
p = buf;
/* decode version */
oh->version = *p++;
- if (H5O_VERSION != oh->version) {
- HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL,
- "bad object header version number");
- }
+ if (H5O_VERSION != oh->version)
+ HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "bad object header version number");
/* reserved */
p++;
@@ -408,10 +391,8 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
/* build the message array */
oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs);
- if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,oh->alloc_nmesgs,1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(oh->mesg=H5FL_ARR_ALLOC(H5O_mesg_t,oh->alloc_nmesgs,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* read each chunk from disk */
while (H5F_addr_defined(chunk_addr)) {
@@ -421,10 +402,8 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
unsigned na = oh->alloc_nchunks + H5O_NCHUNKS;
H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na);
- if (!x) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
oh->alloc_nchunks = na;
oh->chunk = x;
}
@@ -434,15 +413,11 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
oh->chunk[chunkno].dirty = FALSE;
oh->chunk[chunkno].addr = chunk_addr;
oh->chunk[chunkno].size = chunk_size;
- if (NULL==(oh->chunk[chunkno].image = H5FL_BLK_ALLOC(chunk_image,chunk_size,0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(oh->chunk[chunkno].image = H5FL_BLK_ALLOC(chunk_image,chunk_size,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
if (H5F_block_read(f, H5FD_MEM_OHDR, chunk_addr, chunk_size, dxpl_id,
- oh->chunk[chunkno].image) < 0) {
- HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL,
- "unable to read object header data");
- }
+ oh->chunk[chunkno].image) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL, "unable to read object header data");
/* load messages from this chunk */
for (p = oh->chunk[chunkno].image;
@@ -454,14 +429,10 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
flags = *p++;
p += 3; /*reserved*/
- if (id >= NELMTS(message_type_g) || NULL == message_type_g[id]) {
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL,
- "corrupt object header");
- }
- if (p + mesg_size > oh->chunk[chunkno].image + chunk_size) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "corrupt object header");
- }
+ if (id >= NELMTS(message_type_g) || NULL == message_type_g[id])
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "corrupt object header");
+ if (p + mesg_size > oh->chunk[chunkno].image + chunk_size)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "corrupt object header");
if (H5O_NULL_ID == id && oh->nmesgs > 0 &&
H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id &&
oh->mesg[oh->nmesgs - 1].chunkno == chunkno) {
@@ -470,10 +441,8 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
oh->mesg[mesgno].raw_size += H5O_SIZEOF_MSGHDR(f) + mesg_size;
} else {
/* new message */
- if (oh->nmesgs >= nmesgs) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "corrupt object header");
- }
+ if (oh->nmesgs >= nmesgs)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header");
mesgno = oh->nmesgs++;
oh->mesg[mesgno].type = message_type_g[id];
oh->mesg[mesgno].dirty = FALSE;
@@ -501,6 +470,8 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void * UNUSED _udata1,
}
}
}
+
+ /* Set return value */
ret_value = oh;
done:
@@ -516,6 +487,7 @@ done:
oh->mesg = H5FL_ARR_FREE(H5O_mesg_t,oh->mesg);
H5FL_FREE(H5O_t,oh);
}
+
FUNC_LEAVE(ret_value);
}
@@ -556,6 +528,7 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
H5O_cont_t *cont = NULL;
herr_t (*encode)(H5F_t*, uint8_t*, const void*) = NULL;
unsigned combine=0; /* Whether to combine the object header prefix & the first chunk */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_flush, FAIL);
@@ -594,10 +567,8 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
} /* end if */
else {
if (H5F_block_write(f, H5FD_MEM_OHDR, addr, H5O_SIZEOF_HDR(f),
- dxpl_id, buf) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to write object header hdr to disk");
- }
+ dxpl_id, buf) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header hdr to disk");
} /* end else */
/* encode messages */
@@ -625,10 +596,8 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
assert(!H5F_addr_defined(oh->chunk[cont->chunkno].addr));
cont->size = oh->chunk[cont->chunkno].size;
if (HADDR_UNDEF==(cont->addr=H5MF_alloc(f,
- H5FD_MEM_OHDR, (hsize_t)cont->size))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate space for object header data");
- }
+ H5FD_MEM_OHDR, (hsize_t)cont->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for object header data");
oh->chunk[cont->chunkno].addr = cont->addr;
}
@@ -649,10 +618,8 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
} else {
encode = oh->mesg[u].type->encode;
}
- if ((encode)(f, oh->mesg[u].raw, oh->mesg[u].native)<0) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL,
- "unable to encode object header message");
- }
+ if ((encode)(f, oh->mesg[u].raw, oh->mesg[u].native)<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode object header message");
}
oh->mesg[u].dirty = FALSE;
oh->chunk[oh->mesg[u].chunkno].dirty = TRUE;
@@ -666,7 +633,7 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
if(u==0 && combine) {
/* Allocate space for the combined prefix and first chunk */
if((p=H5FL_BLK_ALLOC(chunk_image,(H5O_SIZEOF_HDR(f)+oh->chunk[u].size),0))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Copy in the prefix */
HDmemcpy(p,buf,H5O_SIZEOF_HDR(f));
@@ -677,10 +644,8 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
/* Write the combined prefix/chunk out */
if (H5F_block_write(f, H5FD_MEM_OHDR, addr,
(H5O_SIZEOF_HDR(f)+oh->chunk[u].size),
- dxpl_id, p) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to write object header data to disk");
- } /* end if */
+ dxpl_id, p) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk");
/* Release the memory for the combined prefix/chunk */
p = H5FL_BLK_FREE(chunk_image,p);
@@ -688,10 +653,8 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
else {
if (H5F_block_write(f, H5FD_MEM_OHDR, oh->chunk[u].addr,
(oh->chunk[u].size),
- dxpl_id, oh->chunk[u].image) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to write object header data to disk");
- } /* end if */
+ dxpl_id, oh->chunk[u].image) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to write object header data to disk");
} /* end else */
oh->chunk[u].dirty = FALSE;
} /* end if */
@@ -701,15 +664,8 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
if (destroy) {
/* destroy chunks */
- /*the conditional below is because of the microsoft c run time library
- it calls its own version of malloc and free and does checks on the mem.
- causes problems with this code so i am taking it out for the win32 debug
- version until i can figure out a way around it*/
-/* I commented this back in to use the new free list routines - QAK 3/23/00 */
-/* #if !defined(WIN32) && !defined(_DEBUG) */
for (u = 0; u < oh->nchunks; u++)
oh->chunk[u].image = H5FL_BLK_FREE(chunk_image,oh->chunk[u].image);
-/* #endif */
oh->chunk = H5FL_ARR_FREE(H5O_chunk_t,oh->chunk);
/* destroy messages */
@@ -725,7 +681,9 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
/* destroy object header */
H5FL_FREE(H5O_t,oh);
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -749,19 +707,21 @@ H5O_flush(H5F_t *f, hid_t dxpl_id, hbool_t destroy, haddr_t addr, H5O_t *oh)
herr_t
H5O_reset(const H5O_class_t *type, void *native)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5O_reset, FAIL);
if (native) {
if (type->reset) {
- if ((type->reset) (native) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "reset method failed");
- }
+ if ((type->reset) (native) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "reset method failed");
} else {
HDmemset(native, 0, type->native_size);
}
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -827,12 +787,11 @@ H5O_copy (const H5O_class_t *type, const void *mesg, void *dst)
assert (type->copy);
if (mesg) {
- if (NULL==(ret_value=(type->copy)(mesg, dst))) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
- "unable to copy object header message");
- }
+ if (NULL==(ret_value=(type->copy)(mesg, dst)))
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy object header message");
}
+done:
FUNC_LEAVE (ret_value);
}
@@ -873,24 +832,18 @@ H5O_link(H5G_entry_t *ent, int adjust)
assert(ent);
assert(ent->file);
assert(H5F_addr_defined(ent->header));
- if (adjust!=0 && 0==(ent->file->intent & H5F_ACC_RDWR)) {
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+ if (adjust!=0 && 0==(ent->file->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file");
/* get header */
if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, ent->header,
- NULL, NULL))) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
+ NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
/* adjust link count */
if (adjust<0) {
- if (oh->nlink + adjust < 0) {
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL,
- "link count would be negative");
- }
+ if (oh->nlink + adjust < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "link count would be negative");
oh->nlink += adjust;
oh->dirty = TRUE;
} else if (adjust>0) {
@@ -898,12 +851,13 @@ H5O_link(H5G_entry_t *ent, int adjust)
oh->dirty = TRUE;
}
+ /* Set return value */
ret_value = oh->nlink;
- done:
- if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
+
+done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0 && ret_value>=0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+
FUNC_LEAVE(ret_value);
}
@@ -931,6 +885,7 @@ H5O_count (H5G_entry_t *ent, const H5O_class_t *type)
H5O_t *oh = NULL;
int acc;
unsigned u;
+ int ret_value;
FUNC_ENTER_NOAPI(H5O_count, FAIL);
@@ -941,16 +896,18 @@ H5O_count (H5G_entry_t *ent, const H5O_class_t *type)
assert (type);
/* Load the object header */
- if (NULL==(oh=H5AC_find (ent->file, H5AC_OHDR, ent->header, NULL, NULL))) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
+ if (NULL==(oh=H5AC_find (ent->file, H5AC_OHDR, ent->header, NULL, NULL)))
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
for (u=acc=0; u<oh->nmesgs; u++) {
if (oh->mesg[u].type==type)
acc++;
}
+ /* Set return value */
+ ret_value=acc;
+
+done:
FUNC_LEAVE (acc);
}
@@ -980,6 +937,7 @@ H5O_exists(H5G_entry_t *ent, const H5O_class_t *type, int sequence)
{
H5O_t *oh=NULL;
unsigned u;
+ htri_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_exists, FAIL);
@@ -989,10 +947,8 @@ H5O_exists(H5G_entry_t *ent, const H5O_class_t *type, int sequence)
assert(sequence>=0);
/* Load the object header */
- if (NULL==(oh=H5AC_find(ent->file, H5AC_OHDR, ent->header, NULL, NULL))) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
+ if (NULL==(oh=H5AC_find(ent->file, H5AC_OHDR, ent->header, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
/* Scan through the messages looking for the right one */
for (u=0; u<oh->nmesgs; u++) {
@@ -1002,7 +958,11 @@ H5O_exists(H5G_entry_t *ent, const H5O_class_t *type, int sequence)
break;
}
- FUNC_LEAVE(sequence<0);
+ /* Set return value */
+ ret_value=(sequence<0);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1054,23 +1014,17 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mesg)
if (H5O_fast_g[cache_type]) {
ret_value = (H5O_fast_g[cache_type]) (cache, type, mesg);
if (ret_value)
- HRETURN(ret_value);
+ HGOTO_DONE(ret_value);
H5E_clear(); /*don't care, try reading from header */
}
/* can we get it from the object header? */
- if ((idx = H5O_find_in_ohdr(ent->file, ent->header, &type,
- sequence)) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL,
- "unable to find message in object header");
- }
+ if ((idx = H5O_find_in_ohdr(ent->file, ent->header, &type, sequence)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "unable to find message in object header");
/* copy the message to the user-supplied buffer */
- if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, ent->header,
- NULL, NULL))) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "unable to load object header");
- }
+ if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, ent->header, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header");
if (oh->mesg[idx].flags & H5O_FLAG_SHARED) {
/*
* If the message is shared then then the native pointer points to an
@@ -1082,17 +1036,12 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mesg)
shared = (H5O_shared_t *)(oh->mesg[idx].native);
if (shared->in_gh) {
- if (NULL==(tmp_buf = H5HG_read (ent->file, &(shared->u.gh),
- NULL))) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
- "unable to read shared message from global heap");
- }
+ if (NULL==(tmp_buf = H5HG_read (ent->file, &(shared->u.gh), NULL)))
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL, "unable to read shared message from global heap");
tmp_mesg = (type->decode)(ent->file, tmp_buf, shared);
tmp_buf = H5MM_xfree (tmp_buf);
- if (!tmp_mesg) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
- "unable to decode object header shared message");
- }
+ if (!tmp_mesg)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL, "unable to decode object header shared message");
if (mesg) {
HDmemcpy (mesg, tmp_mesg, type->native_size);
H5MM_xfree (tmp_mesg);
@@ -1102,10 +1051,8 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mesg)
} else {
ret_value = H5O_read (&(shared->u.ent), type, 0, mesg);
if (type->set_share &&
- (type->set_share)(ent->file, ret_value, shared)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
- "unable to set sharing information");
- }
+ (type->set_share)(ent->file, ret_value, shared)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to set sharing information");
}
} else {
/*
@@ -1114,18 +1061,14 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, int sequence, void *mesg)
* the raw message) so we must copy the native message before
* returning.
*/
- if (NULL==(ret_value = (type->copy) (oh->mesg[idx].native, mesg))) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
- "unable to copy message to user space");
- }
+ if (NULL==(ret_value = (type->copy) (oh->mesg[idx].native, mesg)))
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL, "unable to copy message to user space");
}
- done:
- if (H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, NULL,
- "unable to release object header");
- }
- oh = NULL;
+done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0 && ret_value!=NULL)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, NULL, "unable to release object header");
+
FUNC_LEAVE(ret_value);
}
@@ -1156,6 +1099,7 @@ H5O_find_in_ohdr(H5F_t *f, haddr_t addr, const H5O_class_t **type_p,
H5O_t *oh = NULL;
unsigned u;
const H5O_class_t *type = NULL;
+ unsigned ret_value;
FUNC_ENTER_NOINIT(H5O_find_in_ohdr);
@@ -1165,10 +1109,8 @@ H5O_find_in_ohdr(H5F_t *f, haddr_t addr, const H5O_class_t **type_p,
assert(type_p);
/* Load the object header */
- if (NULL == (oh = H5AC_find(f, H5AC_OHDR, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, UFAIL,
- "unable to load object header");
- }
+ if (NULL == (oh = H5AC_find(f, H5AC_OHDR, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, UFAIL, "unable to load object header");
/* Scan through the messages looking for the right one */
for (u = 0; u < oh->nmesgs; u++) {
@@ -1177,10 +1119,8 @@ H5O_find_in_ohdr(H5F_t *f, haddr_t addr, const H5O_class_t **type_p,
if (--sequence < 0)
break;
}
- if (sequence >= 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_NOTFOUND, UFAIL,
- "unable to find object header message");
- }
+ if (sequence >= 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, UFAIL, "unable to find object header message");
/*
* Decode the message if necessary. If the message is shared then decode
@@ -1194,10 +1134,8 @@ H5O_find_in_ohdr(H5F_t *f, haddr_t addr, const H5O_class_t **type_p,
if (NULL == oh->mesg[u].native) {
assert(type->decode);
oh->mesg[u].native = (type->decode) (f, oh->mesg[u].raw, NULL);
- if (NULL == oh->mesg[u].native) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTDECODE, UFAIL,
- "unable to decode message");
- }
+ if (NULL == oh->mesg[u].native)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, UFAIL, "unable to decode message");
}
/*
@@ -1205,7 +1143,12 @@ H5O_find_in_ohdr(H5F_t *f, haddr_t addr, const H5O_class_t **type_p,
* pointed-to type.
*/
*type_p = oh->mesg[u].type;
- FUNC_LEAVE(u);
+
+ /* Set return value */
+ ret_value=u;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1266,16 +1209,12 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
assert(type);
assert(mesg);
assert (0==(flags & ~H5O_FLAG_BITS));
- if (0==(ent->file->intent & H5F_ACC_RDWR)) {
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
- if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, ent->header,
- NULL, NULL))) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
+ if (0==(ent->file->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file");
+
+ if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, ent->header, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
/* Count similar messages */
for (idx = 0, sequence = -1; idx < oh->nmesgs; idx++) {
@@ -1287,7 +1226,7 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
/* Was the right message found? */
if (overwrite >= 0 &&
- (idx >= oh->nmesgs || sequence != overwrite)) {
+ (idx >= oh->nmesgs || sequence != overwrite)) {
/* But can we insert a new one with this sequence number? */
if (overwrite == sequence + 1) {
@@ -1299,10 +1238,8 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
if (overwrite < 0) {
/* Allocate space for the new message */
if (flags & H5O_FLAG_SHARED) {
- if (NULL==type->get_share) {
- HGOTO_ERROR (H5E_OHDR, H5E_UNSUPPORTED, FAIL,
- "message class is not sharable");
- }
+ if (NULL==type->get_share)
+ HGOTO_ERROR (H5E_OHDR, H5E_UNSUPPORTED, FAIL, "message class is not sharable");
if ((type->get_share)(ent->file, mesg, &sh_mesg/*out*/)<0) {
/*
* If the message isn't shared then turn off the shared bit
@@ -1315,10 +1252,8 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
* The shared message is stored in the global heap.
* Increment the reference count on the global heap message.
*/
- if (H5HG_link (ent->file, &(sh_mesg.u.gh), 1)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
- "unable to adjust shared object link count");
- }
+ if (H5HG_link (ent->file, &(sh_mesg.u.gh), 1)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count");
size = (H5O_SHARED->raw_size)(ent->file, &sh_mesg);
} else {
/*
@@ -1327,56 +1262,41 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
* new object header. Increment the reference count on that
* object header.
*/
- if (sh_mesg.u.ent.file->shared != ent->file->shared) {
- HGOTO_ERROR(H5E_OHDR, H5E_LINK, FAIL,
- "interfile hard links are not allowed");
- }
- if (H5O_link (&(sh_mesg.u.ent), 1)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
- "unable to adjust shared object link count");
- }
+ if (sh_mesg.u.ent.file->shared != ent->file->shared)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINK, FAIL, "interfile hard links are not allowed");
+ if (H5O_link (&(sh_mesg.u.ent), 1)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to adjust shared object link count");
size = (H5O_SHARED->raw_size)(ent->file, &sh_mesg);
}
}
if (0==(flags & H5O_FLAG_SHARED)) {
size = (type->raw_size) (ent->file, mesg);
- if (size>=65536) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
- "object header message is too large (16k max)");
- }
+ if (size>=65536)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL, "object header message is too large (16k max)");
}
idx = H5O_alloc(ent->file, oh, type, size);
- if (idx == UFAIL) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to allocate space for message");
- }
+ if (idx == UFAIL)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for message");
sequence++;
} else if (oh->mesg[idx].flags & H5O_FLAG_CONSTANT) {
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to modify constant message");
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify constant message");
} else if (oh->mesg[idx].flags & H5O_FLAG_SHARED) {
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to modify shared (constant) message");
+ HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL, "unable to modify shared (constant) message");
}
/* Copy the native value into the object header */
if (flags & H5O_FLAG_SHARED) {
- if (NULL==(oh->mesg[idx].native = H5MM_malloc (sizeof (H5O_shared_t)))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(oh->mesg[idx].native = H5MM_malloc (sizeof (H5O_shared_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
HDmemcpy(oh->mesg[idx].native,&sh_mesg,sizeof(H5O_shared_t));
} else {
- if (oh->mesg[idx].native) {
+ if (oh->mesg[idx].native)
H5O_reset (oh->mesg[idx].type, oh->mesg[idx].native);
- }
oh->mesg[idx].native = (type->copy) (mesg, oh->mesg[idx].native);
- if (NULL == oh->mesg[idx].native) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to copy message to object header");
- }
+ if (NULL == oh->mesg[idx].native)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to copy message to object header");
}
/* Update the modification time message if any */
@@ -1385,13 +1305,13 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, int overwrite,
oh->mesg[idx].flags = flags;
oh->mesg[idx].dirty = TRUE;
oh->dirty = TRUE;
+
+ /* Set return value */
ret_value = sequence;
- done:
- if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
+done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0 && ret_value!=NULL)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
FUNC_LEAVE(ret_value);
}
@@ -1419,6 +1339,7 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force)
unsigned idx;
time_t now = HDtime(NULL);
size_t size;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5O_touch_oh);
@@ -1433,27 +1354,23 @@ H5O_touch_oh(H5F_t *f, H5O_t *oh, hbool_t force)
/* Create a new message */
if (idx==oh->nmesgs) {
if (!force)
- HRETURN(SUCCEED); /*nothing to do*/
+ HGOTO_DONE(SUCCEED); /*nothing to do*/
size = (H5O_MTIME->raw_size)(f, &now);
- if ((idx=H5O_alloc(f, oh, H5O_MTIME, size))==UFAIL) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to allocate space for modification time message");
- }
+ if ((idx=H5O_alloc(f, oh, H5O_MTIME, size))==UFAIL)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for modification time message");
}
/* Update the native part */
if (NULL==oh->mesg[idx].native) {
- if (NULL==(oh->mesg[idx].native = H5FL_ALLOC(time_t,0))) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "memory allocation failed for modification time "
- "message");
- }
+ if (NULL==(oh->mesg[idx].native = H5FL_ALLOC(time_t,0)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "memory allocation failed for modification time message");
}
*((time_t*)(oh->mesg[idx].native)) = now;
oh->mesg[idx].dirty = TRUE;
oh->dirty = TRUE;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1478,7 +1395,7 @@ herr_t
H5O_touch(H5G_entry_t *ent, hbool_t force)
{
H5O_t *oh = NULL;
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_touch, FAIL);
@@ -1486,30 +1403,21 @@ H5O_touch(H5G_entry_t *ent, hbool_t force)
assert(ent);
assert(ent->file);
assert(H5F_addr_defined(ent->header));
- if (0==(ent->file->intent & H5F_ACC_RDWR)) {
- HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+ if (0==(ent->file->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL, "no write intent on file");
/* Get the object header */
- if (NULL==(oh=H5AC_protect(ent->file, H5AC_OHDR, ent->header,
- NULL, NULL))) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
+ if (NULL==(oh=H5AC_protect(ent->file, H5AC_OHDR, ent->header, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
/* Create/Update the modification time message */
- if (H5O_touch_oh(ent->file, oh, force)<0) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to update object modificaton time");
- }
- ret_value = SUCCEED;
+ if (H5O_touch_oh(ent->file, oh, force)<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to update object modificaton time");
+
+done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh)<0 && ret_value>=0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
- done:
- if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh)<0) {
- HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
FUNC_LEAVE(ret_value);
}
@@ -1545,7 +1453,7 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, int sequence)
H5O_t *oh = NULL;
int seq, nfailed = 0;
unsigned u;
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
H5O_shared_t *sh_mesg = NULL;
FUNC_ENTER_NOAPI(H5O_remove, FAIL);
@@ -1555,17 +1463,13 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, int sequence)
assert(ent->file);
assert(H5F_addr_defined(ent->header));
assert(type);
- if (0==(ent->file->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "no write intent on file");
- }
+
+ if (0==(ent->file->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file");
/* load the object header */
- if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, ent->header,
- NULL, NULL))) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
+ if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, ent->header, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
for (u = seq = 0; u < oh->nmesgs; u++) {
if (type->id != oh->mesg[u].type->id)
@@ -1584,23 +1488,15 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, int sequence)
if (NULL==oh->mesg[u].native) {
sh_mesg = (H5O_SHARED->decode)(ent->file, oh->mesg[u].raw,
NULL);
- if (NULL==(oh->mesg[u].native = sh_mesg)) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTDECODE, FAIL,
- "unable to decode shared message info");
- }
+ if (NULL==(oh->mesg[u].native = sh_mesg))
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode shared message info");
}
if (sh_mesg->in_gh) {
- if (H5HG_link (ent->file, &(sh_mesg->u.gh), -1)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
- "unable to decrement link count on "
- "shared message");
- }
+ if (H5HG_link (ent->file, &(sh_mesg->u.gh), -1)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to decrement link count on shared message");
} else {
- if (H5O_link (&(sh_mesg->u.ent), -1)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL,
- "unable to decrement link count on "
- "shared message");
- }
+ if (H5O_link (&(sh_mesg->u.ent), -1)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_LINK, FAIL, "unable to decrement link count on shared message");
}
}
@@ -1615,17 +1511,13 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, int sequence)
}
/* Fail if we tried to remove any constant messages */
- if (nfailed) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to remove constant message(s)");
- }
- ret_value = SUCCEED;
+ if (nfailed)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to remove constant message(s)");
+
+done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0 && ret_value>=0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
- done:
- if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, ent->header, oh) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
FUNC_LEAVE(ret_value);
}
@@ -1666,6 +1558,7 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size)
size_t delta, old_size;
size_t aligned_size = H5O_ALIGN(size);
uint8_t *old_addr;
+ unsigned ret_value;
FUNC_ENTER_NOINIT(H5O_alloc_extend_chunk);
@@ -1674,9 +1567,8 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size)
assert(chunkno < oh->nchunks);
assert(size > 0);
- if (H5F_addr_defined(oh->chunk[chunkno].addr)) {
- HRETURN_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "chunk is on disk");
- }
+ if (H5F_addr_defined(oh->chunk[chunkno].addr))
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "chunk is on disk");
/* try to extend a null message */
for (idx=0; idx<oh->nmesgs; idx++) {
@@ -1694,10 +1586,8 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size)
/* Be careful not to indroduce garbage */
oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image,old_addr,
(oh->chunk[chunkno].size + delta));
- if (NULL==oh->chunk[chunkno].image) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (NULL==oh->chunk[chunkno].image)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
HDmemset(oh->chunk[chunkno].image + oh->chunk[chunkno].size,
0, delta);
oh->chunk[chunkno].size += delta;
@@ -1705,13 +1595,12 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size)
/* adjust raw addresses for messages of this chunk */
if (old_addr != oh->chunk[chunkno].image) {
for (u = 0; u < oh->nmesgs; u++) {
- if (oh->mesg[u].chunkno == chunkno) {
+ if (oh->mesg[u].chunkno == chunkno)
oh->mesg[u].raw = oh->chunk[chunkno].image +
(oh->mesg[u].raw - old_addr);
- }
}
}
- HRETURN(idx);
+ HGOTO_DONE(idx);
}
}
@@ -1720,10 +1609,8 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size)
unsigned na = oh->alloc_nmesgs + H5O_NMESGS;
H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na);
- if (NULL==x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (NULL==x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
oh->alloc_nmesgs = na;
oh->mesg = x;
}
@@ -1744,23 +1631,25 @@ H5O_alloc_extend_chunk(H5O_t *oh, unsigned chunkno, size_t size)
oh->chunk[chunkno].size += delta;
oh->chunk[chunkno].image = H5FL_BLK_REALLOC(chunk_image,old_addr,
oh->chunk[chunkno].size);
- if (NULL==oh->chunk[chunkno].image) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (NULL==oh->chunk[chunkno].image)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
HDmemset(oh->chunk[chunkno].image+old_size, 0,
oh->chunk[chunkno].size - old_size);
/* adjust raw addresses for messages of this chunk */
if (old_addr != oh->chunk[chunkno].image) {
for (u = 0; u < oh->nmesgs; u++) {
- if (oh->mesg[u].chunkno == chunkno) {
+ if (oh->mesg[u].chunkno == chunkno)
oh->mesg[u].raw = oh->chunk[chunkno].image +
(oh->mesg[u].raw - old_addr);
- }
}
}
- FUNC_LEAVE(idx);
+
+ /* Set return value */
+ ret_value=idx;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1797,11 +1686,12 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
size_t cont_size; /*continuation message size */
int found_null = (-1); /*best fit null message */
int found_other = (-1); /*best fit other message */
- unsigned idx; /*message number return value */
+ unsigned idx; /*message number */
uint8_t *p = NULL; /*ptr into new chunk */
H5O_cont_t *cont = NULL; /*native continuation message */
int chunkno;
unsigned u;
+ unsigned ret_value; /*return value */
FUNC_ENTER_NOINIT(H5O_alloc_new_chunk);
@@ -1861,10 +1751,8 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
unsigned na = oh->alloc_nchunks + H5O_NCHUNKS;
H5O_chunk_t *x = H5FL_ARR_REALLOC (H5O_chunk_t, oh->chunk, na);
- if (!x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (!x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
oh->alloc_nchunks = na;
oh->chunk = x;
}
@@ -1872,10 +1760,8 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
oh->chunk[chunkno].dirty = TRUE;
oh->chunk[chunkno].addr = HADDR_UNDEF;
oh->chunk[chunkno].size = size;
- if (NULL==(oh->chunk[chunkno].image = p = H5FL_BLK_ALLOC(chunk_image,size,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (NULL==(oh->chunk[chunkno].image = p = H5FL_BLK_ALLOC(chunk_image,size,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
/*
* Make sure we have enough space for all possible new messages
@@ -1886,10 +1772,8 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
unsigned na = oh->alloc_nmesgs + MAX (H5O_NMESGS, 3);
H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na);
- if (!x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (!x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
oh->alloc_nmesgs = na;
oh->mesg = x;
@@ -1952,16 +1836,18 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
*/
oh->mesg[found_null].type = H5O_CONT;
oh->mesg[found_null].dirty = TRUE;
- if (NULL==(cont = H5MM_calloc(sizeof(H5O_cont_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (NULL==(cont = H5MM_calloc(sizeof(H5O_cont_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
cont->addr = HADDR_UNDEF;
cont->size = 0;
cont->chunkno = chunkno;
oh->mesg[found_null].native = cont;
- FUNC_LEAVE(idx);
+ /* Set return value */
+ ret_value=idx;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1989,6 +1875,7 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
unsigned idx;
unsigned null_idx;
size_t aligned_size = H5O_ALIGN(size);
+ unsigned ret_value; /* Return value */
FUNC_ENTER_NOINIT(H5O_alloc);
@@ -1999,7 +1886,7 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
/* look for a null message which is large enough */
for (idx = 0; idx < oh->nmesgs; idx++) {
if (H5O_NULL_ID == oh->mesg[idx].type->id &&
- oh->mesg[idx].raw_size >= aligned_size)
+ oh->mesg[idx].raw_size >= aligned_size)
break;
}
@@ -2030,10 +1917,8 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
* Create a new chunk
*/
if (idx == UFAIL) {
- if ((idx = H5O_alloc_new_chunk(f, oh, size)) == UFAIL) {
- HRETURN_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL,
- "unable to create a new object header data chunk");
- }
+ if ((idx = H5O_alloc_new_chunk(f, oh, size)) == UFAIL)
+ HGOTO_ERROR(H5E_OHDR, H5E_NOSPACE, UFAIL, "unable to create a new object header data chunk");
}
}
@@ -2046,10 +1931,8 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
unsigned na = oh->alloc_nmesgs + H5O_NMESGS;
H5O_mesg_t *x = H5FL_ARR_REALLOC (H5O_mesg_t, oh->mesg, na);
- if (!x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL,
- "memory allocation failed");
- }
+ if (!x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, UFAIL, "memory allocation failed");
oh->alloc_nmesgs = na;
oh->mesg = x;
@@ -2076,7 +1959,12 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
oh->mesg[idx].native = NULL;
oh->dirty = TRUE;
- FUNC_LEAVE(idx);
+
+ /* Set return value */
+ ret_value=idx;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2103,7 +1991,7 @@ H5O_share (H5F_t *f, const H5O_class_t *type, const void *mesg,
{
size_t size;
void *buf = NULL;
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_share, FAIL);
@@ -2115,23 +2003,18 @@ H5O_share (H5F_t *f, const H5O_class_t *type, const void *mesg,
/* Encode the message put it in the global heap */
if ((size = (type->raw_size)(f, mesg))>0) {
- if (NULL==(buf = H5MM_malloc (size))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- if ((type->encode)(f, buf, mesg)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL,
- "unable to encode message");
- }
- if (H5HG_insert (f, size, buf, hobj)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to store message in global heap");
- }
+ if (NULL==(buf = H5MM_malloc (size)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if ((type->encode)(f, buf, mesg)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL, "unable to encode message");
+ if (H5HG_insert (f, size, buf, hobj)<0)
+ HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL, "unable to store message in global heap");
}
- ret_value = SUCCEED;
- done:
- H5MM_xfree (buf);
+done:
+ if(buf)
+ H5MM_xfree (buf);
+
FUNC_LEAVE (ret_value);
}
@@ -2173,10 +2056,8 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)
assert(indent >= 0);
assert(fwidth >= 0);
- if (NULL == (oh = H5AC_protect(f, H5AC_OHDR, addr, NULL, NULL))) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
+ if (NULL == (oh = H5AC_protect(f, H5AC_OHDR, addr, NULL, NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to load object header");
/* debug */
HDfprintf(stream, "%*sObject Header...\n", indent, "");
@@ -2213,19 +2094,16 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)
"Address:", oh->chunk[i].addr);
tmp_addr = addr + (hsize_t)H5O_SIZEOF_HDR(f);
- if (0 == i && H5F_addr_ne(oh->chunk[i].addr, tmp_addr)) {
+ if (0 == i && H5F_addr_ne(oh->chunk[i].addr, tmp_addr))
HDfprintf(stream, "*** WRONG ADDRESS!\n");
- }
HDfprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3),
"Size in bytes:",
(unsigned long) (oh->chunk[i].size));
}
/* debug each message */
- if (NULL==(sequence = H5MM_calloc(NELMTS(message_type_g)*sizeof(int)))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(sequence = H5MM_calloc(NELMTS(message_type_g)*sizeof(int))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
for (i=0, mesg_total=0; i<oh->nmesgs; i++) {
mesg_total += H5O_SIZEOF_MSGHDR(f) + oh->mesg[i].raw_size;
HDfprintf(stream, "%*sMessage %d...\n", indent, "", i);
@@ -2263,14 +2141,13 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)
"Chunk number:",
(int) (oh->mesg[i].chunkno));
chunkno = oh->mesg[i].chunkno;
- if (chunkno >= oh->nchunks) {
+ if (chunkno >= oh->nchunks)
HDfprintf(stream, "*** BAD CHUNK NUMBER\n");
- }
/* check the size */
if ((oh->mesg[i].raw + oh->mesg[i].raw_size >
- oh->chunk[chunkno].image + oh->chunk[chunkno].size) ||
- (oh->mesg[i].raw < oh->chunk[chunkno].image)) {
+ oh->chunk[chunkno].image + oh->chunk[chunkno].size) ||
+ (oh->mesg[i].raw < oh->chunk[chunkno].image)) {
HDfprintf(stream, "*** BAD MESSAGE RAW ADDRESS\n");
}
@@ -2282,20 +2159,16 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)
decode = oh->mesg[i].type->decode;
debug = oh->mesg[i].type->debug;
}
- if (NULL==oh->mesg[i].native && oh->mesg[i].type->decode) {
+ if (NULL==oh->mesg[i].native && oh->mesg[i].type->decode)
oh->mesg[i].native = (decode)(f, oh->mesg[i].raw, NULL);
- }
- if (NULL==oh->mesg[i].native) {
+ if (NULL==oh->mesg[i].native)
debug = NULL;
- }
/* print the message */
- if (debug) {
+ if (debug)
(debug)(f, oh->mesg[i].native, stream, indent+3, MAX(0, fwidth-3));
- } else {
- HDfprintf(stream, "%*sNo info for this message.\n",
- indent + 3, "");
- }
+ else
+ HDfprintf(stream, "%*sNo info for this message.\n", indent + 3, "");
/* If the message is shared then also print the pointed-to message */
if (oh->mesg[i].flags & H5O_FLAG_SHARED) {
@@ -2317,15 +2190,12 @@ H5O_debug(H5F_t *f, haddr_t addr, FILE *stream, int indent, int fwidth)
}
sequence = H5MM_xfree(sequence);
- if (mesg_total != chunk_total) {
+ if (mesg_total != chunk_total)
HDfprintf(stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n");
- }
- ret_value = SUCCEED;
- done:
- if (oh && H5AC_unprotect(f, H5AC_OHDR, addr, oh) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
+done:
+ if (oh && H5AC_unprotect(f, H5AC_OHDR, addr, oh) < 0 && ret_value>=0)
+ HDONE_ERROR(H5E_OHDR, H5E_PROTECT, FAIL, "unable to release object header");
+
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Oattr.c b/src/H5Oattr.c
index a15a624..1ec7a3f 100644
--- a/src/H5Oattr.c
+++ b/src/H5Oattr.c
@@ -95,6 +95,7 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
H5S_simple_t *simple; /*simple dimensionality information */
size_t name_len; /*attribute name length */
int version; /*message version number*/
+ H5A_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_attr_decode, NULL);
@@ -103,12 +104,12 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
assert(p);
if (NULL==(attr = H5MM_calloc(sizeof(H5A_t))))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Version number */
version = *p++;
if (version!=H5O_ATTR_VERSION)
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for attribute message");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for attribute message");
/* Reserved */
p++;
@@ -123,18 +124,18 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
/* Decode and store the name */
if (NULL==(attr->name=H5MM_malloc(name_len)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy(attr->name,p,name_len);
p += H5O_ALIGN(name_len); /* advance the memory pointer */
/* decode the attribute datatype */
if((attr->dt=(H5O_DTYPE->decode)(f,p,NULL))==NULL)
- HRETURN_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype");
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDECODE, NULL, "can't decode attribute datatype");
p += H5O_ALIGN(attr->dt_size);
/* decode the attribute dataspace */
if (NULL==(attr->ds = H5FL_ALLOC(H5S_t,1)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
if((simple=(H5O_SDSPACE->decode)(f,p,NULL))!=NULL) {
attr->ds->extent.type = H5S_SIMPLE;
HDmemcpy(&(attr->ds->extent.u.simple),simple, sizeof(H5S_simple_t));
@@ -144,7 +145,7 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
}
/* Default to entire dataspace being selected */
if(H5S_select_all(attr->ds,0)<0)
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
p += H5O_ALIGN(attr->ds_size);
/* Compute the size of the data */
@@ -152,7 +153,7 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
/* Go get the data */
if (NULL==(attr->data = H5MM_malloc(attr->data_size)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy(attr->data,p,attr->data_size);
/* Indicate that the fill values aren't to be written out */
@@ -165,9 +166,14 @@ H5O_attr_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
}
#endif
- FUNC_LEAVE(attr);
+ /* Set return value */
+ ret_value=attr;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_attr_encode
@@ -196,6 +202,7 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
{
const H5A_t *attr = (const H5A_t *) mesg;
size_t name_len; /* Attribute name length */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_attr_encode, FAIL);
@@ -229,27 +236,25 @@ H5O_attr_encode(H5F_t *f, uint8_t *p, const void *mesg)
p += H5O_ALIGN(name_len);
/* encode the attribute datatype */
- if((H5O_DTYPE->encode)(f,p,attr->dt)<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL,
- "can't encode attribute datatype");
- }
+ if((H5O_DTYPE->encode)(f,p,attr->dt)<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute datatype");
HDmemset(p+attr->dt_size, 0, H5O_ALIGN(attr->dt_size)-attr->dt_size);
p += H5O_ALIGN(attr->dt_size);
/* encode the attribute dataspace */
- if((H5O_SDSPACE->encode)(f,p,&(attr->ds->extent.u.simple))<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL,
- "can't encode attribute dataspace");
- }
+ if((H5O_SDSPACE->encode)(f,p,&(attr->ds->extent.u.simple))<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "can't encode attribute dataspace");
HDmemset(p+attr->ds_size, 0, H5O_ALIGN(attr->ds_size)-attr->ds_size);
p += H5O_ALIGN(attr->ds_size);
/* Store attribute data */
HDmemcpy(p,attr->data,attr->data_size);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_attr_copy
@@ -270,6 +275,7 @@ H5O_attr_copy(const void *_src, void *_dst)
{
const H5A_t *src = (const H5A_t *) _src;
H5A_t *dst = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_attr_copy, NULL);
@@ -277,18 +283,23 @@ H5O_attr_copy(const void *_src, void *_dst)
assert(src);
/* copy */
- if (NULL == (dst = H5A_copy(src))) {
- HRETURN_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute");
- }
+ if (NULL == (dst = H5A_copy(src)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "can't copy attribute");
/* was result already allocated? */
if (_dst) {
*((H5A_t *) _dst) = *dst;
H5MM_xfree(dst);
dst = (H5A_t *) _dst;
}
- FUNC_LEAVE((void *) dst);
+
+ /* Set return value */
+ ret_value=dst;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_attr_size
@@ -355,21 +366,23 @@ H5O_attr_reset(void *_mesg)
{
H5A_t *attr = (H5A_t *) _mesg;
H5A_t *tmp = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_attr_reset, FAIL);
if (attr) {
- if (NULL==(tmp = H5MM_malloc(sizeof(H5A_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(tmp = H5MM_malloc(sizeof(H5A_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
HDmemcpy(tmp,attr,sizeof(H5A_t));
H5A_close(tmp);
HDmemset(attr, 0, sizeof(H5A_t));
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_attr_debug
diff --git a/src/H5Ocomp.c b/src/H5Ocomp.c
index 3946d80..fdfb0c5 100644
--- a/src/H5Ocomp.c
+++ b/src/H5Ocomp.c
@@ -71,7 +71,7 @@ H5O_pline_decode(H5F_t UNUSED *f, const uint8_t *p,
H5O_shared_t UNUSED *sh)
{
H5O_pline_t *pline = NULL;
- void *ret_value = NULL;
+ void *ret_value;
unsigned version;
size_t i, j, n, name_length;
@@ -81,34 +81,24 @@ H5O_pline_decode(H5F_t UNUSED *f, const uint8_t *p,
assert(p);
/* Decode */
- if (NULL==(pline = H5FL_ALLOC(H5O_pline_t,1))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(pline = H5FL_ALLOC(H5O_pline_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
version = *p++;
- if (version!=H5O_PLINE_VERSION) {
- HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL,
- "bad version number for filter pipeline message");
- }
+ if (version!=H5O_PLINE_VERSION)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "bad version number for filter pipeline message");
pline->nfilters = *p++;
- if (pline->nfilters>32) {
- HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL,
- "filter pipeline message has too many filters");
- }
+ if (pline->nfilters>32)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter pipeline message has too many filters");
p += 6; /*reserved*/
pline->nalloc = pline->nfilters;
pline->filter = H5MM_calloc(pline->nalloc*sizeof(pline->filter[0]));
- if (NULL==pline->filter) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==pline->filter)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
for (i=0; i<pline->nfilters; i++) {
UINT16DECODE(p, pline->filter[i].id);
UINT16DECODE(p, name_length);
- if (name_length % 8) {
- HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL,
- "filter name length is not a multiple of eight");
- }
+ if (name_length % 8)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, NULL, "filter name length is not a multiple of eight");
UINT16DECODE(p, pline->filter[i].flags);
UINT16DECODE(p, pline->filter[i].cd_nelmts);
if (name_length) {
@@ -127,21 +117,19 @@ H5O_pline_decode(H5F_t UNUSED *f, const uint8_t *p,
* Read the client data values and the padding
*/
pline->filter[i].cd_values = H5MM_malloc(n*sizeof(unsigned));
- if (NULL==pline->filter[i].cd_values) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for client data");
- }
- for (j=0; j<pline->filter[i].cd_nelmts; j++) {
+ if (NULL==pline->filter[i].cd_values)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for client data");
+ for (j=0; j<pline->filter[i].cd_nelmts; j++)
UINT32DECODE(p, pline->filter[i].cd_values[j]);
- }
- if (pline->filter[i].cd_nelmts % 2) {
+ if (pline->filter[i].cd_nelmts % 2)
p += 4; /*padding*/
- }
}
}
+
+ /* Set return value */
ret_value = pline;
- done:
+done:
if (NULL==ret_value && pline) {
if (pline->filter) {
for (i=0; i<pline->nfilters; i++) {
@@ -152,6 +140,7 @@ H5O_pline_decode(H5F_t UNUSED *f, const uint8_t *p,
}
H5FL_FREE(H5O_pline_t,pline);
}
+
FUNC_LEAVE(ret_value);
}
@@ -200,9 +189,8 @@ H5O_pline_encode (H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg)
* as it was registered.
*/
if (NULL==(name=pline->filter[i].name) &&
- (cls=H5Z_find(pline->filter[i].id))) {
+ (cls=H5Z_find(pline->filter[i].id)))
name = cls->name;
- }
name_length = name ? HDstrlen(name)+1 : 0;
/* Encode the filter */
@@ -213,14 +201,13 @@ H5O_pline_encode (H5F_t UNUSED *f, uint8_t *p/*out*/, const void *mesg)
if (name_length>0) {
HDmemcpy(p, name, name_length);
p += name_length;
- while (name_length++ % 8) *p++ = 0;
+ while (name_length++ % 8)
+ *p++ = 0;
}
- for (j=0; j<pline->filter[i].cd_nelmts; j++) {
+ for (j=0; j<pline->filter[i].cd_nelmts; j++)
UINT32ENCODE(p, pline->filter[i].cd_values[j]);
- }
- if (pline->filter[i].cd_nelmts % 2) {
+ if (pline->filter[i].cd_nelmts % 2)
UINT32ENCODE(p, 0);
- }
}
FUNC_LEAVE (SUCCEED);
@@ -255,19 +242,15 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/)
FUNC_ENTER_NOAPI(H5O_pline_copy, NULL);
- if (!dst && NULL==(dst = H5FL_ALLOC (H5O_pline_t,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!dst && NULL==(dst = H5FL_ALLOC (H5O_pline_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
*dst = *src;
dst->nalloc = dst->nfilters;
if (dst->nalloc>0) {
dst->filter = H5MM_calloc(dst->nalloc * sizeof(dst->filter[0]));
- if (NULL==dst->filter) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==dst->filter)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
} else {
dst->filter = NULL;
}
@@ -280,17 +263,17 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/)
if (src->filter[i].cd_nelmts>0) {
dst->filter[i].cd_values = H5MM_malloc(src->filter[i].cd_nelmts*
sizeof(unsigned));
- if (NULL==dst->filter[i].cd_values) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==dst->filter[i].cd_values)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy (dst->filter[i].cd_values, src->filter[i].cd_values,
src->filter[i].cd_nelmts * sizeof(unsigned));
}
}
+
+ /* Set return value */
ret_value = dst;
- done:
+done:
if (!ret_value && dst) {
if (dst->filter) {
for (i=0; i<dst->nfilters; i++) {
@@ -299,7 +282,8 @@ H5O_pline_copy (const void *_src, void *_dst/*out*/)
}
H5MM_xfree(dst->filter);
}
- if (!_dst) H5FL_FREE(H5O_pline_t,dst);
+ if (!_dst)
+ H5FL_FREE(H5O_pline_t,dst);
}
FUNC_LEAVE (ret_value);
@@ -340,9 +324,8 @@ H5O_pline_size (H5F_t UNUSED *f, const void *mesg)
for (i=0; i<pline->nfilters; i++) {
/* Get the name of the filter, same as done with H5O_pline_encode() */
if (NULL==(name=pline->filter[i].name) &&
- (cls=H5Z_find(pline->filter[i].id))) {
+ (cls=H5Z_find(pline->filter[i].id)))
name = cls->name;
- }
name_len = name ? HDstrlen(name)+1 : 0;
@@ -353,7 +336,8 @@ H5O_pline_size (H5F_t UNUSED *f, const void *mesg)
H5O_ALIGN(name_len); /*length of the filter name */
size += pline->filter[i].cd_nelmts * 4;
- if (pline->filter[i].cd_nelmts % 2) size += 4;
+ if (pline->filter[i].cd_nelmts % 2)
+ size += 4;
}
FUNC_LEAVE (size);
@@ -384,6 +368,7 @@ H5O_pline_reset (void *mesg)
FUNC_ENTER_NOAPI(H5O_pline_reset, FAIL);
assert (pline);
+
for (i=0; i<pline->nfilters; i++) {
H5MM_xfree(pline->filter[i].name);
H5MM_xfree(pline->filter[i].cd_values);
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index c79f01e..95e9ff9 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -72,6 +72,7 @@ static void *
H5O_cont_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
{
H5O_cont_t *cont = NULL;
+ void *ret_value;
FUNC_ENTER_NOAPI(H5O_cont_decode, NULL);
@@ -81,15 +82,18 @@ H5O_cont_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
assert (!sh);
/* decode */
- if (NULL==(cont = H5MM_calloc(sizeof(H5O_cont_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(cont = H5MM_calloc(sizeof(H5O_cont_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
H5F_addr_decode(f, &p, &(cont->addr));
H5F_DECODE_LENGTH(f, p, cont->size);
- FUNC_LEAVE((void *) cont);
+ /* Set return value */
+ ret_value=cont;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_cont_encode
@@ -124,6 +128,7 @@ H5O_cont_encode(H5F_t *f, uint8_t *p, const void *_mesg)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_cont_debug
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index cad92d9..abab4cf 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -92,6 +92,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
unsigned flags, version;
int i, j;
size_t z;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5O_dtype_decode_helper);
@@ -102,10 +103,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
/* decode */
UINT32DECODE(*pp, flags);
version = (flags>>4) & 0x0f;
- if (version!=H5O_DTYPE_VERSION_COMPAT && version!=H5O_DTYPE_VERSION_UPDATED) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL,
- "bad version number for data type message");
- }
+ if (version!=H5O_DTYPE_VERSION_COMPAT && version!=H5O_DTYPE_VERSION_UPDATED)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "bad version number for data type message");
dt->type = (H5T_class_t)(flags & 0x0f);
flags >>= 8;
UINT32DECODE(*pp, dt->size);
@@ -140,10 +139,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
*/
z = flags & 0xff;
assert(0==(z&0x7)); /*must be aligned*/
- if (NULL==(dt->u.opaque.tag=H5MM_malloc(z+1))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(dt->u.opaque.tag=H5MM_malloc(z+1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
HDmemcpy(dt->u.opaque.tag, *pp, z);
dt->u.opaque.tag[z] = '\0';
*pp += z;
@@ -168,8 +165,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown floating-point normalization");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown floating-point normalization");
}
dt->u.atomic.u.f.sign = (flags >> 8) & 0xff;
UINT16DECODE(*pp, dt->u.atomic.offset);
@@ -192,10 +188,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
dt->u.compnd.nalloc = dt->u.compnd.nmembs;
dt->u.compnd.memb = H5MM_calloc(dt->u.compnd.nalloc*
sizeof(H5T_cmemb_t));
- if (NULL==dt->u.compnd.memb) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==dt->u.compnd.memb)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
for (i = 0; i < dt->u.compnd.nmembs; i++) {
int ndims=0; /* Number of dimensions of the array field */
hsize_t dim[H5O_LAYOUT_NDIMS]; /* Dimensions of the array */
@@ -234,10 +228,8 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
/* Allocate space for the field's datatype */
temp_type = H5FL_ALLOC (H5T_t,1);
- if (NULL==temp_type) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==temp_type)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
temp_type->ent.header = HADDR_UNDEF;
/* Decode the field's datatype information */
@@ -245,7 +237,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
for (j=0; j<=i; j++)
H5MM_xfree(dt->u.compnd.memb[j].name);
H5MM_xfree(dt->u.compnd.memb);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode member type");
}
/* Go create the array datatype now, for older versions of the datatype message */
@@ -261,7 +253,7 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
for (j=0; j<=i; j++)
H5MM_xfree(dt->u.compnd.memb[j].name);
H5MM_xfree(dt->u.compnd.memb);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create array datatype");
}
/* Close the base type for the array */
@@ -297,22 +289,15 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
*/
dt->u.enumer.nmembs = dt->u.enumer.nalloc = flags & 0xffff;
assert(dt->u.enumer.nmembs>=0);
- if (NULL==(dt->parent=H5FL_ALLOC(H5T_t,1))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(dt->parent=H5FL_ALLOC(H5T_t,1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
dt->parent->ent.header = HADDR_UNDEF;
- if (H5O_dtype_decode_helper(f, pp, dt->parent)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL,
- "unable to decode parent data type");
- }
- if (NULL==(dt->u.enumer.name=H5MM_calloc(dt->u.enumer.nalloc *
- sizeof(char*))) ||
- NULL==(dt->u.enumer.value=H5MM_calloc(dt->u.enumer.nalloc *
- dt->parent->size))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (H5O_dtype_decode_helper(f, pp, dt->parent)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode parent data type");
+ if (NULL==(dt->u.enumer.name=H5MM_calloc(dt->u.enumer.nalloc * sizeof(char*))) ||
+ NULL==(dt->u.enumer.value=H5MM_calloc(dt->u.enumer.nalloc *
+ dt->parent->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Names, each a multiple of 8 with null termination */
for (i=0; i<dt->u.enumer.nmembs; i++) {
@@ -359,18 +344,15 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
/* Decode base type of VL information */
if (NULL==(dt->parent = H5FL_ALLOC(H5T_t,1)))
- HRETURN_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed");
dt->parent->ent.header = HADDR_UNDEF;
if (H5O_dtype_decode_helper(f, pp, dt->parent)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL,
- "unable to decode VL parent type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type");
dt->force_conv=TRUE;
/* Mark this type as on disk */
if (H5T_vlen_mark(dt, f, H5T_VLEN_DISK)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "invalid VL location");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
break;
case H5T_TIME: /* Time datatypes */
@@ -400,10 +382,10 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
/* Decode base type of array */
if (NULL==(dt->parent = H5FL_ALLOC(H5T_t,1)))
- HRETURN_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_NOSPACE, FAIL, "memory allocation failed");
dt->parent->ent.header = HADDR_UNDEF;
if (H5O_dtype_decode_helper(f, pp, dt->parent)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL, "unable to decode VL parent type");
/*
* Set the "force conversion" flag if a VL base datatype is used or
@@ -414,11 +396,11 @@ H5O_dtype_decode_helper(H5F_t *f, const uint8_t **pp, H5T_t *dt)
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown datatype class found");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown datatype class found");
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -444,6 +426,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
char *hdr = (char *)*pp;
int i, j;
size_t n, z, aligned;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5O_dtype_encode_helper);
@@ -467,8 +450,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x01;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
}
switch (dt->u.atomic.lsb_pad) {
@@ -478,8 +460,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x02;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
}
switch (dt->u.atomic.msb_pad) {
@@ -489,8 +470,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x04;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
}
switch (dt->u.atomic.u.i.sign) {
@@ -500,8 +480,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x08;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "sign scheme is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "sign scheme is not supported in file format yet");
}
UINT16ENCODE(*pp, dt->u.atomic.offset);
@@ -519,8 +498,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x01;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
}
switch (dt->u.atomic.lsb_pad) {
@@ -530,8 +508,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x02;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
}
switch (dt->u.atomic.msb_pad) {
@@ -541,8 +518,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x04;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
}
UINT16ENCODE(*pp, dt->u.atomic.offset);
@@ -574,8 +550,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x01;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
}
switch (dt->u.atomic.lsb_pad) {
@@ -585,8 +560,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x02;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
}
switch (dt->u.atomic.msb_pad) {
@@ -596,8 +570,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x04;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
}
switch (dt->u.atomic.u.f.pad) {
@@ -607,8 +580,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x08;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "bit padding is not supported in file format yet");
}
switch (dt->u.atomic.u.f.norm) {
@@ -621,8 +593,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x20;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "normalization scheme is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "normalization scheme is not supported in file format yet");
}
flags |= (dt->u.atomic.u.f.sign << 8) & 0xff00;
@@ -681,10 +652,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
} /* end if */
/* Subtype */
- if (H5O_dtype_encode_helper(pp, dt->u.compnd.memb[i].type)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL,
- "unable to encode member type");
- }
+ if (H5O_dtype_encode_helper(pp, dt->u.compnd.memb[i].type)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode member type");
}
break;
@@ -695,10 +664,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags = dt->u.enumer.nmembs & 0xffff;
/* Parent type */
- if (H5O_dtype_encode_helper(pp, dt->parent)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL,
- "unable to encode parent data type");
- }
+ if (H5O_dtype_encode_helper(pp, dt->parent)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode parent data type");
/* Names, each a multiple of eight bytes */
for (i=0; i<dt->u.enumer.nmembs; i++) {
@@ -740,9 +707,8 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
} /* end if */
/* Encode base type of VL information */
- if (H5O_dtype_encode_helper(pp, dt->parent)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type");
- }
+ if (H5O_dtype_encode_helper(pp, dt->parent)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type");
break;
case H5T_TIME: /* Time datatypes... */
@@ -753,8 +719,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
flags |= 0x01;
break;
default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "byte order is not supported in file format yet");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "byte order is not supported in file format yet");
}
UINT16ENCODE(*pp, dt->u.atomic.prec);
break;
@@ -781,7 +746,7 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
/* Encode base type of array's information */
if (H5O_dtype_encode_helper(pp, dt->parent)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "unable to encode VL parent type");
break;
default:
@@ -794,9 +759,11 @@ H5O_dtype_encode_helper(uint8_t **pp, const H5T_t *dt)
*hdr++ = (flags >> 8) & 0xff;
*hdr++ = (flags >> 16) & 0xff;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_dtype_decode
@@ -820,26 +787,33 @@ H5O_dtype_decode(H5F_t *f, const uint8_t *p,
H5O_shared_t UNUSED *sh)
{
H5T_t *dt = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_dtype_decode, NULL);
/* check args */
assert(p);
- if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->ent.header = HADDR_UNDEF;
- if (H5O_dtype_decode_helper(f, &p, dt) < 0) {
- H5FL_FREE(H5T_t,dt);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL,
- "can't decode type");
- }
- FUNC_LEAVE(dt);
+ if (H5O_dtype_decode_helper(f, &p, dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL, "can't decode type");
+
+ /* Set return value */
+ ret_value=dt;
+
+done:
+ if(ret_value==NULL) {
+ if(dt!=NULL)
+ H5FL_FREE(H5T_t,dt);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_dtype_encode
@@ -861,6 +835,7 @@ static herr_t
H5O_dtype_encode(H5F_t UNUSED *f, uint8_t *p, const void *mesg)
{
const H5T_t *dt = (const H5T_t *) mesg;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_dtype_encode, FAIL);
@@ -870,13 +845,14 @@ H5O_dtype_encode(H5F_t UNUSED *f, uint8_t *p, const void *mesg)
assert(dt);
/* encode */
- if (H5O_dtype_encode_helper(&p, dt) < 0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL,
- "can't encode type");
- }
+ if (H5O_dtype_encode_helper(&p, dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL, "can't encode type");
+
+done:
FUNC_LEAVE(SUCCEED);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_dtype_copy
@@ -899,6 +875,7 @@ H5O_dtype_copy(const void *_src, void *_dst)
{
const H5T_t *src = (const H5T_t *) _src;
H5T_t *dst = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_dtype_copy, NULL);
@@ -907,7 +884,7 @@ H5O_dtype_copy(const void *_src, void *_dst)
/* copy */
if (NULL == (dst = H5T_copy(src, H5T_COPY_ALL)))
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type");
/* was result already allocated? */
if (_dst) {
@@ -915,9 +892,15 @@ H5O_dtype_copy(const void *_src, void *_dst)
H5FL_FREE(H5T_t,dst);
dst = (H5T_t *) _dst;
}
- FUNC_LEAVE((void *) dst);
+
+ /* Set return value */
+ ret_value=dst;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_dtype_size
@@ -977,9 +960,8 @@ H5O_dtype_size(H5F_t *f, const void *mesg)
case H5T_ENUM:
ret_value += H5O_dtype_size(f, dt->parent);
- for (i=0; i<dt->u.enumer.nmembs; i++) {
+ for (i=0; i<dt->u.enumer.nmembs; i++)
ret_value += ((HDstrlen(dt->u.enumer.name[i])+8)/8)*8;
- }
ret_value += dt->u.enumer.nmembs * dt->parent->size;
break;
@@ -1005,6 +987,7 @@ H5O_dtype_size(H5F_t *f, const void *mesg)
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_dtype_reset
@@ -1026,19 +1009,20 @@ H5O_dtype_reset(void *_mesg)
{
H5T_t *dt = (H5T_t *) _mesg;
H5T_t *tmp = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_dtype_reset, FAIL);
if (dt) {
- if (NULL==(tmp = H5FL_ALLOC(H5T_t,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(tmp = H5FL_ALLOC(H5T_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
*tmp = *dt;
H5T_close(tmp);
HDmemset(dt, 0, sizeof(H5T_t));
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1089,6 +1073,7 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg,
H5O_shared_t *sh/*out*/)
{
const H5T_t *dt = (const H5T_t *)_mesg;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_dtype_get_share, FAIL);
@@ -1099,12 +1084,11 @@ H5O_dtype_get_share(H5F_t UNUSED *f, const void *_mesg,
assert (H5T_STATE_NAMED==dt->state || H5T_STATE_OPEN==dt->state);
sh->in_gh = FALSE;
sh->u.ent = dt->ent;
- } else {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "data type is not sharable");
- }
+ } else
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type is not sharable");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1140,6 +1124,7 @@ H5O_dtype_set_share (H5F_t UNUSED *f, void *_mesg/*in,out*/,
FUNC_LEAVE (SUCCEED);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_dtype_debug
@@ -1179,43 +1164,43 @@ H5O_dtype_debug(H5F_t *f, const void *mesg, FILE *stream,
assert(fwidth >= 0);
switch (dt->type) {
- case H5T_INTEGER:
- s = "integer";
- break;
- case H5T_FLOAT:
- s = "floating-point";
- break;
- case H5T_TIME:
- s = "date and time";
- break;
- case H5T_STRING:
- s = "text string";
- break;
- case H5T_BITFIELD:
- s = "bit field";
- break;
- case H5T_OPAQUE:
- s = "opaque";
- break;
- case H5T_COMPOUND:
- s = "compound";
- break;
- case H5T_REFERENCE:
- s = "reference";
- break;
- case H5T_ENUM:
- s = "enum";
- break;
- case H5T_ARRAY:
- s = "array";
- break;
- case H5T_VLEN:
- s = "variable-length sequence";
- break;
- default:
- sprintf(buf, "H5T_CLASS_%d", (int) (dt->type));
- s = buf;
- break;
+ case H5T_INTEGER:
+ s = "integer";
+ break;
+ case H5T_FLOAT:
+ s = "floating-point";
+ break;
+ case H5T_TIME:
+ s = "date and time";
+ break;
+ case H5T_STRING:
+ s = "text string";
+ break;
+ case H5T_BITFIELD:
+ s = "bit field";
+ break;
+ case H5T_OPAQUE:
+ s = "opaque";
+ break;
+ case H5T_COMPOUND:
+ s = "compound";
+ break;
+ case H5T_REFERENCE:
+ s = "reference";
+ break;
+ case H5T_ENUM:
+ s = "enum";
+ break;
+ case H5T_ARRAY:
+ s = "array";
+ break;
+ case H5T_VLEN:
+ s = "variable-length sequence";
+ break;
+ default:
+ sprintf(buf, "H5T_CLASS_%d", (int) (dt->type));
+ s = buf;
+ break;
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Type class:",
@@ -1237,28 +1222,6 @@ H5O_dtype_debug(H5F_t *f, const void *mesg, FILE *stream,
fprintf(stream, "%*s%-*s %lu\n", indent+3, "", MAX(0, fwidth-3),
"Byte offset:",
(unsigned long) (dt->u.compnd.memb[i].offset));
-#ifdef OLD_WAY
- fprintf(stream, "%*s%-*s %d%s\n", indent+3, "", MAX(0, fwidth-3),
- "Dimensionality:",
- dt->u.compnd.memb[i].ndims,
- 0==dt->u.compnd.memb[i].ndims?" (scalar)":"");
- if (dt->u.compnd.memb[i].ndims>0) {
- fprintf(stream, "%*s%-*s {", indent+3, "", MAX(0, fwidth-3),
- "Size:");
- for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
- fprintf(stream, "%s%lu", j?", ":"",
- (unsigned long)(dt->u.compnd.memb[i].dim[j]));
- }
- fprintf(stream, "}\n");
- fprintf(stream, "%*s%-*s {", indent+3, "", MAX(0, fwidth-3),
- "Permutation:");
- for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
- fprintf(stream, "%s%lu", j?", ":"",
- (unsigned long)(dt->u.compnd.memb[i].perm[j]));
- }
- fprintf(stream, "}\n");
- }
-#endif /* OLD_WAY */
H5O_dtype_debug(f, dt->u.compnd.memb[i].type, stream,
indent+3, MAX(0, fwidth - 3));
}
@@ -1309,22 +1272,22 @@ H5O_dtype_debug(H5F_t *f, const void *mesg, FILE *stream,
H5O_dtype_debug(f, dt->parent, stream, indent+3, MAX(0, fwidth-3));
} else {
switch (dt->u.atomic.order) {
- case H5T_ORDER_LE:
- s = "little endian";
- break;
- case H5T_ORDER_BE:
- s = "big endian";
- break;
- case H5T_ORDER_VAX:
- s = "VAX";
- break;
- case H5T_ORDER_NONE:
- s = "none";
- break;
- default:
- sprintf(buf, "H5T_ORDER_%d", dt->u.atomic.order);
- s = buf;
- break;
+ case H5T_ORDER_LE:
+ s = "little endian";
+ break;
+ case H5T_ORDER_BE:
+ s = "big endian";
+ break;
+ case H5T_ORDER_VAX:
+ s = "VAX";
+ break;
+ case H5T_ORDER_NONE:
+ s = "none";
+ break;
+ default:
+ sprintf(buf, "H5T_ORDER_%d", dt->u.atomic.order);
+ s = buf;
+ break;
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Byte order:",
@@ -1341,66 +1304,66 @@ H5O_dtype_debug(H5F_t *f, const void *mesg, FILE *stream,
1==dt->u.atomic.offset?"":"s");
switch (dt->u.atomic.lsb_pad) {
- case H5T_PAD_ZERO:
- s = "zero";
- break;
- case H5T_PAD_ONE:
- s = "one";
- break;
- default:
- s = "pad?";
- break;
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ s = "pad?";
+ break;
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Low pad type:", s);
switch (dt->u.atomic.msb_pad) {
- case H5T_PAD_ZERO:
- s = "zero";
- break;
- case H5T_PAD_ONE:
- s = "one";
- break;
- default:
- s = "pad?";
- break;
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ s = "pad?";
+ break;
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"High pad type:", s);
if (H5T_FLOAT == dt->type) {
switch (dt->u.atomic.u.f.pad) {
- case H5T_PAD_ZERO:
- s = "zero";
- break;
- case H5T_PAD_ONE:
- s = "one";
- break;
- default:
- if (dt->u.atomic.u.f.pad < 0) {
- sprintf(buf, "H5T_PAD_%d", -(dt->u.atomic.u.f.pad));
- } else {
- sprintf(buf, "bit-%d", dt->u.atomic.u.f.pad);
- }
- s = buf;
- break;
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ if (dt->u.atomic.u.f.pad < 0) {
+ sprintf(buf, "H5T_PAD_%d", -(dt->u.atomic.u.f.pad));
+ } else {
+ sprintf(buf, "bit-%d", dt->u.atomic.u.f.pad);
+ }
+ s = buf;
+ break;
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Internal pad type:", s);
switch (dt->u.atomic.u.f.norm) {
- case H5T_NORM_IMPLIED:
- s = "implied";
- break;
- case H5T_NORM_MSBSET:
- s = "msb set";
- break;
- case H5T_NORM_NONE:
- s = "none";
- break;
- default:
- sprintf(buf, "H5T_NORM_%d", (int) (dt->u.atomic.u.f.norm));
- s = buf;
+ case H5T_NORM_IMPLIED:
+ s = "implied";
+ break;
+ case H5T_NORM_MSBSET:
+ s = "msb set";
+ break;
+ case H5T_NORM_NONE:
+ s = "none";
+ break;
+ default:
+ sprintf(buf, "H5T_NORM_%d", (int) (dt->u.atomic.u.f.norm));
+ s = buf;
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Normalization:", s);
@@ -1431,16 +1394,16 @@ H5O_dtype_debug(H5F_t *f, const void *mesg, FILE *stream,
} else if (H5T_INTEGER == dt->type) {
switch (dt->u.atomic.u.i.sign) {
- case H5T_SGN_NONE:
- s = "none";
- break;
- case H5T_SGN_2:
- s = "2's comp";
- break;
- default:
- sprintf(buf, "H5T_SGN_%d", (int) (dt->u.atomic.u.i.sign));
- s = buf;
- break;
+ case H5T_SGN_NONE:
+ s = "none";
+ break;
+ case H5T_SGN_2:
+ s = "2's comp";
+ break;
+ default:
+ sprintf(buf, "H5T_SGN_%d", (int) (dt->u.atomic.u.i.sign));
+ s = buf;
+ break;
}
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
"Sign scheme:", s);
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 2dbeaa9..76ac990 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -73,6 +73,7 @@ H5O_efl_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
H5O_efl_t *mesg = NULL;
int i, version;
const char *s = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_efl_decode, NULL);
@@ -81,17 +82,13 @@ H5O_efl_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
assert(p);
assert (!sh);
- if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Version */
version = *p++;
- if (version!=H5O_EFL_VERSION) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "bad version number for external file list message");
- }
+ if (version!=H5O_EFL_VERSION)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message");
/* Reserved */
p += 3;
@@ -112,11 +109,8 @@ H5O_efl_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
/* Decode the file list */
mesg->slot = H5MM_calloc(mesg->nalloc*sizeof(H5O_efl_entry_t));
- if (NULL==mesg->slot) {
- H5MM_xfree (mesg);
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==mesg->slot)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
for (i=0; i<mesg->nused; i++) {
/* Name */
H5F_DECODE_LENGTH (f, p, mesg->slot[i].name_offset);
@@ -132,8 +126,17 @@ H5O_efl_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
assert (mesg->slot[i].size>0);
}
- FUNC_LEAVE(mesg);
+ /* Set return value */
+ ret_value=mesg;
+
+done:
+ if(ret_value==NULL) {
+ if(mesg!=NULL)
+ H5MM_xfree (mesg);
+ } /* end if */
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_efl_encode
@@ -226,6 +229,7 @@ H5O_efl_copy(const void *_mesg, void *_dest)
const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
H5O_efl_t *dest = (H5O_efl_t *) _dest;
int i;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_efl_copy, NULL);
@@ -233,19 +237,14 @@ H5O_efl_copy(const void *_mesg, void *_dest)
assert(mesg);
if (!dest) {
if (NULL==(dest = H5MM_calloc(sizeof(H5O_efl_t))) ||
- NULL==(dest->slot=H5MM_malloc(mesg->nalloc*
- sizeof(H5O_efl_entry_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ NULL==(dest->slot=H5MM_malloc(mesg->nalloc* sizeof(H5O_efl_entry_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
} else if (dest->nalloc<mesg->nalloc) {
H5MM_xfree(dest->slot);
if (NULL==(dest->slot = H5MM_malloc(mesg->nalloc*
- sizeof(H5O_efl_entry_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ sizeof(H5O_efl_entry_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
}
dest->heap_addr = mesg->heap_addr;
dest->nalloc = mesg->nalloc;
@@ -256,7 +255,11 @@ H5O_efl_copy(const void *_mesg, void *_dest)
dest->slot[i].name = H5MM_xstrdup (mesg->slot[i].name);
}
- FUNC_LEAVE((void *)dest);
+ /* Set return value */
+ ret_value=dest;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -330,9 +333,8 @@ H5O_efl_reset(void *_mesg)
assert(mesg);
/* reset */
- for (i=0; i<mesg->nused; i++) {
+ for (i=0; i<mesg->nused; i++)
mesg->slot[i].name = H5MM_xfree (mesg->slot[i].name);
- }
mesg->heap_addr = HADDR_UNDEF;
mesg->nused = mesg->nalloc = 0;
mesg->slot = H5MM_xfree(mesg->slot);
@@ -372,13 +374,12 @@ H5O_efl_total_size (H5O_efl_t *efl)
} else {
for (i=0; i<efl->nused; i++, ret_value=tmp) {
tmp = ret_value + efl->slot[i].size;
- if (tmp<=ret_value) {
- HRETURN_ERROR (H5E_EFL, H5E_OVERFLOW, 0,
- "total external storage size overflowed");
- }
+ if (tmp<=ret_value)
+ HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, 0, "total external storage size overflowed");
}
}
+done:
FUNC_LEAVE (ret_value);
}
@@ -413,7 +414,7 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
hsize_t skip=0;
haddr_t cur;
ssize_t n;
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_efl_read, FAIL);
@@ -435,22 +436,14 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
/* Read the data */
while (size) {
- if (i>=efl->nused) {
- HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
- "read past logical end of file");
- }
- if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip)) {
- HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
- "external file address overflowed");
- }
- if ((fd=HDopen (efl->slot[i].name, O_RDONLY, 0))<0) {
- HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL,
- "unable to open external raw data file");
- }
- if (HDlseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0) {
- HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL,
- "unable to seek in external raw data file");
- }
+ if (i>=efl->nused)
+ HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "read past logical end of file");
+ if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip))
+ HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed");
+ if ((fd=HDopen (efl->slot[i].name, O_RDONLY, 0))<0)
+ HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file");
+ if (HDlseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0)
+ HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file");
#ifndef NDEBUG
tempto_read = MIN(efl->slot[i].size-skip,(hsize_t)size);
H5_CHECK_OVERFLOW(tempto_read,hsize_t,size_t);
@@ -459,8 +452,7 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
to_read = MIN((size_t)(efl->slot[i].size-skip), size);
#endif /* NDEBUG */
if ((n=HDread (fd, buf, to_read))<0) {
- HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL,
- "read error in external raw data file");
+ HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "read error in external raw data file");
} else if ((size_t)n<to_read) {
HDmemset (buf+n, 0, to_read-n);
}
@@ -471,10 +463,11 @@ H5O_efl_read (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
skip = 0;
i++;
}
- ret_value = SUCCEED;
- done:
- if (fd>=0) HDclose (fd);
+done:
+ if (fd>=0)
+ HDclose (fd);
+
FUNC_LEAVE (ret_value);
}
@@ -508,7 +501,7 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
#endif /* NDEBUG */
haddr_t cur;
hsize_t skip=0;
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_efl_write, FAIL);
@@ -530,27 +523,19 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
/* Write the data */
while (size) {
- if (i>=efl->nused) {
- HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
- "write past logical end of file");
- }
- if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip)) {
- HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL,
- "external file address overflowed");
- }
+ if (i>=efl->nused)
+ HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "write past logical end of file");
+ if (H5F_OVERFLOW_HSIZET2OFFT (efl->slot[i].offset+skip))
+ HGOTO_ERROR (H5E_EFL, H5E_OVERFLOW, FAIL, "external file address overflowed");
if ((fd=HDopen (efl->slot[i].name, O_RDWR, 0))<0) {
if (HDaccess (efl->slot[i].name, F_OK)<0) {
- HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL,
- "external raw data file does not exist");
+ HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "external raw data file does not exist");
} else {
- HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL,
- "unable to open external raw data file");
+ HGOTO_ERROR (H5E_EFL, H5E_CANTOPENFILE, FAIL, "unable to open external raw data file");
}
}
- if (HDlseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0) {
- HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL,
- "unable to seek in external raw data file");
- }
+ if (HDlseek (fd, (off_t)(efl->slot[i].offset+skip), SEEK_SET)<0)
+ HGOTO_ERROR (H5E_EFL, H5E_SEEKERROR, FAIL, "unable to seek in external raw data file");
#ifndef NDEBUG
tempto_write = MIN(efl->slot[i].size-skip,(hsize_t)size);
H5_CHECK_OVERFLOW(tempto_write,hsize_t,size_t);
@@ -558,10 +543,8 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
#else /* NDEBUG */
to_write = MIN((size_t)(efl->slot[i].size-skip), size);
#endif /* NDEBUG */
- if ((size_t)HDwrite (fd, buf, to_write)!=to_write) {
- HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL,
- "write error in external raw data file");
- }
+ if ((size_t)HDwrite (fd, buf, to_write)!=to_write)
+ HGOTO_ERROR (H5E_EFL, H5E_READERROR, FAIL, "write error in external raw data file");
HDclose (fd);
fd = -1;
size -= to_write;
@@ -569,10 +552,11 @@ H5O_efl_write (H5F_t UNUSED *f, const H5O_efl_t *efl, haddr_t addr,
skip = 0;
i++;
}
- ret_value = SUCCEED;
- done:
- if (fd>=0) HDclose (fd);
+done:
+ if (fd>=0)
+ HDclose (fd);
+
FUNC_LEAVE (ret_value);
}
diff --git a/src/H5Ofill.c b/src/H5Ofill.c
index 77523e0..697e920 100644
--- a/src/H5Ofill.c
+++ b/src/H5Ofill.c
@@ -96,7 +96,7 @@ H5O_fill_new_decode(H5F_t UNUSED *f, const uint8_t *p,
{
H5O_fill_new_t *mesg=NULL;
int version;
- void *ret_value = NULL;
+ void *ret_value;
FUNC_ENTER_NOAPI(H5O_fill_new_decode, NULL);
@@ -104,17 +104,13 @@ H5O_fill_new_decode(H5F_t UNUSED *f, const uint8_t *p,
assert(p);
assert(!sh);
- if (NULL==(mesg=H5MM_calloc(sizeof(H5O_fill_new_t)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill value message");
- }
+ if (NULL==(mesg=H5MM_calloc(sizeof(H5O_fill_new_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message");
/* Version */
version = *p++;
- if( version != H5O_FILL_VERSION) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "bad version number for fill value message");
- }
+ if( version != H5O_FILL_VERSION)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for fill value message");
/* Space allocation time */
mesg->space_time = (H5D_space_time_t)*p++;
@@ -129,21 +125,21 @@ H5O_fill_new_decode(H5F_t UNUSED *f, const uint8_t *p,
UINT32DECODE(p, mesg->size);
if (mesg->size>0) {
H5_CHECK_OVERFLOW(mesg->size,ssize_t,size_t);
- if (NULL==(mesg->buf=H5MM_malloc((size_t)mesg->size))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill value");
- }
+ if (NULL==(mesg->buf=H5MM_malloc((size_t)mesg->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value");
HDmemcpy(mesg->buf, p, (size_t)mesg->size);
}
+ /* Set return value */
ret_value = (void*)mesg;
- done:
+done:
if (!ret_value && mesg) {
if(mesg->buf)
H5MM_xfree(mesg->buf);
H5MM_xfree(mesg);
}
+
FUNC_LEAVE(ret_value);
}
@@ -169,7 +165,7 @@ H5O_fill_decode(H5F_t UNUSED *f, const uint8_t *p,
H5O_shared_t UNUSED *sh)
{
H5O_fill_t *mesg=NULL;
- void *ret_value = NULL;
+ void *ret_value;
FUNC_ENTER_NOAPI(H5O_fill_decode, NULL);
@@ -177,27 +173,25 @@ H5O_fill_decode(H5F_t UNUSED *f, const uint8_t *p,
assert(p);
assert(!sh);
- if (NULL==(mesg=H5MM_calloc(sizeof(H5O_fill_t)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill value message");
- }
+ if (NULL==(mesg=H5MM_calloc(sizeof(H5O_fill_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value message");
UINT32DECODE(p, mesg->size);
if (mesg->size>0) {
- if (NULL==(mesg->buf=H5MM_malloc(mesg->size))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill value");
- }
+ if (NULL==(mesg->buf=H5MM_malloc(mesg->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value");
HDmemcpy(mesg->buf, p, mesg->size);
}
+ /* Set return value */
ret_value = (void*)mesg;
- done:
+done:
if (!ret_value && mesg) {
if(mesg->buf)
H5MM_xfree(mesg->buf);
H5MM_xfree(mesg);
}
+
FUNC_LEAVE(ret_value);
}
@@ -307,29 +301,25 @@ H5O_fill_new_copy(const void *_mesg, void *_dest)
{
const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg;
H5O_fill_new_t *dest = (H5O_fill_new_t *)_dest;
- void *ret_value = NULL;
+ void *ret_value;
FUNC_ENTER_NOAPI(H5O_fill_new_copy, NULL);
assert(mesg);
- if (!dest && NULL==(dest=H5MM_calloc(sizeof(H5O_fill_new_t)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill message");
- }
+ if (!dest && NULL==(dest=H5MM_calloc(sizeof(H5O_fill_new_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message");
+
/* Copy data type of fill value */
if (mesg->type &&
- NULL==(dest->type=H5T_copy(mesg->type, H5T_COPY_TRANSIENT))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to copy fill value data type");
- }
+ NULL==(dest->type=H5T_copy(mesg->type, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy fill value data type");
+
/* Copy fill value and its size */
if (mesg->buf) {
H5_CHECK_OVERFLOW(mesg->size,ssize_t,size_t);
- if (NULL==(dest->buf=H5MM_malloc((size_t)mesg->size))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill value");
- }
+ if (NULL==(dest->buf=H5MM_malloc((size_t)mesg->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value");
dest->size = mesg->size;
HDmemcpy(dest->buf, mesg->buf, (size_t)mesg->size);
}
@@ -339,6 +329,7 @@ H5O_fill_new_copy(const void *_mesg, void *_dest)
dest->fill_time = mesg->fill_time;
dest->fill_defined = mesg->fill_defined;
+ /* Set return value */
ret_value = dest;
done:
@@ -350,6 +341,7 @@ done:
if (!_dest)
H5MM_xfree(dest);
}
+
FUNC_LEAVE(ret_value);
}
@@ -376,29 +368,25 @@ H5O_fill_copy(const void *_mesg, void *_dest)
{
const H5O_fill_t *mesg = (const H5O_fill_t *)_mesg;
H5O_fill_t *dest = (H5O_fill_t *)_dest;
- void *ret_value = NULL;
+ void *ret_value;
FUNC_ENTER_NOAPI(H5O_fill_copy, NULL);
assert(mesg);
- if (!dest && NULL==(dest=H5MM_calloc(sizeof(H5O_fill_t)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill message");
- }
+ if (!dest && NULL==(dest=H5MM_calloc(sizeof(H5O_fill_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill message");
if (mesg->type &&
- NULL==(dest->type=H5T_copy(mesg->type, H5T_COPY_TRANSIENT))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to copy fill value data type");
- }
+ NULL==(dest->type=H5T_copy(mesg->type, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy fill value data type");
if (mesg->buf) {
- if (NULL==(dest->buf=H5MM_malloc(mesg->size))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for fill value");
- }
+ if (NULL==(dest->buf=H5MM_malloc(mesg->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value");
dest->size = mesg->size;
HDmemcpy(dest->buf, mesg->buf, mesg->size);
}
+
+ /* Set return value */
ret_value = dest;
done:
@@ -410,6 +398,7 @@ done:
if (!_dest)
H5MM_xfree(dest);
}
+
FUNC_LEAVE(ret_value);
}
@@ -438,7 +427,7 @@ static size_t
H5O_fill_new_size(H5F_t UNUSED *f, const void *_mesg)
{
const H5O_fill_new_t *mesg = (const H5O_fill_new_t *)_mesg;
- size_t ret_value = 0;
+ size_t ret_value;
FUNC_ENTER_NOAPI(H5O_fill_new_size, 0);
@@ -451,6 +440,7 @@ H5O_fill_new_size(H5F_t UNUSED *f, const void *_mesg)
1 + /* Fill value defined */
4 + /* Fill value size */
(mesg->size>0 ? mesg->size : 0); /* Size of fill value */
+
FUNC_LEAVE(ret_value);
}
@@ -522,6 +512,7 @@ H5O_fill_new_reset(void *_mesg)
mesg->space_time = (H5D_space_time_t)0;
mesg->fill_time = (H5D_fill_time_t)0;
mesg->fill_defined = (H5D_fill_value_t)0;
+
FUNC_LEAVE(SUCCEED);
}
@@ -669,7 +660,7 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type)
H5T_path_t *tpath=NULL; /*type conversion info */
void *buf=NULL, *bkg=NULL; /*conversion buffers */
hid_t src_id=-1, dst_id=-1; /*data type identifiers */
- herr_t ret_value=FAIL; /*return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5O_fill_convert, FAIL);
@@ -678,9 +669,10 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type)
/* No-op cases */
if (!fill->buf || !fill->type || 0==H5T_cmp(fill->type, dset_type)) {
- if (fill->type) H5T_close(fill->type);
+ if (fill->type)
+ H5T_close(fill->type);
fill->type = NULL;
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
/*
@@ -692,11 +684,9 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type)
}
if ((src_id = H5I_register(H5I_DATATYPE,
H5T_copy(fill->type, H5T_COPY_TRANSIENT)))<0 ||
- (dst_id = H5I_register(H5I_DATATYPE,
- H5T_copy(dset_type, H5T_COPY_TRANSIENT)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to copy/register data type");
- }
+ (dst_id = H5I_register(H5I_DATATYPE,
+ H5T_copy(dset_type, H5T_COPY_TRANSIENT)))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy/register data type");
/*
* Data type conversions are always done in place, so we need a buffer
@@ -705,10 +695,8 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type)
if (H5T_get_size(fill->type)>=H5T_get_size(dset_type)) {
buf = fill->buf;
} else {
- if (NULL==(buf=H5MM_malloc(H5T_get_size(dset_type)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for type conversion");
- }
+ if (NULL==(buf=H5MM_malloc(H5T_get_size(dset_type))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
HDmemcpy(buf, fill->buf, H5T_get_size(fill->type));
}
if (tpath->cdata.need_bkg && NULL==(bkg=H5MM_malloc(H5T_get_size(dset_type))))
@@ -726,12 +714,16 @@ H5O_fill_convert(void *_fill, H5T_t *dset_type)
H5T_close(fill->type);
fill->type = NULL;
H5_ASSIGN_OVERFLOW(fill->size,H5T_get_size(dset_type),size_t,ssize_t);
- ret_value = SUCCEED;
- done:
- if (src_id>=0) H5I_dec_ref(src_id);
- if (dst_id>=0) H5I_dec_ref(dst_id);
- if (buf!=fill->buf) H5MM_xfree(buf);
- if (bkg) H5MM_xfree(bkg);
+done:
+ if (src_id>=0)
+ H5I_dec_ref(src_id);
+ if (dst_id>=0)
+ H5I_dec_ref(dst_id);
+ if (buf!=fill->buf)
+ H5MM_xfree(buf);
+ if (bkg)
+ H5MM_xfree(bkg);
+
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index b1b4680..a6dfdbc 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -82,6 +82,7 @@ H5O_layout_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
H5O_layout_t *mesg = NULL;
int version;
unsigned u;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_layout_decode, NULL);
@@ -91,25 +92,18 @@ H5O_layout_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
assert (!sh);
/* decode */
- if (NULL==(mesg = H5FL_ALLOC(H5O_layout_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(mesg = H5FL_ALLOC(H5O_layout_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Version. 1 when space allocated; 2 when space allocation is delayed */
version = *p++;
- if (version!=H5O_LAYOUT_VERSION_1 && version!=H5O_LAYOUT_VERSION_2) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "bad version number for layout message");
- }
+ if (version!=H5O_LAYOUT_VERSION_1 && version!=H5O_LAYOUT_VERSION_2)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for layout message");
/* Dimensionality */
mesg->ndims = *p++;
- if (mesg->ndims>H5O_LAYOUT_NDIMS) {
- H5FL_FREE(H5O_layout_t,mesg);
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "dimensionality is too large");
- }
+ if (mesg->ndims>H5O_LAYOUT_NDIMS)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "dimensionality is too large");
/* Layout class */
mesg->type = *p++;
@@ -122,12 +116,20 @@ H5O_layout_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
H5F_addr_decode(f, &p, &(mesg->addr));
/* Read the size */
- for (u = 0; u < mesg->ndims; u++) {
+ for (u = 0; u < mesg->ndims; u++)
UINT32DECODE(p, mesg->dim[u]);
- }
- FUNC_LEAVE(mesg);
+ /* Set return value */
+ ret_value=mesg;
+
+done:
+ if(ret_value==NULL) {
+ if(mesg)
+ H5FL_FREE(H5O_layout_t,mesg);
+ } /* end if */
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_layout_encode
@@ -186,12 +188,12 @@ H5O_layout_encode(H5F_t *f, uint8_t *p, const void *_mesg)
H5F_addr_encode(f, &p, mesg->addr);
/* dimension size */
- for (u = 0; u < mesg->ndims; u++) {
+ for (u = 0; u < mesg->ndims; u++)
UINT32ENCODE(p, mesg->dim[u]);
- }
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_layout_copy
@@ -215,21 +217,25 @@ H5O_layout_copy(const void *_mesg, void *_dest)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
H5O_layout_t *dest = (H5O_layout_t *) _dest;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_layout_copy, NULL);
/* check args */
assert(mesg);
- if (!dest && NULL==(dest=H5FL_ALLOC(H5O_layout_t,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!dest && NULL==(dest=H5FL_ALLOC(H5O_layout_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* copy */
*dest = *mesg;
- FUNC_LEAVE((void *) dest);
+ /* Set return value */
+ ret_value=dest;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_layout_size
@@ -253,7 +259,7 @@ static size_t
H5O_layout_size(H5F_t *f, const void *_mesg)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
- size_t ret_value = 0;
+ size_t ret_value;
FUNC_ENTER_NOAPI(H5O_layout_size, 0);
diff --git a/src/H5Omtime.c b/src/H5Omtime.c
index a424f27..ff5020c 100644
--- a/src/H5Omtime.c
+++ b/src/H5Omtime.c
@@ -78,6 +78,7 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p,
int i;
struct tm tm;
static int ncalls=0;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_mtime_decode, NULL);
@@ -91,10 +92,8 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p,
/* decode */
for (i=0; i<14; i++) {
- if (!HDisdigit(p[i])) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "badly formatted modification time message");
- }
+ if (!HDisdigit(p[i]))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message");
}
/*
@@ -112,10 +111,8 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p,
tm.tm_min = (p[10]-'0')*10 + (p[11]-'0');
tm.tm_sec = (p[12]-'0')*10 + (p[13]-'0');
tm.tm_isdst = -1; /*figure it out*/
- if ((time_t)-1==(the_time=HDmktime(&tm))) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "badly formatted modification time message");
- }
+ if ((time_t)-1==(the_time=HDmktime(&tm)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "badly formatted modification time message");
#if defined(H5_HAVE_TM_GMTOFF)
/* FreeBSD, OSF 4.0 */
@@ -130,20 +127,16 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p,
/* Irix5.3 */
{
struct timezone tz;
- if (HDBSDgettimeofday(NULL, &tz)<0) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "unable to obtain local timezone information");
- }
+ if (HDBSDgettimeofday(NULL, &tz)<0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information");
the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0);
}
#elif defined(H5_HAVE_GETTIMEOFDAY) && defined(H5_HAVE_STRUCT_TIMEZONE)
{
struct timezone tz;
- if (HDgettimeofday(NULL, &tz) < 0) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "unable to obtain local timezone information");
- }
+ if (HDgettimeofday(NULL, &tz) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information");
the_time -= tz.tz_minuteswest * 60 - (tm.tm_isdst ? 3600 : 0);
}
@@ -169,18 +162,19 @@ H5O_mtime_decode(H5F_t UNUSED *f, const uint8_t *p,
*/
/* Irix64 */
- HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "unable to obtain local timezone information");
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to obtain local timezone information");
#endif
/* The return value */
- if (NULL==(mesg = H5FL_ALLOC(time_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(mesg = H5FL_ALLOC(time_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
*mesg = the_time;
- FUNC_LEAVE((void*)mesg);
+ /* Set return value */
+ ret_value=mesg;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -245,21 +239,25 @@ H5O_mtime_copy(const void *_mesg, void *_dest)
{
const time_t *mesg = (const time_t *) _mesg;
time_t *dest = (time_t *) _dest;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_mtime_copy, NULL);
/* check args */
assert(mesg);
- if (!dest && NULL==(dest = H5FL_ALLOC(time_t,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!dest && NULL==(dest = H5FL_ALLOC(time_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* copy */
*dest = *mesg;
- FUNC_LEAVE((void *) dest);
+ /* Set return value */
+ ret_value=dest;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_mtime_size
@@ -355,7 +353,6 @@ H5O_mtime_debug(H5F_t UNUSED *f, const void *_mesg, FILE *stream,
/* debug */
tm = HDlocaltime(mesg);
-
HDstrftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %Z", tm);
fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
diff --git a/src/H5Oname.c b/src/H5Oname.c
index cd39d24..bbd4cb1 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -73,7 +73,8 @@ static void *
H5O_name_decode(H5F_t UNUSED *f, const uint8_t *p,
H5O_shared_t UNUSED *sh)
{
- H5O_name_t *mesg;
+ H5O_name_t *mesg;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_name_decode, NULL);
@@ -84,15 +85,22 @@ H5O_name_decode(H5F_t UNUSED *f, const uint8_t *p,
/* decode */
if (NULL==(mesg = H5MM_calloc(sizeof(H5O_name_t))) ||
- NULL==(mesg->s = H5MM_malloc (HDstrlen((const char*)p)+1))) {
- H5MM_xfree (mesg);
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ NULL==(mesg->s = H5MM_malloc (HDstrlen((const char*)p)+1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDstrcpy(mesg->s, (const char*)p);
- FUNC_LEAVE(mesg);
+ /* Set return value */
+ ret_value=mesg;
+
+done:
+ if(ret_value==NULL) {
+ if(mesg)
+ H5MM_xfree (mesg);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_encode
@@ -123,8 +131,10 @@ H5O_name_encode(H5F_t UNUSED *f, uint8_t *p, const void *_mesg)
/* encode */
HDstrcpy((char*)p, mesg->s);
+
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_copy
@@ -149,22 +159,27 @@ H5O_name_copy(const void *_mesg, void *_dest)
{
const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
H5O_name_t *dest = (H5O_name_t *) _dest;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_name_copy, NULL);
/* check args */
assert(mesg);
- if (!dest && NULL==(dest = H5MM_calloc(sizeof(H5O_name_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!dest && NULL==(dest = H5MM_calloc(sizeof(H5O_name_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* copy */
*dest = *mesg;
- dest->s = H5MM_xstrdup(mesg->s);
+ if((dest->s = H5MM_xstrdup(mesg->s))==NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
- FUNC_LEAVE((void *) dest);
+ /* Set return value */
+ ret_value=dest;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_size
@@ -199,8 +214,10 @@ H5O_name_size(H5F_t UNUSED *f, const void *_mesg)
assert(mesg);
size = mesg->s ? HDstrlen(mesg->s) + 1 : 0;
+
FUNC_LEAVE(size);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_reset
@@ -233,6 +250,7 @@ H5O_name_reset(void *_mesg)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_name_debug
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index b1244af..9173615 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -62,6 +62,7 @@ H5FL_EXTERN(H5S_simple_t);
/* Declare external the free list for hsize_t arrays */
H5FL_ARR_EXTERN(hsize_t);
+
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_decode
@@ -92,7 +93,7 @@ static void *
H5O_sdspace_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
{
H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */
- void *ret_value = NULL;
+ void *ret_value;
unsigned u; /* local counting variable */
unsigned flags, version;
@@ -106,54 +107,49 @@ H5O_sdspace_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
/* decode */
if ((sdim = H5FL_ALLOC(H5S_simple_t,1)) != NULL) {
version = *p++;
- if (version!=H5O_SDSPACE_VERSION) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "wrong version number in data space message");
- }
+ if (version!=H5O_SDSPACE_VERSION)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "wrong version number in data space message");
sdim->rank = *p++;
- if (sdim->rank>H5S_MAX_RANK) {
- HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
- "simple data space dimensionality is too large");
- }
+ if (sdim->rank>H5S_MAX_RANK)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "simple data space dimensionality is too large");
flags = *p++;
p += 5; /*reserved*/
if (sdim->rank > 0) {
- if (NULL==(sdim->size=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- for (u = 0; u < sdim->rank; u++) {
+ if (NULL==(sdim->size=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ for (u = 0; u < sdim->rank; u++)
H5F_DECODE_LENGTH (f, p, sdim->size[u]);
- }
if (flags & H5S_VALID_MAX) {
- if (NULL==(sdim->max=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
- for (u = 0; u < sdim->rank; u++) {
+ if (NULL==(sdim->max=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ for (u = 0; u < sdim->rank; u++)
H5F_DECODE_LENGTH (f, p, sdim->max[u]);
- }
}
#ifdef LATER
if (flags & H5S_VALID_PERM) {
- if (NULL==(sdim->perm=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0))) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(sdim->perm=H5FL_ARR_ALLOC(hsize_t,sdim->rank,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
for (u = 0; u < sdim->rank; u++)
UINT32DECODE(p, sdim->perm[u]);
}
-#endif
+#endif /* LATER */
}
}
+
+ /* Set return value */
ret_value = (void*)sdim; /*success*/
- done:
- if (!ret_value) H5FL_FREE(H5S_simple_t,sdim);
+done:
+ if (!ret_value && sdim) {
+ H5S_release_simple(sdim);
+ H5FL_FREE(H5S_simple_t,sdim);
+ } /* end if */
+
FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_encode
@@ -225,9 +221,11 @@ H5O_sdspace_encode(H5F_t *f, uint8_t *p, const void *mesg)
}
#endif
}
+
FUNC_LEAVE(SUCCEED);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_copy
@@ -248,46 +246,44 @@ H5O_sdspace_copy(const void *mesg, void *dest)
{
const H5S_simple_t *src = (const H5S_simple_t *) mesg;
H5S_simple_t *dst = (H5S_simple_t *) dest;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_sdspace_copy, NULL);
/* check args */
assert(src);
- if (!dst && NULL==(dst = H5FL_ALLOC(H5S_simple_t,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!dst && NULL==(dst = H5FL_ALLOC(H5S_simple_t,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* deep copy -- pointed-to values are copied also */
HDmemcpy(dst, src, sizeof(H5S_simple_t));
if (src->size) {
- if (NULL==(dst->size = H5FL_ARR_ALLOC(hsize_t,src->rank,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(dst->size = H5FL_ARR_ALLOC(hsize_t,src->rank,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy (dst->size, src->size, src->rank*sizeof(src->size[0]));
}
if (src->max) {
- if (NULL==(dst->max=H5FL_ARR_ALLOC(hsize_t,src->rank,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(dst->max=H5FL_ARR_ALLOC(hsize_t,src->rank,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy (dst->max, src->max, src->rank*sizeof(src->max[0]));
}
#ifdef LATER
if (src->perm) {
- if (NULL==(dst->perm=H5FL_ARR_ALLOC(hsize_t,src->rank,0))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(dst->perm=H5FL_ARR_ALLOC(hsize_t,src->rank,0)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy (dst->perm, src->perm, src->rank*sizeof(src->perm[0]));
}
#endif
- FUNC_LEAVE((void *) dst);
+ /* Set return value */
+ ret_value=dst;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_size
@@ -390,6 +386,7 @@ H5O_sdspace_free (void *mesg)
FUNC_LEAVE (SUCCEED);
}
+
/*--------------------------------------------------------------------------
NAME
H5O_sdspace_debug
@@ -429,9 +426,8 @@ H5O_sdspace_debug(H5F_t UNUSED *f, const void *mesg,
(unsigned long) (sdim->rank));
HDfprintf(stream, "%*s%-*s {", indent, "", fwidth, "Dim Size:");
- for (u = 0; u < sdim->rank; u++) {
+ for (u = 0; u < sdim->rank; u++)
HDfprintf (stream, "%s%Hu", u?", ":"", sdim->size[u]);
- }
HDfprintf (stream, "}\n");
HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Dim Max:");
diff --git a/src/H5Oshared.c b/src/H5Oshared.c
index d012149..29e93bf 100644
--- a/src/H5Oshared.c
+++ b/src/H5Oshared.c
@@ -68,8 +68,9 @@ static int interface_initialize_g = 0;
static void *
H5O_shared_decode (H5F_t *f, const uint8_t *buf, H5O_shared_t UNUSED *sh)
{
- H5O_shared_t *mesg;
+ H5O_shared_t *mesg=NULL;
unsigned flags, version;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_shared_decode, NULL);
@@ -79,17 +80,13 @@ H5O_shared_decode (H5F_t *f, const uint8_t *buf, H5O_shared_t UNUSED *sh)
assert (!sh);
/* Decode */
- if (NULL==(mesg = H5MM_calloc (sizeof *mesg))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(mesg = H5MM_calloc (sizeof *mesg)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Version */
version = *buf++;
- if (version!=H5O_SHARED_VERSION) {
- HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
- "bad version number for shared object message");
- }
+ if (version!=H5O_SHARED_VERSION)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for shared object message");
/* Flags */
flags = *buf++;
@@ -106,7 +103,16 @@ H5O_shared_decode (H5F_t *f, const uint8_t *buf, H5O_shared_t UNUSED *sh)
H5G_ent_decode (f, &buf, &(mesg->u.ent));
}
- FUNC_LEAVE (mesg);
+ /* Set return value */
+ ret_value=mesg;
+
+done:
+ if(ret_value==NULL) {
+ if(mesg!=NULL)
+ H5MM_xfree(mesg);
+ } /* end if */
+
+ FUNC_LEAVE (ret_value);
}
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index 76aef3b..37f2d0e 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -77,7 +77,8 @@ H5FL_DEFINE_STATIC(H5O_stab_t);
static void *
H5O_stab_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
{
- H5O_stab_t *stab;
+ H5O_stab_t *stab=NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_stab_decode, NULL);
@@ -87,15 +88,23 @@ H5O_stab_decode(H5F_t *f, const uint8_t *p, H5O_shared_t UNUSED *sh)
assert (!sh);
/* decode */
- if (NULL==(stab = H5FL_ALLOC(H5O_stab_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(stab = H5FL_ALLOC(H5O_stab_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
H5F_addr_decode(f, &p, &(stab->btree_addr));
H5F_addr_decode(f, &p, &(stab->heap_addr));
- FUNC_LEAVE(stab);
+ /* Set return value */
+ ret_value=stab;
+
+done:
+ if(ret_value==NULL) {
+ if(stab!=NULL)
+ H5FL_FREE(H5O_stab_t,stab);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_stab_encode
@@ -130,6 +139,7 @@ H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg)
FUNC_LEAVE(SUCCEED);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_stab_fast
@@ -153,7 +163,8 @@ H5O_stab_encode(H5F_t *f, uint8_t *p, const void *_mesg)
void *
H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
{
- H5O_stab_t *stab = NULL;
+ H5O_stab_t *stab = NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_stab_fast, NULL);
@@ -165,14 +176,19 @@ H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
if (_mesg) {
stab = (H5O_stab_t *) _mesg;
} else if (NULL==(stab = H5FL_ALLOC(H5O_stab_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
}
stab->btree_addr = cache->stab.btree_addr;
stab->heap_addr = cache->stab.heap_addr;
}
- FUNC_LEAVE(stab);
+
+ /* Set return value */
+ ret_value=stab;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_stab_copy
@@ -197,21 +213,25 @@ H5O_stab_copy(const void *_mesg, void *_dest)
{
const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
H5O_stab_t *dest = (H5O_stab_t *) _dest;
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5O_stab_copy, NULL);
/* check args */
assert(stab);
- if (!dest && NULL==(dest = H5FL_ALLOC(H5O_stab_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!dest && NULL==(dest = H5FL_ALLOC(H5O_stab_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* copy */
*dest = *stab;
- FUNC_LEAVE((void *) dest);
+ /* Set return value */
+ ret_value=dest;
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5O_stab_size
diff --git a/src/H5P.c b/src/H5P.c
index eb19ad3..d77ec18 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -98,6 +98,7 @@ H5P_init(void)
FUNC_LEAVE(SUCCEED);
}
+
/*--------------------------------------------------------------------------
NAME
H5P_xor_name -- Generate an xor'ed value for a string
@@ -129,6 +130,7 @@ H5P_xor_name(const char *s)
FUNC_LEAVE(ret);
} /* end H5P_xor_name() */
+
/*--------------------------------------------------------------------------
NAME
H5P_hash_name -- Generate a hash value for a string
@@ -150,6 +152,7 @@ H5P_hash_name(const char *s, unsigned hashsize)
FUNC_LEAVE(H5P_xor_name(s)%hashsize);
} /* end H5P_hash_name() */
+
/*--------------------------------------------------------------------------
NAME
H5P_init_interface -- Initialize interface-specific information
@@ -173,79 +176,81 @@ H5P_init_interface(void)
/* Make certain IDs are initialized */
if (ret_value < 0)
- HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group");
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group");
/*
* Initialize the Generic Property class & object groups.
*/
if (H5I_init_group(H5I_GENPROP_CLS, H5I_GENPROPCLS_HASHSIZE, 0, (H5I_free_t)H5P_close_class) < 0)
- HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group");
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group");
if (H5I_init_group(H5I_GENPROP_LST, H5I_GENPROPOBJ_HASHSIZE, 0, (H5I_free_t)H5P_close) < 0)
- HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group");
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "unable to initialize atom group");
/* Create root property list class */
/* Allocate the root class */
assert(H5P_CLS_NO_CLASS_g==(-1));
if (NULL==(root_class = H5P_create_class (NULL,"none",H5P_NO_CLASS_HASH_SIZE,1,NULL,NULL,NULL,NULL,NULL,NULL)))
- HRETURN_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
/* Register the root class */
if ((H5P_CLS_NO_CLASS_g = H5I_register (H5I_GENPROP_CLS, root_class))<0)
- HRETURN_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
/* Register the file creation and file access property classes */
/* Allocate the file creation class */
assert(H5P_CLS_FILE_CREATE_g==(-1));
if (NULL==(pclass = H5P_create_class (root_class,"file create",H5P_FILE_CREATE_HASH_SIZE,1,NULL,NULL,NULL,NULL,NULL,NULL)))
- HRETURN_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
/* Register the file creation class */
if ((H5P_CLS_FILE_CREATE_g = H5I_register (H5I_GENPROP_CLS, pclass))<0)
- HRETURN_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
/* Allocate the file access class */
assert(H5P_CLS_FILE_ACCESS_g==(-1));
if (NULL==(pclass = H5P_create_class (root_class,"file access",H5P_FILE_ACCESS_HASH_SIZE,1,H5F_acs_create,NULL,H5F_acs_copy,NULL,H5F_acs_close,NULL)))
- HRETURN_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
/* Register the file access class */
if ((H5P_CLS_FILE_ACCESS_g = H5I_register (H5I_GENPROP_CLS, pclass))<0)
- HRETURN_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
/* Register the dataset creation and data xfer property classes */
/* Allocate the dataset creation class */
assert(H5P_CLS_DATASET_CREATE_g==(-1));
if (NULL==(pclass = H5P_create_class (root_class,"dataset create",H5P_DATASET_CREATE_HASH_SIZE,1,NULL,NULL,H5D_crt_copy,NULL,H5D_crt_close,NULL)))
- HRETURN_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
/* Register the dataset creation class */
if ((H5P_CLS_DATASET_CREATE_g = H5I_register (H5I_GENPROP_CLS, pclass))<0)
- HRETURN_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
/* Allocate the data xfer class */
assert(H5P_CLS_DATASET_XFER_g==(-1));
if (NULL==(pclass = H5P_create_class (root_class,"data xfer",H5P_DATASET_XFER_HASH_SIZE,1,H5D_xfer_create,NULL,H5D_xfer_copy,NULL,H5D_xfer_close,NULL)))
- HRETURN_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
/* Register the data xfer class */
if ((H5P_CLS_DATASET_XFER_g = H5I_register (H5I_GENPROP_CLS, pclass))<0)
- HRETURN_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
/* Allocate the mount class */
assert(H5P_CLS_MOUNT_g==(-1));
if (NULL==(pclass = H5P_create_class (root_class,"file mount",H5P_MOUNT_HASH_SIZE,1,NULL,NULL,NULL,NULL,NULL,NULL)))
- HRETURN_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTINIT, FAIL, "class initialization failed");
/* Register the mount class */
if ((H5P_CLS_MOUNT_g = H5I_register (H5I_GENPROP_CLS, pclass))<0)
- HRETURN_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+ HGOTO_ERROR (H5E_PLIST, H5E_CANTREGISTER, FAIL, "can't register property list class");
+done:
FUNC_LEAVE(ret_value);
}
+
/*--------------------------------------------------------------------------
NAME
H5P_term_interface
@@ -605,7 +610,7 @@ H5Pget_version(hid_t plist_id, int *boot/*out*/, int *freelist/*out*/,
int *stab/*out*/, int *shhdr/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_version, FAIL);
H5TRACE5("e","ixxxx",plist_id,boot,freelist,stab,shhdr);
@@ -621,23 +626,16 @@ H5Pget_version(hid_t plist_id, int *boot/*out*/, int *freelist/*out*/,
/* Get values */
if (boot)
if(H5P_get(plist, H5F_CRT_BOOT_VERS_NAME, boot) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,
- "can't get boot version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get boot version");
if (freelist)
if(H5P_get(plist, H5F_CRT_FREESPACE_VERS_NAME, freelist) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,
- "can't get free-space version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space version");
if (stab)
if(H5P_get(plist, H5F_CRT_OBJ_DIR_VERS_NAME, stab) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,
- "can't get object directory version");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object directory version");
if (shhdr)
if(H5P_get(plist, H5F_CRT_SHARE_HEAD_VERS_NAME, shhdr) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,
- "can't get shared-header version");
-
- /* Set return value */
- ret_value=SUCCEED;
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get shared-header version");
done:
FUNC_LEAVE(ret_value);
@@ -832,7 +830,7 @@ H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/,
hsize_t *alignment/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_alignment, FAIL);
H5TRACE3("e","ixx",fapl_id,threshold,alignment);
@@ -853,9 +851,6 @@ H5Pget_alignment(hid_t fapl_id, hsize_t *threshold/*out*/,
if(H5P_get(plist, H5F_ACS_ALIGN_NAME, alignment) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get alignment");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
}
@@ -1003,7 +998,7 @@ H5Pset_sym_k(hid_t plist_id, int ik, int lk)
{
int btree_k[H5B_NUM_BTREE_ID];
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pset_sym_k, FAIL);
H5TRACE3("e","iIsIs",plist_id,ik,lk);
@@ -1028,9 +1023,6 @@ H5Pset_sym_k(hid_t plist_id, int ik, int lk)
if(H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for symbol table leaf nodes");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
}
@@ -1061,7 +1053,7 @@ H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , int *lk /*out */ )
{
int btree_k[H5B_NUM_BTREE_ID];
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_sym_k, FAIL);
H5TRACE3("e","ixx",plist_id,ik,lk);
@@ -1084,9 +1076,6 @@ H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , int *lk /*out */ )
if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
}
@@ -1127,7 +1116,7 @@ H5Pset_sym_k(hid_t plist_id, int ik, unsigned lk)
{
int btree_k[H5B_NUM_BTREE_ID];
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pset_sym_k, FAIL);
H5TRACE3("e","iIsIu",plist_id,ik,lk);
@@ -1152,9 +1141,6 @@ H5Pset_sym_k(hid_t plist_id, int ik, unsigned lk)
if(H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for symbol table leaf nodes");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
}
@@ -1185,7 +1171,7 @@ H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , unsigned *lk /*out */ )
{
int btree_k[H5B_NUM_BTREE_ID];
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pget_sym_k, FAIL);
H5TRACE3("e","ixx",plist_id,ik,lk);
@@ -1208,9 +1194,6 @@ H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , unsigned *lk /*out */ )
if(H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
}
@@ -1241,7 +1224,7 @@ H5Pset_istore_k(hid_t plist_id, int ik)
{
int btree_k[H5B_NUM_BTREE_ID];
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pset_istore_k, FAIL);
H5TRACE2("e","iIs",plist_id,ik);
@@ -1263,9 +1246,6 @@ H5Pset_istore_k(hid_t plist_id, int ik)
if(H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree interanl nodes");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
}
@@ -1591,7 +1571,7 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size)
hsize_t total, tmp;
H5O_efl_t efl;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Pset_external, FAIL);
H5TRACE4("e","isoh",plist_id,name,offset,size);
@@ -1644,9 +1624,6 @@ H5Pset_external(hid_t plist_id, const char *name, off_t offset, hsize_t size)
if(H5P_set(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set external file list");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
}
@@ -1678,7 +1655,7 @@ H5Pget_external_count(hid_t plist_id)
{
H5O_efl_t efl;
H5P_genplist_t *plist; /* Property list pointer */
- int ret_value=SUCCEED; /* return value */
+ int ret_value; /* return value */
FUNC_ENTER_API(H5Pget_external_count, FAIL);
H5TRACE1("Is","i",plist_id);
@@ -1695,7 +1672,7 @@ H5Pget_external_count(hid_t plist_id)
if(H5P_get(plist, H5D_CRT_EXT_FILE_LIST_NAME, &efl) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external file list");
- /* Return value */
+ /* Set return value */
ret_value=efl.nused;
done:
@@ -1962,7 +1939,7 @@ done:
hid_t
H5P_get_driver(H5P_genplist_t *plist)
{
- hid_t ret_value=-1;
+ hid_t ret_value=FAIL; /* Return value */
FUNC_ENTER_NOAPI(H5P_get_driver, FAIL);
@@ -2017,16 +1994,17 @@ hid_t
H5Pget_driver(hid_t plist_id)
{
H5P_genplist_t *plist; /* Property list pointer */
- hid_t ret_value=-1;
+ hid_t ret_value; /* Return value */
FUNC_ENTER_API(H5Pget_driver, FAIL);
H5TRACE1("i","i",plist_id);
if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list");
ret_value = H5P_get_driver(plist);
+done:
FUNC_LEAVE(ret_value);
}
@@ -2110,16 +2088,17 @@ void *
H5Pget_driver_info(hid_t plist_id)
{
H5P_genplist_t *plist; /* Property list pointer */
- void *ret_value=NULL;
+ void *ret_value; /* Return value */
FUNC_ENTER_API(H5Pget_driver_info, NULL);
if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list");
if((ret_value=H5P_get_driver_info(plist))==NULL)
- HRETURN_ERROR(H5E_PLIST,H5E_CANTGET,NULL,"can't get driver info");
+ HGOTO_ERROR(H5E_PLIST,H5E_CANTGET,NULL,"can't get driver info");
+done:
FUNC_LEAVE(ret_value);
} /* end H5Pget_driver_info() */
@@ -2462,7 +2441,7 @@ H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
size_t size; /* Type conversion buffer size */
- hsize_t ret_value=0; /* Type conversion buffer size */
+ hsize_t ret_value; /* Return value */
FUNC_ENTER_API(H5Pget_buffer, 0);
H5TRACE3("h","ixx",plist_id,tconv,bkg);
@@ -2572,7 +2551,7 @@ H5Pget_buffer(hid_t plist_id, void **tconv/*out*/, void **bkg/*out*/)
{
H5P_genplist_t *plist; /* Property list pointer */
size_t size; /* Type conversion buffer size */
- size_t ret_value=0; /* Type conversion buffer size */
+ size_t ret_value; /* Return value */
FUNC_ENTER_API(H5Pget_buffer, 0);
H5TRACE3("z","ixx",plist_id,tconv,bkg);
@@ -3271,12 +3250,10 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value)
/* Set the fill value */
if (NULL==(fill.type=H5T_copy(type, H5T_COPY_TRANSIENT)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to copy data type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type");
fill.size = H5T_get_size(type);
if (NULL==(fill.buf=H5MM_malloc(fill.size)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL,
- "memory allocation failed for fill value");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, FAIL, "memory allocation failed for fill value");
HDmemcpy(fill.buf, value, fill.size);
} else {
fill.type = fill.buf = NULL;
@@ -3323,7 +3300,7 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/)
void *buf = NULL; /*conversion buffer */
void *bkg = NULL; /*conversion buffer */
hid_t src_id = -1; /*source data type id */
- herr_t ret_value = FAIL; /*return value */
+ herr_t ret_value=SUCCEED; /* Return value */
H5P_genplist_t *plist; /* Property list pointer */
FUNC_ENTER_API(H5Pget_fill_value, FAIL);
@@ -3350,12 +3327,11 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/)
if(H5P_get(plist, H5D_CRT_FILL_VALUE_NAME, &fill) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value");
if(fill.size == (size_t)-1)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL,
- "fill value is undefined");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "fill value is undefined");
if(fill.size == 0) {
HDmemset(value, 0, H5T_get_size(type));
- HRETURN(SUCCEED);
+ HGOTO_DONE(SUCCEED);
}
/*
* Can we convert between the source and destination data types?
@@ -3388,7 +3364,6 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed");
if (buf!=value)
HDmemcpy(value, buf, H5T_get_size(type));
- ret_value = SUCCEED;
done:
if (buf!=value)
@@ -3481,7 +3456,7 @@ H5Pfill_value_defined(hid_t plist_id, H5D_fill_value_t *status)
/* Check arguments */
if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation proprety list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation proprety list");
/* Get the plist structure */
if(NULL == (plist = H5I_object(plist_id)))
@@ -3759,9 +3734,7 @@ H5Pget_gc_references(hid_t plist_id, unsigned *gc_ref/*out*/)
/* Get values */
if (gc_ref)
-
if(H5P_get(plist, H5F_ACS_GARBG_COLCT_REF_NAME, gc_ref) < 0)
-
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get garbage collect reference");
done:
@@ -4508,7 +4481,7 @@ static H5P_genprop_t *
H5P_dup_prop(H5P_genprop_t *oprop)
{
H5P_genprop_t *prop=NULL; /* Pointer to new property copied */
- H5P_genprop_t *ret_value=NULL; /* Return value */
+ H5P_genprop_t *ret_value; /* Return value */
FUNC_ENTER_NOINIT(H5P_dup_prop);
@@ -4601,7 +4574,7 @@ H5P_create_prop(const char *name, size_t size, void *def_value, void *value,
H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close)
{
H5P_genprop_t *prop=NULL; /* Pointer to new property copied */
- H5P_genprop_t *ret_value=NULL; /* Return value */
+ H5P_genprop_t *ret_value; /* Return value */
FUNC_ENTER_NOINIT(H5P_create_prop);
@@ -4691,7 +4664,6 @@ static herr_t
H5P_add_prop(H5P_genprop_t *hash[], unsigned hashsize, H5P_genprop_t *prop)
{
unsigned loc; /* Hash table location */
- herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5P_add_prop);
@@ -4706,10 +4678,7 @@ H5P_add_prop(H5P_genprop_t *hash[], unsigned hashsize, H5P_genprop_t *prop)
prop->next=hash[loc];
hash[loc]=prop;
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5P_add_prop() */
@@ -4787,8 +4756,6 @@ H5P_find_prop(H5P_genprop_t *hash[], unsigned hashsize, const char *name)
static herr_t
H5P_free_prop(H5P_genprop_t *prop)
{
- herr_t ret_value=SUCCEED; /* Return value */
-
FUNC_ENTER_NOINIT(H5P_free_prop);
assert(prop);
@@ -4803,10 +4770,7 @@ H5P_free_prop(H5P_genprop_t *prop)
H5MM_xfree(prop->name);
H5MM_xfree(prop);
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5P_free_prop() */
@@ -4835,7 +4799,6 @@ H5P_free_all_prop(H5P_genprop_t *hash[], unsigned hashsize, unsigned make_cb)
{
H5P_genprop_t *tprop, *next;/* Temporary pointer to properties */
unsigned u; /* Local index variable */
- herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5P_free_all_prop);
@@ -4860,10 +4823,7 @@ H5P_free_all_prop(H5P_genprop_t *hash[], unsigned hashsize, unsigned make_cb)
} /* end while */
} /* end for */
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5P_free_all_prop() */
@@ -4892,8 +4852,6 @@ done:
static herr_t
H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod)
{
- herr_t ret_value=SUCCEED; /* Return value */
-
FUNC_ENTER_NOINIT(H5P_access_class);
assert(pclass);
@@ -4943,10 +4901,7 @@ H5P_access_class(H5P_genclass_t *pclass, H5P_class_mod_t mod)
H5MM_xfree(pclass);
} /* end if */
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5P_access_class() */
@@ -4992,7 +4947,7 @@ H5P_create_class(H5P_genclass_t *par_class, const char *name, unsigned hashsize,
)
{
H5P_genclass_t *pclass; /* Property list class created */
- H5P_genclass_t *ret_value=NULL; /* return value */
+ H5P_genclass_t *ret_value; /* return value */
FUNC_ENTER_NOINIT(H5P_create_class);
@@ -5091,7 +5046,7 @@ H5Pcreate_class(hid_t parent, const char *name, unsigned hashsize,
{
H5P_genclass_t *par_class = NULL; /* Pointer to the parent class */
H5P_genclass_t *pclass = NULL; /* Property list class created */
- hid_t ret_value = FAIL; /* Return value */
+ hid_t ret_value; /* Return value */
FUNC_ENTER_API(H5Pcreate_class, FAIL);
H5TRACE9("i","isIuxxxxxx",parent,name,hashsize,cls_create,create_data,
@@ -5105,8 +5060,8 @@ H5Pcreate_class(hid_t parent, const char *name, unsigned hashsize,
if (hashsize==0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hashsize too small");
if ((create_data!=NULL && cls_create==NULL)
- || (copy_data!=NULL && cls_copy==NULL)
- || (close_data!=NULL && cls_close==NULL))
+ || (copy_data!=NULL && cls_copy==NULL)
+ || (close_data!=NULL && cls_close==NULL))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data specified, but no callback provided");
/* Get the pointer to the parent class */
@@ -5160,10 +5115,10 @@ static H5P_genplist_t *H5P_create(H5P_genclass_t *pclass)
{
H5P_genclass_t *tclass=NULL; /* Temporary class pointer */
H5P_genplist_t *plist=NULL; /* New property list created */
- H5P_genplist_t *ret_value=NULL; /* return value */
+ H5P_genplist_t *ret_value; /* return value */
H5P_genprop_t *tmp; /* Temporary pointer to parent class properties */
H5P_genprop_t *pcopy; /* Copy of property to insert into class */
- unsigned u; /* Local index variable */
+ unsigned u; /* Local index variable */
FUNC_ENTER_NOINIT(H5P_create);
@@ -5287,8 +5242,8 @@ done:
hid_t H5P_create_id(H5P_genclass_t *pclass)
{
H5P_genplist_t *plist=NULL; /* Property list created */
- hid_t plist_id=FAIL; /* Property list ID */
- hid_t ret_value=FAIL; /* return value */
+ hid_t plist_id=FAIL; /* Property list ID */
+ hid_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5P_create_id, FAIL);
@@ -5353,7 +5308,7 @@ done:
hid_t H5Pcreate(hid_t cls_id)
{
H5P_genclass_t *pclass; /* Property list class to modify */
- hid_t ret_value=FAIL; /* return value */
+ hid_t ret_value; /* return value */
FUNC_ENTER_API(H5Pcreate, FAIL);
@@ -5510,7 +5465,7 @@ herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size,
H5P_genprop_t *new_prop=NULL; /* Temporary property pointer */
H5P_genprop_t *pcopy; /* Property copy */
unsigned u; /* Local index variable */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5P_register, FAIL);
@@ -5564,9 +5519,6 @@ herr_t H5P_register(H5P_genclass_t *pclass, const char *name, size_t size,
/* Increment property count for class */
pclass->nprops++;
- /* Set return value */
- ret_value=SUCCEED;
-
done:
if(ret_value==FAIL) {
if(new_prop!=NULL) {
@@ -5720,7 +5672,7 @@ herr_t H5Pregister(hid_t cls_id, const char *name, size_t size, void *def_value,
H5P_prp_copy_func_t prp_copy, H5P_prp_close_func_t prp_close)
{
H5P_genclass_t *pclass; /* Property list class to modify */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Pregister, FAIL);
@@ -5854,7 +5806,7 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size,
H5P_prp_close_func_t prp_close)
{
H5P_genprop_t *new_prop=NULL; /* Temporary property pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5P_insert);
@@ -5877,9 +5829,6 @@ H5P_insert(H5P_genplist_t *plist, const char *name, size_t size,
/* Increment property count for class */
plist->nprops++;
- /* Set return value */
- ret_value=SUCCEED;
-
done:
if(ret_value==FAIL) {
if(new_prop!=NULL) {
@@ -5892,6 +5841,7 @@ done:
H5MM_xfree(new_prop);
} /* end if */
} /* end if */
+
FUNC_LEAVE (ret_value);
} /* H5P_insert() */
@@ -6007,7 +5957,7 @@ herr_t H5Pinsert(hid_t plist_id, const char *name, size_t size, void *value,
H5P_prp_close_func_t prp_close)
{
H5P_genplist_t *plist; /* Property list to modify */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Pinsert, FAIL);
@@ -6062,7 +6012,7 @@ done:
herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value)
{
H5P_genprop_t *prop; /* Temporary property pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5P_set, FAIL);
@@ -6101,9 +6051,6 @@ herr_t H5P_set(H5P_genplist_t *plist, const char *name, const void *value)
else
HDmemcpy(prop->value,value,prop->size);
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5P_set() */
@@ -6272,7 +6219,7 @@ htri_t H5Pexist(hid_t id, const char *name)
{
H5P_genplist_t *plist; /* Property list to query */
H5P_genclass_t *pclass; /* Property class to query */
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_API(H5Pexist, FAIL);
@@ -6423,7 +6370,7 @@ herr_t H5Pget_size(hid_t id, const char *name, size_t *size)
{
H5P_genclass_t *pclass; /* Property class to query */
H5P_genplist_t *plist; /* Property list to query */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Pget_size, FAIL);
@@ -6482,7 +6429,7 @@ done:
static H5P_genclass_t *
H5P_get_class(H5P_genplist_t *plist)
{
- H5P_genclass_t *ret_value=NULL; /* return value */
+ H5P_genclass_t *ret_value; /* return value */
FUNC_ENTER_NOINIT(H5P_get_class);
@@ -6570,8 +6517,6 @@ done:
static herr_t
H5P_get_nprops_plist(H5P_genplist_t *plist, size_t *nprops)
{
- herr_t ret_value=SUCCEED; /* return value */
-
FUNC_ENTER_NOINIT(H5P_get_nprops_plist);
assert(plist);
@@ -6580,7 +6525,7 @@ H5P_get_nprops_plist(H5P_genplist_t *plist, size_t *nprops)
/* Get property size */
*nprops=plist->nprops;
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5P_get_nprops_plist() */
@@ -6606,8 +6551,6 @@ H5P_get_nprops_plist(H5P_genplist_t *plist, size_t *nprops)
--------------------------------------------------------------------------*/
herr_t H5P_get_nprops_pclass(H5P_genclass_t *pclass, size_t *nprops)
{
- herr_t ret_value=SUCCEED; /* return value */
-
FUNC_ENTER_NOAPI(H5P_get_nprops_pclass, FAIL);
assert(pclass);
@@ -6616,7 +6559,7 @@ herr_t H5P_get_nprops_pclass(H5P_genclass_t *pclass, size_t *nprops)
/* Get property size */
*nprops=pclass->nprops;
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5P_get_nprops_pclass() */
@@ -7036,7 +6979,7 @@ done:
static htri_t
H5P_isa_class_real(H5P_genclass_t *pclass1, H5P_genclass_t *pclass2)
{
- htri_t ret_value=FAIL;
+ htri_t ret_value;
FUNC_ENTER_NOINIT(H5P_isa_class_real);
@@ -7091,7 +7034,7 @@ htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id)
{
H5P_genplist_t *plist; /* Property list to query */
H5P_genclass_t *pclass; /* Property list class */
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5P_isa_class, FAIL);
@@ -7135,7 +7078,7 @@ done:
--------------------------------------------------------------------------*/
htri_t H5Pisa_class(hid_t plist_id, hid_t pclass_id)
{
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_API(H5Pisa_class, FAIL);
@@ -7303,7 +7246,7 @@ static int
H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_data)
{
H5P_genplist_t *plist; /* Property list pointer */
- int ret_value=0; /* Return value */
+ int ret_value; /* Return value */
FUNC_ENTER_NOINIT(H5P_iterate_plist);
@@ -7377,7 +7320,7 @@ static int
H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, void *iter_data)
{
H5P_genclass_t *pclass; /* Property list pointer */
- int ret_value=0; /* Return value */
+ int ret_value; /* Return value */
FUNC_ENTER_NOINIT(H5P_iterate_pclass);
@@ -7451,7 +7394,7 @@ iteration, the function's behavior is undefined.
int H5Piterate(hid_t id, int *idx, H5P_iterate_t iter_func, void *iter_data)
{
int fake_idx=0; /* Index when user doesn't provide one */
- int ret_value=FAIL; /* return value */
+ int ret_value; /* return value */
FUNC_ENTER_API(H5Piterate, FAIL);
@@ -7726,7 +7669,7 @@ size_t H5P_peek_size_t(H5P_genplist_t *plist, const char *name)
herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value)
{
H5P_genprop_t *prop; /* Temporary property pointer */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5P_get, FAIL);
@@ -7765,9 +7708,6 @@ herr_t H5P_get(H5P_genplist_t *plist, const char *name, void *value)
else
HDmemcpy(value,prop->value,prop->size);
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5P_get() */
@@ -7857,7 +7797,7 @@ H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name)
H5P_genprop_t *prop; /* Temporary property pointer */
H5P_genprop_t *tprop, *prev;/* Temporary pointer to properties */
unsigned loc; /* Hash table location */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5P_remove);
@@ -7912,9 +7852,6 @@ H5P_remove(hid_t plist_id, H5P_genplist_t *plist, const char *name)
/* Decrement the number of properties in list */
plist->nprops--;
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5P_remove() */
@@ -7949,7 +7886,7 @@ done:
herr_t H5Premove(hid_t plist_id, const char *name)
{
H5P_genplist_t *plist; /* Property list to modify */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Premove, FAIL);
@@ -8243,7 +8180,7 @@ H5P_unregister(H5P_genclass_t *pclass, const char *name)
H5P_genprop_t *prop; /* Temporary property pointer */
H5P_genprop_t *tprop, *prev;/* Temporary pointer to properties */
unsigned loc; /* Hash table location */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5P_unregister);
@@ -8290,9 +8227,6 @@ H5P_unregister(H5P_genclass_t *pclass, const char *name)
/* Decrement the number of registered properties in class */
pclass->nprops--;
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5P_unregister() */
@@ -8322,7 +8256,7 @@ done:
herr_t H5Punregister(hid_t pclass_id, const char *name)
{
H5P_genclass_t *pclass; /* Property list class to modify */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Punregister, FAIL);
@@ -8466,7 +8400,7 @@ done:
--------------------------------------------------------------------------*/
char *H5P_get_class_name(H5P_genclass_t *pclass)
{
- char *ret_value=NULL; /* return value */
+ char *ret_value; /* return value */
FUNC_ENTER_NOAPI(H5P_get_class_name, NULL);
@@ -8502,7 +8436,7 @@ char *H5P_get_class_name(H5P_genclass_t *pclass)
char *H5Pget_class_name(hid_t pclass_id)
{
H5P_genclass_t *pclass; /* Property class to query */
- char *ret_value=NULL; /* return value */
+ char *ret_value; /* return value */
FUNC_ENTER_API(H5Pget_class_name, NULL);
@@ -8541,7 +8475,7 @@ done:
static H5P_genclass_t *
H5P_get_class_parent(H5P_genclass_t *pclass)
{
- H5P_genclass_t *ret_value=NULL; /* return value */
+ H5P_genclass_t *ret_value; /* return value */
FUNC_ENTER_NOINIT(H5P_get_class_parent);
@@ -8577,7 +8511,7 @@ hid_t H5Pget_class_parent(hid_t pclass_id)
{
H5P_genclass_t *pclass; /* Property class to query */
H5P_genclass_t *parent=NULL; /* Parent's property class */
- hid_t ret_value=FAIL; /* return value */
+ hid_t ret_value; /* return value */
FUNC_ENTER_API(H5Pget_class_parent, FAIL);
@@ -8626,7 +8560,7 @@ static herr_t
H5P_close_class(void *_pclass)
{
H5P_genclass_t *pclass=(H5P_genclass_t *)_pclass;
- herr_t ret_value = FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5P_close_class);
@@ -8651,9 +8585,6 @@ H5P_close_class(void *_pclass)
HGOTO_ERROR (H5E_PLIST, H5E_NOTFOUND, FAIL,"Can't check class ref count");
} /* end if */
- /* Set return value */
- ret_value = SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5P_close_class() */
diff --git a/src/H5R.c b/src/H5R.c
index 9d4f27f..795bc56 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -56,16 +56,17 @@ DESCRIPTION
static herr_t
H5R_init_interface(void)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5R_init_interface);
/* Initialize the atom group for the file IDs */
if (H5I_init_group(H5I_REFERENCE, H5I_REFID_HASHSIZE, H5R_RESERVED_ATOMS,
- (H5I_free_t)NULL)<0) {
- HRETURN_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL,
- "unable to initialize interface");
- }
+ (H5I_free_t)NULL)<0)
+ HGOTO_ERROR (H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -138,7 +139,7 @@ static herr_t
H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space)
{
H5G_stat_t sb; /* Stat buffer for retrieving OID */
- herr_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5R_create);
@@ -196,8 +197,7 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type,
/* Get the amount of space required to serialize the selection */
if ((buf_size = (*space->select.serial_size)(space)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL,
- "Invalid amount of space for serializing selection");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection");
/* Increase buffer size to allow for the dataset OID */
buf_size+=sizeof(haddr_t);
@@ -205,7 +205,7 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type,
/* Allocate the space to store the serialized information */
H5_CHECK_OVERFLOW(buf_size,hssize_t,size_t);
if (NULL==(buf = H5MM_malloc((size_t)buf_size)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* Serialize information for dataset OID */
p=(uint8_t *)buf;
@@ -232,20 +232,15 @@ H5R_create(void *_ref, H5G_entry_t *loc, const char *name, H5R_type_t ref_type,
}
case H5R_INTERNAL:
- HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
- "Internal references are not yet supported");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "Internal references are not yet supported");
case H5R_BADTYPE:
case H5R_MAXTYPE:
default:
assert("unknown reference type" && 0);
- HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown reference type)");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)");
} /* end switch */
- /* Return success */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE(ret_value);
} /* end H5R_create() */
@@ -283,24 +278,24 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t
{
H5G_entry_t *loc = NULL; /* File location */
H5S_t *space = NULL; /* Pointer to dataspace containing region */
- herr_t ret_value = FAIL;
+ herr_t ret_value; /* Return value */
FUNC_ENTER_API(H5Rcreate, FAIL);
H5TRACE5("e","xisRti",ref,loc_id,name,ref_type,space_id);
/* Check args */
if(ref==NULL)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
if (NULL==(loc=H5G_loc (loc_id)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
if (!name || !*name)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
if(ref_type!=H5R_OBJECT && ref_type!=H5R_DATASET_REGION)
- HRETURN_ERROR (H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported");
+ HGOTO_ERROR (H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported");
if (space_id!=(-1) && (NULL==(space=H5I_object_verify(space_id,H5I_DATASPACE))))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
/* Create reference */
if ((ret_value=H5R_create(ref,loc,name,ref_type,space))<0)
@@ -342,7 +337,7 @@ H5R_dereference(H5F_t *file, H5R_type_t ref_type, void *_ref)
H5G_entry_t ent; /* Symbol table entry */
uint8_t *p; /* Pointer to OID to store */
int oid_type; /* type of object being dereferenced */
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_NOINIT(H5R_dereference);
@@ -382,8 +377,7 @@ H5R_dereference(H5F_t *file, H5R_type_t ref_type, void *_ref)
/* Get the dataset region from the heap (allocate inside routine) */
if((buf=H5HG_read(ent.file,&hobjid,NULL))==NULL)
- HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL,
- "Unable to read dataset region information");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information");
/* Get the object oid for the dataset */
p=(uint8_t *)buf;
@@ -395,66 +389,57 @@ H5R_dereference(H5F_t *file, H5R_type_t ref_type, void *_ref)
break;
case H5R_INTERNAL:
- HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
- "Internal references are not yet supported");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "Internal references are not yet supported");
case H5R_BADTYPE:
case H5R_MAXTYPE:
default:
assert("unknown reference type" && 0);
- HRETURN_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown reference type)");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)");
} /* end switch */
/* Check to make certain that this object hasn't been deleted since the reference was created */
if(H5O_link(&ent,0)<=0)
- HRETURN_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_LINKCOUNT, FAIL, "dereferencing deleted object");
/* Open the dataset object */
oid_type=H5G_get_type(&ent);
switch(oid_type) {
case H5G_GROUP:
- if ((group=H5G_open_oid(&ent)) == NULL) {
+ if ((group=H5G_open_oid(&ent)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
- }
/* Create an atom for the dataset */
if ((ret_value = H5I_register(H5I_GROUP, group)) < 0) {
H5G_close(group);
- HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL,
- "can't register group");
+ HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "can't register group");
}
break;
case H5G_TYPE:
- if ((datatype=H5T_open_oid(&ent)) == NULL) {
+ if ((datatype=H5T_open_oid(&ent)) == NULL)
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found");
- }
/* Create an atom for the dataset */
if ((ret_value = H5I_register(H5I_DATATYPE, datatype)) < 0) {
H5T_close(datatype);
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "can't register group");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "can't register group");
}
break;
case H5G_DATASET:
- if ((dataset=H5D_open_oid(&ent)) == NULL) {
+ if ((dataset=H5D_open_oid(&ent)) == NULL)
HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found");
- }
/* Create an atom for the dataset */
if ((ret_value = H5I_register(H5I_DATASET, dataset)) < 0) {
H5D_close(dataset);
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "can't register dataset");
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset");
}
break;
default:
- HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL,
- "can't identify type of object referenced");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_BADTYPE, FAIL, "can't identify type of object referenced");
} /* end switch */
done:
@@ -489,18 +474,18 @@ H5Rdereference(hid_t id, H5R_type_t ref_type, void *_ref)
{
H5G_entry_t *loc = NULL; /* Symbol table entry */
H5F_t *file=NULL; /* File object */
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Rdereference, FAIL);
H5TRACE3("i","iRtx",id,ref_type,_ref);
/* Check args */
if (NULL == (loc = H5G_loc(id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
if(_ref==NULL)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
/* Get the file pointer from the entry */
file=loc->file;
@@ -545,7 +530,7 @@ H5R_get_region(H5F_t *file, H5R_type_t UNUSED ref_type, void *_ref)
hdset_reg_ref_t *ref=(hdset_reg_ref_t *)_ref; /* Get pointer to correct type of reference struct */
H5HG_t hobjid; /* Heap object ID */
uint8_t *buf; /* Buffer to store serialized selection in */
- H5S_t *ret_value = NULL;
+ H5S_t *ret_value;
FUNC_ENTER_NOINIT(H5R_get_region);
@@ -565,35 +550,30 @@ H5R_get_region(H5F_t *file, H5R_type_t UNUSED ref_type, void *_ref)
/* Get the dataset region from the heap (allocate inside routine) */
if((buf=H5HG_read(ent.file,&hobjid,NULL))==NULL)
- HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL,
- "Unable to read dataset region information");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, NULL, "Unable to read dataset region information");
/* Get the object oid for the dataset */
p=(uint8_t *)buf;
H5F_addr_decode(ent.file,(const uint8_t **)&p,&(ent.header));
/* Open the dataset object */
- if ((dataset=H5D_open_oid(&ent)) == NULL) {
+ if ((dataset=H5D_open_oid(&ent)) == NULL)
HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found");
- }
/* Copy the dataspace object */
- if ((ret_value=H5D_get_space(dataset)) == NULL) {
+ if ((ret_value=H5D_get_space(dataset)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, NULL, "not found");
- }
/* Unserialize the selection */
- if (H5S_select_deserialize(ret_value,p) < 0) {
+ if (H5S_select_deserialize(ret_value,p) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, NULL, "can't deserialize selection");
- }
/* Free the buffer allocated in H5HG_read() */
H5MM_xfree(buf);
/* Close the dataset we opened */
- if (H5D_close(dataset) < 0) {
+ if (H5D_close(dataset) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "not found");
- }
done:
FUNC_LEAVE(ret_value);
@@ -629,18 +609,18 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, void *_ref)
H5G_entry_t *loc = NULL; /* Symbol table entry */
H5S_t *space = NULL; /* dataspace object */
H5F_t *file=NULL; /* File object */
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Rget_region, FAIL);
H5TRACE3("i","iRtx",id,ref_type,_ref);
/* Check args */
if (NULL == (loc = H5G_loc(id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
if(ref_type!=H5R_DATASET_REGION)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
if(_ref==NULL)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer");
/* Get the file pointer from the entry */
file=loc->file;
@@ -686,7 +666,7 @@ H5R_get_object_type(H5F_t *file, void *_ref)
H5G_entry_t ent; /* Symbol table entry */
hobj_ref_t *ref=(hobj_ref_t *)_ref; /* Only object references currently supported */
uint8_t *p; /* Pointer to OID to store */
- int ret_value = H5G_UNKNOWN;
+ int ret_value;
FUNC_ENTER_NOINIT(H5R_get_object_type);
@@ -710,6 +690,7 @@ done:
#endif /* LATER */
FUNC_LEAVE(ret_value);
} /* end H5R_get_object_type() */
+
/*--------------------------------------------------------------------------
NAME
@@ -738,26 +719,23 @@ H5Rget_object_type(hid_t id, void *_ref)
{
H5G_entry_t *loc = NULL; /* Symbol table entry */
H5F_t *file=NULL; /* File object */
- hid_t ret_value = H5G_UNKNOWN;
+ hid_t ret_value;
FUNC_ENTER_API(H5Rget_object_type, H5G_UNKNOWN);
H5TRACE2("Is","ix",id,_ref);
/* Check args */
if (NULL == (loc = H5G_loc(id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
if(_ref==NULL)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN,
- "invalid reference pointer");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer");
/* Get the file pointer from the entry */
file=loc->file;
/* Get the object information */
- if ((ret_value=H5R_get_object_type(file,_ref))<0) {
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN,
- "unable to determine object type");
- }
+ if ((ret_value=H5R_get_object_type(file,_ref))<0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type");
done:
FUNC_LEAVE(ret_value);
@@ -792,7 +770,7 @@ H5R_get_obj_type(H5F_t *file, H5R_type_t ref_type, void *_ref)
{
H5G_entry_t ent; /* Symbol table entry */
uint8_t *p; /* Pointer to OID to store */
- int ret_value = H5G_UNKNOWN;
+ int ret_value;
FUNC_ENTER_NOINIT(H5R_get_obj_type);
@@ -828,8 +806,7 @@ H5R_get_obj_type(H5F_t *file, H5R_type_t ref_type, void *_ref)
/* Get the dataset region from the heap (allocate inside routine) */
if((buf=H5HG_read(ent.file,&hobjid,NULL))==NULL)
- HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, H5G_UNKNOWN,
- "Unable to read dataset region information");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, H5G_UNKNOWN, "Unable to read dataset region information");
/* Get the object oid for the dataset */
p=(uint8_t *)buf;
@@ -841,15 +818,13 @@ H5R_get_obj_type(H5F_t *file, H5R_type_t ref_type, void *_ref)
break;
case H5R_INTERNAL:
- HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, H5G_UNKNOWN,
- "Internal references are not yet supported");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, H5G_UNKNOWN, "Internal references are not yet supported");
case H5R_BADTYPE:
case H5R_MAXTYPE:
default:
assert("unknown reference type" && 0);
- HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, H5G_UNKNOWN,
- "internal error (unknown reference type)");
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, H5G_UNKNOWN, "internal error (unknown reference type)");
} /* end switch */
/* Check to make certain that this object hasn't been deleted since the reference was created */
@@ -862,6 +837,7 @@ H5R_get_obj_type(H5F_t *file, H5R_type_t ref_type, void *_ref)
done:
FUNC_LEAVE(ret_value);
} /* end H5R_get_obj_type() */
+
/*--------------------------------------------------------------------------
NAME
@@ -891,28 +867,25 @@ H5Rget_obj_type(hid_t id, H5R_type_t ref_type, void *_ref)
{
H5G_entry_t *loc = NULL; /* Symbol table entry */
H5F_t *file=NULL; /* File object */
- hid_t ret_value = H5G_UNKNOWN;
+ hid_t ret_value;
FUNC_ENTER_API(H5Rget_obj_type, H5G_UNKNOWN);
H5TRACE3("Is","iRtx",id,ref_type,_ref);
/* Check args */
if (NULL == (loc = H5G_loc(id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
if(ref_type<=H5R_BADTYPE || ref_type>=H5R_MAXTYPE)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type");
if(_ref==NULL)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN,
- "invalid reference pointer");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer");
/* Get the file pointer from the entry */
file=loc->file;
/* Get the object information */
- if ((ret_value=H5R_get_obj_type(file,ref_type,_ref))<0) {
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN,
- "unable to determine object type");
- }
+ if ((ret_value=H5R_get_obj_type(file,ref_type,_ref))<0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type");
done:
FUNC_LEAVE(ret_value);
diff --git a/src/H5S.c b/src/H5S.c
index 11403ac..70cf3f3 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -77,12 +77,14 @@ DESCRIPTION
static herr_t
H5S_init_interface(void)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5S_init_interface);
/* Initialize the atom group for the file IDs */
if (H5I_init_group(H5I_DATASPACE, H5I_DATASPACEID_HASHSIZE,
H5S_RESERVED_ATOMS, (H5I_free_t)H5S_close)<0)
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface");
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface");
#ifdef H5_HAVE_PARALLEL
{
@@ -99,7 +101,8 @@ H5S_init_interface(void)
}
#endif /* H5_HAVE_PARALLEL */
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -295,7 +298,7 @@ H5S_term_interface(void)
H5S_t *
H5S_create(H5S_class_t type)
{
- H5S_t *ret_value = NULL;
+ H5S_t *ret_value;
FUNC_ENTER_NOAPI(H5S_create, NULL);
@@ -303,9 +306,10 @@ H5S_create(H5S_class_t type)
if((ret_value = H5FL_ALLOC(H5S_t,1))!=NULL) {
ret_value->extent.type = type;
if(H5S_select_all(ret_value,0)<0)
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
} /* end if */
+done:
FUNC_LEAVE(ret_value);
} /* end H5S_create() */
@@ -332,7 +336,7 @@ hid_t
H5Screate(H5S_class_t type)
{
H5S_t *new_ds=NULL; /* New dataspace structure */
- hid_t ret_value = FAIL; /* Return value */
+ hid_t ret_value; /* Return value */
FUNC_ENTER_API(H5Screate, FAIL);
H5TRACE1("i","Sc",type);
@@ -465,19 +469,23 @@ H5S_close(H5S_t *ds)
herr_t
H5Sclose(hid_t space_id)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5Sclose, FAIL);
H5TRACE1("e","i",space_id);
/* Check args */
if (NULL == H5I_object_verify(space_id,H5I_DATASPACE))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
/* When the reference count reaches zero the resources are freed */
if (H5I_dec_ref(space_id) < 0)
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5S_release_simple
@@ -534,22 +542,28 @@ H5Scopy(hid_t space_id)
{
H5S_t *src = NULL;
H5S_t *dst = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Scopy, FAIL);
H5TRACE1("i","i",space_id);
/* Check args */
if (NULL==(src=H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
/* Copy */
if (NULL==(dst=H5S_copy (src)))
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space");
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space");
/* Atomize */
if ((ret_value=H5I_register (H5I_DATASPACE, dst))<0)
- HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom");
+ HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space atom");
+
+done:
+ if(ret_value<0) {
+ if(dst!=NULL)
+ H5S_close(dst);
+ } /* end if */
FUNC_LEAVE (ret_value);
}
@@ -581,14 +595,15 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id)
/* Check args */
if (NULL==(src=H5I_object_verify(src_id, H5I_DATASPACE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if (NULL==(dst=H5I_object_verify(dst_id, H5I_DATASPACE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
/* Copy */
if (H5S_extent_copy(&(dst->extent),&(src->extent))<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy extent");
+done:
FUNC_LEAVE (ret_value);
}
@@ -669,24 +684,29 @@ H5S_t *
H5S_copy(const H5S_t *src)
{
H5S_t *dst = NULL;
+ H5S_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5S_copy, NULL);
if (NULL==(dst = H5FL_ALLOC(H5S_t,0)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Copy the field in the struct */
*dst = *src;
/* Copy the source dataspace's extent */
if (H5S_extent_copy(&(dst->extent),&(src->extent))<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent");
/* Copy the source dataspace's selection */
if (H5S_select_copy(dst,src)<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy select");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy select");
- FUNC_LEAVE(dst);
+ /* Set the return value */
+ ret_value=dst;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -710,7 +730,7 @@ H5S_copy(const H5S_t *src)
hssize_t
H5S_get_simple_extent_npoints(const H5S_t *ds)
{
- hssize_t ret_value = -1;
+ hssize_t ret_value;
unsigned u;
FUNC_ENTER_NOAPI(H5S_get_simple_extent_npoints, -1);
@@ -729,13 +749,14 @@ H5S_get_simple_extent_npoints(const H5S_t *ds)
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, -1, "complex data spaces are not supported yet");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet");
default:
assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, -1, "internal error (unknown data space class)");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)");
}
+done:
FUNC_LEAVE(ret_value);
}
@@ -761,17 +782,18 @@ hssize_t
H5Sget_simple_extent_npoints(hid_t space_id)
{
H5S_t *ds = NULL;
- hssize_t ret_value = -1;
+ hssize_t ret_value;
- FUNC_ENTER_API(H5Sget_simple_extent_npoints, -1);
+ FUNC_ENTER_API(H5Sget_simple_extent_npoints, FAIL);
H5TRACE1("Hs","i",space_id);
/* Check args */
if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
ret_value = H5S_get_simple_extent_npoints(ds);
+done:
FUNC_LEAVE(ret_value);
}
@@ -800,7 +822,7 @@ H5Sget_simple_extent_npoints(hid_t space_id)
hsize_t
H5S_get_npoints_max(const H5S_t *ds)
{
- hsize_t ret_value = 0;
+ hsize_t ret_value;
unsigned u;
FUNC_ENTER_NOAPI(H5S_get_npoints_max, 0);
@@ -831,13 +853,14 @@ H5S_get_npoints_max(const H5S_t *ds)
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "complex data spaces are not supported yet");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "complex data spaces are not supported yet");
default:
assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown data space class)");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown data space class)");
}
+done:
FUNC_LEAVE(ret_value);
}
@@ -862,17 +885,18 @@ int
H5Sget_simple_extent_ndims(hid_t space_id)
{
H5S_t *ds = NULL;
- int ret_value = 0;
+ int ret_value;
FUNC_ENTER_API(H5Sget_simple_extent_ndims, FAIL);
H5TRACE1("Is","i",space_id);
/* Check args */
if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
ret_value = H5S_get_simple_extent_ndims(ds);
+done:
FUNC_LEAVE(ret_value);
}
@@ -897,7 +921,7 @@ H5Sget_simple_extent_ndims(hid_t space_id)
int
H5S_get_simple_extent_ndims(const H5S_t *ds)
{
- int ret_value = FAIL;
+ int ret_value;
FUNC_ENTER_NOAPI(H5S_get_simple_extent_ndims, FAIL);
@@ -914,15 +938,14 @@ H5S_get_simple_extent_ndims(const H5S_t *ds)
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not supported yet");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet");
default:
assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown data space class)");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)");
}
+done:
FUNC_LEAVE(ret_value);
}
@@ -954,17 +977,18 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/,
hsize_t maxdims[]/*out*/)
{
H5S_t *ds = NULL;
- int ret_value = 0;
+ int ret_value;
FUNC_ENTER_API(H5Sget_simple_extent_dims, FAIL);
H5TRACE3("Is","ixx",space_id,dims,maxdims);
/* Check args */
if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims);
+done:
FUNC_LEAVE(ret_value);
}
@@ -989,7 +1013,7 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/,
int
H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[])
{
- int ret_value = FAIL;
+ int ret_value;
int i;
FUNC_ENTER_NOAPI(H5S_get_simple_extent_dims, FAIL);
@@ -1017,13 +1041,14 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[])
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not supported yet");
default:
assert("unknown data space class" && 0);
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "internal error (unknown data space class)");
}
+done:
FUNC_LEAVE(ret_value);
}
@@ -1046,6 +1071,8 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[])
herr_t
H5S_modify(H5G_entry_t *ent, const H5S_t *ds)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5S_modify, FAIL);
assert(ent);
@@ -1055,18 +1082,19 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds)
case H5S_SCALAR:
case H5S_SIMPLE:
if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->extent.u.simple))<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple data space message");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't update simple data space message");
break;
case H5S_COMPLEX:
- HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not implemented yet");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "complex data spaces are not implemented yet");
default:
assert("unknown data space class" && 0);
break;
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1092,7 +1120,7 @@ H5S_t *
H5S_read(H5G_entry_t *ent)
{
H5S_t *ds = NULL; /* Dataspace to return */
- H5S_t *ret_value = NULL; /* Return value */
+ H5S_t *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5S_read, NULL);
@@ -1154,6 +1182,7 @@ int
H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
{
unsigned u;
+ int ret_value=0; /* Return value */
FUNC_ENTER_NOAPI(H5S_cmp, 0);
@@ -1163,22 +1192,22 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
/* compare */
if (ds1->extent.type < ds2->extent.type)
- HRETURN(-1);
+ HGOTO_DONE(-1);
if (ds1->extent.type > ds2->extent.type)
- HRETURN(1);
+ HGOTO_DONE(1);
switch (ds1->extent.type) {
case H5S_SIMPLE:
if (ds1->extent.u.simple.rank < ds2->extent.u.simple.rank)
- HRETURN(-1);
+ HGOTO_DONE(-1);
if (ds1->extent.u.simple.rank > ds2->extent.u.simple.rank)
- HRETURN(1);
+ HGOTO_DONE(1);
for (u = 0; u < ds1->extent.u.simple.rank; u++) {
if (ds1->extent.u.simple.size[u] < ds2->extent.u.simple.size[u])
- HRETURN(-1);
+ HGOTO_DONE(-1);
if (ds1->extent.u.simple.size[u] > ds2->extent.u.simple.size[u])
- HRETURN(1);
+ HGOTO_DONE(1);
}
/* don't compare max dimensions */
@@ -1187,10 +1216,10 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
for (u = 0; u < ds1->extent.u.simple.rank; u++) {
if ((ds1->extent.u.simple.perm ? ds1->extent.u.simple.perm[u] : u) <
(ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i))
- HRETURN(-1);
+ HGOTO_DONE(-1);
if ((ds1->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : u) >
(ds2->extent.u.simple.perm ? ds2->extent.u.simple.perm[u] : i))
- HRETURN(1);
+ HGOTO_DONE(1);
}
#endif
@@ -1200,7 +1229,8 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
assert("not implemented yet" && 0);
}
- FUNC_LEAVE(0);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1221,7 +1251,7 @@ H5S_cmp(const H5S_t *ds1, const H5S_t *ds2)
htri_t
H5S_is_simple(const H5S_t *sdim)
{
- htri_t ret_value = FAIL;
+ htri_t ret_value;
FUNC_ENTER_NOAPI(H5S_is_simple, FAIL);
@@ -1252,7 +1282,7 @@ htri_t
H5Sis_simple(hid_t space_id)
{
H5S_t *space = NULL; /* dataspace to modify */
- htri_t ret_value = FAIL;
+ htri_t ret_value;
FUNC_ENTER_API(H5Sis_simple, FAIL);
H5TRACE1("b","i",space_id);
@@ -1299,37 +1329,39 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/],
{
H5S_t *space = NULL; /* dataspace to modify */
int u; /* local counting variable */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sset_extent_simple, FAIL);
H5TRACE4("e","iIs*[a1]h*[a1]h",space_id,rank,dims,max);
/* Check args */
if ((space = H5I_object_verify(space_id,H5I_DATASPACE)) == NULL)
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
if (rank > 0 && dims == NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
if (rank<0 || rank>H5S_MAX_RANK)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank");
if (dims) {
for (u=0; u<rank; u++) {
if (((max!=NULL && max[u]!=H5S_UNLIMITED) || max==NULL) && dims[u]==0)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimension size");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimension size");
}
}
if (max!=NULL) {
if(dims==NULL)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "maximum dimension specified, but no current dimensions specified");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "maximum dimension specified, but no current dimensions specified");
for (u=0; u<rank; u++) {
if (max[u]!=H5S_UNLIMITED && max[u]<dims[u])
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid maximum dimension size");
}
}
/* Do it */
if (H5S_set_extent_simple(space, (unsigned)rank, dims, max)<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set simple extent");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1352,6 +1384,8 @@ herr_t
H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
const hsize_t *max)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5S_set_extent_simple, FAIL);
/* Check args */
@@ -1364,7 +1398,7 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
/* Allocate space for the offset and set it to zeros */
if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,rank,1)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
/* shift out of the previous state to a "simple" dataspace */
switch (space->extent.type) {
@@ -1384,8 +1418,7 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
/* Fall through to report error */
default:
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL,
- "unknown data space class");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "unknown data space class");
}
if (rank == 0) { /* scalar variable */
@@ -1405,7 +1438,9 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
HDmemcpy(space->extent.u.simple.max, max, sizeof(hsize_t) * rank);
} /* end if */
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -1442,11 +1477,13 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
H5S_conv_t *
H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
{
- H5S_conv_t *path; /* Space conversion path */
+ H5S_conv_t *path=NULL; /* Space conversion path */
#ifdef H5_HAVE_PARALLEL
htri_t opt; /* Flag whether a selection is optimizable */
#endif /* H5_HAVE_PARALLEL */
size_t i; /* Index variable */
+ H5S_conv_t *ret_value; /* Return value */
+
FUNC_ENTER_NOAPI(H5S_find, NULL);
@@ -1461,7 +1498,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
* different number of data points.
*/
if ((*mem_space->select.get_npoints)(mem_space) != (*file_space->select.get_npoints) (file_space))
- HRETURN_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL, "memory and file data spaces are different sizes");
+ HGOTO_ERROR (H5E_DATASPACE, H5E_BADRANGE, NULL, "memory and file data spaces are different sizes");
/*
* Is this path already present in the data space conversion path table?
@@ -1477,7 +1514,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
*/
opt=H5S_mpio_opt_possible(mem_space,file_space,flags);
if(opt==FAIL)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
/* Check if we can use the optimized parallel I/O routines */
if(opt==TRUE) {
@@ -1492,7 +1529,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
} /* end else */
#endif /* H5_HAVE_PARALLEL */
- HRETURN(H5S_conv_g[i]);
+ HGOTO_DONE(H5S_conv_g[i]);
}
}
@@ -1500,7 +1537,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
* The path wasn't found. Create a new path.
*/
if (NULL==(path = H5MM_calloc(sizeof(*path))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path");
/* Initialize file & memory conversion functions */
path->ftype = file_space->select.type;
@@ -1512,7 +1549,7 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
*/
opt=H5S_mpio_opt_possible(mem_space,file_space,flags);
if(opt==FAIL)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, NULL, "invalid check for contiguous dataspace ");
/* Check if we can use the optimized parallel I/O routines */
if(opt==TRUE) {
@@ -1535,13 +1572,22 @@ H5S_find (const H5S_t *mem_space, const H5S_t *file_space, unsigned flags)
H5S_conv_t **p = H5MM_realloc(H5S_conv_g, n*sizeof(H5S_conv_g[0]));
if (NULL==p)
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path table");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for data space conversion path table");
H5S_aconv_g = n;
H5S_conv_g = p;
} /* end if */
H5S_conv_g[H5S_nconv_g++] = path;
- FUNC_LEAVE(path);
+ /* Set the return value */
+ ret_value=path;
+
+done:
+ if(ret_value==NULL) {
+ if(path!=NULL)
+ H5MM_xfree(path);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -1578,7 +1624,7 @@ H5S_extend (H5S_t *space, const hsize_t *size)
if (space->extent.u.simple.max &&
H5S_UNLIMITED!=space->extent.u.simple.max[u] &&
space->extent.u.simple.max[u]<size[u])
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be increased");
ret_value++;
}
}
@@ -1591,6 +1637,7 @@ H5S_extend (H5S_t *space, const hsize_t *size)
}
}
+done:
FUNC_LEAVE (ret_value);
}
@@ -1624,7 +1671,7 @@ hid_t
H5Screate_simple(int rank, const hsize_t dims[/*rank*/],
const hsize_t maxdims[/*rank*/])
{
- hid_t ret_value = FAIL;
+ hid_t ret_value;
H5S_t *space = NULL;
int i;
@@ -1693,7 +1740,7 @@ done:
H5S_class_t
H5S_get_simple_extent_type(const H5S_t *space)
{
- H5S_class_t ret_value = H5S_NO_CLASS;
+ H5S_class_t ret_value;
FUNC_ENTER_NOAPI(H5S_get_simple_extent_type, H5S_NO_CLASS);
@@ -1726,18 +1773,19 @@ H5S_get_simple_extent_type(const H5S_t *space)
H5S_class_t
H5Sget_simple_extent_type(hid_t sid)
{
- H5S_class_t ret_value = H5S_NO_CLASS;
- H5S_t *space = NULL;
+ H5S_class_t ret_value;
+ H5S_t *space;
FUNC_ENTER_API(H5Sget_simple_extent_type, H5S_NO_CLASS);
H5TRACE1("Sc","i",sid);
/* Check arguments */
if (NULL == (space = H5I_object_verify(sid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace");
ret_value=H5S_get_simple_extent_type(space);
+done:
FUNC_LEAVE(ret_value);
}
@@ -1760,21 +1808,23 @@ herr_t
H5Sset_extent_none(hid_t space_id)
{
H5S_t *space = NULL; /* dataspace to modify */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sset_extent_none, FAIL);
H5TRACE1("e","i",space_id);
/* Check args */
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
/* Clear the previous extent from the dataspace */
if(H5S_extent_release(space)<0)
- HRETURN_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTDELETE, FAIL, "can't release previous dataspace");
space->extent.type=H5S_NO_CLASS;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5Sset_extent_none() */
@@ -1798,26 +1848,28 @@ herr_t
H5Soffset_simple(hid_t space_id, const hssize_t *offset)
{
H5S_t *space = NULL; /* dataspace to modify */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Soffset_simple, FAIL);
H5TRACE2("e","i*Hs",space_id,offset);
/* Check args */
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
if (offset == NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified");
/* Allocate space for new offset */
if(space->select.offset==NULL) {
if (NULL==(space->select.offset = H5FL_ARR_ALLOC(hssize_t,space->extent.u.simple.rank,0)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
}
/* Copy the offset over */
HDmemcpy(space->select.offset,offset,sizeof(hssize_t)*space->extent.u.simple.rank);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5Soffset_simple() */
@@ -1839,8 +1891,8 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset)
herr_t
H5S_set_extent( H5S_t *space, const hsize_t *size )
{
- herr_t ret_value=SUCCEED;
unsigned u;
+ herr_t ret_value=SUCCEED;
FUNC_ENTER_NOAPI( H5S_set_extent, FAIL );
@@ -1856,12 +1908,13 @@ H5S_set_extent( H5S_t *space, const hsize_t *size )
if ( space->extent.u.simple.max &&
H5S_UNLIMITED != space->extent.u.simple.max[u] &&
space->extent.u.simple.max[u]<size[u] )
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,"dimension cannot be modified");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,"dimension cannot be modified");
/* Update dimensions with new values */
for ( u = 0; u < space->extent.u.simple.rank; u++ )
space->extent.u.simple.size[u] = size[u];
+done:
FUNC_LEAVE( ret_value );
}
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 64bf457..c286175 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -475,7 +475,7 @@ H5S_hyper_npoints (const H5S_t *space)
static H5S_hyper_span_t *
H5S_hyper_new_span (hssize_t low, hssize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next)
{
- H5S_hyper_span_t *ret_value=NULL;
+ H5S_hyper_span_t *ret_value;
FUNC_ENTER_NOINIT(H5S_hyper_new_span);
@@ -523,7 +523,7 @@ static herr_t
H5S_hyper_span_precompute_helper (H5S_hyper_span_info_t *spans, size_t elmt_size)
{
H5S_hyper_span_t *span; /* Hyperslab span */
- herr_t ret_value=FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_hyper_span_precompute);
@@ -554,9 +554,6 @@ H5S_hyper_span_precompute_helper (H5S_hyper_span_info_t *spans, size_t elmt_size
} /* end while */
} /* end if */
- /* Success! */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5S_hyper_span_precompute_helper() */
@@ -584,7 +581,7 @@ done:
static herr_t
H5S_hyper_span_precompute (H5S_hyper_span_info_t *spans, size_t elmt_size)
{
- herr_t ret_value=FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_hyper_span_precompute);
@@ -598,9 +595,6 @@ H5S_hyper_span_precompute (H5S_hyper_span_info_t *spans, size_t elmt_size)
if(H5S_hyper_span_scratch(spans,NULL)==FAIL)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "can't reset hyperslab scratch pointer");
- /* Success! */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5S_hyper_span_precompute() */
@@ -627,7 +621,7 @@ static herr_t
H5S_hyper_span_scratch (H5S_hyper_span_info_t *spans, void *scr_value)
{
H5S_hyper_span_t *span; /* Hyperslab span */
- herr_t ret_value=FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_hyper_span_scratch);
@@ -652,9 +646,6 @@ H5S_hyper_span_scratch (H5S_hyper_span_info_t *spans, void *scr_value)
} /* end while */
} /* end if */
- /* Success! */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5S_hyper_span_scratch() */
@@ -684,7 +675,7 @@ H5S_hyper_copy_span_helper (H5S_hyper_span_info_t *spans)
H5S_hyper_span_t *new_span; /* Temporary hyperslab span */
H5S_hyper_span_t *prev_span; /* Previous hyperslab span */
H5S_hyper_span_info_t *new_down; /* New down span tree */
- H5S_hyper_span_info_t *ret_value=NULL;
+ H5S_hyper_span_info_t *ret_value;
FUNC_ENTER_NOINIT(H5S_hyper_copy_span_helper);
@@ -770,7 +761,7 @@ done:
static H5S_hyper_span_info_t *
H5S_hyper_copy_span (H5S_hyper_span_info_t *spans)
{
- H5S_hyper_span_info_t *ret_value=NULL;
+ H5S_hyper_span_info_t *ret_value;
FUNC_ENTER_NOINIT(H5S_hyper_copy_span);
@@ -917,7 +908,7 @@ static herr_t
H5S_hyper_free_span_info (H5S_hyper_span_info_t *span_info)
{
H5S_hyper_span_t *span, *next_span;
- herr_t ret_value=SUCCEED;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_hyper_free_span_info);
@@ -1218,7 +1209,7 @@ static hssize_t
H5S_hyper_span_nblocks (H5S_hyper_span_info_t *spans)
{
H5S_hyper_span_t *span; /* Hyperslab span */
- hssize_t ret_value=FAIL;
+ hssize_t ret_value;
FUNC_ENTER_NOINIT(H5S_hyper_span_nblocks);
@@ -1241,9 +1232,6 @@ H5S_hyper_span_nblocks (H5S_hyper_span_info_t *spans)
} /* end while */
} /* end else */
-#ifdef LATER
-done:
-#endif /* LATER */
FUNC_LEAVE (ret_value);
} /* H5S_hyper_span_nblocks() */
@@ -1268,8 +1256,8 @@ done:
static hssize_t
H5S_get_select_hyper_nblocks(H5S_t *space)
{
- hssize_t ret_value=FAIL; /* return value */
- unsigned u; /* Counter */
+ hssize_t ret_value; /* return value */
+ unsigned u; /* Counter */
FUNC_ENTER_NOINIT(H5S_get_select_hyper_nblocks);
@@ -1309,19 +1297,20 @@ hssize_t
H5Sget_select_hyper_nblocks(hid_t spaceid)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- hssize_t ret_value=FAIL; /* return value */
+ hssize_t ret_value; /* return value */
FUNC_ENTER_API(H5Sget_select_hyper_nblocks, FAIL);
H5TRACE1("Hs","i",spaceid);
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if(space->select.type!=H5S_SEL_HYPERSLABS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
ret_value = H5S_get_select_hyper_nblocks(space);
+done:
FUNC_LEAVE (ret_value);
} /* H5Sget_select_hyper_nblocks() */
@@ -1348,9 +1337,9 @@ H5Sget_select_hyper_nblocks(hid_t spaceid)
hssize_t
H5S_hyper_serial_size (const H5S_t *space)
{
- unsigned u; /* Counter */
+ unsigned u; /* Counter */
hssize_t block_count; /* block counter for regular hyperslabs */
- hssize_t ret_value=FAIL; /* return value */
+ hssize_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_hyper_serial_size, FAIL);
@@ -1493,7 +1482,6 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf)
int temp_dim; /* Temporary rank holder */
int ndims; /* Rank of the dataspace */
int done; /* Whether we are done with the iteration */
- herr_t ret_value=FAIL; /* return value */
FUNC_ENTER_NOAPI(H5S_hyper_serialize, FAIL);
@@ -1612,10 +1600,7 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf)
/* Encode length */
UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
- /* Set success */
- ret_value=SUCCEED;
-
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5S_hyper_serialize() */
@@ -1859,7 +1844,7 @@ H5S_get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numbloc
int temp_dim; /* Temporary rank holder */
int ndims; /* Rank of the dataspace */
int done; /* Whether we are done with the iteration */
- herr_t ret_value=SUCCEED; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_get_select_hyper_blocklist);
@@ -1991,18 +1976,18 @@ herr_t
H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numblocks, hsize_t *buf)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Sget_select_hyper_blocklist, FAIL);
H5TRACE4("e","ihh*h",spaceid,startblock,numblocks,buf);
/* Check args */
if(buf==NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if(space->select.type!=H5S_SEL_HYPERSLABS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a hyperslab selection");
/* Go get the correct number of blocks */
if(numblocks>0)
@@ -2010,6 +1995,7 @@ H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numbloc
else
ret_value=SUCCEED; /* Successfully got 0 blocks... */
+done:
FUNC_LEAVE (ret_value);
} /* H5Sget_select_hyper_blocklist() */
@@ -2046,7 +2032,7 @@ static herr_t
H5S_hyper_bounds_helper (const H5S_hyper_span_info_t *spans, const hssize_t *offset, hsize_t rank, hsize_t *start, hsize_t *end)
{
H5S_hyper_span_t *curr; /* Hyperslab information nodes */
- herr_t ret_value=SUCCEED; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_hyper_bounds_helper);
@@ -2432,7 +2418,7 @@ H5S_hyper_is_single(const H5S_t *space)
htri_t
H5S_hyper_is_regular(const H5S_t *space)
{
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_hyper_is_regular, FAIL);
@@ -2527,8 +2513,6 @@ done:
static herr_t
H5S_hyper_recover_span (unsigned *recover, H5S_hyper_span_t **curr_span, H5S_hyper_span_t *next_span)
{
- herr_t ret_value=FAIL;
-
FUNC_ENTER_NOINIT(H5S_hyper_recover_span);
assert(recover);
@@ -2543,13 +2527,7 @@ H5S_hyper_recover_span (unsigned *recover, H5S_hyper_span_t **curr_span, H5S_hyp
/* Set the current span to next span */
*curr_span=next_span;
- /* Success! */
- ret_value=SUCCEED;
-
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5S_hyper_recover_span() */
@@ -2579,7 +2557,7 @@ static herr_t
H5S_hyper_append_span (H5S_hyper_span_t **prev_span, H5S_hyper_span_info_t ** span_tree, hssize_t low, hssize_t high, H5S_hyper_span_info_t *down, H5S_hyper_span_t *next)
{
H5S_hyper_span_t *new_span;
- herr_t ret_value=FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_hyper_append_span);
@@ -2647,9 +2625,6 @@ H5S_hyper_append_span (H5S_hyper_span_t **prev_span, H5S_hyper_span_info_t ** sp
} /* end else */
} /* end else */
- /* Success! */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5S_hyper_append_span() */
@@ -2700,7 +2675,7 @@ H5S_hyper_clip_spans (H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
H5S_hyper_span_info_t *down_a_and_b; /* Temporary pointer to a_and_b span tree of down spans for overlapping nodes */
H5S_hyper_span_info_t *down_b_not_a; /* Temporary pointer to b_and_a span tree of down spans for overlapping nodes */
unsigned recover_a, recover_b; /* Flags to indicate when to recover temporary spans */
- herr_t ret_value=FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_hyper_clip_spans);
@@ -3154,9 +3129,6 @@ H5S_hyper_clip_spans (H5S_hyper_span_info_t *a_spans, H5S_hyper_span_info_t *b_s
} /* end else */
} /* end else */
- /* Success! */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5S_hyper_clip_spans() */
@@ -3193,7 +3165,7 @@ H5S_hyper_merge_spans_helper (H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
H5S_hyper_span_t *span_b; /* Pointer to current span 'b' working on */
H5S_hyper_span_t *prev_span_merge; /* Pointer to previous merged span */
unsigned recover_a, recover_b; /* Flags to indicate when to recover temporary spans */
- H5S_hyper_span_info_t *ret_value=NULL;
+ H5S_hyper_span_info_t *ret_value;
FUNC_ENTER_NOINIT(H5S_hyper_merge_spans_helper);
@@ -3465,7 +3437,7 @@ H5S_hyper_merge_spans_helper (H5S_hyper_span_info_t *a_spans, H5S_hyper_span_inf
} /* end if */
} /* end else */
- /* Success! */
+ /* Set return value */
ret_value=merged_spans;
done:
@@ -3498,8 +3470,6 @@ done:
static herr_t
H5S_hyper_merge_spans (H5S_t *space, H5S_hyper_span_info_t *new_spans)
{
- herr_t ret_value=FAIL;
-
FUNC_ENTER_NOINIT(H5S_hyper_merge_spans);
/* Check args */
@@ -3526,13 +3496,7 @@ H5S_hyper_merge_spans (H5S_t *space, H5S_hyper_span_info_t *new_spans)
space->select.sel_info.hslab.span_lst=merged_spans;
} /* end else */
- /* Success! */
- ret_value=SUCCEED;
-
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5S_hyper_merge_spans() */
@@ -3557,7 +3521,7 @@ static hssize_t
H5S_hyper_spans_nelem (H5S_hyper_span_info_t *spans)
{
H5S_hyper_span_t *span; /* Hyperslab span */
- hssize_t ret_value=FAIL;
+ hssize_t ret_value;
FUNC_ENTER_NOINIT(H5S_hyper_spans_nelem);
@@ -3580,9 +3544,6 @@ H5S_hyper_spans_nelem (H5S_hyper_span_info_t *spans)
} /* end while */
} /* end else */
-#ifdef LATER
-done:
-#endif /* LATER */
FUNC_LEAVE (ret_value);
} /* H5S_hyper_spans_nelem() */
@@ -3622,7 +3583,7 @@ H5S_hyper_make_spans (unsigned rank, const hssize_t *start, const hsize_t *strid
H5S_hyper_span_t *head; /* Head of new hyperslab span list */
int i; /* Counters */
unsigned u; /* Counters */
- H5S_hyper_span_info_t *ret_value=NULL;
+ H5S_hyper_span_info_t *ret_value;
FUNC_ENTER_NOINIT(H5S_hyper_make_spans);
@@ -3728,7 +3689,7 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
H5S_hyper_span_info_t *b_not_a=NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */
hssize_t nelem; /* Number of elements in hyperslab span tree */
unsigned u; /* Counters */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_generate_hyperslab);
@@ -3898,9 +3859,6 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
if(H5S_hyper_free_span_info(new_spans)<0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTFREE, FAIL, "failed to release temporary hyperslab spans");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* end H5S_generate_hyperslab() */
@@ -3931,7 +3889,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
hsize_t *_block=NULL; /* Block size array */
unsigned u; /* Counters */
H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5S_select_hyperslab, FAIL);
@@ -4139,8 +4097,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
space->select.is_single=H5S_hyper_is_single;
space->select.is_regular=H5S_hyper_is_regular;
- ret_value=SUCCEED;
-
done:
if(_stride!=NULL)
H5FL_ARR_FREE(hsize_t,_stride);
@@ -4181,23 +4137,25 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
const hsize_t stride[], const hsize_t count[], const hsize_t block[])
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sselect_hyperslab, FAIL);
H5TRACE6("e","iSs*Hs*h*h*h",space_id,op,start,stride,count,block);
/* Check args */
if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if(start==NULL || count==NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
- HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
if (H5S_select_hyperslab(space, op, start, stride, count, block)<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5Sselect_hyperslab() */
#else /* NEW_HYPERSLAB_API */ /* Works */
@@ -4223,7 +4181,7 @@ H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper
H5S_hyper_span_info_t *a_and_b=NULL; /* Span tree for hyperslab spans in both old and new span trees */
H5S_hyper_span_info_t *b_not_a=NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */
hssize_t nelem; /* Number of elements in hyperslab span tree */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_operate_hyperslab);
@@ -4371,11 +4329,7 @@ H5S_operate_hyperslab (H5S_t *result, H5S_hyper_span_info_t *spans1, H5S_seloper
space->select.is_contiguous=H5S_hyper_is_contiguous;
space->select.is_single=H5S_hyper_is_single;
- /* Set the return value */
- ret_value=SUCCEED;
-
done:
-
FUNC_LEAVE (ret_value);
} /* end H5S_operate_hyperslab() */
@@ -4407,7 +4361,7 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
H5S_hyper_span_info_t *new_spans=NULL; /* Span tree for new hyperslab */
H5S_hyper_span_info_t *tmp_spans=NULL; /* Temporary copy of selection */
unsigned u; /* Counters */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_generate_hyperslab);
@@ -4447,9 +4401,6 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
if(H5S_operate_hyperslab(space,tmp_spans,op,new_spans)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information");
- /* Set return value */
- ret_value=SUCCEED;
-
done:
/* Free temporary data structures */
if(tmp_spans!=NULL)
@@ -4486,7 +4437,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
hsize_t *_block=NULL; /* Block size array */
unsigned u; /* Counters */
H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI (H5S_select_hyperslab, FAIL);
@@ -4677,8 +4628,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
else
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
- ret_value=SUCCEED;
-
done:
if(_stride!=NULL)
H5FL_ARR_FREE(hsize_t,_stride);
@@ -4719,23 +4668,25 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
const hsize_t stride[], const hsize_t count[], const hsize_t block[])
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sselect_hyperslab, FAIL);
H5TRACE6("e","iSs*Hs*h*h*h",space_id,op,start,stride,count,block);
/* Check args */
if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if(start==NULL || count==NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
- HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
if (H5S_select_hyperslab(space, op, start, stride, count, block)<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5Sselect_hyperslab() */
@@ -4774,7 +4725,7 @@ H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
H5S_t *new_space = NULL; /* New dataspace created */
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Scombine_hyperslab, FAIL);
H5TRACE6("i","iSs*Hs*h*h*h",space_id,op,start,stride,count,block);
@@ -4826,7 +4777,7 @@ static H5S_t *
H5S_combine_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
{
H5S_t *new_space=NULL; /* New dataspace generated */
- H5S_t *ret_value=NULL; /* return value */
+ H5S_t *ret_value; /* return value */
FUNC_ENTER_NOINIT(H5S_combine_select);
@@ -4843,7 +4794,7 @@ H5S_combine_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
if(H5S_operate_hyperslab(new_space,space1->select.sel_info.hslab.span_lst,op,space2->select.sel_info.hslab.span_lst)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, NULL, "can't clip hyperslab information");
- /* Set the return value */
+ /* Set return value */
ret_value=new_space;
done:
@@ -4882,7 +4833,7 @@ H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id)
H5S_t *space1; /* First Dataspace */
H5S_t *space2; /* Second Dataspace */
H5S_t *new_space = NULL; /* New Dataspace */
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Scombine_select, FAIL);
H5TRACE3("i","iSsi",space1_id,op,space2_id);
@@ -4937,7 +4888,7 @@ static herr_t
H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
{
H5S_hyper_span_info_t *tmp_spans=NULL; /* Temporary copy of selection */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_select_select);
@@ -4954,9 +4905,6 @@ H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
if(H5S_operate_hyperslab(space1,tmp_spans,op,space2->select.sel_info.hslab.span_lst)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information");
- /* Set the return value */
- ret_value=SUCCEED;
-
done:
if(tmp_spans!=NULL)
H5S_hyper_free_span_info(tmp_spans);
@@ -4992,7 +4940,7 @@ H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id)
{
H5S_t *space1; /* First Dataspace */
H5S_t *space2; /* Second Dataspace */
- hid_t ret_value = FAIL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sselect_select, FAIL);
H5TRACE3("e","iSsi",space1_id,op,space2_id);
@@ -5017,9 +4965,6 @@ H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id)
if (H5S_select_select(space1, op, space2)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to modify hyperslab selection");
- /* Set the return value */
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* end H5Sselect_select() */
@@ -5078,7 +5023,6 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
int fast_dim; /* Rank of the fastest changing dimension for the dataspace */
int curr_dim; /* Current dimension being operated on */
int i; /* Index variable */
- herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOINIT (H5S_hyper_get_seq_list_gen);
@@ -5434,10 +5378,7 @@ partial_done: /* Yes, goto's are evil, so sue me... :-) */
/* Set the number of bytes used */
*nbytes=(start_io_bytes_left-io_bytes_left);
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* end H5S_hyper_get_seq_list_gen() */
@@ -5511,7 +5452,6 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
#ifndef NO_DUFFS_DEVICE
size_t duffs_index; /* Counting index for Duff's device */
#endif /* NO_DUFFS_DEVICE */
- herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOINIT (H5S_hyper_get_seq_list_opt);
@@ -5997,10 +5937,7 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
/* Set the number of bytes used */
*nbytes=(start_io_left-io_left)*elmt_size;
-#ifdef LATER
-done:
-#endif /* LATER */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* end H5S_hyper_get_seq_list_opt() */
@@ -6041,7 +5978,7 @@ H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t
size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
hsize_t *off, size_t *len)
{
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_NOAPI (H5S_hyper_get_seq_list, FAIL);
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index ab91b21..8285e18 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -114,6 +114,8 @@ H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_
{
hsize_t total_bytes;
unsigned u;
+ int mpi_code; /* MPI return code */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_mpio_all_type);
@@ -129,10 +131,10 @@ H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_
if(prefer_derived_types) {
/* fill in the return values */
H5_CHECK_OVERFLOW(total_bytes, hsize_t, int);
- if (MPI_Type_contiguous( (int)total_bytes, MPI_BYTE, new_type ))
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't create MPI contiguous type");
- if(MPI_Type_commit(new_type))
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't commit MPI contiguous type");
+ if (MPI_SUCCESS != (mpi_code=MPI_Type_contiguous( (int)total_bytes, MPI_BYTE, new_type )))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code);
+ if(MPI_SUCCESS != (mpi_code=MPI_Type_commit(new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code);
*count = 1;
*extra_offset = 0;
*use_view = 1;
@@ -147,10 +149,11 @@ H5S_mpio_all_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derived_
*is_derived_type = 0;
} /* end else */
+done:
#ifdef H5Smpi_DEBUG
HDfprintf(stdout, "Leave %s total_bytes=%Hu\n", FUNC, total_bytes );
#endif
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE (ret_value);
}
@@ -204,7 +207,7 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
hsize_t count;
} d[H5S_MAX_RANK];
- int i, err, new_rank, num_to_collapse;
+ int i, new_rank, num_to_collapse;
herr_t ret_value = SUCCEED;
int offset[H5S_MAX_RANK];
int max_xtent[H5S_MAX_RANK];
@@ -213,6 +216,7 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
int block_length[2];
MPI_Datatype inner_type, outer_type, old_type[2];
MPI_Aint extent_len, displacement[2];
+ int mpi_code; /* MPI return code */
FUNC_ENTER_NOINIT(H5S_mpio_hyper_type);
@@ -344,9 +348,8 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
for (i=new_rank-1; i>=0; --i)
HDfprintf(stdout, "d[%d].xtent=%Hu \n", i, d[i].xtent);
#endif
- err = MPI_Type_contiguous( (int)elmt_size, MPI_BYTE, &inner_type );
- if (err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't create MPI contiguous type");
+ if (MPI_SUCCESS != (mpi_code= MPI_Type_contiguous( (int)elmt_size, MPI_BYTE, &inner_type )))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code);
/*******************************************************
* Construct the type by walking the hyperslab dims
@@ -365,18 +368,19 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
/****************************************
* Build vector in current dimension:
****************************************/
- err = MPI_Type_vector ( (int)(d[i].count), /* count */
+ mpi_code = MPI_Type_vector ( (int)(d[i].count), /* count */
(int)(d[i].block), /* blocklength */
(int)(d[i].strid), /* stride */
inner_type, /* old type */
&outer_type ); /* new type */
MPI_Type_free( &inner_type );
- if (err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't create MPI vector type");
+ if (mpi_code!=MPI_SUCCESS)
+ HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code);
displacement[1] = (MPI_Aint)elmt_size * max_xtent[i];
- err = MPI_Type_extent(outer_type, &extent_len);
+ if(MPI_SUCCESS != (mpi_code = MPI_Type_extent(outer_type, &extent_len)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_extent failed", mpi_code);
/*************************************************
* Restructure this datatype ("outer_type")
@@ -391,7 +395,7 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
#endif
#ifdef H5_HAVE_MPI2 /* have MPI-2 */
- err = MPI_Type_create_resized
+ mpi_code = MPI_Type_create_resized
( outer_type, /* old type */
0, /* blocklengths */
displacement[1], /* displacements */
@@ -408,7 +412,7 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
HDfprintf(stdout, "hyper_type: i=%d Extending struct type\n"
"***displacements: 0, %d\n", i, displacement[1]);
#endif
- err = MPI_Type_struct ( 2, /* count */
+ mpi_code = MPI_Type_struct ( 2, /* count */
block_length, /* blocklengths */
displacement, /* displacements */
old_type, /* old types */
@@ -416,8 +420,8 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
#endif
MPI_Type_free (&outer_type);
- if (err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't resize MPI vector type");
+ if (mpi_code!=MPI_SUCCESS)
+ HMPI_GOTO_ERROR(FAIL, "couldn't resize MPI vector type", mpi_code);
}
else {
inner_type = outer_type;
@@ -451,26 +455,24 @@ H5S_mpio_hyper_type( const H5S_t *space, size_t elmt_size, hbool_t UNUSED prefer
block_length[0], displacement[0]);
#endif
- err = MPI_Type_struct( 1, /* count */
- block_length, /* blocklengths */
- displacement, /* displacements */
- old_type, /* old type */
- new_type ); /* new type */
- if (err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't create MPI struct type");
-
- err=MPI_Type_free (&old_type[0]);
- if (err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't resize MPI vector type");
+ if (MPI_SUCCESS != (mpi_code= MPI_Type_struct( 1, /* count */
+ block_length, /* blocklengths */
+ displacement, /* displacements */
+ old_type, /* old type */
+ new_type )) /* new type */
+ )
+ HMPI_GOTO_ERROR(FAIL, "couldn't create MPI struct type", mpi_code);
+
+ if (MPI_SUCCESS != (mpi_code= MPI_Type_free (&old_type[0])))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_free failed", mpi_code);
}
else {
*new_type = inner_type;
}
- err = MPI_Type_commit( new_type );
- if (err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't commit MPI vector type");
+ if (MPI_SUCCESS != (mpi_code= MPI_Type_commit( new_type )))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code);
/* fill in the remaining return values */
*count = 1; /* only have to move one of these suckers! */
@@ -537,6 +539,8 @@ H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer
hssize_t offset[H5O_LAYOUT_NDIMS]; /* Offset in selection */
int ndims; /* Number of dimensions of dataset */
int i; /* Local index */
+ int mpi_code; /* MPI return code */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_mpio_hyper_contig_type);
@@ -571,10 +575,10 @@ H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer
if(prefer_derived_types) {
/* fill in the return values */
H5_CHECK_OVERFLOW(total_bytes, hsize_t, int);
- if (MPI_Type_contiguous( (int)total_bytes, MPI_BYTE, new_type ))
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't create MPI contiguous type");
- if(MPI_Type_commit(new_type))
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL,"couldn't commit MPI contiguous type");
+ if (MPI_SUCCESS != (mpi_code=MPI_Type_contiguous( (int)total_bytes, MPI_BYTE, new_type )))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code);
+ if(MPI_SUCCESS != (mpi_code=MPI_Type_commit(new_type)))
+ HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code);
*count = 1;
*extra_offset = byte_offset;
*use_view = 1;
@@ -589,10 +593,11 @@ H5S_mpio_hyper_contig_type( const H5S_t *space, size_t elmt_size, hbool_t prefer
*is_derived_type = 0;
} /* end else */
+done:
#ifdef H5Smpi_DEBUG
HDfprintf(stdout, "Leave %s total_bytes=%Hu\n", FUNC, total_bytes );
#endif
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE (ret_value);
} /* end H5S_mpio_hyper_contig_type() */
@@ -652,10 +657,9 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive
switch(space->select.type) {
case H5S_SEL_NONE:
case H5S_SEL_ALL:
- err = H5S_mpio_all_type( space, elmt_size, prefer_derived_types,
- /* out: */ new_type, count, extra_offset, use_view, is_derived_type );
- if (err<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type");
+ if ( H5S_mpio_all_type( space, elmt_size, prefer_derived_types,
+ /* out: */ new_type, count, extra_offset, use_view, is_derived_type ) <0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type");
break;
case H5S_SEL_POINTS:
@@ -673,7 +677,7 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive
/* out: */ new_type, count, extra_offset, use_view, is_derived_type );
} /* end else */
if (err<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't convert \"all\" selection to MPI type");
break;
default:
@@ -692,6 +696,7 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive
break;
}
+done:
FUNC_LEAVE (ret_value);
}
@@ -761,7 +766,7 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size,
hbool_t plist_is_setup=0; /* Whether the dxpl has been customized */
hbool_t prefer_derived_types=0;/* Whether to prefer MPI derived types or not */
uint8_t *buf=(uint8_t *)_buf; /* Alias for pointer arithmetic */
- int err; /* Error detection value */
+ int mpi_code; /* MPI return code */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5S_mpio_spaces_xfer);
@@ -782,25 +787,23 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size,
prefer_derived_types= H5S_mpi_prefer_derived_types_g;
/* create the MPI buffer type */
- err = H5S_mpio_space_type( mem_space, elmt_size, prefer_derived_types,
+ if (H5S_mpio_space_type( mem_space, elmt_size, prefer_derived_types,
/* out: */
&mpi_buf_type,
&mpi_buf_count,
&mpi_buf_offset,
&mbt_use_view,
- &mbt_is_derived );
- if (MPI_SUCCESS != err)
+ &mbt_is_derived )<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI buf type");
/* create the MPI file type */
- err = H5S_mpio_space_type( file_space, elmt_size, prefer_derived_types,
+ if ( H5S_mpio_space_type( file_space, elmt_size, prefer_derived_types,
/* out: */
&mpi_file_type,
&mpi_file_count,
&mpi_file_offset,
&mft_use_view,
- &mft_is_derived );
- if (MPI_SUCCESS != err)
+ &mft_is_derived )<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL,"couldn't create MPI file type");
/* Use the absolute base address of the dataset (or chunk, eventually) as
@@ -825,12 +828,10 @@ H5S_mpio_spaces_xfer(H5F_t *f, const H5O_layout_t *layout, size_t elmt_size,
/* transfer the data */
if (do_write) {
- err = H5FD_write(f->shared->lf, H5FD_MEM_DRAW, dxpl_id, addr, mpi_buf_count, buf);
- if (err<0)
+ if (H5FD_write(f->shared->lf, H5FD_MEM_DRAW, dxpl_id, addr, mpi_buf_count, buf) <0)
HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,"MPI write failed");
} else {
- err = H5FD_read (f->shared->lf, H5FD_MEM_DRAW, dxpl_id, addr, mpi_buf_count, buf);
- if (err<0)
+ if ( H5FD_read (f->shared->lf, H5FD_MEM_DRAW, dxpl_id, addr, mpi_buf_count, buf) <0)
HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,"MPI read failed");
}
@@ -838,19 +839,17 @@ done:
/* Reset the dxpl settings */
if(plist_is_setup) {
if(H5FD_mpio_teardown(dxpl_id)<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to reset dxpl values");
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "unable to reset dxpl values");
} /* end if */
/* free the MPI buf and file types */
if (mbt_is_derived) {
- err = MPI_Type_free( &mpi_buf_type );
- if (MPI_SUCCESS != err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL, "unable to free MPI file type");
+ if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_buf_type )))
+ HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code);
}
if (mft_is_derived) {
- err = MPI_Type_free( &mpi_file_type );
- if (MPI_SUCCESS != err)
- HRETURN_ERROR(H5E_DATASPACE, H5E_MPI, FAIL, "unable to free MPI file type");
+ if (MPI_SUCCESS != (mpi_code= MPI_Type_free( &mpi_file_type )))
+ HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code);
}
FUNC_LEAVE (ret_value);
@@ -883,7 +882,7 @@ H5S_mpio_spaces_read(H5F_t *f, const H5O_layout_t *layout,
const H5S_t *file_space, const H5S_t *mem_space,
hid_t dxpl_id, void *buf/*out*/)
{
- herr_t ret_value = FAIL;
+ herr_t ret_value;
FUNC_ENTER_NOAPI(H5S_mpio_spaces_read, FAIL);
@@ -921,7 +920,7 @@ H5S_mpio_spaces_write(H5F_t *f, const H5O_layout_t *layout,
const H5S_t *file_space, const H5S_t *mem_space,
hid_t dxpl_id, const void *buf)
{
- herr_t ret_value = FAIL;
+ herr_t ret_value;
FUNC_ENTER_NOAPI(H5S_mpio_spaces_write, FAIL);
diff --git a/src/H5Snone.c b/src/H5Snone.c
index f9abe49..fc95d1f 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -155,14 +155,12 @@ H5S_none_release (H5S_t * UNUSED space)
hsize_t
H5S_none_npoints (const H5S_t *space)
{
- hsize_t ret_value=0;
-
FUNC_ENTER_NOAPI(H5S_none_npoints, 0);
/* Check args */
assert (space);
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (0);
} /* H5S_none_npoints() */
@@ -257,8 +255,6 @@ H5S_none_serial_size (const H5S_t *space)
herr_t
H5S_none_serialize (const H5S_t *space, uint8_t *buf)
{
- herr_t ret_value=FAIL; /* return value */
-
FUNC_ENTER_NOAPI(H5S_none_serialize, FAIL);
assert(space);
@@ -269,11 +265,9 @@ H5S_none_serialize (const H5S_t *space, uint8_t *buf)
UINT32ENCODE(buf, (uint32_t)0); /* Store the un-used padding */
UINT32ENCODE(buf, (uint32_t)0); /* Store the additional information length */
- /* Set success */
- ret_value=SUCCEED;
-
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5S_none_serialize() */
+
/*--------------------------------------------------------------------------
NAME
@@ -297,7 +291,7 @@ H5S_none_serialize (const H5S_t *space, uint8_t *buf)
herr_t
H5S_none_deserialize (H5S_t *space, const uint8_t UNUSED *buf)
{
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_none_deserialize, FAIL);
@@ -512,18 +506,19 @@ done:
herr_t H5Sselect_none (hid_t spaceid)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Sselect_none, FAIL);
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
/* Change to "none" selection */
if((ret_value=H5S_select_none(space))<0)
- HRETURN_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
+done:
FUNC_LEAVE (ret_value);
} /* H5Sselect_none() */
@@ -565,8 +560,6 @@ H5S_none_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t
size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
hsize_t *off, size_t *len)
{
- herr_t ret_value=SUCCEED; /* return value */
-
FUNC_ENTER_NOAPI (H5S_none_get_seq_list, FAIL);
/* Check args */
@@ -586,5 +579,5 @@ H5S_none_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t
/* The don't use any bytes, either */
*nbytes=0;
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* end H5S_all_get_seq_list() */
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index d20a0b7..6e6ca5b 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -143,7 +143,7 @@ H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t *
H5S_pnt_node_t *top, *curr, *new_node; /* Point selection nodes */
const hssize_t *coord=(const hssize_t *)_coord; /* Pointer to the actual coordinates */
unsigned i; /* Counter */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5S_point_add, FAIL);
@@ -156,12 +156,10 @@ H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t *
for(i=0; i<num_elem; i++) {
/* Allocate space for the new node */
if((new_node = H5FL_ALLOC(H5S_pnt_node_t,0))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate point node");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node");
if((new_node->pnt = H5MM_malloc(space->extent.u.simple.rank*sizeof(hssize_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate coordinate information");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information");
/* Copy over the coordinates */
HDmemcpy(new_node->pnt,coord+(i*space->extent.u.simple.rank),(space->extent.u.simple.rank*sizeof(hssize_t)));
@@ -200,8 +198,6 @@ H5S_point_add (H5S_t *space, H5S_seloper_t op, size_t num_elem, const hssize_t *
/* Add the number of elements in the new selection */
space->select.num_elem+=num_elem;
- ret_value=SUCCEED;
-
done:
FUNC_LEAVE (ret_value);
} /* H5S_point_add() */
@@ -398,19 +394,16 @@ H5S_point_copy (H5S_t *dst, const H5S_t *src)
/* Allocate room for the head of the point list */
if((dst->select.sel_info.pnt_lst=H5FL_ALLOC(H5S_pnt_list_t,0))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate point node");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node");
curr=src->select.sel_info.pnt_lst->head;
new_head=NULL;
while(curr!=NULL) {
/* Create each point */
if((new_node=H5FL_ALLOC(H5S_pnt_node_t,0))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate point node");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate point node");
if((new_node->pnt = H5MM_malloc(src->extent.u.simple.rank*sizeof(hssize_t)))==NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate coordinate information");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate coordinate information");
HDmemcpy(new_node->pnt,curr->pnt,(src->extent.u.simple.rank*sizeof(hssize_t)));
new_node->next=NULL;
@@ -535,19 +528,20 @@ hssize_t
H5Sget_select_elem_npoints(hid_t spaceid)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- hssize_t ret_value=FAIL; /* return value */
+ hssize_t ret_value; /* return value */
FUNC_ENTER_API(H5Sget_select_elem_npoints, FAIL);
H5TRACE1("Hs","i",spaceid);
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if(space->select.type!=H5S_SEL_POINTS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an element selection");
ret_value = H5S_get_select_elem_npoints(space);
+done:
FUNC_LEAVE (ret_value);
} /* H5Sget_select_elem_npoints() */
@@ -575,7 +569,7 @@ hssize_t
H5S_point_serial_size (const H5S_t *space)
{
H5S_pnt_node_t *curr; /* Point information nodes */
- hssize_t ret_value=FAIL; /* return value */
+ hssize_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_point_serial_size, FAIL);
@@ -625,7 +619,6 @@ H5S_point_serialize (const H5S_t *space, uint8_t *buf)
uint8_t *lenp; /* pointer to length location for later storage */
uint32_t len=0; /* number of bytes used */
unsigned u; /* local counting variable */
- herr_t ret_value=FAIL; /* return value */
FUNC_ENTER_NOAPI(H5S_point_serialize, FAIL);
@@ -662,10 +655,7 @@ H5S_point_serialize (const H5S_t *space, uint8_t *buf)
/* Encode length */
UINT32ENCODE(lenp, (uint32_t)len); /* Store the length of the extra information */
- /* Set success */
- ret_value=SUCCEED;
-
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5S_point_serialize() */
@@ -696,7 +686,7 @@ H5S_point_deserialize (H5S_t *space, const uint8_t *buf)
size_t num_elem=0; /* Number of elements in selection */
hssize_t *coord=NULL, *tcoord; /* Pointer to array of elements */
unsigned i,j; /* local counting variables */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_point_deserialize, FAIL);
@@ -767,7 +757,6 @@ H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoint
{
H5S_pnt_node_t *node; /* Point node */
int rank; /* Dataspace rank */
- herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOINIT(H5S_get_select_elem_pointlist);
@@ -794,7 +783,7 @@ H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoint
node=node->next;
} /* end while */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5Sget_select_elem_pointlist() */
@@ -831,21 +820,22 @@ herr_t
H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoints, hsize_t *buf)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Sget_select_elem_pointlist, FAIL);
H5TRACE4("e","ihh*h",spaceid,startpoint,numpoints,buf);
/* Check args */
if(buf==NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if(space->select.type!=H5S_SEL_POINTS)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a point selection");
ret_value = H5S_get_select_elem_pointlist(space,startpoint,numpoints,buf);
+done:
FUNC_LEAVE (ret_value);
} /* H5Sget_select_elem_pointlist() */
@@ -882,7 +872,6 @@ H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
H5S_pnt_node_t *node; /* Point node */
int rank; /* Dataspace rank */
int i; /* index variable */
- herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOAPI(H5S_point_bounds, FAIL);
@@ -911,7 +900,7 @@ H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
node=node->next;
} /* end while */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE (SUCCEED);
} /* H5Sget_point_bounds() */
@@ -939,7 +928,7 @@ H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
htri_t
H5S_point_is_contiguous(const H5S_t *space)
{
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_point_is_contiguous, FAIL);
@@ -976,7 +965,7 @@ H5S_point_is_contiguous(const H5S_t *space)
htri_t
H5S_point_is_single(const H5S_t *space)
{
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_point_is_single, FAIL);
@@ -1016,7 +1005,7 @@ H5S_point_is_single(const H5S_t *space)
htri_t
H5S_point_is_regular(const H5S_t *space)
{
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_NOAPI(H5S_point_is_regular, FAIL);
@@ -1068,17 +1057,17 @@ H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem,
const hssize_t **coord)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=SUCCEED; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Sselect_elements, FAIL);
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if(coord==NULL || num_elem==0)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
if(!(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND))
- HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operations other than H5S_SELECT_SET not supported currently");
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operations other than H5S_SELECT_SET not supported currently");
/* Call the real element selection routine */
if((ret_value=H5S_select_elements(space,op,num_elem,coord))<0)
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 18b5ca7..1905d7a 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -76,7 +76,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
/* Copy offset information */
if (NULL==(dst->select.offset = H5FL_ARR_ALLOC(hssize_t,src->extent.u.simple.rank,1)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
if(src->select.offset!=NULL)
HDmemcpy(dst->select.offset,src->select.offset,(src->extent.u.simple.rank*sizeof(hssize_t)));
@@ -117,6 +117,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
break;
} /* end switch */
+done:
FUNC_LEAVE (ret_value);
} /* H5S_select_copy() */
@@ -142,17 +143,18 @@ hssize_t
H5Sget_select_npoints(hid_t spaceid)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- hssize_t ret_value=FAIL; /* return value */
+ hssize_t ret_value; /* return value */
FUNC_ENTER_API(H5Sget_select_npoints, 0);
H5TRACE1("Hs","i",spaceid);
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
ret_value = (*space->select.get_npoints)(space);
+done:
FUNC_LEAVE (ret_value);
} /* H5Sget_select_npoints() */
@@ -181,17 +183,18 @@ htri_t
H5Sselect_valid(hid_t spaceid)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- htri_t ret_value=FAIL; /* return value */
+ htri_t ret_value; /* return value */
FUNC_ENTER_API(H5Sselect_valid, 0);
H5TRACE1("b","i",spaceid);
/* Check args */
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
ret_value = (*space->select.is_valid)(space);
+done:
FUNC_LEAVE (ret_value);
} /* H5Sselect_valid() */
@@ -287,19 +290,20 @@ herr_t
H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end)
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
- herr_t ret_value=FAIL; /* return value */
+ herr_t ret_value; /* return value */
FUNC_ENTER_API(H5Sget_select_bounds, FAIL);
H5TRACE3("e","i*h*h",spaceid,start,end);
/* Check args */
if(start==NULL || end==NULL)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer");
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
ret_value = (*space->select.bounds)(space,start,end);
+done:
FUNC_LEAVE (ret_value);
} /* H5Sget_select_bounds() */
@@ -491,15 +495,20 @@ H5S_sel_type
H5Sget_select_type(hid_t space_id)
{
H5S_t *space = NULL; /* dataspace to modify */
+ H5S_sel_type ret_value; /* Return value */
FUNC_ENTER_API(H5Sget_select_type, H5S_SEL_ERROR);
H5TRACE1("St","i",space_id);
/* Check args */
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a data space");
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a data space");
- FUNC_LEAVE(space->select.type);
+ /* Set return value */
+ ret_value=space->select.type;
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5Sget_select_type() */
diff --git a/src/H5T.c b/src/H5T.c
index 449508b..34b45c0 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -277,6 +277,7 @@ H5T_init_interface(void)
H5T_t *array=NULL; /* Datatype structure for array objects */
hsize_t dim[1]={1}; /* Dimension info for array datatype */
herr_t status;
+ unsigned copied_dtype=1; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */
herr_t ret_value=SUCCEED;
FUNC_ENTER_NOINIT(H5T_init_interface);
@@ -339,10 +340,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8;
/* Atomize result */
- if ((H5T_NATIVE_INT8_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT8_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
if (H5T_NATIVE_UINT8_g<0) {
/* Base off of native datatype */
@@ -355,10 +354,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8;
/* Atomize result */
- if ((H5T_NATIVE_UINT8_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT8_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_LEAST8_g<0) {
/* Base off of native datatype */
@@ -371,10 +368,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8;
/* Atomize result */
- if ((H5T_NATIVE_INT_LEAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_LEAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_LEAST8_g<0) {
/* Base off of native datatype */
@@ -387,10 +382,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8;
/* Atomize result */
- if ((H5T_NATIVE_UINT_LEAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_LEAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_FAST8_g<0) {
/* Base off of native datatype */
@@ -403,10 +396,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8;
/* Atomize result */
- if ((H5T_NATIVE_INT_FAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_FAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_FAST8_g<0) {
/* Base off of native datatype */
@@ -419,10 +410,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8;
/* Atomize result */
- if ((H5T_NATIVE_UINT_FAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_FAST8_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
/* int16 */
@@ -437,10 +426,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 16;
/* Atomize result */
- if ((H5T_NATIVE_INT16_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT16_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT16_g<0) {
/* Base off of native datatype */
@@ -453,10 +440,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 16;
/* Atomize result */
- if ((H5T_NATIVE_UINT16_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT16_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_LEAST16_g<0) {
/* Base off of native datatype */
@@ -469,10 +454,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 16;
/* Atomize result */
- if ((H5T_NATIVE_INT_LEAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_LEAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_LEAST16_g<0) {
/* Base off of native datatype */
@@ -485,10 +468,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 16;
/* Atomize result */
- if ((H5T_NATIVE_UINT_LEAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_LEAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_FAST16_g<0) {
/* Base off of native datatype */
@@ -501,10 +482,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 16;
/* Atomize result */
- if ((H5T_NATIVE_INT_FAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_FAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_FAST16_g<0) {
/* Base off of native datatype */
@@ -517,10 +496,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 16;
/* Atomize result */
- if ((H5T_NATIVE_UINT_FAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_FAST16_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
/* int32 */
@@ -535,10 +512,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 32;
/* Atomize result */
- if ((H5T_NATIVE_INT32_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT32_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT32_g<0) {
/* Base off of native datatype */
@@ -551,10 +526,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 32;
/* Atomize result */
- if ((H5T_NATIVE_UINT32_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT32_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_LEAST32_g<0) {
/* Base off of native datatype */
@@ -567,10 +540,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 32;
/* Atomize result */
- if ((H5T_NATIVE_INT_LEAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_LEAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_LEAST32_g<0) {
/* Base off of native datatype */
@@ -583,10 +554,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 32;
/* Atomize result */
- if ((H5T_NATIVE_UINT_LEAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_LEAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_FAST32_g<0) {
/* Base off of native datatype */
@@ -599,10 +568,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 32;
/* Atomize result */
- if ((H5T_NATIVE_INT_FAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_FAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_FAST32_g<0) {
/* Base off of native datatype */
@@ -615,10 +582,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 32;
/* Atomize result */
- if ((H5T_NATIVE_UINT_FAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_FAST32_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
/* int64 */
@@ -633,10 +598,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Atomize result */
- if ((H5T_NATIVE_INT64_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT64_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT64_g<0) {
/* Base off of native datatype */
@@ -649,10 +612,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Atomize result */
- if ((H5T_NATIVE_UINT64_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT64_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_LEAST64_g<0) {
/* Base off of native datatype */
@@ -665,10 +626,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Atomize result */
- if ((H5T_NATIVE_INT_LEAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_LEAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_LEAST64_g<0) {
/* Base off of native datatype */
@@ -681,10 +640,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Atomize result */
- if ((H5T_NATIVE_UINT_LEAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_LEAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_INT_FAST64_g<0) {
/* Base off of native datatype */
@@ -697,10 +654,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Atomize result */
- if ((H5T_NATIVE_INT_FAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_INT_FAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
if (H5T_NATIVE_UINT_FAST64_g<0) {
/* Base off of native datatype */
@@ -713,10 +668,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Atomize result */
- if ((H5T_NATIVE_UINT_FAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_UINT_FAST64_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
}
@@ -738,10 +691,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 8;
/* Atomize result */
- if ((H5T_NATIVE_B8_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_B8_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 2-byte bit field */
@@ -757,10 +708,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 16;
/* Atomize result */
- if ((H5T_NATIVE_B16_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_B16_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 4-byte bit field */
@@ -776,10 +725,8 @@ H5T_init_interface(void)
dt->u.atomic.prec = 32;
/* Atomize result */
- if ((H5T_NATIVE_B32_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_B32_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 8-byte bit field */
@@ -795,29 +742,10 @@ H5T_init_interface(void)
dt->u.atomic.prec = 64;
/* Atomize result */
- if ((H5T_NATIVE_B64_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_B64_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
- /* Opaque data */
- if(H5T_NATIVE_OPAQUE_g<0) {
- if (NULL==(dt = H5FL_ALLOC(H5T_t,1)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
-
- /* Set information */
- dt->state = H5T_STATE_IMMUTABLE;
- dt->ent.header = HADDR_UNDEF;
- dt->type = H5T_OPAQUE;
- dt->size = 1;
- dt->u.opaque.tag = H5MM_strdup("");
-
- /* Atomize result */
- if ((H5T_NATIVE_OPAQUE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize H5T layer");
- } /* end if */
-
/* haddr_t */
if(H5T_NATIVE_HADDR_g<0) {
/* Base off of native datatype */
@@ -831,10 +759,8 @@ H5T_init_interface(void)
dt->u.atomic.offset = 0;
/* Atomize result */
- if ((H5T_NATIVE_HADDR_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_HADDR_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* hsize_t */
@@ -850,10 +776,8 @@ H5T_init_interface(void)
dt->u.atomic.offset = 0;
/* Atomize result */
- if ((H5T_NATIVE_HSIZE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_HSIZE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* hssize_t */
@@ -869,10 +793,8 @@ H5T_init_interface(void)
dt->u.atomic.offset = 0;
/* Atomize result */
- if ((H5T_NATIVE_HSSIZE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_HSSIZE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* herr_t */
@@ -888,10 +810,8 @@ H5T_init_interface(void)
dt->u.atomic.offset = 0;
/* Atomize result */
- if ((H5T_NATIVE_HERR_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_HERR_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* hbool_t */
@@ -907,10 +827,8 @@ H5T_init_interface(void)
dt->u.atomic.offset = 0;
/* Atomize result */
- if ((H5T_NATIVE_HBOOL_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_NATIVE_HBOOL_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/*------------------------------------------------------------
@@ -942,10 +860,8 @@ H5T_init_interface(void)
dt->u.atomic.u.f.pad = H5T_PAD_ZERO;
/* Atomize result */
- if ((H5T_IEEE_F32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_IEEE_F32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* IEEE 4-byte big-endian float */
@@ -972,10 +888,8 @@ H5T_init_interface(void)
dt->u.atomic.u.f.pad = H5T_PAD_ZERO;
/* Atomize result */
- if ((H5T_IEEE_F32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_IEEE_F32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* IEEE 8-byte little-endian float */
@@ -1002,10 +916,8 @@ H5T_init_interface(void)
dt->u.atomic.u.f.pad = H5T_PAD_ZERO;
/* Atomize result */
- if ((H5T_IEEE_F64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_IEEE_F64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* IEEE 8-byte big-endian float */
@@ -1032,10 +944,8 @@ H5T_init_interface(void)
dt->u.atomic.u.f.pad = H5T_PAD_ZERO;
/* Atomize result */
- if ((H5T_IEEE_F64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_IEEE_F64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/*------------------------------------------------------------
@@ -1061,10 +971,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I8LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I8LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 1-byte big-endian (endianness is irrelevant) signed integer */
@@ -1084,10 +992,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I8BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I8BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 2-byte little-endian signed integer */
@@ -1107,10 +1013,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I16LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I16LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 2-byte big-endian signed integer */
@@ -1130,10 +1034,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I16BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I16BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 4-byte little-endian signed integer */
@@ -1153,10 +1055,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 4-byte big-endian signed integer */
@@ -1176,10 +1076,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 8-byte little-endian signed integer */
@@ -1199,10 +1097,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 8-byte big-endian signed integer */
@@ -1222,10 +1118,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_2;
/* Atomize result */
- if ((H5T_STD_I64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_I64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 1-byte little-endian (endianness is irrelevant) unsigned integer */
@@ -1245,10 +1139,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U8LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U8LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register little-endian (order is irrelevant) 8-bit bitfield now also
@@ -1262,10 +1154,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B8LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B8LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 1-byte big-endian (endianness is irrelevant) unsigned integer */
@@ -1285,10 +1175,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U8BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U8BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register big-endian (order is irrelevant) 8-bit bitfield now also
@@ -1302,10 +1190,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B8BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B8BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 2-byte little-endian unsigned integer */
@@ -1325,10 +1211,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U16LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U16LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register little-endian 16-bit bitfield now also
@@ -1342,10 +1226,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B16LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B16LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 2-byte big-endian unsigned integer */
@@ -1365,10 +1247,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U16BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U16BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register big-endian 16-bit bitfield now also
@@ -1382,10 +1262,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B16BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B16BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 4-byte little-endian unsigned integer */
@@ -1405,10 +1283,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register little-endian 32-bit bitfield now also
@@ -1422,10 +1298,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register 4-byte little-endian UNIX time_t now also
@@ -1439,10 +1313,8 @@ H5T_init_interface(void)
dt->type = H5T_TIME;
/* Atomize result */
- if ((H5T_UNIX_D32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_UNIX_D32LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 4-byte big-endian unsigned integer */
@@ -1462,10 +1334,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register big-endian 32-bit bitfield now also
@@ -1479,10 +1349,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register 4-byte big-endian UNIX time_t now also
@@ -1496,10 +1364,8 @@ H5T_init_interface(void)
dt->type = H5T_TIME;
/* Atomize result */
- if ((H5T_UNIX_D32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_UNIX_D32BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 8-byte little-endian unsigned integer */
@@ -1519,10 +1385,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register little-endian 64-bit bitfield now also
@@ -1536,10 +1400,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register 8-byte little-endian UNIX time_t now also
@@ -1553,10 +1415,8 @@ H5T_init_interface(void)
dt->type = H5T_TIME;
/* Atomize result */
- if ((H5T_UNIX_D64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_UNIX_D64LE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
/* 8-byte big-endian unsigned integer */
@@ -1576,10 +1436,8 @@ H5T_init_interface(void)
dt->u.atomic.u.i.sign = H5T_SGN_NONE;
/* Atomize result */
- if ((H5T_STD_U64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_U64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register big-endian 64-bit bitfield now also
@@ -1593,10 +1451,8 @@ H5T_init_interface(void)
dt->type = H5T_BITFIELD;
/* Atomize result */
- if ((H5T_STD_B64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_STD_B64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
/*
* Register 8-byte big-endian UNIX time_t now also
@@ -1610,10 +1466,8 @@ H5T_init_interface(void)
dt->type = H5T_TIME;
/* Atomize result */
- if ((H5T_UNIX_D64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0) {
- H5T_close(dt);
+ if ((H5T_UNIX_D64BE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype atom");
- } /* end if */
} /* end if */
@@ -1631,6 +1485,28 @@ H5T_init_interface(void)
/* Moved into the U32LE, U32BE, U64LE & U64BE sections */
+ /* Indicate that the types that are created from here down are allocated
+ * H5FL_ALLOC(), not copied with H5T_copy()
+ */
+ copied_dtype=0;
+
+ /* Opaque data */
+ if(H5T_NATIVE_OPAQUE_g<0) {
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+
+ /* Set information */
+ dt->state = H5T_STATE_IMMUTABLE;
+ dt->ent.header = HADDR_UNDEF;
+ dt->type = H5T_OPAQUE;
+ dt->size = 1;
+ dt->u.opaque.tag = H5MM_strdup("");
+
+ /* Atomize result */
+ if ((H5T_NATIVE_OPAQUE_g = H5I_register(H5I_DATATYPE, dt)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize H5T layer");
+ } /* end if */
+
/*------------------------------------------------------------
* The `C' architecture
*------------------------------------------------------------
@@ -1733,27 +1609,27 @@ H5T_init_interface(void)
* ending with the most specific.
*/
if (NULL == (fixedpt = H5I_object(H5T_NATIVE_INT_g)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (floatpt = H5I_object(H5T_NATIVE_FLOAT_g)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (string = H5I_object(H5T_C_S1_g)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (bitfield = H5I_object(H5T_STD_B8LE_g)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (compound = H5T_create(H5T_COMPOUND, 1)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (enum_type = H5T_create(H5T_ENUM, 1)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (vlen = H5T_vlen_create(native_int)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL == (array = H5T_array_create(native_int,1,dim,NULL)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL==(std_u32le=H5I_object(H5T_STD_U32LE_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL==(std_i32le=H5I_object(H5T_STD_I32LE_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
if (NULL==(ieee_f64le=H5I_object(H5T_IEEE_F64LE_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype");
status = 0;
status |= H5T_register(H5T_PERS_SOFT, "i_i", fixedpt, fixedpt, H5T_conv_i_i);
@@ -1897,6 +1773,7 @@ H5T_init_interface(void)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to register conversion function(s)");
done:
+ /* General cleanup */
if (compound!=NULL)
H5T_close(compound);
if (enum_type!=NULL)
@@ -1905,6 +1782,18 @@ done:
H5T_close(vlen);
if (array!=NULL)
H5T_close(array);
+
+ /* Error cleanup */
+ if(ret_value<0) {
+ if(dt!=NULL) {
+ /* Check if we should call H5T_close or H5FL_FREE */
+ if(copied_dtype)
+ H5T_close(dt);
+ else
+ H5FL_FREE(H5T_t,dt);
+ } /* end if */
+ } /* end if */
+
FUNC_LEAVE(ret_value);
}
@@ -1933,11 +1822,10 @@ H5T_unlock_cb (void *_dt, hid_t UNUSED id, const void UNUSED *key)
FUNC_ENTER_NOINIT(H5T_unlock_cb);
assert (dt);
- if (H5T_STATE_IMMUTABLE==dt->state) {
+ if (H5T_STATE_IMMUTABLE==dt->state)
dt->state = H5T_STATE_RDONLY;
- }
- FUNC_LEAVE (0);
+ FUNC_LEAVE (SUCCEED);
}
@@ -2135,23 +2023,24 @@ hid_t
H5Tcreate(H5T_class_t type, size_t size)
{
H5T_t *dt = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Tcreate, FAIL);
H5TRACE2("i","Ttz",type,size);
/* check args */
if (size <= 0)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size");
/* create the type */
if (NULL == (dt = H5T_create(type, size)))
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type");
/* Make it an atom */
if ((ret_value = H5I_register(H5I_DATATYPE, dt)) < 0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom");
+done:
FUNC_LEAVE(ret_value);
}
@@ -2177,31 +2066,30 @@ H5Topen(hid_t loc_id, const char *name)
{
H5G_entry_t *loc = NULL;
H5T_t *type = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Topen, FAIL);
H5TRACE2("i","is",loc_id,name);
/* Check args */
- if (NULL==(loc=H5G_loc (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (NULL==(loc=H5G_loc (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
/* Open it */
- if (NULL==(type=H5T_open (loc, name))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL,
- "unable to open named data type");
- }
+ if (NULL==(type=H5T_open (loc, name)))
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named data type");
/* Register the type and return the ID */
- if ((ret_value=H5I_register (H5I_DATATYPE, type))<0) {
- H5T_close (type);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "unable to register named data type");
- }
+ if ((ret_value=H5I_register (H5I_DATATYPE, type))<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named data type");
+
+done:
+ if(ret_value<0) {
+ if(type!=NULL)
+ H5T_close (type);
+ } /* end if */
FUNC_LEAVE (ret_value);
}
@@ -2227,27 +2115,25 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id)
{
H5G_entry_t *loc = NULL;
H5T_t *type = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tcommit, FAIL);
H5TRACE3("e","isi",loc_id,name,type_id);
/* Check arguments */
- if (NULL==(loc=H5G_loc (loc_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
+ if (NULL==(loc=H5G_loc (loc_id)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a location");
+ if (!name || !*name)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/* Commit the type */
- if (H5T_commit (loc, name, type)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to commit data type");
- }
+ if (H5T_commit (loc, name, type)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit data type");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2271,15 +2157,20 @@ htri_t
H5Tcommitted(hid_t type_id)
{
H5T_t *type = NULL;
+ htri_t ret_value; /* Return value */
FUNC_ENTER_API(H5Tcommitted, FAIL);
H5TRACE1("b","i",type_id);
/* Check arguments */
if (NULL==(type=H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+
+ /* Set return value */
+ ret_value= (H5T_STATE_OPEN==type->state || H5T_STATE_NAMED==type->state);
- FUNC_LEAVE (H5T_STATE_OPEN==type->state || H5T_STATE_NAMED==type->state);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2313,7 +2204,7 @@ H5Tcopy(hid_t type_id)
H5T_t *dt = NULL;
H5T_t *new_dt = NULL;
H5D_t *dset = NULL;
- hid_t ret_value = FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Tcopy, FAIL);
H5TRACE1("i","i",type_id);
@@ -2322,31 +2213,35 @@ H5Tcopy(hid_t type_id)
case H5I_DATATYPE:
/* The argument is a data type handle */
if (NULL==(dt=H5I_object (type_id)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
break;
case H5I_DATASET:
/* The argument is a dataset handle */
if (NULL==(dset=H5I_object (type_id)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
if (NULL==(dt=H5D_typeof (dset)))
- HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get the dataset data type");
+ HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get the dataset data type");
break;
default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type or dataset");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type or dataset");
} /* end switch */
/* Copy */
if (NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT)))
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy");
/* Atomize result */
- if ((ret_value = H5I_register(H5I_DATATYPE, new_dt)) < 0) {
- H5T_close(new_dt);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom");
- } /* end if */
+ if ((ret_value = H5I_register(H5I_DATATYPE, new_dt)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom");
+done:
+ if(ret_value<0) {
+ if(new_dt!=NULL)
+ H5T_close(new_dt);
+ } /* end if */
+
FUNC_LEAVE(ret_value);
} /* end H5Tcopy() */
@@ -2369,23 +2264,23 @@ herr_t
H5Tclose(hid_t type_id)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tclose, FAIL);
H5TRACE1("e","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_IMMUTABLE==dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_IMMUTABLE==dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable data type");
/* When the reference count reaches zero the resources are freed */
- if (H5I_dec_ref(type_id) < 0) {
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
- }
+ if (H5I_dec_ref(type_id) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2412,7 +2307,7 @@ H5Tequal(hid_t type1_id, hid_t type2_id)
{
const H5T_t *dt1 = NULL;
const H5T_t *dt2 = NULL;
- htri_t ret_value = FAIL;
+ htri_t ret_value;
FUNC_ENTER_API(H5Tequal, FAIL);
H5TRACE2("b","ii",type1_id,type2_id);
@@ -2420,10 +2315,11 @@ H5Tequal(hid_t type1_id, hid_t type2_id)
/* check args */
if (NULL == (dt1 = H5I_object_verify(type1_id,H5I_DATATYPE)) ||
NULL == (dt2 = H5I_object_verify(type2_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
ret_value = (0 == H5T_cmp(dt1, dt2)) ? TRUE : FALSE;
+done:
FUNC_LEAVE(ret_value);
}
@@ -2456,23 +2352,22 @@ herr_t
H5Tlock(hid_t type_id)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tlock, FAIL);
H5TRACE1("e","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_NAMED==dt->state || H5T_STATE_OPEN==dt->state) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "unable to lock named data type");
- }
- if (H5T_lock (dt, TRUE)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to lock transient data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_NAMED==dt->state || H5T_STATE_OPEN==dt->state)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to lock named data type");
+
+ if (H5T_lock (dt, TRUE)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2497,15 +2392,20 @@ H5T_class_t
H5Tget_class(hid_t type_id)
{
H5T_t *dt = NULL;
+ H5T_class_t ret_value; /* Return value */
FUNC_ENTER_API(H5Tget_class, H5T_NO_CLASS);
H5TRACE1("Tt","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
+
+ /* Set return value */
+ ret_value= H5T_get_class(dt);
- FUNC_LEAVE(H5T_get_class(dt));
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2565,18 +2465,22 @@ htri_t
H5Tdetect_class(hid_t type, H5T_class_t cls)
{
H5T_t *dt = NULL;
+ htri_t ret_value; /* Return value */
FUNC_ENTER_API(H5Tdetect_class, FAIL);
H5TRACE2("b","iTt",type,cls);
/* Check args */
if (NULL == (dt = H5I_object_verify(type,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
- if (!(cls>H5T_NO_CLASS && cls<H5T_NCLASSES)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
+ if (!(cls>H5T_NO_CLASS && cls<H5T_NCLASSES))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type class");
+
+ /* Set return value */
+ ret_value=H5T_detect_class(dt,cls);
- FUNC_LEAVE(H5T_detect_class(dt,cls));
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2599,6 +2503,7 @@ htri_t
H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
{
int i;
+ htri_t ret_value=FALSE; /* Return value */
FUNC_ENTER_NOAPI(H5T_detect_class, FAIL);
@@ -2607,7 +2512,7 @@ H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
/* Check if this type is the correct type */
if(dt->type==cls)
- HRETURN(TRUE);
+ HGOTO_DONE(TRUE);
/* check for types that might have the correct type as a component */
switch(dt->type) {
@@ -2615,24 +2520,25 @@ H5T_detect_class (const H5T_t *dt, H5T_class_t cls)
for (i=0; i<dt->u.compnd.nmembs; i++) {
/* Check if this field's type is the correct type */
if(dt->u.compnd.memb[i].type->type==cls)
- HRETURN(TRUE);
+ HGOTO_DONE(TRUE);
/* Recurse if it's VL, compound or array */
if(dt->u.compnd.memb[i].type->type==H5T_COMPOUND || dt->u.compnd.memb[i].type->type==H5T_VLEN || dt->u.compnd.memb[i].type->type==H5T_ARRAY)
- HRETURN(H5T_detect_class(dt->u.compnd.memb[i].type,cls));
+ HGOTO_DONE(H5T_detect_class(dt->u.compnd.memb[i].type,cls));
} /* end for */
break;
case H5T_ARRAY:
case H5T_VLEN:
case H5T_ENUM:
- HRETURN(H5T_detect_class(dt->parent,cls));
+ HGOTO_DONE(H5T_detect_class(dt->parent,cls));
default:
break;
} /* end if */
- FUNC_LEAVE (FALSE);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2658,19 +2564,20 @@ size_t
H5Tget_size(hid_t type_id)
{
H5T_t *dt = NULL;
- size_t size;
+ size_t ret_value;
FUNC_ENTER_API(H5Tget_size, 0);
H5TRACE1("z","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
/* size */
- size = H5T_get_size(dt);
+ ret_value = H5T_get_size(dt);
- FUNC_LEAVE(size);
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5Tget_size() */
@@ -2706,37 +2613,30 @@ herr_t
H5Tset_size(hid_t type_id, size_t size)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_size, FAIL);
H5TRACE2("e","iz",type_id,size);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (size <= 0 && size!=H5T_VARIABLE) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive");
- }
- if (size == H5T_VARIABLE && dt->type!=H5T_STRING) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length");
- }
- if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not allowed after members are defined");
- }
- if (H5T_COMPOUND==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for this datatype");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (size <= 0 && size!=H5T_VARIABLE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive");
+ if (size == H5T_VARIABLE && dt->type!=H5T_STRING)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "only strings may be variable length");
+ if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined");
+ if (H5T_COMPOUND==dt->type || H5T_ARRAY==dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for this datatype");
/* Do the work */
- if (H5T_set_size(dt, size)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set size for data type");
- }
+ if (H5T_set_size(dt, size)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for data type");
+done:
FUNC_LEAVE(SUCCEED);
}
@@ -2763,27 +2663,26 @@ H5T_order_t
H5Tget_order(hid_t type_id)
{
H5T_t *dt = NULL;
- H5T_order_t order;
+ H5T_order_t ret_value;
FUNC_ENTER_API(H5Tget_order, H5T_ORDER_ERROR);
H5TRACE1("To","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, "not a data type");
if (dt->parent)
dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY ==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR,
- "operation not defined for specified data type");
- }
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY ==dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR, "operation not defined for specified data type");
/* Order */
assert(H5T_is_atomic(dt));
- order = dt->u.atomic.order;
+ ret_value = dt->u.atomic.order;
- FUNC_LEAVE(order);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2807,33 +2706,31 @@ herr_t
H5Tset_order(hid_t type_id, H5T_order_t order)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_order, FAIL);
H5TRACE2("e","iTo",type_id,order);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (order < 0 || order > H5T_ORDER_NONE) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order");
- }
- if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not allowed after members are defined");
- }
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR,
- "operation not defined for specified data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (order < 0 || order > H5T_ORDER_NONE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order");
+ if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_ORDER_ERROR, "operation not defined for specified data type");
/* Commit */
assert(H5T_is_atomic(dt));
dt->u.atomic.order = order;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2863,25 +2760,25 @@ size_t
H5Tget_precision(hid_t type_id)
{
H5T_t *dt = NULL;
- size_t prec;
+ size_t ret_value;
FUNC_ENTER_API(H5Tget_precision, 0);
H5TRACE1("z","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0,
- "operation not defined for specified data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for specified data type");
/* Precision */
assert(H5T_is_atomic(dt));
- prec = dt->u.atomic.prec;
+ ret_value = dt->u.atomic.prec;
- FUNC_LEAVE(prec);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2918,32 +2815,27 @@ herr_t
H5Tset_precision(hid_t type_id, size_t prec)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_precision, FAIL);
H5TRACE2("e","iz",type_id,prec);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (prec <= 0) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "precision must be positive");
- }
- if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not allowed after members are defined");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (prec <= 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive");
+ if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined");
/* Do the work */
- if (H5T_set_precision(dt, prec)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set precision");
- }
+ if (H5T_set_precision(dt, prec)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set precision");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2985,25 +2877,25 @@ int
H5Tget_offset(hid_t type_id)
{
H5T_t *dt = NULL;
- int offset;
+ int ret_value;
FUNC_ENTER_API(H5Tget_offset, -1);
H5TRACE1("Is","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for specified data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type");
/* Offset */
assert(H5T_is_atomic(dt));
- offset = (int)dt->u.atomic.offset;
+ ret_value = (int)dt->u.atomic.offset;
- FUNC_LEAVE(offset);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3050,32 +2942,27 @@ herr_t
H5Tset_offset(hid_t type_id, size_t offset)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_offset, FAIL);
H5TRACE2("e","iz",type_id,offset);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (H5T_STRING == dt->type && offset != 0) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "offset must be zero for this type");
- }
- if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not allowed after members are defined");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (H5T_STRING == dt->type && offset != 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset must be zero for this type");
+ if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined");
/* Do the real work */
- if (H5T_set_offset(dt, offset)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set offset");
- }
+ if (H5T_set_offset(dt, offset)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3101,25 +2988,28 @@ herr_t
H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tget_pad, FAIL);
H5TRACE3("e","ixx",type_id,lsb,msb);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for specified data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type");
/* Get values */
assert(H5T_is_atomic(dt));
- if (lsb) *lsb = dt->u.atomic.lsb_pad;
- if (msb) *msb = dt->u.atomic.msb_pad;
+ if (lsb)
+ *lsb = dt->u.atomic.lsb_pad;
+ if (msb)
+ *msb = dt->u.atomic.msb_pad;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3143,35 +3033,32 @@ herr_t
H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_pad, FAIL);
H5TRACE3("e","iTpTp",type_id,lsb,msb);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (lsb < 0 || lsb >= H5T_NPAD || msb < 0 || msb >= H5T_NPAD) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type");
- }
- if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not allowed after members are defined");
- }
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for specified data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (lsb < 0 || lsb >= H5T_NPAD || msb < 0 || msb >= H5T_NPAD)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type");
+ if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type");
/* Commit */
assert(H5T_is_atomic(dt));
dt->u.atomic.lsb_pad = lsb;
dt->u.atomic.msb_pad = msb;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3196,24 +3083,24 @@ H5T_sign_t
H5Tget_sign(hid_t type_id)
{
H5T_t *dt = NULL;
- H5T_sign_t sign;
+ H5T_sign_t ret_value;
FUNC_ENTER_API(H5Tget_sign, H5T_SGN_ERROR);
H5TRACE1("Ts","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR, "not an integer data type");
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_INTEGER!=dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR, "not an integer data type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_INTEGER!=dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_SGN_ERROR, "operation not defined for data type class");
/* Sign */
- sign = dt->u.atomic.u.i.sign;
+ ret_value = dt->u.atomic.u.i.sign;
- FUNC_LEAVE(sign);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3237,32 +3124,30 @@ herr_t
H5Tset_sign(hid_t type_id, H5T_sign_t sign)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_sign, FAIL);
H5TRACE2("e","iTs",type_id,sign);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (sign < 0 || sign >= H5T_NSGN) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type");
- }
- if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not allowed after members are defined");
- }
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_INTEGER!=dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (sign < 0 || sign >= H5T_NSGN)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type");
+ if (H5T_ENUM==dt->type && dt->u.enumer.nmembs>0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not allowed after members are defined");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_INTEGER!=dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
/* Commit */
dt->u.atomic.u.i.sign = sign;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3295,19 +3180,18 @@ H5Tget_fields(hid_t type_id, size_t *spos/*out*/,
size_t *mpos/*out*/, size_t *msize/*out*/)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tget_fields, FAIL);
H5TRACE6("e","ixxxxx",type_id,spos,epos,esize,mpos,msize);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
if (dt->parent)
dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
/* Get values */
if (spos) *spos = dt->u.atomic.u.f.sign;
@@ -3316,7 +3200,8 @@ H5Tget_fields(hid_t type_id, size_t *spos/*out*/,
if (mpos) *mpos = dt->u.atomic.u.f.mpos;
if (msize) *msize = dt->u.atomic.u.f.msize;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3347,48 +3232,35 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
size_t mpos, size_t msize)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_fields, FAIL);
H5TRACE6("e","izzzzz",type_id,spos,epos,esize,mpos,msize);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
- if (epos + esize > dt->u.atomic.prec) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "exponent bit field size/location is invalid");
- }
- if (mpos + msize > dt->u.atomic.prec) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "mantissa bit field size/location is invalid");
- }
- if (spos >= dt->u.atomic.prec) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "sign location is not valid");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
+ if (epos + esize > dt->u.atomic.prec)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent bit field size/location is invalid");
+ if (mpos + msize > dt->u.atomic.prec)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mantissa bit field size/location is invalid");
+ if (spos >= dt->u.atomic.prec)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign location is not valid");
/* Check for overlap */
- if (spos >= epos && spos < epos + esize) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "sign bit appears within exponent field");
- }
- if (spos >= mpos && spos < mpos + msize) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "sign bit appears within mantissa field");
- }
+ if (spos >= epos && spos < epos + esize)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within exponent field");
+ if (spos >= mpos && spos < mpos + msize)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "sign bit appears within mantissa field");
if ((mpos < epos && mpos + msize > epos) ||
- (epos < mpos && epos + esize > mpos)) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "exponent and mantissa fields overlap");
- }
+ (epos < mpos && epos + esize > mpos))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "exponent and mantissa fields overlap");
/* Commit */
dt->u.atomic.u.f.sign = spos;
@@ -3397,7 +3269,8 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
dt->u.atomic.u.f.esize = esize;
dt->u.atomic.u.f.msize = msize;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3422,24 +3295,24 @@ size_t
H5Tget_ebias(hid_t type_id)
{
H5T_t *dt = NULL;
- size_t ebias;
+ size_t ret_value;
FUNC_ENTER_API(H5Tget_ebias, 0);
H5TRACE1("z","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, 0, "operation not defined for data type class");
/* bias */
- H5_ASSIGN_OVERFLOW(ebias,dt->u.atomic.u.f.ebias,uint64_t,size_t);
+ H5_ASSIGN_OVERFLOW(ret_value,dt->u.atomic.u.f.ebias,uint64_t,size_t);
- FUNC_LEAVE(ebias);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3463,26 +3336,26 @@ herr_t
H5Tset_ebias(hid_t type_id, size_t ebias)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_ebias, FAIL);
H5TRACE2("e","iz",type_id,ebias);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
/* Commit */
dt->u.atomic.u.f.ebias = ebias;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3509,24 +3382,24 @@ H5T_norm_t
H5Tget_norm(hid_t type_id)
{
H5T_t *dt = NULL;
- H5T_norm_t norm;
+ H5T_norm_t ret_value;
FUNC_ENTER_API(H5Tget_norm, H5T_NORM_ERROR);
H5TRACE1("Tn","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a data type");
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_NORM_ERROR,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, "not a data type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_NORM_ERROR, "operation not defined for data type class");
/* norm */
- norm = dt->u.atomic.u.f.norm;
+ ret_value = dt->u.atomic.u.f.norm;
- FUNC_LEAVE(norm);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3551,28 +3424,28 @@ herr_t
H5Tset_norm(hid_t type_id, H5T_norm_t norm)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_norm, FAIL);
H5TRACE2("e","iTn",type_id,norm);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (norm < 0 || norm > H5T_NORM_NONE) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization");
- }
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (norm < 0 || norm > H5T_NORM_NONE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
/* Commit */
dt->u.atomic.u.f.norm = norm;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3601,24 +3474,24 @@ H5T_pad_t
H5Tget_inpad(hid_t type_id)
{
H5T_t *dt = NULL;
- H5T_pad_t pad;
+ H5T_pad_t ret_value;
FUNC_ENTER_API(H5Tget_inpad, H5T_PAD_ERROR);
H5TRACE1("Tp","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a data type");
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_PAD_ERROR,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, "not a data type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_PAD_ERROR, "operation not defined for data type class");
/* pad */
- pad = dt->u.atomic.u.f.pad;
+ ret_value = dt->u.atomic.u.f.pad;
- FUNC_LEAVE(pad);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3645,29 +3518,28 @@ herr_t
H5Tset_inpad(hid_t type_id, H5T_pad_t pad)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_inpad, FAIL);
H5TRACE2("e","iTp",type_id,pad);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (pad < 0 || pad >= H5T_NPAD) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "illegal internal pad type");
- }
- if (dt->parent) dt = dt->parent; /*defer to parent*/
- if (H5T_FLOAT != dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (pad < 0 || pad >= H5T_NPAD)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal internal pad type");
+ if (dt->parent)
+ dt = dt->parent; /*defer to parent*/
+ if (H5T_FLOAT != dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
/* Commit */
dt->u.atomic.u.f.pad = pad;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3695,33 +3567,30 @@ H5T_cset_t
H5Tget_cset(hid_t type_id)
{
H5T_t *dt = NULL;
- H5T_cset_t cset;
+ H5T_cset_t ret_value;
FUNC_ENTER_API(H5Tget_cset, H5T_CSET_ERROR);
H5TRACE1("Tc","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, "not a data type");
/* Don't see any reason for this. Causes problem for variable-length
* string. -SLU (& QAK) */
/*if (dt->parent) dt = dt->parent;*/ /*defer to parent*/
- if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING ==
- dt->u.vlen.type))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_CSET_ERROR,
- "operation not defined for data type class");
- }
+ if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_CSET_ERROR, "operation not defined for data type class");
/* result */
if(H5T_STRING == dt->type)
- cset = dt->u.atomic.u.s.cset;
+ ret_value = dt->u.atomic.u.s.cset;
else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)
- cset = dt->u.vlen.cset;
+ ret_value = dt->u.vlen.cset;
else
- HRETURN_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_CSET_ERROR,
- "can't get cset info");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_CSET_ERROR, "can't get cset info");
- FUNC_LEAVE(cset);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3747,28 +3616,23 @@ herr_t
H5Tset_cset(hid_t type_id, H5T_cset_t cset)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_cset, FAIL);
H5TRACE2("e","iTc",type_id,cset);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (cset < 0 || cset >= H5T_NCSET) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "illegal character set type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (cset < 0 || cset >= H5T_NCSET)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal character set type");
/* Don't see any reason for this. Causes problem for variable-length
* string. -SLU (& QAK) */
/*if (dt->parent) dt = dt->parent;*/ /*defer to parent*/
- if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING ==
- dt->u.vlen.type))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
+ if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
/* Commit */
if(H5T_STRING == dt->type)
@@ -3776,10 +3640,10 @@ H5Tset_cset(hid_t type_id, H5T_cset_t cset)
else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)
dt->u.vlen.cset = cset;
else
- HRETURN_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL,
- "can't set cset info");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "can't set cset info");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3808,33 +3672,30 @@ H5T_str_t
H5Tget_strpad(hid_t type_id)
{
H5T_t *dt = NULL;
- H5T_str_t strpad;
+ H5T_str_t ret_value;
FUNC_ENTER_API(H5Tget_strpad, H5T_STR_ERROR);
H5TRACE1("Tz","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR, "not a data type");
/* Don't see any reason for this. Causes problem for variable-length
* string. -SLU (& QAK) */
/* if (dt->parent) dt = dt->parent;*/ /*defer to parent*/
- if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING ==
- dt->u.vlen.type))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_STR_ERROR,
- "operation not defined for data type class");
- }
+ if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5T_STR_ERROR, "operation not defined for data type class");
/* result */
if(H5T_STRING == dt->type)
- strpad = dt->u.atomic.u.s.pad;
+ ret_value = dt->u.atomic.u.s.pad;
else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)
- strpad = dt->u.vlen.pad;
+ ret_value = dt->u.vlen.pad;
else
- HRETURN_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_STR_ERROR,
- "can't get strpad info");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_STR_ERROR, "can't get strpad info");
- FUNC_LEAVE(strpad);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3871,27 +3732,23 @@ herr_t
H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_strpad, FAIL);
H5TRACE2("e","iTz",type_id,strpad);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (strpad < 0 || strpad >= H5T_NSTR) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (strpad < 0 || strpad >= H5T_NSTR)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type");
/* Don't see any reason for this. Causes problem for variable-length
* string. -SLU (& QAK) */
/* if (dt->parent) dt = dt->parent;*/ /*defer to parent*/
- if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING ==
- dt->u.vlen.type))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
+ if (!(H5T_STRING == dt->type || (H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
/* Commit */
if(H5T_STRING == dt->type)
@@ -3899,10 +3756,10 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
else if(H5T_VLEN == dt->type && H5T_VLEN_STRING == dt->u.vlen.type)
dt->u.vlen.pad = strpad;
else
- HRETURN_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_STR_ERROR,
- "can't set strpad info");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, H5T_STR_ERROR, "can't set strpad info");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3930,24 +3787,23 @@ int
H5Tget_nmembers(hid_t type_id)
{
H5T_t *dt = NULL;
- int ret_value = FAIL;
+ int ret_value;
FUNC_ENTER_API(H5Tget_num_members, FAIL);
H5TRACE1("Is","i",type_id);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_COMPOUND==dt->type) {
+ if (H5T_COMPOUND==dt->type)
ret_value = dt->u.compnd.nmembs;
- } else if (H5T_ENUM==dt->type) {
+ else if (H5T_ENUM==dt->type)
ret_value = dt->u.enumer.nmembs;
- } else {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "operation not supported for type class");
- }
+ else
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for type class");
+done:
FUNC_LEAVE(ret_value);
}
@@ -3977,37 +3833,32 @@ char *
H5Tget_member_name(hid_t type_id, int membno)
{
H5T_t *dt = NULL;
- char *ret_value = NULL;
+ char *ret_value;
FUNC_ENTER_API(H5Tget_member_name, NULL);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
switch (dt->type) {
- case H5T_COMPOUND:
- if (membno<0 || membno>=dt->u.compnd.nmembs) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "invalid member number");
- }
- ret_value = H5MM_xstrdup(dt->u.compnd.memb[membno].name);
- break;
+ case H5T_COMPOUND:
+ if (membno<0 || membno>=dt->u.compnd.nmembs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number");
+ ret_value = H5MM_xstrdup(dt->u.compnd.memb[membno].name);
+ break;
- case H5T_ENUM:
- if (membno<0 || membno>=dt->u.enumer.nmembs) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL,
- "invalid member number");
- }
- ret_value = H5MM_xstrdup(dt->u.enumer.name[membno]);
- break;
-
- default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL,
- "operation not supported for type class");
+ case H5T_ENUM:
+ if (membno<0 || membno>=dt->u.enumer.nmembs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number");
+ ret_value = H5MM_xstrdup(dt->u.enumer.name[membno]);
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "operation not supported for type class");
}
- /* Value */
+done:
FUNC_LEAVE(ret_value);
}
@@ -4034,7 +3885,7 @@ int
H5Tget_member_index(hid_t type_id, const char *name)
{
H5T_t *dt = NULL;
- int ret_value = FAIL;
+ int ret_value=FAIL;
int nmembs, i;
FUNC_ENTER_API(H5Tget_member_index, FAIL);
@@ -4043,27 +3894,26 @@ H5Tget_member_index(hid_t type_id, const char *name)
/* Check arguments */
assert(name);
if(NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/* Locate member by name */
switch (dt->type) {
- case H5T_COMPOUND:
- nmembs = dt->u.compnd.nmembs;
- for(i=0; i<nmembs; i++) {
- if(!HDstrcmp(dt->u.compnd.memb[i].name, name))
- HGOTO_DONE(i);
- }
- break;
- case H5T_ENUM:
- nmembs = dt->u.enumer.nmembs;
- for(i=0; i<nmembs; i++) {
- if(!HDstrcmp(dt->u.enumer.name[i], name))
- HGOTO_DONE(i);
- }
- break;
- default:
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "operation not supported for this type");
+ case H5T_COMPOUND:
+ nmembs = dt->u.compnd.nmembs;
+ for(i=0; i<nmembs; i++) {
+ if(!HDstrcmp(dt->u.compnd.memb[i].name, name))
+ HGOTO_DONE(i);
+ }
+ break;
+ case H5T_ENUM:
+ nmembs = dt->u.enumer.nmembs;
+ for(i=0; i<nmembs; i++) {
+ if(!HDstrcmp(dt->u.enumer.name[i], name))
+ HGOTO_DONE(i);
+ }
+ break;
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "operation not supported for this type");
}
done:
@@ -4095,23 +3945,22 @@ size_t
H5Tget_member_offset(hid_t type_id, int membno)
{
H5T_t *dt = NULL;
- size_t offset = 0;
+ size_t ret_value;
FUNC_ENTER_API(H5Tget_member_offset, 0);
H5TRACE2("z","iIs",type_id,membno);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) ||
- H5T_COMPOUND != dt->type)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound data type");
- if (membno < 0 || membno >= dt->u.compnd.nmembs) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number");
- }
+ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound data type");
+ if (membno < 0 || membno >= dt->u.compnd.nmembs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number");
/* Value */
- offset = dt->u.compnd.memb[membno].offset;
+ ret_value = dt->u.compnd.memb[membno].offset;
- FUNC_LEAVE(offset);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4135,20 +3984,21 @@ H5T_class_t
H5Tget_member_class(hid_t type_id, int membno)
{
H5T_t *dt = NULL;
- H5T_class_t ret_value = H5T_NO_CLASS;
+ H5T_class_t ret_value;
FUNC_ENTER_API(H5Tget_member_class, H5T_NO_CLASS);
H5TRACE2("Tt","iIs",type_id,membno);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a compound data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a compound data type");
if (membno < 0 || membno >= dt->u.compnd.nmembs)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number");
/* Value */
ret_value = dt->u.compnd.memb[membno].type->type;
+done:
FUNC_LEAVE(ret_value);
} /* end H5Tget_member_class() */
@@ -4181,31 +4031,30 @@ hid_t
H5Tget_member_type(hid_t type_id, int membno)
{
H5T_t *dt = NULL, *memb_dt = NULL;
- hid_t memb_type_id;
+ hid_t ret_value;
FUNC_ENTER_API(H5Tget_member_type, FAIL);
H5TRACE2("i","iIs",type_id,membno);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- if (membno < 0 || membno >= dt->u.compnd.nmembs) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ if (membno < 0 || membno >= dt->u.compnd.nmembs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
/* Copy data type into an atom */
- if (NULL == (memb_dt = H5T_copy(dt->u.compnd.memb[membno].type,
- H5T_COPY_REOPEN))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to copy member data type");
- }
- if ((memb_type_id = H5I_register(H5I_DATATYPE, memb_dt)) < 0) {
- H5T_close(memb_dt);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "unable register data type atom");
- }
+ if (NULL == (memb_dt = H5T_copy(dt->u.compnd.memb[membno].type, H5T_COPY_REOPEN)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy member data type");
+ if ((ret_value = H5I_register(H5I_DATATYPE, memb_dt)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable register data type atom");
- FUNC_LEAVE(memb_type_id);
+done:
+ if(ret_value<0) {
+ if(memb_dt!=NULL)
+ H5T_close(memb_dt);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -4238,32 +4087,29 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id)
{
H5T_t *parent = NULL; /*the compound parent data type */
H5T_t *member = NULL; /*the atomic member type */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tinsert, FAIL);
H5TRACE4("e","iszi",parent_id,name,offset,member_id);
/* Check args */
if (parent_id==member_id)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself");
- if (NULL == (parent = H5I_object_verify(parent_id,H5I_DATATYPE)) ||
- H5T_COMPOUND != parent->type)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- if (H5T_STATE_TRANSIENT!=parent->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself");
+ if (NULL == (parent = H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_COMPOUND != parent->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ if (H5T_STATE_TRANSIENT!=parent->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name");
if (NULL == (member = H5I_object_verify(member_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/* Insert */
- if (H5T_insert(parent, name, offset, member) < 0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "unable to insert member");
- }
+ if (H5T_insert(parent, name, offset, member) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "unable to insert member");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4286,25 +4132,23 @@ herr_t
H5Tpack(hid_t type_id)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tpack, FAIL);
H5TRACE1("e","i",type_id);
/* Check args */
- if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) ||
- H5T_COMPOUND != dt->type)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data type is read-only");
- }
+ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)) || H5T_COMPOUND != dt->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data type is read-only");
/* Pack */
- if (H5T_pack(dt) < 0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to pack compound data type");
- }
+ if (H5T_pack(dt) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack compound data type");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4330,32 +4174,28 @@ H5Tenum_create(hid_t parent_id)
{
H5T_t *parent = NULL; /*base integer data type */
H5T_t *dt = NULL; /*new enumeration data type */
- hid_t ret_value = FAIL; /*return value */
+ hid_t ret_value; /*return value */
FUNC_ENTER_API(H5Tenum_create, FAIL);
H5TRACE1("i","i",parent_id);
/* Check args */
- if (NULL==(parent=H5I_object_verify(parent_id,H5I_DATATYPE)) ||
- H5T_INTEGER!=parent->type)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type");
+ if (NULL==(parent=H5I_object_verify(parent_id,H5I_DATATYPE)) || H5T_INTEGER!=parent->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type");
/* Build new type */
- if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
dt->type = H5T_ENUM;
dt->parent = H5T_copy(parent, H5T_COPY_ALL);
dt->size = dt->parent->size;
dt->ent.header = HADDR_UNDEF;
/* Atomize the type */
- if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "unable to register data type atom");
- }
+ if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom");
+done:
FUNC_LEAVE(ret_value);
}
@@ -4385,31 +4225,27 @@ herr_t
H5Tenum_insert(hid_t type, const char *name, void *value)
{
H5T_t *dt=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tenum_insert, FAIL);
H5TRACE3("e","isx",type,name,value);
/* Check args */
if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_ENUM!=dt->type) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not an enumeration data type");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
- }
- if (!value) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_ENUM!=dt->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified");
+ if (!value)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified");
/* Do work */
- if (H5T_enum_insert(dt, name, value)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to insert new enumeration member");
- }
+ if (H5T_enum_insert(dt, name, value)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4434,25 +4270,25 @@ hid_t
H5Tget_super(hid_t type)
{
H5T_t *dt=NULL, *super=NULL;
- hid_t ret_value=FAIL;
+ hid_t ret_value;
FUNC_ENTER_API(H5Tget_super, FAIL);
H5TRACE1("i","i",type);
if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (!dt->parent) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a derived data type");
- }
- if (NULL==(super=H5T_copy(dt->parent, H5T_COPY_ALL))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to copy parent data type");
- }
- if ((ret_value=H5I_register(H5I_DATATYPE, super))<0) {
- H5T_close(super);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "unable to register parent data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (!dt->parent)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a derived data type");
+ if (NULL==(super=H5T_copy(dt->parent, H5T_COPY_ALL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy parent data type");
+ if ((ret_value=H5I_register(H5I_DATATYPE, super))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register parent data type");
+
+done:
+ if(ret_value<0) {
+ if(super!=NULL)
+ H5T_close(super);
+ } /* end if */
FUNC_LEAVE(ret_value);
}
@@ -4475,30 +4311,28 @@ H5Tget_super(hid_t type)
*
*-------------------------------------------------------------------------
*/
-hid_t
+herr_t
H5Tget_member_value(hid_t type, int membno, void *value/*out*/)
{
H5T_t *dt=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tget_member_value, FAIL);
H5TRACE3("i","iIsx",type,membno,value);
if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_ENUM!=dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for data type class");
- }
- if (membno<0 || membno>=dt->u.enumer.nmembs) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
- }
- if (!value) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_ENUM!=dt->type)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class");
+ if (membno<0 || membno>=dt->u.enumer.nmembs)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
+ if (!value)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer");
HDmemcpy(value, dt->u.enumer.value + membno*dt->size, dt->size);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4528,28 +4362,26 @@ herr_t
H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, size_t size)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tenum_nameof, FAIL);
H5TRACE4("e","ixxz",type,value,name,size);
/* Check args */
if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_ENUM!=dt->type) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not an enumeration data type");
- }
- if (!value) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied");
- }
- if (!name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_ENUM!=dt->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type");
+ if (!value)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied");
+ if (!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied");
- if (NULL==H5T_enum_nameof(dt, value, name, size)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed");
- }
- FUNC_LEAVE(SUCCEED);
+ if (NULL==H5T_enum_nameof(dt, value, name, size))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4576,29 +4408,26 @@ herr_t
H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/)
{
H5T_t *dt = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tenum_valueof, FAIL);
H5TRACE3("e","isx",type,name,value);
/* Check args */
if (NULL==(dt=H5I_object_verify(type,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_ENUM!=dt->type) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
- "not an enumeration data type");
- }
- if (!name || !*name) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
- if (!value) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_ENUM!=dt->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type");
+ if (!name || !*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ if (!value)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer");
- if (H5T_enum_valueof(dt, name, value)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "valueof query failed");
- }
- FUNC_LEAVE(SUCCEED);
+ if (H5T_enum_valueof(dt, name, value)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4623,7 +4452,7 @@ static H5T_t *
H5T_vlen_create(H5T_t *base)
{
H5T_t *dt = NULL; /*new VL data type */
- H5T_t *ret_value = NULL; /*return value */
+ H5T_t *ret_value; /*return value */
FUNC_ENTER_NOINIT(H5T_vlen_create);
@@ -4632,7 +4461,7 @@ H5T_vlen_create(H5T_t *base)
/* Build new type */
if (NULL==(dt = H5FL_ALLOC(H5T_t,1)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->ent.header = HADDR_UNDEF;
dt->type = H5T_VLEN;
@@ -4648,11 +4477,12 @@ H5T_vlen_create(H5T_t *base)
/* Set up VL information */
if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
- /* Set the return value */
+ /* Set return value */
ret_value=dt;
+done:
FUNC_LEAVE(ret_value);
}
@@ -4679,23 +4509,24 @@ H5Tvlen_create(hid_t base_id)
{
H5T_t *base = NULL; /*base data type */
H5T_t *dt = NULL; /*new data type */
- hid_t ret_value = FAIL; /*return value */
+ hid_t ret_value; /*return value */
FUNC_ENTER_API(H5Tvlen_create, FAIL);
H5TRACE1("i","i",base_id);
/* Check args */
if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype");
/* Create up VL datatype */
if ((dt=H5T_vlen_create(base))==NULL)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
/* Atomize the type */
if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+done:
FUNC_LEAVE(ret_value);
}
@@ -4718,27 +4549,27 @@ herr_t
H5Tset_tag(hid_t type_id, const char *tag)
{
H5T_t *dt=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tset_tag, FAIL);
H5TRACE2("e","is",type_id,tag);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_STATE_TRANSIENT!=dt->state) {
- HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (H5T_OPAQUE!=dt->type) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an opaque data type");
- }
- if (!tag) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no tag");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_STATE_TRANSIENT!=dt->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ if (H5T_OPAQUE!=dt->type)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an opaque data type");
+ if (!tag)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no tag");
/* Commit */
H5MM_xfree(dt->u.opaque.tag);
dt->u.opaque.tag = H5MM_strdup(tag);
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4761,23 +4592,24 @@ char *
H5Tget_tag(hid_t type_id)
{
H5T_t *dt=NULL;
- char *ret_value=NULL;
+ char *ret_value;
FUNC_ENTER_API(H5Tget_tag, NULL);
/* Check args */
if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
if (dt->parent)
dt = dt->parent; /*defer to parent*/
if (H5T_OPAQUE != dt->type)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "operation not defined for data type class");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "operation not defined for data type class");
/* result */
if (NULL==(ret_value=H5MM_strdup(dt->u.opaque.tag)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+done:
FUNC_LEAVE(ret_value);
}
@@ -5000,6 +4832,7 @@ done:
FUNC_LEAVE(ret_value);
} /* end H5Tregister() */
+
/*-------------------------------------------------------------------------
* Function: H5T_unregister
*
@@ -5084,6 +4917,7 @@ H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src, H5T_t *dst,
FUNC_LEAVE(SUCCEED);
} /* end H5T_unregister() */
+
/*-------------------------------------------------------------------------
* Function: H5Tunregister
*
@@ -5108,24 +4942,25 @@ H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
H5T_conv_t func)
{
H5T_t *src=NULL, *dst=NULL; /*data type descriptors */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tunregister, FAIL);
H5TRACE5("e","Tesiix",pers,name,src_id,dst_id,func);
/* Check arguments */
if (src_id>0 && (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE))))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src is not a data type");
- if (dst_id>0 && (NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src is not a data type");
+ if (dst_id>0 && (NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE))))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst is not a data type");
if (H5T_unregister(pers,name,src,dst,func)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL,
- "internal unregister function failed");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDELETE, FAIL, "internal unregister function failed");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5Tfind
*
@@ -5149,7 +4984,7 @@ H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id,
H5T_conv_t
H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata)
{
- H5T_conv_t ret_value = NULL;
+ H5T_conv_t ret_value;
H5T_t *src = NULL, *dst = NULL;
H5T_path_t *path = NULL;
@@ -5159,20 +4994,21 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata)
/* Check args */
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
- if (!pcdata) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL,
- "no address to receive cdata pointer");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
+ if (!pcdata)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "no address to receive cdata pointer");
/* Find it */
- if (NULL==(path=H5T_path_find(src, dst, NULL, NULL))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
- "conversion function not found");
- }
- if (pcdata) *pcdata = &(path->cdata);
+ if (NULL==(path=H5T_path_find(src, dst, NULL, NULL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "conversion function not found");
+
+ if (pcdata)
+ *pcdata = &(path->cdata);
+
+ /* Set return value */
ret_value = path->func;
+done:
FUNC_LEAVE(ret_value);
}
@@ -5210,6 +5046,7 @@ H5Tconvert(hid_t src_id, hid_t dst_id, hsize_t nelmts, void *buf,
{
H5T_path_t *tpath=NULL; /*type conversion info */
H5T_t *src=NULL, *dst=NULL; /*unatomized types */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Tconvert, FAIL);
H5TRACE6("e","iihxxi",src_id,dst_id,nelmts,buf,background,plist_id);
@@ -5218,21 +5055,17 @@ H5Tconvert(hid_t src_id, hid_t dst_id, hsize_t nelmts, void *buf,
if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)) ||
(H5P_DEFAULT!=plist_id && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/* Find the conversion function */
- if (NULL==(tpath=H5T_path_find(src, dst, NULL, NULL))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert between src and dst data types");
- }
+ if (NULL==(tpath=H5T_path_find(src, dst, NULL, NULL)))
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert between src and dst data types");
- if (H5T_convert(tpath, src_id, dst_id, nelmts, 0, 0, buf, background,
- plist_id)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "data type conversion failed");
- }
+ if (H5T_convert(tpath, src_id, dst_id, nelmts, 0, 0, buf, background, plist_id)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "data type conversion failed");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -5258,15 +5091,19 @@ H5Tconvert(hid_t src_id, hid_t dst_id, hsize_t nelmts, void *buf,
H5T_overflow_t
H5Tget_overflow(void)
{
+ H5T_overflow_t ret_value; /* Return value */
+
FUNC_ENTER_API(H5Tget_overflow, NULL);
H5TRACE0("x","");
- if (NULL==H5T_overflow_g) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNINITIALIZED, NULL,
- "no overflow handling function is registered");
- }
+ if (NULL==H5T_overflow_g)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNINITIALIZED, NULL, "no overflow handling function is registered");
+
+ /* Set return value */
+ ret_value=H5T_overflow_g;
- FUNC_LEAVE(H5T_overflow_g);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5328,6 +5165,7 @@ H5T_create(H5T_class_t type, size_t size)
{
H5T_t *dt = NULL;
hid_t subtype;
+ H5T_t *ret_value;
FUNC_ENTER_NOAPI(H5T_create, NULL);
@@ -5339,15 +5177,12 @@ H5T_create(H5T_class_t type, size_t size)
case H5T_TIME:
case H5T_STRING:
case H5T_BITFIELD:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
- "type class is not appropriate - use H5Tcopy()");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "type class is not appropriate - use H5Tcopy()");
case H5T_OPAQUE:
case H5T_COMPOUND:
- if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->type = type;
break;
@@ -5363,38 +5198,38 @@ H5T_create(H5T_class_t type, size_t size)
} else if (sizeof(long_long)==size) {
subtype = H5T_NATIVE_LLONG_g;
} else {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "no applicable native integer type");
- }
- if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no applicable native integer type");
}
+ if (NULL==(dt = H5FL_ALLOC(H5T_t,1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
dt->type = type;
- if (NULL==(dt->parent=H5T_copy(H5I_object(subtype),
- H5T_COPY_ALL))) {
- H5FL_FREE(H5T_t,dt);
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to copy base data type");
- }
+ if (NULL==(dt->parent=H5T_copy(H5I_object(subtype), H5T_COPY_ALL)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy base data type");
break;
case H5T_VLEN: /* Variable length datatype */
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
- "base type required - use H5Tvlen_create()");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tvlen_create()");
case H5T_ARRAY: /* Array datatype */
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
- "base type required - use H5Tarray_create()");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL, "base type required - use H5Tarray_create()");
default:
- HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL,
- "unknown data type class");
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL, "unknown data type class");
}
dt->ent.header = HADDR_UNDEF;
dt->size = size;
- FUNC_LEAVE(dt);
+
+ /* Set return value */
+ ret_value=dt;
+
+done:
+ if(ret_value==NULL) {
+ if(dt!=NULL)
+ H5FL_FREE(H5T_t,dt);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -5420,16 +5255,16 @@ H5T_create(H5T_class_t type, size_t size)
htri_t
H5T_isa(H5G_entry_t *ent)
{
- htri_t exists;
+ htri_t ret_value;
FUNC_ENTER_NOAPI(H5T_isa, FAIL);
assert(ent);
- if ((exists=H5O_exists(ent, H5O_DTYPE, 0))<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to read object header");
- }
- FUNC_LEAVE(exists);
+ if ((ret_value=H5O_exists(ent, H5O_DTYPE, 0))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to read object header");
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5453,8 +5288,9 @@ H5T_isa(H5G_entry_t *ent)
H5T_t *
H5T_open (H5G_entry_t *loc, const char *name)
{
- H5T_t *dt = NULL;
+ H5T_t *dt;
H5G_entry_t ent;
+ H5T_t *ret_value;
FUNC_ENTER_NOAPI(H5T_open, NULL);
@@ -5465,15 +5301,18 @@ H5T_open (H5G_entry_t *loc, const char *name)
* Find the named data type object header and read the data type message
* from it.
*/
- if (H5G_find (loc, name, NULL, &ent/*out*/)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found");
- }
+ if (H5G_find (loc, name, NULL, &ent/*out*/)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found");
+
/* Open the datatype object */
- if ((dt=H5T_open_oid(&ent)) ==NULL) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found");
- }
+ if ((dt=H5T_open_oid(&ent)) ==NULL)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found");
- FUNC_LEAVE (dt);
+ /* Set return value */
+ ret_value=dt;
+
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -5496,27 +5335,32 @@ H5T_open (H5G_entry_t *loc, const char *name)
H5T_t *
H5T_open_oid (H5G_entry_t *ent)
{
- H5T_t *dt = NULL;
+ H5T_t *dt=NULL;
+ H5T_t *ret_value;
FUNC_ENTER_NOAPI(H5T_open_oid, NULL);
assert (ent);
- if (H5O_open (ent)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL,
- "unable to open named data type");
- }
- if (NULL==(dt=H5O_read (ent, H5O_DTYPE, 0, NULL))) {
- H5O_close(ent);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to load type message from object header");
- }
+ if (H5O_open (ent)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named data type");
+ if (NULL==(dt=H5O_read (ent, H5O_DTYPE, 0, NULL)))
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to load type message from object header");
/* Mark the type as named and open */
dt->state = H5T_STATE_OPEN;
dt->ent = *ent;
- FUNC_LEAVE (dt);
+ /* Set return value */
+ ret_value=dt;
+
+done:
+ if(ret_value==NULL) {
+ if(dt==NULL)
+ H5O_close(ent);
+ } /* end if */
+
+ FUNC_LEAVE (ret_value);
}
@@ -5559,6 +5403,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
H5T_t *new_dt=NULL, *tmp=NULL;
int i;
char *s;
+ H5T_t *ret_value;
FUNC_ENTER_NOAPI(H5T_copy, NULL);
@@ -5567,7 +5412,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
/* Allocate space */
if (NULL==(new_dt = H5FL_ALLOC(H5T_t,0)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
/* Copy actual information */
*new_dt = *old_dt;
@@ -5605,11 +5450,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
* type.
*/
if (H5F_addr_defined(new_dt->ent.header)) {
- if (H5O_open (&(new_dt->ent))<0) {
- H5FL_FREE (H5T_t,new_dt);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL,
- "unable to reopen named data type");
- }
+ if (H5O_open (&(new_dt->ent))<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type");
new_dt->state = H5T_STATE_OPEN;
}
break;
@@ -5627,10 +5469,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
*/
new_dt->u.compnd.memb = H5MM_malloc(new_dt->u.compnd.nalloc *
sizeof(H5T_cmemb_t));
- if (NULL==new_dt->u.compnd.memb) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==new_dt->u.compnd.memb)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb,
new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t));
@@ -5657,7 +5497,7 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
/* check if we couldn't find a match */
if(old_match<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted");
} /* end if */
else {
old_match=i;
@@ -5688,10 +5528,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
sizeof(char*));
new_dt->u.enumer.value = H5MM_malloc(new_dt->u.enumer.nalloc *
new_dt->size);
- if (NULL==new_dt->u.enumer.value) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (NULL==new_dt->u.enumer.value)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDmemcpy(new_dt->u.enumer.value, old_dt->u.enumer.value,
new_dt->u.enumer.nmembs * new_dt->size);
for (i=0; i<new_dt->u.enumer.nmembs; i++) {
@@ -5703,9 +5541,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
case H5T_VLEN:
if(method==H5T_COPY_TRANSIENT || method==H5T_COPY_REOPEN) {
/* H5T_copy converts any VL type into a memory VL type */
- if (H5T_vlen_mark(new_dt, NULL, H5T_VLEN_MEMORY)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
- }
+ if (H5T_vlen_mark(new_dt, NULL, H5T_VLEN_MEMORY)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid VL location");
}
break;
@@ -5724,8 +5561,17 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
default:
break;
} /* end switch */
+
+ /* Set return value */
+ ret_value=new_dt;
- FUNC_LEAVE(new_dt);
+done:
+ if(ret_value==NULL) {
+ if(new_dt!=NULL)
+ H5FL_FREE (H5T_t,new_dt);
+ } /* end if */
+
+ FUNC_LEAVE(ret_value);
}
@@ -5747,8 +5593,8 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
herr_t
H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type)
{
- herr_t ret_value = FAIL;
H5F_t *file = NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_commit, FAIL);
@@ -5761,47 +5607,34 @@ H5T_commit (H5G_entry_t *loc, const char *name, H5T_t *type)
* normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing
* a named type should always succeed.
*/
- if (H5T_STATE_NAMED==type->state || H5T_STATE_OPEN==type->state) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "data type is already committed");
- }
- if (H5T_STATE_IMMUTABLE==type->state) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "data type is immutable");
- }
+ if (H5T_STATE_NAMED==type->state || H5T_STATE_OPEN==type->state)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "data type is already committed");
+ if (H5T_STATE_IMMUTABLE==type->state)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "data type is immutable");
/* Check for a "sensible" datatype to store on disk */
if(H5T_is_sensible(type)!=TRUE)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible");
/* Find the insertion file */
- if (NULL==(file=H5G_insertion_file(loc, name))) {
- HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to find insertion point");
- }
+ if (NULL==(file=H5G_insertion_file(loc, name)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to find insertion point");
/*
* Create the object header and open it for write access. Insert the data
* type message and then give the object header a name.
*/
- if (H5O_create (file, 64, &(type->ent))<0) {
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to create data type object header");
- }
- if (H5O_modify (&(type->ent), H5O_DTYPE, 0, H5O_FLAG_CONSTANT, type)<0) {
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to update type header message");
- }
- if (H5G_insert (loc, name, &(type->ent))<0) {
- HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to name data type");
- }
+ if (H5O_create (file, 64, &(type->ent))<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create data type object header");
+ if (H5O_modify (&(type->ent), H5O_DTYPE, 0, H5O_FLAG_CONSTANT, type)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to update type header message");
+ if (H5G_insert (loc, name, &(type->ent))<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to name data type");
type->state = H5T_STATE_OPEN;
- ret_value = SUCCEED;
- done:
+done:
if (ret_value<0) {
- if (H5F_addr_defined(type->ent.header)) {
+ if ((type->state==H5T_STATE_TRANSIENT || type->state==H5T_STATE_RDONLY) && H5F_addr_defined(type->ent.header)) {
H5O_close(&(type->ent));
type->ent.header = HADDR_UNDEF;
}
@@ -5836,17 +5669,17 @@ H5T_lock (H5T_t *dt, hbool_t immutable)
assert (dt);
switch (dt->state) {
- case H5T_STATE_TRANSIENT:
- dt->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY;
- break;
- case H5T_STATE_RDONLY:
- if (immutable) dt->state = H5T_STATE_IMMUTABLE;
- break;
- case H5T_STATE_IMMUTABLE:
- case H5T_STATE_NAMED:
- case H5T_STATE_OPEN:
- /*void*/
- break;
+ case H5T_STATE_TRANSIENT:
+ dt->state = immutable ? H5T_STATE_IMMUTABLE : H5T_STATE_RDONLY;
+ break;
+ case H5T_STATE_RDONLY:
+ if (immutable) dt->state = H5T_STATE_IMMUTABLE;
+ break;
+ case H5T_STATE_IMMUTABLE:
+ case H5T_STATE_NAMED:
+ case H5T_STATE_OPEN:
+ /*void*/
+ break;
}
FUNC_LEAVE (SUCCEED);
@@ -5877,6 +5710,7 @@ H5T_close(H5T_t *dt)
{
int i;
H5T_t *parent = dt->parent;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_close, FAIL);
@@ -5887,20 +5721,16 @@ H5T_close(H5T_t *dt)
*/
if (H5T_STATE_OPEN==dt->state) {
assert (H5F_addr_defined(dt->ent.header));
- if (H5O_close(&(dt->ent))<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to close data type object header");
- }
+ if (H5O_close(&(dt->ent))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close data type object header");
dt->state = H5T_STATE_NAMED;
}
/*
* Don't free locked datatypes.
*/
- if (H5T_STATE_IMMUTABLE==dt->state) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL,
- "unable to close immutable datatype");
- }
+ if (H5T_STATE_IMMUTABLE==dt->state)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close immutable datatype");
/* Close the datatype */
switch (dt->type) {
@@ -5931,12 +5761,11 @@ H5T_close(H5T_t *dt)
H5FL_FREE(H5T_t,dt);
/* Close the parent */
- if (parent && H5T_close(parent)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to close parent data type");
- }
+ if (parent && H5T_close(parent)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to close parent data type");
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5959,17 +5788,16 @@ H5T_close(H5T_t *dt)
htri_t
H5T_is_atomic(const H5T_t *dt)
{
- htri_t ret_value = FAIL;
+ htri_t ret_value;
FUNC_ENTER_NOAPI(H5T_is_atomic, FAIL);
assert(dt);
- if (H5T_COMPOUND!=dt->type && H5T_ENUM!=dt->type && H5T_VLEN!=dt->type && H5T_OPAQUE!=dt->type && H5T_ARRAY!=dt->type) {
+ if (H5T_COMPOUND!=dt->type && H5T_ENUM!=dt->type && H5T_VLEN!=dt->type && H5T_OPAQUE!=dt->type && H5T_ARRAY!=dt->type)
ret_value = TRUE;
- } else {
+ else
ret_value = FALSE;
- }
FUNC_LEAVE(ret_value);
}
@@ -6009,6 +5837,7 @@ herr_t
H5T_set_size(H5T_t *dt, size_t size)
{
size_t prec, offset;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_set_size, FAIL);
@@ -6018,10 +5847,8 @@ H5T_set_size(H5T_t *dt, size_t size)
assert(H5T_ENUM!=dt->type || 0==dt->u.enumer.nmembs);
if (dt->parent) {
- if (H5T_set_size(dt->parent, size)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set size for parent data type");
- }
+ if (H5T_set_size(dt->parent, size)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type");
dt->size = dt->parent->size;
} else {
if (H5T_is_atomic(dt)) {
@@ -6043,8 +5870,7 @@ H5T_set_size(H5T_t *dt, size_t size)
switch (dt->type) {
case H5T_COMPOUND:
case H5T_ARRAY:
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set size of specified data type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size of specified data type");
case H5T_INTEGER:
case H5T_TIME:
@@ -6063,7 +5889,7 @@ H5T_set_size(H5T_t *dt, size_t size)
/* Get a copy of unsigned char type as the base/parent type */
if (NULL==(base=H5I_object(H5T_NATIVE_UCHAR)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype");
dt->parent=H5T_copy(base,H5T_COPY_ALL);
/* change this datatype into a VL string */
@@ -6089,8 +5915,7 @@ H5T_set_size(H5T_t *dt, size_t size)
/* Set up VL information */
if (H5T_vlen_mark(dt, NULL, H5T_VLEN_MEMORY)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "invalid VL location");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location");
} else {
prec = 8 * size;
@@ -6106,8 +5931,7 @@ H5T_set_size(H5T_t *dt, size_t size)
if (dt->u.atomic.u.f.sign >= prec ||
dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "adjust sign, mantissa, and exponent fields first");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first");
}
break;
@@ -6125,7 +5949,8 @@ H5T_set_size(H5T_t *dt, size_t size)
}
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6193,6 +6018,7 @@ herr_t
H5T_set_precision(H5T_t *dt, size_t prec)
{
size_t offset, size;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_set_precision, FAIL);
@@ -6202,26 +6028,23 @@ H5T_set_precision(H5T_t *dt, size_t prec)
assert(H5T_ENUM!=dt->type || 0==dt->u.enumer.nmembs);
if (dt->parent) {
- if (H5T_set_precision(dt->parent, prec)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set precision for base type");
- }
+ if (H5T_set_precision(dt->parent, prec)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set precision for base type");
dt->size = dt->parent->size;
} else {
if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for specified data type");
-
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type");
} else if (H5T_ENUM==dt->type) {
/*nothing*/
-
} else if (H5T_is_atomic(dt)) {
/* Adjust the offset and size */
offset = dt->u.atomic.offset;
size = dt->size;
- if (prec > 8*size) offset = 0;
+ if (prec > 8*size)
+ offset = 0;
else if (offset+prec > 8 * size) offset = 8 * size - prec;
- if (prec > 8*size) size = (prec+7) / 8;
+ if (prec > 8*size)
+ size = (prec+7) / 8;
/* Check that things are still kosher */
switch (dt->type) {
@@ -6232,8 +6055,7 @@ H5T_set_precision(H5T_t *dt, size_t prec)
break;
case H5T_STRING:
- HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
- "precision for this type is read-only");
+ HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "precision for this type is read-only");
case H5T_FLOAT:
/*
@@ -6244,9 +6066,7 @@ H5T_set_precision(H5T_t *dt, size_t prec)
if (dt->u.atomic.u.f.sign >= prec ||
dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "adjust sign, mantissa, and exponent fields "
- "first");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first");
}
break;
@@ -6263,7 +6083,8 @@ H5T_set_precision(H5T_t *dt, size_t prec)
}
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6309,6 +6130,8 @@ H5T_set_precision(H5T_t *dt, size_t prec)
herr_t
H5T_set_offset(H5T_t *dt, size_t offset)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_set_offset, FAIL);
/* Check args */
@@ -6317,15 +6140,12 @@ H5T_set_offset(H5T_t *dt, size_t offset)
assert(H5T_ENUM!=dt->type || 0==dt->u.enumer.nmembs);
if (dt->parent) {
- if (H5T_set_offset(dt->parent, offset)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to set offset for base type");
- }
+ if (H5T_set_offset(dt->parent, offset)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set offset for base type");
dt->size = dt->parent->size;
} else {
if (H5T_COMPOUND==dt->type || H5T_OPAQUE==dt->type || H5T_ARRAY==dt->type) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "operation not defined for specified data type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for specified data type");
} else if (H5T_ENUM==dt->type) {
/*nothing*/
} else {
@@ -6336,7 +6156,8 @@ H5T_set_offset(H5T_t *dt, size_t offset)
}
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6363,6 +6184,7 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
{
int idx, i;
size_t total_size;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_insert, FAIL);
@@ -6374,28 +6196,24 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
/* Does NAME already exist in PARENT? */
for (i=0; i<parent->u.compnd.nmembs; i++) {
- if (!HDstrcmp(parent->u.compnd.memb[i].name, name)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "member name is not unique");
- }
+ if (!HDstrcmp(parent->u.compnd.memb[i].name, name))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member name is not unique");
}
/* Does the new member overlap any existing member ? */
total_size=member->size;
for (i=0; i<parent->u.compnd.nmembs; i++) {
if ((offset <= parent->u.compnd.memb[i].offset &&
- offset + total_size > parent->u.compnd.memb[i].offset) ||
- (parent->u.compnd.memb[i].offset <= offset &&
- parent->u.compnd.memb[i].offset +
- parent->u.compnd.memb[i].size > offset)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "member overlaps with another member");
- }
+ offset + total_size > parent->u.compnd.memb[i].offset) ||
+ (parent->u.compnd.memb[i].offset <= offset &&
+ parent->u.compnd.memb[i].offset +
+ parent->u.compnd.memb[i].size > offset))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member overlaps with another member");
}
/* Does the new member overlap the end of the compound type? */
if(offset+total_size>parent->size)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member extends past end of compound type");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL, "member extends past end of compound type");
/* Increase member array if necessary */
if (parent->u.compnd.nmembs >= parent->u.compnd.nalloc) {
@@ -6403,10 +6221,8 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
H5T_cmemb_t *x = H5MM_realloc (parent->u.compnd.memb,
na * sizeof(H5T_cmemb_t));
- if (!x) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (!x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
parent->u.compnd.nalloc = (int)na;
parent->u.compnd.memb = x;
}
@@ -6432,7 +6248,8 @@ H5T_insert(H5T_t *parent, const char *name, size_t offset, const H5T_t *member)
if(member->type==H5T_ARRAY)
parent->u.compnd.has_array=TRUE;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6456,6 +6273,7 @@ H5T_pack(H5T_t *dt)
{
int i;
size_t offset;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_pack, FAIL);
@@ -6466,10 +6284,8 @@ H5T_pack(H5T_t *dt)
/* Recursively pack the members */
for (i=0; i<dt->u.compnd.nmembs; i++) {
- if (H5T_pack(dt->u.compnd.memb[i].type) < 0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to pack part of a compound data type");
- }
+ if (H5T_pack(dt->u.compnd.memb[i].type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to pack part of a compound data type");
}
/* Remove padding between members */
@@ -6483,7 +6299,8 @@ H5T_pack(H5T_t *dt)
dt->size = MAX(1, offset);
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6527,8 +6344,8 @@ H5T_sort_value(H5T_t *dt, int *map)
for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) {
for (j=0, swapped=FALSE; j<i; j++) {
if (dt->u.compnd.memb[j].offset >
- dt->u.compnd.memb[j+1].offset) {
- H5T_cmemb_t tmp = dt->u.compnd.memb[j];
+ dt->u.compnd.memb[j+1].offset) {
+ H5T_cmemb_t tmp = dt->u.compnd.memb[j];
dt->u.compnd.memb[j] = dt->u.compnd.memb[j+1];
dt->u.compnd.memb[j+1] = tmp;
if (map) {
@@ -6691,10 +6508,8 @@ H5T_sort_name(H5T_t *dt, int *map)
}
#ifndef NDEBUG
/* I never trust a sort :-) -RPM */
- for (i=0; i<nmembs-1; i++) {
- assert(HDstrcmp(dt->u.enumer.name[i],
- dt->u.enumer.name[i+1])<0);
- }
+ for (i=0; i<nmembs-1; i++)
+ assert(HDstrcmp(dt->u.enumer.name[i], dt->u.enumer.name[i+1])<0);
#endif
}
}
@@ -6728,6 +6543,7 @@ H5T_enum_insert(H5T_t *dt, const char *name, void *value)
int i;
char **names=NULL;
uint8_t *values=NULL;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_enum_insert, FAIL);
@@ -6737,29 +6553,21 @@ H5T_enum_insert(H5T_t *dt, const char *name, void *value)
/* The name and value had better not already exist */
for (i=0; i<dt->u.enumer.nmembs; i++) {
- if (!HDstrcmp(dt->u.enumer.name[i], name)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "name redefinition");
- }
- if (!HDmemcmp(dt->u.enumer.value+i*dt->size, value, dt->size)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "value redefinition");
- }
+ if (!HDstrcmp(dt->u.enumer.name[i], name))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition");
+ if (!HDmemcmp(dt->u.enumer.value+i*dt->size, value, dt->size))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition");
}
/* Increase table sizes */
if (dt->u.enumer.nmembs >= dt->u.enumer.nalloc) {
int n = MAX(32, 2*dt->u.enumer.nalloc);
- if (NULL==(names=H5MM_realloc(dt->u.enumer.name, n*sizeof(char*)))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(names=H5MM_realloc(dt->u.enumer.name, n*sizeof(char*))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
dt->u.enumer.name = names;
- if (NULL==(values=H5MM_realloc(dt->u.enumer.value, n*dt->size))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ if (NULL==(values=H5MM_realloc(dt->u.enumer.value, n*dt->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
dt->u.enumer.value = values;
dt->u.enumer.nalloc = n;
}
@@ -6770,7 +6578,8 @@ H5T_enum_insert(H5T_t *dt, const char *name, void *value)
dt->u.enumer.name[i] = H5MM_xstrdup(name);
HDmemcpy(dt->u.enumer.value+i*dt->size, value, dt->size);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6804,6 +6613,7 @@ H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size)
{
int lt, md, rt; /*indices for binary search */
int cmp; /*comparison result */
+ char *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5T_enum_nameof, NULL);
@@ -6814,10 +6624,8 @@ H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size)
if (name && size>0) *name = '\0';
/* Sanity check */
- if (dt->u.enumer.nmembs == 0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
- "datatype has no members");
- }
+ if (dt->u.enumer.nmembs == 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members");
/* Do a binary search over the values to find the correct one */
H5T_sort_value(dt, NULL);
@@ -6837,22 +6645,21 @@ H5T_enum_nameof(H5T_t *dt, void *value, char *name/*out*/, size_t size)
}
}
/* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */
- if (cmp!=0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
- "value is currently not defined");
- }
+ if (cmp!=0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined");
/* Save result name */
- if (!name && NULL==(name=H5MM_malloc(HDstrlen(dt->u.enumer.name[md])+1))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!name && NULL==(name=H5MM_malloc(HDstrlen(dt->u.enumer.name[md])+1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
HDstrncpy(name, dt->u.enumer.name[md], size);
- if (HDstrlen(dt->u.enumer.name[md])>=size) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL,
- "name has been truncated");
- }
- FUNC_LEAVE(name);
+ if (HDstrlen(dt->u.enumer.name[md])>=size)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated");
+
+ /* Set return value */
+ ret_value=name;
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6880,6 +6687,7 @@ H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/)
{
int lt, md, rt; /*indices for binary search */
int cmp; /*comparison result */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_enum_valueof, FAIL);
@@ -6889,10 +6697,8 @@ H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/)
assert(value);
/* Sanity check */
- if (dt->u.enumer.nmembs == 0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL,
- "datatype has no members");
- }
+ if (dt->u.enumer.nmembs == 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "datatype has no members");
/* Do a binary search over the names to find the correct one */
H5T_sort_name(dt, NULL);
@@ -6912,13 +6718,13 @@ H5T_enum_valueof(H5T_t *dt, const char *name, void *value/*out*/)
}
}
/* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */
- if (cmp!=0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL,
- "string doesn't exist in the enumeration type");
- }
+ if (cmp!=0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type");
HDmemcpy(value, dt->u.enumer.value+md*dt->size, dt->size);
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6987,10 +6793,8 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
/* Build an index for each type so the names are sorted */
if (NULL==(idx1 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(int))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(int)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
- "memory allocation failed");
- }
+ NULL==(idx2 = H5MM_malloc(dt1->u.compnd.nmembs * sizeof(int))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed");
for (i=0; i<dt1->u.compnd.nmembs; i++)
idx1[i] = idx2[i] = i;
for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
@@ -7063,10 +6867,8 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
/* Build an index for each type so the names are sorted */
if (NULL==(idx1 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(int))) ||
- NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(int)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0,
- "memory allocation failed");
- }
+ NULL==(idx2 = H5MM_malloc(dt1->u.enumer.nmembs * sizeof(int))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed");
for (i=0; i<dt1->u.enumer.nmembs; i++)
idx1[i] = idx2[i] = i;
for (i=dt1->u.enumer.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
@@ -7198,64 +7000,46 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
switch (dt1->type) {
case H5T_INTEGER:
- if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign)
+ HGOTO_DONE(1);
break;
case H5T_FLOAT:
- if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign)
+ HGOTO_DONE(1);
- if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos)
+ HGOTO_DONE(1);
- if (dt1->u.atomic.u.f.esize <
- dt2->u.atomic.u.f.esize) HGOTO_DONE(-1);
- if (dt1->u.atomic.u.f.esize >
- dt2->u.atomic.u.f.esize) HGOTO_DONE(1);
+ if (dt1->u.atomic.u.f.esize < dt2->u.atomic.u.f.esize) HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.esize > dt2->u.atomic.u.f.esize) HGOTO_DONE(1);
- if (dt1->u.atomic.u.f.ebias <
- dt2->u.atomic.u.f.ebias) HGOTO_DONE(-1);
- if (dt1->u.atomic.u.f.ebias >
- dt2->u.atomic.u.f.ebias) HGOTO_DONE(1);
+ if (dt1->u.atomic.u.f.ebias < dt2->u.atomic.u.f.ebias) HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.ebias > dt2->u.atomic.u.f.ebias) HGOTO_DONE(1);
- if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos)
+ HGOTO_DONE(1);
- if (dt1->u.atomic.u.f.msize <
- dt2->u.atomic.u.f.msize) HGOTO_DONE(-1);
- if (dt1->u.atomic.u.f.msize >
- dt2->u.atomic.u.f.msize) HGOTO_DONE(1);
+ if (dt1->u.atomic.u.f.msize < dt2->u.atomic.u.f.msize) HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.msize > dt2->u.atomic.u.f.msize) HGOTO_DONE(1);
- if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm)
+ HGOTO_DONE(1);
- if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad)
+ HGOTO_DONE(1);
break;
@@ -7264,19 +7048,15 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
break;
case H5T_STRING:
- if (dt1->u.atomic.u.s.cset < dt2->u.atomic.u.s.cset) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.s.cset > dt2->u.atomic.u.s.cset) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.s.cset < dt2->u.atomic.u.s.cset)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.s.cset > dt2->u.atomic.u.s.cset)
+ HGOTO_DONE(1);
- if (dt1->u.atomic.u.s.pad < dt2->u.atomic.u.s.pad) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.s.pad > dt2->u.atomic.u.s.pad) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.s.pad < dt2->u.atomic.u.s.pad)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.s.pad > dt2->u.atomic.u.s.pad)
+ HGOTO_DONE(1);
break;
@@ -7285,12 +7065,10 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
break;
case H5T_REFERENCE:
- if (dt1->u.atomic.u.r.rtype < dt2->u.atomic.u.r.rtype) {
- HGOTO_DONE(-1);
- }
- if (dt1->u.atomic.u.r.rtype > dt2->u.atomic.u.r.rtype) {
- HGOTO_DONE(1);
- }
+ if (dt1->u.atomic.u.r.rtype < dt2->u.atomic.u.r.rtype)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.r.rtype > dt2->u.atomic.u.r.rtype)
+ HGOTO_DONE(1);
switch(dt1->u.atomic.u.r.rtype) {
case H5R_OBJECT:
@@ -7319,6 +7097,7 @@ done:
FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_path_find
*
@@ -7358,7 +7137,7 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
int old_npaths; /* Previous number of paths in table */
H5T_path_t *table=NULL; /*path existing in the table */
H5T_path_t *path=NULL; /*new path */
- H5T_path_t *ret_value=NULL; /*return value */
+ H5T_path_t *ret_value; /*return value */
hid_t src_id=-1, dst_id=-1; /*src and dst type identifiers */
int i; /*counter */
int nprint=0; /*lines of output printed */
@@ -7371,16 +7150,11 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
* Make sure the first entry in the table is the no-op conversion path.
*/
if (0==H5T_g.npaths) {
- if (NULL==(H5T_g.path=H5MM_malloc(128*sizeof(H5T_path_t*)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for type conversion path "
- "table");
- }
+ if (NULL==(H5T_g.path=H5MM_malloc(128*sizeof(H5T_path_t*))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path table");
H5T_g.apaths = 128;
- if (NULL==(H5T_g.path[0]=H5FL_ALLOC(H5T_path_t,1))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for no-op conversion path");
- }
+ if (NULL==(H5T_g.path[0]=H5FL_ALLOC(H5T_path_t,1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for no-op conversion path");
HDstrcpy(H5T_g.path[0]->name, "no-op");
H5T_g.path[0]->func = H5T_conv_noop;
H5T_g.path[0]->cdata.command = H5T_CONV_INIT;
@@ -7442,10 +7216,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
* the path.
*/
if (!table || func) {
- if (NULL==(path=H5FL_ALLOC(H5T_path_t,1))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed for type conversion path");
- }
+ if (NULL==(path=H5FL_ALLOC(H5T_path_t,1)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for type conversion path");
if (name && *name) {
HDstrncpy(path->name, name, H5T_NAMELEN);
path->name[H5T_NAMELEN-1] = '\0';
@@ -7453,10 +7225,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
HDstrcpy(path->name, "NONAME");
}
if ((src && NULL==(path->src=H5T_copy(src, H5T_COPY_ALL))) ||
- (dst && NULL==(path->dst=H5T_copy(dst, H5T_COPY_ALL)))) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to copy data type for conversion path");
- }
+ (dst && NULL==(path->dst=H5T_copy(dst, H5T_COPY_ALL))))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type for conversion path");
} else {
path = table;
}
@@ -7469,24 +7239,15 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
assert(path!=table);
assert(NULL==path->func);
if (path->src && (src_id=H5I_register(H5I_DATATYPE,
- H5T_copy(path->src,
- H5T_COPY_ALL)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
- "unable to register source conversion type for query");
- }
+ H5T_copy(path->src, H5T_COPY_ALL)))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register source conversion type for query");
if (path->dst && (dst_id=H5I_register(H5I_DATATYPE,
- H5T_copy(path->dst,
- H5T_COPY_ALL)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
- "unable to register destination conversion type for "
- "query");
- }
+ H5T_copy(path->dst, H5T_COPY_ALL)))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register destination conversion type for query");
path->cdata.command = H5T_CONV_INIT;
if ((func)(src_id, dst_id, &(path->cdata), (hsize_t)0, 0, 0, NULL, NULL,
- H5P_DEFAULT)<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to initialize conversion function");
- }
+ H5P_DEFAULT)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to initialize conversion function");
if (src_id>=0) H5I_dec_ref(src_id);
if (dst_id>=0) H5I_dec_ref(dst_id);
src_id = dst_id = -1;
@@ -7508,11 +7269,9 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
}
if ((src_id=H5I_register(H5I_DATATYPE,
H5T_copy(path->src, H5T_COPY_ALL)))<0 ||
- (dst_id=H5I_register(H5I_DATATYPE,
- H5T_copy(path->dst, H5T_COPY_ALL)))<0) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
- "unable to register conversion types for query");
- }
+ (dst_id=H5I_register(H5I_DATATYPE,
+ H5T_copy(path->dst, H5T_COPY_ALL)))<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL, "unable to register conversion types for query");
path->cdata.command = H5T_CONV_INIT;
if ((H5T_g.soft[i].func) (src_id, dst_id, &(path->cdata),
(hsize_t)0, 0, 0, NULL, NULL, H5P_DEFAULT)<0) {
@@ -7527,10 +7286,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
H5I_dec_ref(dst_id);
src_id = dst_id = -1;
}
- if (!path->func) {
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
- "no appropriate function for conversion path");
- }
+ if (!path->func)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "no appropriate function for conversion path");
/* Check if paths were inserted into the table through a recursive call
* and re-compute the correct location for this path if so. - QAK, 1/26/02
@@ -7582,10 +7339,8 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
size_t na = MAX(128, 2 * H5T_g.apaths);
H5T_path_t **x = H5MM_realloc (H5T_g.path,
na*sizeof(H5T_path_t*));
- if (!x) {
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
- "memory allocation failed");
- }
+ if (!x)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
H5T_g.apaths = (int)na;
H5T_g.path = x;
}
@@ -7596,9 +7351,11 @@ H5T_path_find(const H5T_t *src, const H5T_t *dst, const char *name,
H5T_g.path[md] = path;
table = path;
}
+
+ /* Set return value */
ret_value = path;
- done:
+done:
if (!ret_value && path && path!=table) {
if (path->src) H5T_close(path->src);
if (path->dst) H5T_close(path->dst);
@@ -7660,6 +7417,7 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, hsize_t nelmts,
#ifdef H5T_DEBUG
H5_timer_t timer;
#endif
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_convert, FAIL);
@@ -7668,10 +7426,8 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, hsize_t nelmts,
#endif
tpath->cdata.command = H5T_CONV_CONV;
if ((tpath->func)(src_id, dst_id, &(tpath->cdata), nelmts, buf_stride,
- bkg_stride, buf, bkg, dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL,
- "data type conversion failed");
- }
+ bkg_stride, buf, bkg, dset_xfer_plist)<0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "data type conversion failed");
#ifdef H5T_DEBUG
if (H5DEBUG(T)) {
H5_timer_end(&(tpath->stats.timer), &timer);
@@ -7680,7 +7436,8 @@ H5T_convert(H5T_path_t *tpath, hid_t src_id, hid_t dst_id, hsize_t nelmts,
}
#endif
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -7710,17 +7467,17 @@ H5T_entof (H5T_t *dt)
assert (dt);
switch (dt->state) {
- case H5T_STATE_TRANSIENT:
- case H5T_STATE_RDONLY:
- case H5T_STATE_IMMUTABLE:
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL,
- "not a named data type");
- case H5T_STATE_NAMED:
- case H5T_STATE_OPEN:
- ret_value = &(dt->ent);
- break;
+ case H5T_STATE_TRANSIENT:
+ case H5T_STATE_RDONLY:
+ case H5T_STATE_IMMUTABLE:
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "not a named data type");
+ case H5T_STATE_NAMED:
+ case H5T_STATE_OPEN:
+ ret_value = &(dt->ent);
+ break;
}
+done:
FUNC_LEAVE (ret_value);
}
@@ -7789,9 +7546,6 @@ H5T_get_ref_type(const H5T_t *dt)
if(dt->type==H5T_REFERENCE)
ret_value=dt->u.atomic.u.r.rtype;
-#ifdef LATER
-done:
-#endif /* LATER */
FUNC_LEAVE(ret_value);
} /* end H5T_get_ref_type() */
@@ -7827,30 +7581,31 @@ H5Tarray_create(hid_t base_id, int ndims, const hsize_t dim[/* ndims */],
H5T_t *base = NULL; /* base data type */
H5T_t *dt = NULL; /* new array data type */
int i; /* local index variable */
- hid_t ret_value = FAIL; /* return value */
+ hid_t ret_value; /* return value */
FUNC_ENTER_API(H5Tarray_create, FAIL);
H5TRACE4("i","iIs*h*Is",base_id,ndims,dim,perm);
/* Check args */
if (ndims<1 || ndims>H5S_MAX_RANK)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dimensionality");
if (ndims>0 && !dim)
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
for(i=0; i<ndims; i++)
if(!(dim[i]>0))
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified");
if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype");
/* Create the actual array datatype */
if ((dt=H5T_array_create(base,ndims,dim,perm))==NULL)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to create datatype");
/* Atomize the type */
if ((ret_value=H5I_register(H5I_DATATYPE, dt))<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype");
+done:
FUNC_LEAVE(ret_value);
} /* end H5Tarray_create */
@@ -7891,7 +7646,7 @@ H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */],
/* Build new type */
if (NULL==(ret_value = H5FL_ALLOC(H5T_t,1)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
ret_value->ent.header = HADDR_UNDEF;
ret_value->type = H5T_ARRAY;
@@ -7922,6 +7677,7 @@ H5T_array_create(H5T_t *base, int ndims, const hsize_t dim[/* ndims */],
if(base->type==H5T_VLEN || base->force_conv==TRUE)
ret_value->force_conv=TRUE;
+done:
FUNC_LEAVE(ret_value);
} /* end H5T_array_create */
@@ -7945,20 +7701,21 @@ int
H5Tget_array_ndims(hid_t type_id)
{
H5T_t *dt = NULL; /* pointer to array data type */
- int ret_value = FAIL; /* return value */
+ int ret_value; /* return value */
FUNC_ENTER_API(H5Tget_array_ndims, FAIL);
H5TRACE1("Is","i",type_id);
/* Check args */
if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
if(dt->type!=H5T_ARRAY)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
/* Retrieve the number of dimensions */
ret_value=dt->u.array.ndims;
+done:
FUNC_LEAVE(ret_value);
} /* end H5Tget_array_ndims */
@@ -7990,9 +7747,9 @@ H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[])
/* Check args */
if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object");
if(dt->type!=H5T_ARRAY)
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an array datatype");
/* Retrieve the sizes of the dimensions */
if(dims)
@@ -8004,6 +7761,7 @@ H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[])
for(i=0; i<dt->u.array.ndims; i++)
perm[i]=dt->u.array.perm[i];
+done:
FUNC_LEAVE(ret_value);
} /* end H5Tget_array_dims */
@@ -8028,7 +7786,7 @@ H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[])
htri_t
H5T_is_sensible(const H5T_t *dt)
{
- htri_t ret_value = FAIL;
+ htri_t ret_value;
FUNC_ENTER_NOAPI(H5T_is_sensible, FAIL);
@@ -8155,72 +7913,72 @@ H5T_debug(const H5T_t *dt, FILE *stream)
assert(stream);
switch (dt->type) {
- case H5T_INTEGER:
- s1 = "int";
- break;
- case H5T_FLOAT:
- s1 = "float";
- break;
- case H5T_TIME:
- s1 = "time";
- break;
- case H5T_STRING:
- s1 = "str";
- break;
- case H5T_BITFIELD:
- s1 = "bits";
- break;
- case H5T_OPAQUE:
- s1 = "opaque";
- break;
- case H5T_COMPOUND:
- s1 = "struct";
- break;
- case H5T_ENUM:
- s1 = "enum";
- break;
- default:
- s1 = "";
- break;
+ case H5T_INTEGER:
+ s1 = "int";
+ break;
+ case H5T_FLOAT:
+ s1 = "float";
+ break;
+ case H5T_TIME:
+ s1 = "time";
+ break;
+ case H5T_STRING:
+ s1 = "str";
+ break;
+ case H5T_BITFIELD:
+ s1 = "bits";
+ break;
+ case H5T_OPAQUE:
+ s1 = "opaque";
+ break;
+ case H5T_COMPOUND:
+ s1 = "struct";
+ break;
+ case H5T_ENUM:
+ s1 = "enum";
+ break;
+ default:
+ s1 = "";
+ break;
}
switch (dt->state) {
- case H5T_STATE_TRANSIENT:
- s2 = "[transient]";
- break;
- case H5T_STATE_RDONLY:
- s2 = "[constant]";
- break;
- case H5T_STATE_IMMUTABLE:
- s2 = "[predefined]";
- break;
- case H5T_STATE_NAMED:
- s2 = "[named,closed]";
- break;
- case H5T_STATE_OPEN:
- s2 = "[named,open]";
- break;
+ case H5T_STATE_TRANSIENT:
+ s2 = "[transient]";
+ break;
+ case H5T_STATE_RDONLY:
+ s2 = "[constant]";
+ break;
+ case H5T_STATE_IMMUTABLE:
+ s2 = "[predefined]";
+ break;
+ case H5T_STATE_NAMED:
+ s2 = "[named,closed]";
+ break;
+ case H5T_STATE_OPEN:
+ s2 = "[named,open]";
+ break;
}
fprintf(stream, "%s%s {nbytes=%lu", s1, s2, (unsigned long)(dt->size));
if (H5T_is_atomic(dt)) {
switch (dt->u.atomic.order) {
- case H5T_ORDER_BE:
- s1 = "BE";
- break;
- case H5T_ORDER_LE:
- s1 = "LE";
- break;
- case H5T_ORDER_VAX:
- s1 = "VAX";
- break;
- case H5T_ORDER_NONE:
- s1 = "NONE";
- break;
- default:
- s1 = "order?";
- break;
+ case H5T_ORDER_BE:
+ s1 = "BE";
+ break;
+ case H5T_ORDER_LE:
+ s1 = "LE";
+ break;
+ case H5T_ORDER_VAX:
+ s1 = "VAX";
+ break;
+ case H5T_ORDER_NONE:
+ s1 = "NONE";
+ break;
+ default:
+ s1 = "order?";
+ break;
}
fprintf(stream, ", %s", s1);
@@ -8233,59 +7991,59 @@ H5T_debug(const H5T_t *dt, FILE *stream)
(unsigned long) (dt->u.atomic.prec));
}
switch (dt->type) {
- case H5T_INTEGER:
- switch (dt->u.atomic.u.i.sign) {
- case H5T_SGN_NONE:
- s1 = "unsigned";
- break;
- case H5T_SGN_2:
- s1 = NULL;
- break;
- default:
- s1 = "sign?";
- break;
- }
- if (s1) fprintf(stream, ", %s", s1);
- break;
+ case H5T_INTEGER:
+ switch (dt->u.atomic.u.i.sign) {
+ case H5T_SGN_NONE:
+ s1 = "unsigned";
+ break;
+ case H5T_SGN_2:
+ s1 = NULL;
+ break;
+ default:
+ s1 = "sign?";
+ break;
+ }
+ if (s1) fprintf(stream, ", %s", s1);
+ break;
- case H5T_FLOAT:
- switch (dt->u.atomic.u.f.norm) {
- case H5T_NORM_IMPLIED:
- s1 = "implied";
- break;
- case H5T_NORM_MSBSET:
- s1 = "msbset";
- break;
- case H5T_NORM_NONE:
- s1 = "no-norm";
- break;
- default:
- s1 = "norm?";
- break;
- }
- fprintf(stream, ", sign=%lu+1",
- (unsigned long) (dt->u.atomic.u.f.sign));
- fprintf(stream, ", mant=%lu+%lu (%s)",
- (unsigned long) (dt->u.atomic.u.f.mpos),
- (unsigned long) (dt->u.atomic.u.f.msize), s1);
- fprintf(stream, ", exp=%lu+%lu",
- (unsigned long) (dt->u.atomic.u.f.epos),
- (unsigned long) (dt->u.atomic.u.f.esize));
- tmp = dt->u.atomic.u.f.ebias >> 32;
- if (tmp) {
- size_t hi=(size_t)tmp;
- size_t lo =(size_t)(dt->u.atomic.u.f.ebias & 0xffffffff);
- fprintf(stream, " bias=0x%08lx%08lx",
- (unsigned long)hi, (unsigned long)lo);
- } else {
- size_t lo = (size_t)(dt->u.atomic.u.f.ebias & 0xffffffff);
- fprintf(stream, " bias=0x%08lx", (unsigned long)lo);
- }
- break;
+ case H5T_FLOAT:
+ switch (dt->u.atomic.u.f.norm) {
+ case H5T_NORM_IMPLIED:
+ s1 = "implied";
+ break;
+ case H5T_NORM_MSBSET:
+ s1 = "msbset";
+ break;
+ case H5T_NORM_NONE:
+ s1 = "no-norm";
+ break;
+ default:
+ s1 = "norm?";
+ break;
+ }
+ fprintf(stream, ", sign=%lu+1",
+ (unsigned long) (dt->u.atomic.u.f.sign));
+ fprintf(stream, ", mant=%lu+%lu (%s)",
+ (unsigned long) (dt->u.atomic.u.f.mpos),
+ (unsigned long) (dt->u.atomic.u.f.msize), s1);
+ fprintf(stream, ", exp=%lu+%lu",
+ (unsigned long) (dt->u.atomic.u.f.epos),
+ (unsigned long) (dt->u.atomic.u.f.esize));
+ tmp = dt->u.atomic.u.f.ebias >> 32;
+ if (tmp) {
+ size_t hi=(size_t)tmp;
+ size_t lo =(size_t)(dt->u.atomic.u.f.ebias & 0xffffffff);
+ fprintf(stream, " bias=0x%08lx%08lx",
+ (unsigned long)hi, (unsigned long)lo);
+ } else {
+ size_t lo = (size_t)(dt->u.atomic.u.f.ebias & 0xffffffff);
+ fprintf(stream, " bias=0x%08lx", (unsigned long)lo);
+ }
+ break;
- default:
- /* No additional info */
- break;
+ default:
+ /* No additional info */
+ break;
}
} else if (H5T_COMPOUND==dt->type) {
diff --git a/src/H5TB.c b/src/H5TB.c
index 24b75ee..d59da33 100644
--- a/src/H5TB.c
+++ b/src/H5TB.c
@@ -171,11 +171,12 @@ H5TB_TREE *
H5TB_dmake(H5TB_cmp_t cmp, int arg, unsigned fast_compare)
{
H5TB_TREE *tree;
+ H5TB_TREE *ret_value;
FUNC_ENTER_NOAPI(H5TB_dmake, NULL);
if (NULL == (tree = H5MM_malloc(sizeof(H5TB_TREE))))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
tree->root = NULL;
tree->count = 0;
@@ -183,7 +184,11 @@ H5TB_dmake(H5TB_cmp_t cmp, int arg, unsigned fast_compare)
tree->compar = cmp;
tree->cmparg = arg;
- FUNC_LEAVE (tree);
+ /* Set return value */
+ ret_value=tree;
+
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5TB_dmake() */
@@ -214,7 +219,7 @@ H5TB_dmake(H5TB_cmp_t cmp, int arg, unsigned fast_compare)
H5TB_NODE *
H5TB_dfind(H5TB_TREE * tree, void * key, H5TB_NODE ** pp)
{
- H5TB_NODE *ret_value=NULL;
+ H5TB_NODE *ret_value;
FUNC_ENTER_NOAPI(H5TB_dfind, NULL);
@@ -509,6 +514,7 @@ H5TB_ins(H5TB_NODE ** root, void * item, void * key, H5TB_cmp_t compar, int arg)
{
int cmp;
H5TB_NODE *ptr, *parent;
+ H5TB_NODE *ret_value;
FUNC_ENTER_NOAPI(H5TB_ins,NULL);
@@ -516,9 +522,9 @@ H5TB_ins(H5TB_NODE ** root, void * item, void * key, H5TB_cmp_t compar, int arg)
assert(item);
if (NULL != H5TB_find(*root, (key ? key : item), compar, arg, &parent))
- HRETURN_ERROR (H5E_TBBT, H5E_EXISTS, NULL, "node already in tree");
+ HGOTO_ERROR (H5E_TBBT, H5E_EXISTS, NULL, "node already in tree");
if (NULL == (ptr = H5FL_ALLOC(H5TB_NODE,0)))
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
ptr->data = item;
ptr->key = key ? key : item;
ptr->Parent = parent;
@@ -546,7 +552,11 @@ H5TB_ins(H5TB_NODE ** root, void * item, void * key, H5TB_cmp_t compar, int arg)
H5TB_balance(root, parent, (cmp < 0) ? LEFT : RIGHT, 1);
} /* end else */
- FUNC_LEAVE(ptr);
+ /* Set return value */
+ ret_value=ptr;
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5TB_ins() */
@@ -588,11 +598,12 @@ H5TB_rem(H5TB_NODE ** root, H5TB_NODE * node, void * *kp)
H5TB_NODE *next; /* Next/prev node near `leaf' (`leaf's `side' thread) */
int side; /* `leaf' is `side' child of `par' */
void * data; /* Saved pointer to data item of deleted node */
+ void *ret_value; /* Return value */
FUNC_ENTER_NOAPI(H5TB_rem, NULL);
if (NULL == root || NULL == node)
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "bad arguments to delete");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "bad arguments to delete");
data = node->data; /* Save pointer to data item to be returned at end */
if (NULL != kp)
@@ -646,7 +657,7 @@ H5TB_rem(H5TB_NODE ** root, H5TB_NODE * node, void * *kp)
*root = NULL;
} /* end else */
H5FL_FREE(H5TB_NODE,node);
- HRETURN(data);
+ HGOTO_DONE(data);
}
side = (par->Rchild == leaf) ? RIGHT : LEFT;
next = leaf->link[side];
@@ -710,7 +721,11 @@ H5TB_rem(H5TB_NODE ** root, H5TB_NODE * node, void * *kp)
((H5TB_TREE *) root)->count--;
- FUNC_LEAVE(data);
+ /* Set return value */
+ ret_value=data;
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5TB_rem() */
@@ -858,14 +873,13 @@ H5TB_dfree(H5TB_TREE * tree, void(*fd) (void * /* item */), void(*fk) (void * /*
{
FUNC_ENTER_NOAPI(H5TB_dfree,NULL);
- if (tree == NULL)
- HRETURN(NULL);
-
- /* Free the actual tree */
- H5TB_free(&tree->root, fd, fk);
+ if (tree != NULL) {
+ /* Free the actual tree */
+ H5TB_free(&tree->root, fd, fk);
- /* Free the tree root */
- H5MM_xfree(tree);
+ /* Free the tree root */
+ H5MM_xfree(tree);
+ } /* end if */
FUNC_LEAVE(NULL);
} /* end H5TB_dfree() */
@@ -1020,20 +1034,23 @@ H5TB_dump(H5TB_TREE *tree, void (*key_dump)(void *,void *), int method)
static herr_t
H5TB_printNode(H5TB_NODE * node, void(*key_dump)(void *,void *))
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5TB_printNode);
if (node == NULL) {
printf("ERROR: null node pointer\n");
- HRETURN(FAIL);
- }
+ HGOTO_DONE(FAIL);
+ }
printf("node=%p, key=%p, data=%p, flags=%x\n", node, node->key, node->data, (unsigned) node->flags);
printf("Lcnt=%d, Rcnt=%d\n", (int) node->lcnt, (int) node->rcnt);
printf("Lchild=%p, Rchild=%p, Parent=%p\n", node->Lchild, node->Rchild, node->Parent);
- if (key_dump != NULL) {
+ if (key_dump != NULL)
(*key_dump)(node->key,node->data);
- }
- FUNC_LEAVE(SUCCESS);
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5TB_printNode() */
@@ -1061,10 +1078,12 @@ static herr_t
H5TB_dumpNode(H5TB_NODE *node, void (*key_dump)(void *,void *),
int method)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOINIT(H5TB_dumpNode);
if (node == NULL)
- HRETURN(FAIL);
+ HGOTO_DONE(FAIL);
switch (method) {
case -1: /* Pre-Order Traversal */
@@ -1093,7 +1112,9 @@ H5TB_dumpNode(H5TB_NODE *node, void (*key_dump)(void *,void *),
break;
} /* end switch() */
- FUNC_LEAVE(SUCCESS);
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5TB_dumpNode() */
#endif /* H5TB_DEBUG */
@@ -1133,16 +1154,23 @@ H5TB_end(H5TB_NODE * root, int side)
static H5TB_NODE *
H5TB_nbr(H5TB_NODE * ptr, int side)
{
+ H5TB_NODE *ret_value; /* Return value */
+
FUNC_ENTER_NOINIT(H5TB_nbr);
if (!HasChild(ptr, side))
- HRETURN (ptr->link[side]);
+ HGOTO_DONE (ptr->link[side]);
ptr = ptr->link[side];
if(ptr==NULL)
- HRETURN(NULL);
+ HGOTO_DONE(NULL);
while (HasChild(ptr, Other(side)))
ptr = ptr->link[Other(side)];
- FUNC_LEAVE(ptr);
+
+ /* Set return value */
+ ret_value=ptr;
+
+done:
+ FUNC_LEAVE(ret_value);
} /* end H5TB_nbr() */
/* H5TB_ffind -- Look up a node in a tree based on a key value */
diff --git a/src/H5Tbit.c b/src/H5Tbit.c
index 0813f46..abc39b0 100644
--- a/src/H5Tbit.c
+++ b/src/H5Tbit.c
@@ -317,6 +317,7 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
ssize_t base=(ssize_t)offset;
ssize_t idx, i;
size_t iu;
+ ssize_t ret_value=(-1); /* Return value */
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5T_bit_find);
@@ -333,9 +334,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* Beginning */
if (offset) {
for (iu=offset; iu<8 && size>0; iu++, size--) {
- if (value==(hbool_t)((buf[idx]>>iu) & 0x01)) {
- HRETURN(8*idx+(ssize_t)iu - base);
- }
+ if (value==(hbool_t)((buf[idx]>>iu) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)iu - base);
}
offset = 0;
idx++;
@@ -344,9 +344,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
while (size>=8) {
if ((value?0x00:0xff)!=buf[idx]) {
for (i=0; i<8; i++) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01)) {
- HRETURN(8*idx+i - base);
- }
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
}
}
size -= 8;
@@ -354,9 +353,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
}
/* End */
for (i=0; i<(ssize_t)size; i++) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01)) {
- HRETURN(8*idx+i - base);
- }
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
}
break;
@@ -368,9 +366,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* Beginning */
if (size>8-offset && (offset+size)%8) {
for (iu=(offset+size)%8; iu>0; --iu, --size) {
- if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) {
- HRETURN(8*idx+(ssize_t)(iu-1) - base);
- }
+ if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
}
--idx;
}
@@ -378,9 +375,8 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
while (size>=8) {
if ((value?0x00:0xff)!=buf[idx]) {
for (i=7; i>=0; --i) {
- if (value==(hbool_t)((buf[idx]>>i) & 0x01)) {
- HRETURN(8*idx+i - base);
- }
+ if (value==(hbool_t)((buf[idx]>>i) & 0x01))
+ HGOTO_DONE(8*idx+i - base);
}
}
size -= 8;
@@ -389,16 +385,15 @@ H5T_bit_find (uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction,
/* End */
if (size>0) {
for (iu=offset+size; iu>offset; --iu) {
- if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01)) {
- HRETURN(8*idx+(ssize_t)(iu-1) - base);
- }
+ if (value==(hbool_t)((buf[idx]>>(iu-1)) & 0x01))
+ HGOTO_DONE(8*idx+(ssize_t)(iu-1) - base);
}
}
break;
}
-
- FUNC_LEAVE(-1);
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index f15acf7..43d9dd2 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -285,11 +285,11 @@ H5FL_BLK_DEFINE_STATIC(array_seq);
cdata->need_bkg = H5T_BKG_NO; \
if (NULL==(st=H5I_object_verify(src_id,H5I_DATATYPE)) || \
NULL==(dt=H5I_object_verify(dst_id,H5I_DATATYPE))) { \
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \
"unable to dereference data type object ID"); \
} \
if (st->size!=sizeof(ST) || dt->size!=sizeof(DT)) { \
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \
"disagreement about data type size"); \
} \
CI_ALLOC_PRIV \
@@ -355,7 +355,7 @@ H5FL_BLK_DEFINE_STATIC(array_seq);
break; \
\
default: \
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, \
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, \
"unknown conversion command"); \
} \
}
@@ -381,7 +381,7 @@ H5FL_BLK_DEFINE_STATIC(array_seq);
/* Allocate private alignment structure for atomic types */
# define CI_ALLOC_PRIV \
if (NULL==(cdata->priv=H5MM_calloc(sizeof(H5T_conv_hw_t)))) { \
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, \
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, \
"memory allocation failed"); \
}
@@ -395,17 +395,18 @@ H5FL_BLK_DEFINE_STATIC(array_seq);
/* Increment destination alignment counter */
# define CI_INC_DST(d) if (d) ((H5T_conv_hw_t *)cdata->priv)->d_aligned += nelmts;
-#else
+#else /* H5T_DEBUG */
# define CI_PRINT_STATS(STYPE,DTYPE) /*void*/
# define CI_ALLOC_PRIV cdata->priv=NULL;
# define CI_FREE_PRIV /* void */
# define CI_INC_SRC(s) /* void */
# define CI_INC_DST(d) /* void */
-#endif
+#endif /* H5T_DEBUG */
/* Swap two elements (I & J) of an array using a temporary variable */
#define H5_SWAP_BYTES(ARRAY,I,J) {uint8_t _tmp; _tmp=ARRAY[I]; ARRAY[I]=ARRAY[J]; ARRAY[J]=_tmp;}
+
/*-------------------------------------------------------------------------
* Function: H5T_conv_noop
*
@@ -427,6 +428,8 @@ H5T_conv_noop(hid_t UNUSED src_id, hid_t UNUSED dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void UNUSED *buf,
void UNUSED *background, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_noop, FAIL);
switch (cdata->command) {
@@ -442,13 +445,14 @@ H5T_conv_noop(hid_t UNUSED src_id, hid_t UNUSED dst_id, H5T_cdata_t *cdata,
break;
default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_conv_order_opt
*
@@ -477,6 +481,7 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
H5T_t *src = NULL;
H5T_t *dst = NULL;
hsize_t i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_order_opt, FAIL);
@@ -485,45 +490,38 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
/* Capability query */
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
if (src->size != dst->size ||
- 0 != src->u.atomic.offset ||
- 0 != dst->u.atomic.offset ||
- !((H5T_ORDER_BE == src->u.atomic.order &&
- H5T_ORDER_LE == dst->u.atomic.order) ||
- (H5T_ORDER_LE == src->u.atomic.order &&
- H5T_ORDER_BE == dst->u.atomic.order))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
+ 0 != src->u.atomic.offset ||
+ 0 != dst->u.atomic.offset ||
+ !((H5T_ORDER_BE == src->u.atomic.order &&
+ H5T_ORDER_LE == dst->u.atomic.order) ||
+ (H5T_ORDER_LE == src->u.atomic.order &&
+ H5T_ORDER_BE == dst->u.atomic.order)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
if (src->size!=1 && src->size!=2 && src->size!=4 &&
- src->size!=8 && src->size!=16) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
+ src->size!=8 && src->size!=16)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
switch (src->type) {
- case H5T_INTEGER:
- case H5T_BITFIELD:
- /* nothing to check */
- break;
-
- case H5T_FLOAT:
- if (src->u.atomic.u.f.sign != dst->u.atomic.u.f.sign ||
- src->u.atomic.u.f.epos != dst->u.atomic.u.f.epos ||
- src->u.atomic.u.f.esize != dst->u.atomic.u.f.esize ||
- src->u.atomic.u.f.ebias != dst->u.atomic.u.f.ebias ||
- src->u.atomic.u.f.mpos != dst->u.atomic.u.f.mpos ||
- src->u.atomic.u.f.msize != dst->u.atomic.u.f.msize ||
- src->u.atomic.u.f.norm != dst->u.atomic.u.f.norm ||
- src->u.atomic.u.f.pad != dst->u.atomic.u.f.pad) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
- break;
-
- default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
+ case H5T_INTEGER:
+ case H5T_BITFIELD:
+ /* nothing to check */
+ break;
+
+ case H5T_FLOAT:
+ if (src->u.atomic.u.f.sign != dst->u.atomic.u.f.sign ||
+ src->u.atomic.u.f.epos != dst->u.atomic.u.f.epos ||
+ src->u.atomic.u.f.esize != dst->u.atomic.u.f.esize ||
+ src->u.atomic.u.f.ebias != dst->u.atomic.u.f.ebias ||
+ src->u.atomic.u.f.mpos != dst->u.atomic.u.f.mpos ||
+ src->u.atomic.u.f.msize != dst->u.atomic.u.f.msize ||
+ src->u.atomic.u.f.norm != dst->u.atomic.u.f.norm ||
+ src->u.atomic.u.f.pad != dst->u.atomic.u.f.pad)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
}
cdata->need_bkg = H5T_BKG_NO;
break;
@@ -532,7 +530,7 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
/* The conversion */
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
buf_stride = buf_stride ? buf_stride : src->size;
switch (src->size) {
@@ -826,11 +824,11 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
break;
default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -867,6 +865,7 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
H5T_t *dst = NULL;
hsize_t i;
size_t j, md;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_order, FAIL);
@@ -875,40 +874,35 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Capability query */
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (src->size != dst->size ||
- 0 != src->u.atomic.offset ||
- 0 != dst->u.atomic.offset ||
- !((H5T_ORDER_BE == src->u.atomic.order &&
- H5T_ORDER_LE == dst->u.atomic.order) ||
- (H5T_ORDER_LE == src->u.atomic.order &&
- H5T_ORDER_BE == dst->u.atomic.order))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (src->size != dst->size || 0 != src->u.atomic.offset ||
+ 0 != dst->u.atomic.offset ||
+ !((H5T_ORDER_BE == src->u.atomic.order &&
+ H5T_ORDER_LE == dst->u.atomic.order) ||
+ (H5T_ORDER_LE == src->u.atomic.order &&
+ H5T_ORDER_BE == dst->u.atomic.order)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
switch (src->type) {
- case H5T_INTEGER:
- case H5T_BITFIELD:
- /* nothing to check */
- break;
-
- case H5T_FLOAT:
- if (src->u.atomic.u.f.sign != dst->u.atomic.u.f.sign ||
- src->u.atomic.u.f.epos != dst->u.atomic.u.f.epos ||
- src->u.atomic.u.f.esize != dst->u.atomic.u.f.esize ||
- src->u.atomic.u.f.ebias != dst->u.atomic.u.f.ebias ||
- src->u.atomic.u.f.mpos != dst->u.atomic.u.f.mpos ||
- src->u.atomic.u.f.msize != dst->u.atomic.u.f.msize ||
- src->u.atomic.u.f.norm != dst->u.atomic.u.f.norm ||
- src->u.atomic.u.f.pad != dst->u.atomic.u.f.pad) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
- break;
+ case H5T_INTEGER:
+ case H5T_BITFIELD:
+ /* nothing to check */
+ break;
+
+ case H5T_FLOAT:
+ if (src->u.atomic.u.f.sign != dst->u.atomic.u.f.sign ||
+ src->u.atomic.u.f.epos != dst->u.atomic.u.f.epos ||
+ src->u.atomic.u.f.esize != dst->u.atomic.u.f.esize ||
+ src->u.atomic.u.f.ebias != dst->u.atomic.u.f.ebias ||
+ src->u.atomic.u.f.mpos != dst->u.atomic.u.f.mpos ||
+ src->u.atomic.u.f.msize != dst->u.atomic.u.f.msize ||
+ src->u.atomic.u.f.norm != dst->u.atomic.u.f.norm ||
+ src->u.atomic.u.f.pad != dst->u.atomic.u.f.pad) {
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
+ }
+ break;
- default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
+ default:
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "conversion not supported");
}
cdata->need_bkg = H5T_BKG_NO;
break;
@@ -917,14 +911,13 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* The conversion */
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
buf_stride = buf_stride ? buf_stride : src->size;
md = src->size / 2;
for (i=0; i<nelmts; i++, buf+=buf_stride) {
- for (j=0; j<md; j++) {
+ for (j=0; j<md; j++)
H5_SWAP_BYTES(buf, j, src->size-(j+1));
- }
}
break;
@@ -933,13 +926,14 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
break;
default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_conv_b_b
*
@@ -973,184 +967,179 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
uint8_t dbuf[256]; /*temp destination buffer */
size_t msb_pad_offset; /*offset for dest MSB padding */
size_t i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_b_b, FAIL);
switch(cdata->command) {
- case H5T_CONV_INIT:
- /* Capability query */
- if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_ORDER_LE!=src->u.atomic.order &&
- H5T_ORDER_BE!=src->u.atomic.order) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported byte order");
- }
- if (H5T_ORDER_LE!=dst->u.atomic.order &&
- H5T_ORDER_BE!=dst->u.atomic.order) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported byte order");
- }
- cdata->need_bkg = H5T_BKG_NO;
- break;
+ case H5T_CONV_INIT:
+ /* Capability query */
+ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_ORDER_LE!=src->u.atomic.order &&
+ H5T_ORDER_BE!=src->u.atomic.order)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
+ if (H5T_ORDER_LE!=dst->u.atomic.order &&
+ H5T_ORDER_BE!=dst->u.atomic.order)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
+ cdata->need_bkg = H5T_BKG_NO;
+ break;
- case H5T_CONV_FREE:
- break;
+ case H5T_CONV_FREE:
+ break;
- case H5T_CONV_CONV:
- /* Get the data types */
- if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
-
- /*
- * Do we process the values from beginning to end or vice versa? Also,
- * how many of the elements have the source and destination areas
- * overlapping?
- */
- if (src->size==dst->size || buf_stride) {
- sp = dp = (uint8_t*)buf;
- direction = 1;
- olap = nelmts;
- } else if (src->size>=dst->size) {
- double olap_d = HDceil((double)(dst->size)/
- (double)(src->size-dst->size));
-
- olap = (size_t)olap_d;
- sp = dp = (uint8_t*)buf;
- direction = 1;
- } else {
- double olap_d = HDceil((double)(src->size)/
- (double)(dst->size-src->size));
- olap = (size_t)olap_d;
- sp = (uint8_t*)buf + (nelmts-1) * src->size;
- dp = (uint8_t*)buf + (nelmts-1) * dst->size;
- direction = -1;
- }
+ case H5T_CONV_CONV:
+ /* Get the data types */
+ if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+
+ /*
+ * Do we process the values from beginning to end or vice versa? Also,
+ * how many of the elements have the source and destination areas
+ * overlapping?
+ */
+ if (src->size==dst->size || buf_stride) {
+ sp = dp = (uint8_t*)buf;
+ direction = 1;
+ olap = nelmts;
+ } else if (src->size>=dst->size) {
+ double olap_d = HDceil((double)(dst->size)/
+ (double)(src->size-dst->size));
+
+ olap = (size_t)olap_d;
+ sp = dp = (uint8_t*)buf;
+ direction = 1;
+ } else {
+ double olap_d = HDceil((double)(src->size)/
+ (double)(dst->size-src->size));
+ olap = (size_t)olap_d;
+ sp = (uint8_t*)buf + (nelmts-1) * src->size;
+ dp = (uint8_t*)buf + (nelmts-1) * dst->size;
+ direction = -1;
+ }
- /* The conversion loop */
- for (elmtno=0; elmtno<nelmts; elmtno++) {
+ /* The conversion loop */
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
- /*
- * If the source and destination buffers overlap then use a
- * temporary buffer for the destination.
- */
- if (direction>0) {
- s = sp;
- d = elmtno<olap ? dbuf : dp;
- } else {
- s = sp;
- d = elmtno+olap >= nelmts ? dbuf : dp;
- }
+ /*
+ * If the source and destination buffers overlap then use a
+ * temporary buffer for the destination.
+ */
+ if (direction>0) {
+ s = sp;
+ d = elmtno<olap ? dbuf : dp;
+ } else {
+ s = sp;
+ d = elmtno+olap >= nelmts ? dbuf : dp;
+ }
#ifndef NDEBUG
- /* I don't quite trust the overlap calculations yet --rpm */
- if (d==dbuf) {
- assert ((dp>=sp && dp<sp+src->size) ||
- (sp>=dp && sp<dp+dst->size));
- } else {
- assert ((dp<sp && dp+dst->size<=sp) ||
- (sp<dp && sp+src->size<=dp));
- }
+ /* I don't quite trust the overlap calculations yet --rpm */
+ if (d==dbuf) {
+ assert ((dp>=sp && dp<sp+src->size) ||
+ (sp>=dp && sp<dp+dst->size));
+ } else {
+ assert ((dp<sp && dp+dst->size<=sp) ||
+ (sp<dp && sp+src->size<=dp));
+ }
#endif
-
- /*
- * Put the data in little endian order so our loops aren't so
- * complicated. We'll do all the conversion stuff assuming
- * little endian and then we'll fix the order at the end.
- */
- if (H5T_ORDER_BE==src->u.atomic.order) {
- half_size = src->size/2;
- for (i=0; i<half_size; i++) {
- uint8_t tmp = s[src->size-(i+1)];
- s[src->size-(i+1)] = s[i];
- s[i] = tmp;
- }
- }
+
+ /*
+ * Put the data in little endian order so our loops aren't so
+ * complicated. We'll do all the conversion stuff assuming
+ * little endian and then we'll fix the order at the end.
+ */
+ if (H5T_ORDER_BE==src->u.atomic.order) {
+ half_size = src->size/2;
+ for (i=0; i<half_size; i++) {
+ uint8_t tmp = s[src->size-(i+1)];
+ s[src->size-(i+1)] = s[i];
+ s[i] = tmp;
+ }
+ }
- /*
- * Copy the significant part of the value. If the source is larger
- * than the destination then invoke the overflow function or copy
- * as many bits as possible. Zero extra bits in the destination.
- */
- if (src->u.atomic.prec>dst->u.atomic.prec) {
- if (!H5T_overflow_g ||
- (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- H5T_bit_copy(d, dst->u.atomic.offset,
- s, src->u.atomic.offset, dst->u.atomic.prec);
- }
- } else {
- H5T_bit_copy(d, dst->u.atomic.offset,
- s, src->u.atomic.offset,
- src->u.atomic.prec);
- H5T_bit_set(d, dst->u.atomic.offset+src->u.atomic.prec,
- dst->u.atomic.prec-src->u.atomic.prec, FALSE);
- }
+ /*
+ * Copy the significant part of the value. If the source is larger
+ * than the destination then invoke the overflow function or copy
+ * as many bits as possible. Zero extra bits in the destination.
+ */
+ if (src->u.atomic.prec>dst->u.atomic.prec) {
+ if (!H5T_overflow_g ||
+ (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ H5T_bit_copy(d, dst->u.atomic.offset,
+ s, src->u.atomic.offset, dst->u.atomic.prec);
+ }
+ } else {
+ H5T_bit_copy(d, dst->u.atomic.offset,
+ s, src->u.atomic.offset,
+ src->u.atomic.prec);
+ H5T_bit_set(d, dst->u.atomic.offset+src->u.atomic.prec,
+ dst->u.atomic.prec-src->u.atomic.prec, FALSE);
+ }
- /*
- * Fill the destination padding areas.
- */
- switch (dst->u.atomic.lsb_pad) {
- case H5T_PAD_ZERO:
- H5T_bit_set(d, 0, dst->u.atomic.offset, FALSE);
- break;
- case H5T_PAD_ONE:
- H5T_bit_set(d, 0, dst->u.atomic.offset, TRUE);
- break;
- default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported LSB padding");
- }
- msb_pad_offset = dst->u.atomic.offset + dst->u.atomic.prec;
- switch (dst->u.atomic.msb_pad) {
- case H5T_PAD_ZERO:
- H5T_bit_set(d, msb_pad_offset, 8*dst->size-msb_pad_offset,
- FALSE);
- break;
- case H5T_PAD_ONE:
- H5T_bit_set(d, msb_pad_offset, 8*dst->size-msb_pad_offset,
- TRUE);
- break;
- default:
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported MSB padding");
- }
+ /*
+ * Fill the destination padding areas.
+ */
+ switch (dst->u.atomic.lsb_pad) {
+ case H5T_PAD_ZERO:
+ H5T_bit_set(d, 0, dst->u.atomic.offset, FALSE);
+ break;
+ case H5T_PAD_ONE:
+ H5T_bit_set(d, 0, dst->u.atomic.offset, TRUE);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported LSB padding");
+ }
+ msb_pad_offset = dst->u.atomic.offset + dst->u.atomic.prec;
+ switch (dst->u.atomic.msb_pad) {
+ case H5T_PAD_ZERO:
+ H5T_bit_set(d, msb_pad_offset, 8*dst->size-msb_pad_offset,
+ FALSE);
+ break;
+ case H5T_PAD_ONE:
+ H5T_bit_set(d, msb_pad_offset, 8*dst->size-msb_pad_offset,
+ TRUE);
+ break;
+ default:
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported MSB padding");
+ }
- /*
- * Put the destination in the correct byte order. See note at
- * beginning of loop.
- */
- if (H5T_ORDER_BE==dst->u.atomic.order) {
- half_size = dst->size/2;
- for (i=0; i<half_size; i++) {
- uint8_t tmp = d[dst->size-(i+1)];
- d[dst->size-(i+1)] = d[i];
- d[i] = tmp;
- }
- }
+ /*
+ * Put the destination in the correct byte order. See note at
+ * beginning of loop.
+ */
+ if (H5T_ORDER_BE==dst->u.atomic.order) {
+ half_size = dst->size/2;
+ for (i=0; i<half_size; i++) {
+ uint8_t tmp = d[dst->size-(i+1)];
+ d[dst->size-(i+1)] = d[i];
+ d[i] = tmp;
+ }
+ }
- /*
- * If we had used a temporary buffer for the destination then we
- * should copy the value to the true destination buffer.
- */
- if (d==dbuf) HDmemcpy (dp, d, dst->size);
- if (buf_stride) {
- sp += direction * buf_stride;
- dp += direction * buf_stride;
- } else {
- sp += direction * src->size;
- dp += direction * dst->size;
- }
- }
-
- break;
+ /*
+ * If we had used a temporary buffer for the destination then we
+ * should copy the value to the true destination buffer.
+ */
+ if (d==dbuf) HDmemcpy (dp, d, dst->size);
+ if (buf_stride) {
+ sp += direction * buf_stride;
+ dp += direction * buf_stride;
+ } else {
+ sp += direction * src->size;
+ dp += direction * dst->size;
+ }
+ }
+
+ break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ default:
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1188,6 +1177,7 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
int i, j, *src2dst = NULL;
H5T_t *type = NULL;
hid_t tid;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5T_conv_struct_init);
@@ -1196,15 +1186,13 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
* Allocate private data structure and arrays.
*/
if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(H5T_conv_struct_t))) ||
- NULL==(priv->src2dst=H5MM_malloc(src->u.compnd.nmembs *
- sizeof(int))) ||
- NULL==(priv->src_memb_id=H5MM_malloc(src->u.compnd.nmembs *
- sizeof(hid_t))) ||
- NULL==(priv->dst_memb_id=H5MM_malloc(dst->u.compnd.nmembs *
- sizeof(hid_t)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ NULL==(priv->src2dst=H5MM_malloc(src->u.compnd.nmembs *
+ sizeof(int))) ||
+ NULL==(priv->src_memb_id=H5MM_malloc(src->u.compnd.nmembs *
+ sizeof(hid_t))) ||
+ NULL==(priv->dst_memb_id=H5MM_malloc(dst->u.compnd.nmembs *
+ sizeof(hid_t))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
src2dst = priv->src2dst;
/*
@@ -1251,10 +1239,8 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
src2dst = priv->src2dst;
H5MM_xfree(priv->memb_path);
if (NULL==(priv->memb_path=H5MM_malloc(src->u.compnd.nmembs *
- sizeof(H5T_path_t*)))) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
+ sizeof(H5T_path_t*))))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
for (i=0; i<src->u.compnd.nmembs; i++) {
if (src2dst[i]>=0) {
@@ -1267,8 +1253,7 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
H5MM_xfree(priv->dst_memb_id);
H5MM_xfree(priv->memb_path);
cdata->priv = priv = H5MM_xfree (priv);
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unable to convert member data type");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert member data type");
}
}
}
@@ -1278,9 +1263,12 @@ H5T_conv_struct_init (H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
cdata->need_bkg = H5T_BKG_YES;
cdata->recalc = FALSE;
- FUNC_LEAVE (SUCCEED);
+
+done:
+ FUNC_LEAVE (ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5T_conv_struct
*
@@ -1339,174 +1327,167 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
hsize_t elmtno;
int i; /*counters */
H5T_conv_struct_t *priv = (H5T_conv_struct_t *)(cdata->priv);
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_struct, FAIL);
switch (cdata->command) {
- case H5T_CONV_INIT:
- /*
- * First, determine if this conversion function applies to the
- * conversion path SRC_ID-->DST_ID. If not, return failure;
- * otherwise initialize the `priv' field of `cdata' with information
- * that remains (almost) constant for this conversion path.
- */
- if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- assert (H5T_COMPOUND==src->type);
- assert (H5T_COMPOUND==dst->type);
+ case H5T_CONV_INIT:
+ /*
+ * First, determine if this conversion function applies to the
+ * conversion path SRC_ID-->DST_ID. If not, return failure;
+ * otherwise initialize the `priv' field of `cdata' with information
+ * that remains (almost) constant for this conversion path.
+ */
+ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ assert (H5T_COMPOUND==src->type);
+ assert (H5T_COMPOUND==dst->type);
- if (H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
- break;
+ if (H5T_conv_struct_init (src, dst, cdata)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
+ break;
- case H5T_CONV_FREE:
- /*
- * Free the private conversion data.
- */
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv->src_memb_id);
- H5MM_xfree(priv->dst_memb_id);
- H5MM_xfree(priv->memb_path);
- cdata->priv = priv = H5MM_xfree (priv);
- break;
+ case H5T_CONV_FREE:
+ /*
+ * Free the private conversion data.
+ */
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_path);
+ cdata->priv = priv = H5MM_xfree (priv);
+ break;
- case H5T_CONV_CONV:
- /*
- * Conversion.
- */
- if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- assert (priv);
- assert (bkg && cdata->need_bkg);
+ case H5T_CONV_CONV:
+ /*
+ * Conversion.
+ */
+ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ assert (priv);
+ assert (bkg && cdata->need_bkg);
- if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
+ if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
+
+ /*
+ * Insure that members are sorted.
+ */
+ H5T_sort_value(src, NULL);
+ H5T_sort_value(dst, NULL);
+ src2dst = priv->src2dst;
- /*
- * Insure that members are sorted.
- */
- H5T_sort_value(src, NULL);
- H5T_sort_value(dst, NULL);
- src2dst = priv->src2dst;
-
- /*
- * Direction of conversion and striding through background.
- */
- if (buf_stride) {
- src_delta = buf_stride;
- if (!bkg_stride)
+ /*
+ * Direction of conversion and striding through background.
+ */
+ if (buf_stride) {
+ src_delta = buf_stride;
+ if (!bkg_stride)
+ bkg_stride = dst->size;
+ } else if (dst->size <= src->size) {
+ src_delta = src->size;
bkg_stride = dst->size;
- } else if (dst->size <= src->size) {
- src_delta = src->size;
- bkg_stride = dst->size;
- } else {
- src_delta = -(int)src->size; /*overflow shouldn't be possible*/
- bkg_stride = -(int)dst->size; /*overflow shouldn't be possible*/
- xbuf += (nelmts-1) * src->size;
- xbkg += (nelmts-1) * dst->size;
- }
+ } else {
+ src_delta = -(int)src->size; /*overflow shouldn't be possible*/
+ bkg_stride = -(int)dst->size; /*overflow shouldn't be possible*/
+ xbuf += (nelmts-1) * src->size;
+ xbkg += (nelmts-1) * dst->size;
+ }
- /* Conversion loop... */
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- /*
- * For each source member which will be present in the
- * destination, convert the member to the destination type unless
- * it is larger than the source type. Then move the member to the
- * left-most unoccupied position in the buffer. This makes the
- * data point as small as possible with all the free space on the
- * right side.
- */
- for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]<0) continue; /*subsetting*/
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
-
- if (dst_memb->size <= src_memb->size) {
- if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i],
- priv->dst_memb_id[src2dst[i]],
- (hsize_t)1, 0, 0, /*no striding (packed array)*/
- xbuf+src_memb->offset, xbkg+dst_memb->offset,
- dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data type member");
- }
- HDmemmove (xbuf+offset, xbuf+src_memb->offset,
- dst_memb->size);
- offset += dst_memb->size;
- } else {
- HDmemmove (xbuf+offset, xbuf+src_memb->offset,
- src_memb->size);
- offset += src_memb->size;
- }
- }
+ /* Conversion loop... */
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+ /*
+ * For each source member which will be present in the
+ * destination, convert the member to the destination type unless
+ * it is larger than the source type. Then move the member to the
+ * left-most unoccupied position in the buffer. This makes the
+ * data point as small as possible with all the free space on the
+ * right side.
+ */
+ for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
+ if (src2dst[i]<0) continue; /*subsetting*/
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+
+ if (dst_memb->size <= src_memb->size) {
+ if (H5T_convert(priv->memb_path[i], priv->src_memb_id[i],
+ priv->dst_memb_id[src2dst[i]],
+ (hsize_t)1, 0, 0, /*no striding (packed array)*/
+ xbuf+src_memb->offset, xbkg+dst_memb->offset,
+ dset_xfer_plist)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
+ HDmemmove (xbuf+offset, xbuf+src_memb->offset,
+ dst_memb->size);
+ offset += dst_memb->size;
+ } else {
+ HDmemmove (xbuf+offset, xbuf+src_memb->offset,
+ src_memb->size);
+ offset += src_memb->size;
+ }
+ }
- /*
- * For each source member which will be present in the
- * destination, convert the member to the destination type if it
- * is larger than the source type (that is, has not been converted
- * yet). Then copy the member to the destination offset in the
- * background buffer.
- */
- for (i=src->u.compnd.nmembs-1; i>=0; --i) {
- if (src2dst[i]<0) continue; /*subsetting*/
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
-
- if (dst_memb->size > src_memb->size) {
- offset -= src_memb->size;
- if (H5T_convert(priv->memb_path[i],
- priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]],
- (hsize_t)1, 0, 0, /*no striding (packed array)*/
- xbuf+offset, xbkg+dst_memb->offset,
- dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data type member");
- }
- } else {
- offset -= dst_memb->size;
- }
- HDmemmove (xbkg+dst_memb->offset, xbuf+offset, dst_memb->size);
- }
- assert (0==offset);
+ /*
+ * For each source member which will be present in the
+ * destination, convert the member to the destination type if it
+ * is larger than the source type (that is, has not been converted
+ * yet). Then copy the member to the destination offset in the
+ * background buffer.
+ */
+ for (i=src->u.compnd.nmembs-1; i>=0; --i) {
+ if (src2dst[i]<0) continue; /*subsetting*/
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+
+ if (dst_memb->size > src_memb->size) {
+ offset -= src_memb->size;
+ if (H5T_convert(priv->memb_path[i],
+ priv->src_memb_id[i], priv->dst_memb_id[src2dst[i]],
+ (hsize_t)1, 0, 0, /*no striding (packed array)*/
+ xbuf+offset, xbkg+dst_memb->offset,
+ dset_xfer_plist)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
+ } else {
+ offset -= dst_memb->size;
+ }
+ HDmemmove (xbkg+dst_memb->offset, xbuf+offset, dst_memb->size);
+ }
+ assert (0==offset);
- /*
- * Update pointers
- */
- xbuf += src_delta;
- xbkg += bkg_stride;
- }
+ /*
+ * Update pointers
+ */
+ xbuf += src_delta;
+ xbkg += bkg_stride;
+ }
- /* If the bkg_stride was set to -(dst->size), make it positive now */
- if(buf_stride==0 && dst->size>src->size)
- bkg_stride=dst->size;
-
- /*
- * Copy the background buffer back into the in-place conversion
- * buffer.
- */
- for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbuf, xbkg, dst->size);
- xbuf += buf_stride ? buf_stride : dst->size;
- xbkg += bkg_stride;
- }
- break;
+ /* If the bkg_stride was set to -(dst->size), make it positive now */
+ if(buf_stride==0 && dst->size>src->size)
+ bkg_stride=dst->size;
- default:
- /* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ /*
+ * Copy the background buffer back into the in-place conversion
+ * buffer.
+ */
+ for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbuf, xbkg, dst->size);
+ xbuf += buf_stride ? buf_stride : dst->size;
+ xbkg += bkg_stride;
+ }
+ break;
+
+ default:
+ /* Some other command we don't know about yet.*/
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
-
+
/*-------------------------------------------------------------------------
* Function: H5T_conv_struct_opt
*
@@ -1578,209 +1559,198 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t elmtno; /*element counter */
int i; /*counters */
H5T_conv_struct_t *priv = NULL; /*private data */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_struct_opt, FAIL);
switch (cdata->command) {
- case H5T_CONV_INIT:
- /*
- * First, determine if this conversion function applies to the
- * conversion path SRC_ID-->DST_ID. If not, return failure;
- * otherwise initialize the `priv' field of `cdata' with information
- * that remains (almost) constant for this conversion path.
- */
- if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- assert (H5T_COMPOUND==src->type);
- assert (H5T_COMPOUND==dst->type);
-
- /* Initialize data which is relatively constant */
- if (H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
- priv = (H5T_conv_struct_t *)(cdata->priv);
- src2dst = priv->src2dst;
-
- /*
- * If the destination type is not larger than the source type then
- * this conversion function is guaranteed to work (provided all
- * members can be converted also). Otherwise the determination is
- * quite a bit more complicated. Essentially we have to make sure
- * that there is always room in the source buffer to do the
- * conversion of a member in place. This is basically the same pair
- * of loops as in the actual conversion except it checks that there
- * is room for each conversion instead of actually doing anything.
- */
- if (dst->size > src->size) {
- for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]<0)
- continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
- if (dst_memb->size > src_memb->size)
- offset += src_memb->size;
- }
- for (i=src->u.compnd.nmembs-1; i>=0; --i) {
- if (src2dst[i]<0)
- continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
- if (dst_memb->size > src_memb->size) {
- offset -= src_memb->size;
- if (dst_memb->size > src->size-offset) {
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv->src_memb_id);
- H5MM_xfree(priv->dst_memb_id);
- H5MM_xfree(priv->memb_path);
- cdata->priv = priv = H5MM_xfree (priv);
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "convertion is unsupported by this "
- "function");
+ case H5T_CONV_INIT:
+ /*
+ * First, determine if this conversion function applies to the
+ * conversion path SRC_ID-->DST_ID. If not, return failure;
+ * otherwise initialize the `priv' field of `cdata' with information
+ * that remains (almost) constant for this conversion path.
+ */
+ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ assert (H5T_COMPOUND==src->type);
+ assert (H5T_COMPOUND==dst->type);
+
+ /* Initialize data which is relatively constant */
+ if (H5T_conv_struct_init (src, dst, cdata)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
+ priv = (H5T_conv_struct_t *)(cdata->priv);
+ src2dst = priv->src2dst;
+
+ /*
+ * If the destination type is not larger than the source type then
+ * this conversion function is guaranteed to work (provided all
+ * members can be converted also). Otherwise the determination is
+ * quite a bit more complicated. Essentially we have to make sure
+ * that there is always room in the source buffer to do the
+ * conversion of a member in place. This is basically the same pair
+ * of loops as in the actual conversion except it checks that there
+ * is room for each conversion instead of actually doing anything.
+ */
+ if (dst->size > src->size) {
+ for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+ if (dst_memb->size > src_memb->size)
+ offset += src_memb->size;
+ }
+ for (i=src->u.compnd.nmembs-1; i>=0; --i) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+ if (dst_memb->size > src_memb->size) {
+ offset -= src_memb->size;
+ if (dst_memb->size > src->size-offset) {
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_path);
+ cdata->priv = priv = H5MM_xfree (priv);
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "convertion is unsupported by this function");
+ }
+ }
}
}
- }
- }
- break;
+ break;
- case H5T_CONV_FREE:
- /*
- * Free the private conversion data.
- */
- priv = (H5T_conv_struct_t *)(cdata->priv);
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv->src_memb_id);
- H5MM_xfree(priv->dst_memb_id);
- H5MM_xfree(priv->memb_path);
- cdata->priv = priv = H5MM_xfree (priv);
- break;
+ case H5T_CONV_FREE:
+ /*
+ * Free the private conversion data.
+ */
+ priv = (H5T_conv_struct_t *)(cdata->priv);
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv->src_memb_id);
+ H5MM_xfree(priv->dst_memb_id);
+ H5MM_xfree(priv->memb_path);
+ cdata->priv = priv = H5MM_xfree (priv);
+ break;
- case H5T_CONV_CONV:
- /*
- * Conversion.
- */
- if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ case H5T_CONV_CONV:
+ /*
+ * Conversion.
+ */
+ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- /* Update cached data if necessary */
- if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize conversion data");
- }
- priv = (H5T_conv_struct_t *)(cdata->priv);
- src2dst = priv->src2dst;
- assert(priv);
- assert(bkg && cdata->need_bkg);
-
- /*
- * Insure that members are sorted.
- */
- H5T_sort_value(src, NULL);
- H5T_sort_value(dst, NULL);
-
- /*
- * Calculate strides. If BUF_STRIDE is non-zero then convert one
- * data element at every BUF_STRIDE bytes through the main buffer
- * (BUF), leaving the result of each conversion at the same
- * location; otherwise assume the source and destination data are
- * packed tightly based on src->size and dst->size. Also, if
- * BUF_STRIDE and BKG_STRIDE are both non-zero then place
- * background data into the BKG buffer at multiples of BKG_STRIDE;
- * otherwise assume BKG buffer is the packed destination datatype.
- */
- if (!buf_stride || !bkg_stride) bkg_stride = dst->size;
-
- /*
- * For each member where the destination is not larger than the
- * source, stride through all the elements converting only that member
- * in each element and then copying the element to its final
- * destination in the bkg buffer. Otherwise move the element as far
- * left as possible in the buffer.
- */
- for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
- if (src2dst[i]<0) continue; /*subsetting*/
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
-
- if (dst_memb->size <= src_memb->size) {
- xbuf = buf + src_memb->offset;
- xbkg = bkg + dst_memb->offset;
- if (H5T_convert(priv->memb_path[i],
- priv->src_memb_id[i],
- priv->dst_memb_id[src2dst[i]], nelmts,
- buf_stride ? buf_stride : src->size,
- bkg_stride, xbuf, xbkg,
- dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data "
- "type member");
- }
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbkg, xbuf, dst_memb->size);
- xbuf += buf_stride ? buf_stride : src->size;
- xbkg += bkg_stride;
- }
- } else {
- for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbuf+offset, xbuf+src_memb->offset,
- src_memb->size);
- xbuf += buf_stride ? buf_stride : src->size;
+ /* Update cached data if necessary */
+ if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize conversion data");
+ priv = (H5T_conv_struct_t *)(cdata->priv);
+ src2dst = priv->src2dst;
+ assert(priv);
+ assert(bkg && cdata->need_bkg);
+
+ /*
+ * Insure that members are sorted.
+ */
+ H5T_sort_value(src, NULL);
+ H5T_sort_value(dst, NULL);
+
+ /*
+ * Calculate strides. If BUF_STRIDE is non-zero then convert one
+ * data element at every BUF_STRIDE bytes through the main buffer
+ * (BUF), leaving the result of each conversion at the same
+ * location; otherwise assume the source and destination data are
+ * packed tightly based on src->size and dst->size. Also, if
+ * BUF_STRIDE and BKG_STRIDE are both non-zero then place
+ * background data into the BKG buffer at multiples of BKG_STRIDE;
+ * otherwise assume BKG buffer is the packed destination datatype.
+ */
+ if (!buf_stride || !bkg_stride) bkg_stride = dst->size;
+
+ /*
+ * For each member where the destination is not larger than the
+ * source, stride through all the elements converting only that member
+ * in each element and then copying the element to its final
+ * destination in the bkg buffer. Otherwise move the element as far
+ * left as possible in the buffer.
+ */
+ for (i=0, offset=0; i<src->u.compnd.nmembs; i++) {
+ if (src2dst[i]<0) continue; /*subsetting*/
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+
+ if (dst_memb->size <= src_memb->size) {
+ xbuf = buf + src_memb->offset;
+ xbkg = bkg + dst_memb->offset;
+ if (H5T_convert(priv->memb_path[i],
+ priv->src_memb_id[i],
+ priv->dst_memb_id[src2dst[i]], nelmts,
+ buf_stride ? buf_stride : src->size,
+ bkg_stride, xbuf, xbkg,
+ dset_xfer_plist)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbkg, xbuf, dst_memb->size);
+ xbuf += buf_stride ? buf_stride : src->size;
+ xbkg += bkg_stride;
+ }
+ } else {
+ for (xbuf=buf, elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbuf+offset, xbuf+src_memb->offset,
+ src_memb->size);
+ xbuf += buf_stride ? buf_stride : src->size;
+ }
+ offset += src_memb->size;
+ }
}
- offset += src_memb->size;
- }
- }
- /*
- * Work from right to left, converting those members that weren't
- * converted in the previous loop (those members where the destination
- * is larger than the source) and them to their final position in the
- * bkg buffer.
- */
- for (i=src->u.compnd.nmembs-1; i>=0; --i) {
- if (src2dst[i]<0)
- continue;
- src_memb = src->u.compnd.memb + i;
- dst_memb = dst->u.compnd.memb + src2dst[i];
-
- if (dst_memb->size > src_memb->size) {
- offset -= src_memb->size;
- xbuf = buf + offset;
- xbkg = bkg + dst_memb->offset;
- if (H5T_convert(priv->memb_path[i],
- priv->src_memb_id[i],
- priv->dst_memb_id[src2dst[i]], nelmts,
+ /*
+ * Work from right to left, converting those members that weren't
+ * converted in the previous loop (those members where the destination
+ * is larger than the source) and them to their final position in the
+ * bkg buffer.
+ */
+ for (i=src->u.compnd.nmembs-1; i>=0; --i) {
+ if (src2dst[i]<0)
+ continue;
+ src_memb = src->u.compnd.memb + i;
+ dst_memb = dst->u.compnd.memb + src2dst[i];
+
+ if (dst_memb->size > src_memb->size) {
+ offset -= src_memb->size;
+ xbuf = buf + offset;
+ xbkg = bkg + dst_memb->offset;
+ if (H5T_convert(priv->memb_path[i],
+ priv->src_memb_id[i],
+ priv->dst_memb_id[src2dst[i]], nelmts,
buf_stride ? buf_stride : src->size,
bkg_stride, xbuf, xbkg,
- dset_xfer_plist)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to convert compound data type "
- "member");
- }
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbkg, xbuf, dst_memb->size);
- xbuf += buf_stride ? buf_stride : src->size;
- xbkg += bkg_stride;
- }
- }
- }
+ dset_xfer_plist)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to convert compound data type member");
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbkg, xbuf, dst_memb->size);
+ xbuf += buf_stride ? buf_stride : src->size;
+ xbkg += bkg_stride;
+ }
+ }
+ }
- /* Move background buffer into result buffer */
- for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
- HDmemmove(xbuf, xbkg, dst->size);
- xbuf += buf_stride ? buf_stride : dst->size;
- xbkg += bkg_stride;
- }
- break;
+ /* Move background buffer into result buffer */
+ for (xbuf=buf, xbkg=bkg, elmtno=0; elmtno<nelmts; elmtno++) {
+ HDmemmove(xbuf, xbkg, dst->size);
+ xbuf += buf_stride ? buf_stride : dst->size;
+ xbkg += bkg_stride;
+ }
+ break;
- default:
- /* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ default:
+ /* Some other command we don't know about yet.*/
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -1808,19 +1778,16 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
int domain[2]; /*min and max source values */
int *map=NULL; /*map from src value to dst idx */
int length; /*nelmts in map array */
- herr_t ret_value=FAIL; /*return value */
int i, j; /*counters */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOINIT(H5T_conv_enum_init);
cdata->need_bkg = H5T_BKG_NO;
- if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(*priv)))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- if (0==src->u.enumer.nmembs) {
- HRETURN(SUCCEED);
- }
+ if (NULL==(priv=cdata->priv=H5MM_calloc(sizeof(*priv))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ if (0==src->u.enumer.nmembs)
+ HGOTO_DONE(SUCCEED);
/*
* Check that the source symbol names are a subset of the destination
@@ -1829,19 +1796,16 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
*/
H5T_sort_name(src, NULL);
H5T_sort_name(dst, NULL);
- if (NULL==(priv->src2dst=H5MM_malloc(src->u.enumer.nmembs*sizeof(int)))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");;
- }
+ if (NULL==(priv->src2dst=H5MM_malloc(src->u.enumer.nmembs*sizeof(int))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");;
for (i=0, j=0;
- i<src->u.enumer.nmembs && j<dst->u.enumer.nmembs;
- i++, j++) {
+ i<src->u.enumer.nmembs && j<dst->u.enumer.nmembs;
+ i++, j++) {
while (j<dst->u.enumer.nmembs &&
- HDstrcmp(src->u.enumer.name[i], dst->u.enumer.name[j])) j++;
- if (j>=dst->u.enumer.nmembs) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "source type is not a subset of destination type");
- }
+ HDstrcmp(src->u.enumer.name[i], dst->u.enumer.name[j]))
+ j++;
+ if (j>=dst->u.enumer.nmembs)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source type is not a subset of destination type");
priv->src2dst[i] = j;
}
@@ -1884,11 +1848,10 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
(double)length/src->u.enumer.nmembs<1.2) {
priv->base = domain[0];
priv->length = length;
- if (NULL==(map=H5MM_malloc(length*sizeof(int)))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed");
- }
- for (i=0; i<length; i++) map[i] = -1; /*entry unused*/
+ if (NULL==(map=H5MM_malloc(length*sizeof(int))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
+ for (i=0; i<length; i++)
+ map[i] = -1; /*entry unused*/
for (i=0; i<src->u.enumer.nmembs; i++) {
if (1==src->size) {
n = *((signed char*)(src->u.enumer.value+i));
@@ -1916,9 +1879,8 @@ H5T_conv_enum_init(H5T_t *src, H5T_t *dst, H5T_cdata_t *cdata)
H5T_sort_value(src, priv->src2dst);
}
}
- ret_value = SUCCEED;
- done:
+done:
if (ret_value<0 && priv) {
H5MM_xfree(priv->src2dst);
H5MM_xfree(priv);
@@ -1960,135 +1922,135 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
int n; /*src value cast as native int */
hsize_t i; /*counters */
H5T_enum_struct_t *priv = (H5T_enum_struct_t*)(cdata->priv);
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_enum, FAIL);
switch (cdata->command) {
- case H5T_CONV_INIT:
- /*
- * Determine if this conversion function applies to the conversion
- * path SRC_ID->DST_ID. If not return failure; otherwise initialize
- * the `priv' field of `cdata' with information about the underlying
- * integer conversion.
- */
- if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- assert (H5T_ENUM==src->type);
- assert (H5T_ENUM==dst->type);
- if (H5T_conv_enum_init(src, dst, cdata)<0) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize private data");
- }
- break;
+ case H5T_CONV_INIT:
+ /*
+ * Determine if this conversion function applies to the conversion
+ * path SRC_ID->DST_ID. If not return failure; otherwise initialize
+ * the `priv' field of `cdata' with information about the underlying
+ * integer conversion.
+ */
+ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ assert (H5T_ENUM==src->type);
+ assert (H5T_ENUM==dst->type);
+ if (H5T_conv_enum_init(src, dst, cdata)<0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to initialize private data");
+ break;
- case H5T_CONV_FREE:
+ case H5T_CONV_FREE:
#ifdef H5T_DEBUG
- if (H5DEBUG(T)) {
- fprintf(H5DEBUG(T), " Using %s mapping function%s\n",
- priv->length?"O(1)":"O(log N)",
- priv->length?"":", where N is the number of enum members");
- }
+ if (H5DEBUG(T)) {
+ fprintf(H5DEBUG(T), " Using %s mapping function%s\n",
+ priv->length?"O(1)":"O(log N)",
+ priv->length?"":", where N is the number of enum members");
+ }
#endif
- if (priv) {
- H5MM_xfree(priv->src2dst);
- H5MM_xfree(priv);
- }
- cdata->priv = NULL;
- break;
+ if (priv) {
+ H5MM_xfree(priv->src2dst);
+ H5MM_xfree(priv);
+ }
+ cdata->priv = NULL;
+ break;
- case H5T_CONV_CONV:
- if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- assert (H5T_ENUM==src->type);
- assert (H5T_ENUM==dst->type);
-
- if (priv->length) {
- /* Use O(1) lookup */
- H5T_sort_name(src, NULL);
- H5T_sort_name(dst, NULL);
- } else {
- /* Use O(log N) lookup */
- H5T_sort_value(src, NULL); /*yes, by value*/
- H5T_sort_name(dst, NULL); /*yes, by name*/
- }
-
- /*
- * Direction of conversion.
- */
- if (buf_stride) {
- src_delta = dst_delta = (int)buf_stride;
- s = d = buf;
- } else if (dst->size <= src->size) {
- src_delta = (int)src->size; /*overflow shouldn't be possible*/
- dst_delta = (int)dst->size; /*overflow shouldn't be possible*/
- s = d = buf;
- } else {
- src_delta = -(int)src->size; /*overflow shouldn't be possible*/
- dst_delta = -(int)dst->size; /*overflow shouldn't be possible*/
- s = buf + (nelmts-1) * src->size;
- d = buf + (nelmts-1) * dst->size;
- }
+ case H5T_CONV_CONV:
+ if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ assert (H5T_ENUM==src->type);
+ assert (H5T_ENUM==dst->type);
- for (i=0; i<nelmts; i++, s+=src_delta, d+=dst_delta) {
- if (priv->length) {
- /* Use O(1) lookup */
- if (1==src->size) {
- n = *((signed char*)s);
- } else if (sizeof(short)==src->size) {
- n = *((short*)s);
- } else {
- n = *((int*)s);
- }
- n -= priv->base;
- if (n<0 || n>=priv->length || priv->src2dst[n]<0) {
- if (!H5T_overflow_g ||
- (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- HDmemset(d, 0xff, dst->size);
- }
- } else {
- HDmemcpy(d,
- dst->u.enumer.value+priv->src2dst[n]*dst->size,
- dst->size);
- }
- } else {
- /* Use O(log N) lookup */
- int lt = 0;
- int rt = src->u.enumer.nmembs;
- int md, cmp;
- while (lt<rt) {
- md = (lt+rt)/2;
- cmp = HDmemcmp(s, src->u.enumer.value+md*src->size,
- src->size);
- if (cmp<0) {
- rt = md;
- } else if (cmp>0) {
- lt = md+1;
- } else {
- break;
- }
- }
- if (lt>=rt) {
- if (!H5T_overflow_g ||
- (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- HDmemset(d, 0xff, dst->size);
- }
- } else {
- HDmemcpy(d,
- dst->u.enumer.value+priv->src2dst[md]*dst->size,
- dst->size);
- }
- }
- }
- break;
+ if (priv->length) {
+ /* Use O(1) lookup */
+ H5T_sort_name(src, NULL);
+ H5T_sort_name(dst, NULL);
+ } else {
+ /* Use O(log N) lookup */
+ H5T_sort_value(src, NULL); /*yes, by value*/
+ H5T_sort_name(dst, NULL); /*yes, by name*/
+ }
+
+ /*
+ * Direction of conversion.
+ */
+ if (buf_stride) {
+ src_delta = dst_delta = (int)buf_stride;
+ s = d = buf;
+ } else if (dst->size <= src->size) {
+ src_delta = (int)src->size; /*overflow shouldn't be possible*/
+ dst_delta = (int)dst->size; /*overflow shouldn't be possible*/
+ s = d = buf;
+ } else {
+ src_delta = -(int)src->size; /*overflow shouldn't be possible*/
+ dst_delta = -(int)dst->size; /*overflow shouldn't be possible*/
+ s = buf + (nelmts-1) * src->size;
+ d = buf + (nelmts-1) * dst->size;
+ }
- default:
- /* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ for (i=0; i<nelmts; i++, s+=src_delta, d+=dst_delta) {
+ if (priv->length) {
+ /* Use O(1) lookup */
+ if (1==src->size) {
+ n = *((signed char*)s);
+ } else if (sizeof(short)==src->size) {
+ n = *((short*)s);
+ } else {
+ n = *((int*)s);
+ }
+ n -= priv->base;
+ if (n<0 || n>=priv->length || priv->src2dst[n]<0) {
+ if (!H5T_overflow_g ||
+ (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ HDmemset(d, 0xff, dst->size);
+ }
+ } else {
+ HDmemcpy(d,
+ dst->u.enumer.value+priv->src2dst[n]*dst->size,
+ dst->size);
+ }
+ } else {
+ /* Use O(log N) lookup */
+ int lt = 0;
+ int rt = src->u.enumer.nmembs;
+ int md, cmp;
+ while (lt<rt) {
+ md = (lt+rt)/2;
+ cmp = HDmemcmp(s, src->u.enumer.value+md*src->size,
+ src->size);
+ if (cmp<0) {
+ rt = md;
+ } else if (cmp>0) {
+ lt = md+1;
+ } else {
+ break;
+ }
+ }
+ if (lt>=rt) {
+ if (!H5T_overflow_g ||
+ (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ HDmemset(d, 0xff, dst->size);
+ }
+ } else {
+ HDmemcpy(d,
+ dst->u.enumer.value+priv->src2dst[md]*dst->size,
+ dst->size);
+ }
+ }
+ }
+ break;
+
+ default:
+ /* Some other command we don't know about yet.*/
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -2157,6 +2119,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
int nested=0; /*flag of nested VL case */
hsize_t elmtno; /*element number counter */
hsize_t i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_vlen, FAIL);
@@ -2171,7 +2134,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
*/
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
assert (H5T_VLEN==src->type);
assert (H5T_VLEN==dst->type);
@@ -2190,7 +2153,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
*/
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/*
* Do we process the values from beginning to end or vice
@@ -2247,16 +2210,15 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Get initial conversion buffer */
conv_buf_size=MAX(src_base_size,dst_base_size);
if ((conv_buf=H5FL_BLK_ALLOC(vlen_seq,conv_buf_size,1))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
/* Set up conversion path for base elements */
if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, NULL, NULL))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes");
} else if (!H5T_IS_NOOP(tpath)) {
if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->parent, H5T_COPY_ALL)))<0 ||
- (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0) {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion");
- }
+ (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion");
}
/* Check if we need a temporary buffer for this conversion */
@@ -2264,7 +2226,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Set up initial background buffer */
tmp_buf_size=MAX(src_base_size,dst_base_size);
if ((tmp_buf=H5FL_BLK_ALLOC(vlen_seq,tmp_buf_size,1))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
} /* end if */
/* Set the flag for nested VL case */
@@ -2287,14 +2249,12 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
if(conv_buf_size<MAX(src_size,dst_size)) {
conv_buf_size=MAX(src_size,dst_size);
if((conv_buf=H5FL_BLK_REALLOC(vlen_seq,conv_buf, conv_buf_size))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for type conversion");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
} /* end if */
/* Read in VL sequence */
if((*(src->u.vlen.read))(src->u.vlen.f,s,conv_buf,src_size)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL,
- "can't read VL data");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL data");
/* Check if temporary buffer is large enough, resize if necessary */
/* (Chain off the conversion buffer size) */
@@ -2303,7 +2263,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Set up initial background buffer */
tmp_buf_size=conv_buf_size;
if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf,tmp_buf_size))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
} /* end if */
/* If we are writing and there is a nested VL type, read
@@ -2317,16 +2277,14 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
tmp_buf_size=bg_seq_len*MAX(src_base_size,
dst_base_size);
if((tmp_buf=H5FL_BLK_REALLOC(vlen_seq,tmp_buf,
- tmp_buf_size))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for type conversion");
+ tmp_buf_size))==NULL)
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
}
H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp,
&(bg_hobjid.addr));
INT32DECODE(tmp, bg_hobjid.idx);
if(H5HG_read(dst->u.vlen.f,&bg_hobjid,tmp_buf)==NULL)
- HRETURN_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL,
- "can't read VL sequence into background buffer");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_READERROR, FAIL, "can't read VL sequence into background buffer");
} /* end if */
/* If the sequence gets shorter, pad out the original sequence with zeros */
@@ -2340,13 +2298,11 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Convert VL sequence */
H5_CHECK_OVERFLOW(seq_len,hssize_t,hsize_t);
if (H5T_convert(tpath, tsrc_id, tdst_id, (hsize_t)seq_len, 0, bkg_stride, conv_buf, tmp_buf, dset_xfer_plist)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "datatype conversion failed");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed");
/* Write sequence to destination location */
if((*(dst->u.vlen.write))(dset_xfer_plist,dst->u.vlen.f,d,conv_buf, bg_ptr, (hsize_t)seq_len,(hsize_t)dst_base_size)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL,
- "can't write VL data");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "can't write VL data");
/* For nested VL case, free leftover heap objects from the deeper level if the length of new data elements is shorted than the old data elements.*/
H5_CHECK_OVERFLOW(bg_seq_len,hsize_t,hssize_t);
@@ -2359,7 +2315,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
H5F_addr_decode(dst->u.vlen.f, (const uint8_t **)&tmp_p, &(parent_hobjid.addr));
INT32DECODE(tmp_p, parent_hobjid.idx);
if(H5HG_remove(dst->u.vlen.f, &parent_hobjid)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object");
}
}
}
@@ -2399,11 +2355,11 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
break;
default: /* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
} /* end switch */
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2438,6 +2394,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
int i; /* local index variable */
void *bkg_buf=NULL; /*temporary background buffer */
size_t bkg_buf_size=0; /*size of background buffer in bytes */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_array, FAIL);
@@ -2452,20 +2409,20 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
*/
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
assert (H5T_ARRAY==src->type);
assert (H5T_ARRAY==dst->type);
/* Check the number and sizes of the dimensions */
if(src->u.array.ndims!=dst->u.array.ndims)
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same number of dimensions");
for(i=0; i<src->u.array.ndims; i++)
if(src->u.array.dim[i]!=dst->u.array.dim[i])
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same sizes of dimensions");
#ifdef LATER
for(i=0; i<src->u.array.ndims; i++)
if(src->u.array.perm[i]!=dst->u.array.perm[i])
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same dimension permutations");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "array datatypes do not have the same dimension permutations");
#endif /* LATER */
/* Array datatypes don't need a background buffer */
@@ -2483,7 +2440,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
*/
if (NULL == (src = H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL == (dst = H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/*
* Do we process the values from beginning to end or vice
@@ -2509,12 +2466,11 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Set up conversion path for base elements */
if (NULL==(tpath=H5T_path_find(src->parent, dst->parent, NULL, NULL))) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unable to convert between src and dest datatypes");
} else if (!H5T_IS_NOOP(tpath)) {
if ((tsrc_id = H5I_register(H5I_DATATYPE, H5T_copy(src->parent, H5T_COPY_ALL)))<0 ||
- (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0) {
- HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion");
- }
+ (tdst_id = H5I_register(H5I_DATATYPE, H5T_copy(dst->parent, H5T_COPY_ALL)))<0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register types for conversion");
}
/* Check if we need a background buffer for this conversion */
@@ -2522,7 +2478,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Allocate background buffer */
bkg_buf_size=src->u.array.nelem*MAX(src->size,dst->size);
if ((bkg_buf=H5FL_BLK_ALLOC(array_seq,bkg_buf_size,0))==NULL)
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion");
} /* end if */
/* Perform the actual conversion */
@@ -2532,7 +2488,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
/* Convert array */
if (H5T_convert(tpath, tsrc_id, tdst_id, (hsize_t)src->u.array.nelem, 0, bkg_stride, dp, bkg_buf, dset_xfer_plist)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype conversion failed");
/* Advance the source & destination pointers */
sp += src_delta;
@@ -2551,11 +2507,11 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
break;
default: /* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
} /* end switch */
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5T_conv_array() */
@@ -2598,291 +2554,286 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
size_t first;
ssize_t sfirst; /*a signed version of `first' */
size_t i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_i_i, FAIL);
switch (cdata->command) {
- case H5T_CONV_INIT:
- if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (H5T_ORDER_LE!=src->u.atomic.order &&
- H5T_ORDER_BE!=src->u.atomic.order) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported byte order");
- }
- if (H5T_ORDER_LE!=dst->u.atomic.order &&
- H5T_ORDER_BE!=dst->u.atomic.order) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported byte order");
- }
- if (dst->size>sizeof dbuf) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "destination size is too large");
- }
- cdata->need_bkg = H5T_BKG_NO;
- break;
-
- case H5T_CONV_FREE:
- break;
-
- case H5T_CONV_CONV:
- /* Get the data types */
- if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
-
- /*
- * Do we process the values from beginning to end or vice versa? Also,
- * how many of the elements have the source and destination areas
- * overlapping?
- */
- if (src->size==dst->size || buf_stride) {
- sp = dp = (uint8_t*)buf;
- direction = 1;
- olap = nelmts;
- } else if (src->size>=dst->size) {
- double olap_d = HDceil((double)(dst->size)/
- (double)(src->size-dst->size));
-
- olap = (size_t)olap_d;
- sp = dp = (uint8_t*)buf;
- direction = 1;
- } else {
- double olap_d = HDceil((double)(src->size)/
- (double)(dst->size-src->size));
- olap = (size_t)olap_d;
- sp = (uint8_t*)buf + (nelmts-1) * src->size;
- dp = (uint8_t*)buf + (nelmts-1) * dst->size;
- direction = -1;
- }
-
- /* The conversion loop */
- for (elmtno=0; elmtno<nelmts; elmtno++) {
-
- /*
- * If the source and destination buffers overlap then use a
- * temporary buffer for the destination.
- */
- if (direction>0) {
- s = sp;
- d = elmtno<olap ? dbuf : dp;
- } else {
- s = sp;
- d = elmtno+olap >= nelmts ? dbuf : dp;
- }
-#ifndef NDEBUG
- /* I don't quite trust the overlap calculations yet --rpm */
- if (d==dbuf) {
- assert ((dp>=sp && dp<sp+src->size) || (sp>=dp && sp<dp+dst->size));
- } else {
- assert ((dp<sp && dp+dst->size<=sp) || (sp<dp && sp+src->size<=dp));
- }
-#endif
-
- /*
- * Put the data in little endian order so our loops aren't so
- * complicated. We'll do all the conversion stuff assuming
- * little endian and then we'll fix the order at the end.
- */
- if (H5T_ORDER_BE==src->u.atomic.order) {
- half_size = src->size/2;
- for (i=0; i<half_size; i++) {
- uint8_t tmp = s[src->size-(i+1)];
- s[src->size-(i+1)] = s[i];
- s[i] = tmp;
- }
- }
+ case H5T_CONV_INIT:
+ if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ if (H5T_ORDER_LE!=src->u.atomic.order &&
+ H5T_ORDER_BE!=src->u.atomic.order)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
+ if (H5T_ORDER_LE!=dst->u.atomic.order &&
+ H5T_ORDER_BE!=dst->u.atomic.order)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
+ if (dst->size>sizeof dbuf)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large");
+ cdata->need_bkg = H5T_BKG_NO;
+ break;
+
+ case H5T_CONV_FREE:
+ break;
- /*
- * What is the bit number for the msb bit of S which is set? The
- * bit number is relative to the significant part of the number.
- */
- sfirst = H5T_bit_find (s, src->u.atomic.offset, src->u.atomic.prec,
- H5T_BIT_MSB, TRUE);
- first = (size_t)sfirst;
+ case H5T_CONV_CONV:
+ /* Get the data types */
+ if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (sfirst<0) {
/*
- * The source has no bits set and must therefore be zero.
- * Set the destination to zero.
- */
- H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE);
-
- } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign &&
- H5T_SGN_NONE==dst->u.atomic.u.i.sign) {
- /*
- * Source and destination are both unsigned, but if the
- * source has more precision bits than the destination then
- * it's possible to overflow. When overflow occurs the
- * destination will be set to the maximum possible value.
+ * Do we process the values from beginning to end or vice versa? Also,
+ * how many of the elements have the source and destination areas
+ * overlapping?
*/
- if (src->u.atomic.prec <= dst->u.atomic.prec) {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- src->u.atomic.prec);
- H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec,
- dst->u.atomic.prec-src->u.atomic.prec, FALSE);
- } else if (first>=dst->u.atomic.prec) {
- /*overflow*/
- if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE);
- }
+ if (src->size==dst->size || buf_stride) {
+ sp = dp = (uint8_t*)buf;
+ direction = 1;
+ olap = nelmts;
+ } else if (src->size>=dst->size) {
+ double olap_d = HDceil((double)(dst->size)/
+ (double)(src->size-dst->size));
+
+ olap = (size_t)olap_d;
+ sp = dp = (uint8_t*)buf;
+ direction = 1;
} else {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- dst->u.atomic.prec);
+ double olap_d = HDceil((double)(src->size)/
+ (double)(dst->size-src->size));
+ olap = (size_t)olap_d;
+ sp = (uint8_t*)buf + (nelmts-1) * src->size;
+ dp = (uint8_t*)buf + (nelmts-1) * dst->size;
+ direction = -1;
}
-
- } else if (H5T_SGN_2==src->u.atomic.u.i.sign &&
- H5T_SGN_NONE==dst->u.atomic.u.i.sign) {
- /*
- * If the source is signed and the destination isn't then we
- * can have overflow if the source contains more bits than
- * the destination (destination is set to the maximum
- * possible value) or overflow if the source is negative
- * (destination is set to zero).
- */
- if (first+1 == src->u.atomic.prec) {
- /*overflow*/
- if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE);
+
+ /* The conversion loop */
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+
+ /*
+ * If the source and destination buffers overlap then use a
+ * temporary buffer for the destination.
+ */
+ if (direction>0) {
+ s = sp;
+ d = elmtno<olap ? dbuf : dp;
+ } else {
+ s = sp;
+ d = elmtno+olap >= nelmts ? dbuf : dp;
}
- } else if (src->u.atomic.prec < dst->u.atomic.prec) {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- src->u.atomic.prec-1);
- H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec-1,
- (dst->u.atomic.prec-src->u.atomic.prec)+1, FALSE);
- } else if (first>=dst->u.atomic.prec) {
- /*overflow*/
- if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE);
+#ifndef NDEBUG
+ /* I don't quite trust the overlap calculations yet --rpm */
+ if (d==dbuf) {
+ assert ((dp>=sp && dp<sp+src->size) || (sp>=dp && sp<dp+dst->size));
+ } else {
+ assert ((dp<sp && dp+dst->size<=sp) || (sp<dp && sp+src->size<=dp));
}
- } else {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- dst->u.atomic.prec);
- }
-
- } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign &&
- H5T_SGN_2==dst->u.atomic.u.i.sign) {
- /*
- * If the source is not signed but the destination is then
- * overflow can occur in which case the destination is set to
- * the largest possible value (all bits set except the msb).
- */
- if (first+1 >= dst->u.atomic.prec) {
- /*overflow*/
- if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE);
- H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE);
+#endif
+
+ /*
+ * Put the data in little endian order so our loops aren't so
+ * complicated. We'll do all the conversion stuff assuming
+ * little endian and then we'll fix the order at the end.
+ */
+ if (H5T_ORDER_BE==src->u.atomic.order) {
+ half_size = src->size/2;
+ for (i=0; i<half_size; i++) {
+ uint8_t tmp = s[src->size-(i+1)];
+ s[src->size-(i+1)] = s[i];
+ s[i] = tmp;
+ }
}
- } else if (src->u.atomic.prec<dst->u.atomic.prec) {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- src->u.atomic.prec);
- H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec,
- dst->u.atomic.prec-src->u.atomic.prec, FALSE);
- } else {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- dst->u.atomic.prec);
- }
-
- } else if (first+1 == src->u.atomic.prec) {
- /*
- * Both the source and the destination are signed and the
- * source value is negative. We could experience overflow
- * if the destination isn't wide enough in which case the
- * destination is set to a negative number with the largest
- * possible magnitude.
- */
- ssize_t sfz = H5T_bit_find (s, src->u.atomic.offset,
- src->u.atomic.prec-1, H5T_BIT_MSB, FALSE);
- size_t fz = (size_t)sfz;
-
- if (sfz>=0 && fz+1>=dst->u.atomic.prec) {
- /*overflow*/
- if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, FALSE);
- H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, TRUE);
+
+ /*
+ * What is the bit number for the msb bit of S which is set? The
+ * bit number is relative to the significant part of the number.
+ */
+ sfirst = H5T_bit_find (s, src->u.atomic.offset, src->u.atomic.prec,
+ H5T_BIT_MSB, TRUE);
+ first = (size_t)sfirst;
+
+ if (sfirst<0) {
+ /*
+ * The source has no bits set and must therefore be zero.
+ * Set the destination to zero.
+ */
+ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE);
+
+ } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign &&
+ H5T_SGN_NONE==dst->u.atomic.u.i.sign) {
+ /*
+ * Source and destination are both unsigned, but if the
+ * source has more precision bits than the destination then
+ * it's possible to overflow. When overflow occurs the
+ * destination will be set to the maximum possible value.
+ */
+ if (src->u.atomic.prec <= dst->u.atomic.prec) {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ src->u.atomic.prec);
+ H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec,
+ dst->u.atomic.prec-src->u.atomic.prec, FALSE);
+ } else if (first>=dst->u.atomic.prec) {
+ /*overflow*/
+ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE);
+ }
+ } else {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ dst->u.atomic.prec);
+ }
+
+ } else if (H5T_SGN_2==src->u.atomic.u.i.sign &&
+ H5T_SGN_NONE==dst->u.atomic.u.i.sign) {
+ /*
+ * If the source is signed and the destination isn't then we
+ * can have overflow if the source contains more bits than
+ * the destination (destination is set to the maximum
+ * possible value) or overflow if the source is negative
+ * (destination is set to zero).
+ */
+ if (first+1 == src->u.atomic.prec) {
+ /*overflow*/
+ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, FALSE);
+ }
+ } else if (src->u.atomic.prec < dst->u.atomic.prec) {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ src->u.atomic.prec-1);
+ H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec-1,
+ (dst->u.atomic.prec-src->u.atomic.prec)+1, FALSE);
+ } else if (first>=dst->u.atomic.prec) {
+ /*overflow*/
+ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec, TRUE);
+ }
+ } else {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ dst->u.atomic.prec);
+ }
+
+ } else if (H5T_SGN_NONE==src->u.atomic.u.i.sign &&
+ H5T_SGN_2==dst->u.atomic.u.i.sign) {
+ /*
+ * If the source is not signed but the destination is then
+ * overflow can occur in which case the destination is set to
+ * the largest possible value (all bits set except the msb).
+ */
+ if (first+1 >= dst->u.atomic.prec) {
+ /*overflow*/
+ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE);
+ H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE);
+ }
+ } else if (src->u.atomic.prec<dst->u.atomic.prec) {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ src->u.atomic.prec);
+ H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec,
+ dst->u.atomic.prec-src->u.atomic.prec, FALSE);
+ } else {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ dst->u.atomic.prec);
+ }
+
+ } else if (first+1 == src->u.atomic.prec) {
+ /*
+ * Both the source and the destination are signed and the
+ * source value is negative. We could experience overflow
+ * if the destination isn't wide enough in which case the
+ * destination is set to a negative number with the largest
+ * possible magnitude.
+ */
+ ssize_t sfz = H5T_bit_find (s, src->u.atomic.offset,
+ src->u.atomic.prec-1, H5T_BIT_MSB, FALSE);
+ size_t fz = (size_t)sfz;
+
+ if (sfz>=0 && fz+1>=dst->u.atomic.prec) {
+ /*overflow*/
+ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, FALSE);
+ H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, TRUE);
+ }
+ } else if (src->u.atomic.prec<dst->u.atomic.prec) {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, src->u.atomic.prec);
+ H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, dst->u.atomic.prec-src->u.atomic.prec, TRUE);
+ } else {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, dst->u.atomic.prec);
+ }
+
+ } else {
+ /*
+ * Source and destination are both signed but the source
+ * value is positive. We could have an overflow in which
+ * case the destination is set to the largest possible
+ * positive value.
+ */
+ if (first+1>=dst->u.atomic.prec) {
+ /*overflow*/
+ if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
+ H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE);
+ H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE);
+ }
+ } else if (src->u.atomic.prec<dst->u.atomic.prec) {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ src->u.atomic.prec);
+ H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec,
+ dst->u.atomic.prec-src->u.atomic.prec, FALSE);
+ } else {
+ H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
+ dst->u.atomic.prec);
+ }
}
- } else if (src->u.atomic.prec<dst->u.atomic.prec) {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, src->u.atomic.prec);
- H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec, dst->u.atomic.prec-src->u.atomic.prec, TRUE);
- } else {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset, dst->u.atomic.prec);
- }
-
- } else {
- /*
- * Source and destination are both signed but the source
- * value is positive. We could have an overflow in which
- * case the destination is set to the largest possible
- * positive value.
- */
- if (first+1>=dst->u.atomic.prec) {
- /*overflow*/
- if (!H5T_overflow_g || (H5T_overflow_g)(src_id, dst_id, s, d)<0) {
- H5T_bit_set (d, dst->u.atomic.offset, dst->u.atomic.prec-1, TRUE);
- H5T_bit_set (d, (dst->u.atomic.offset + dst->u.atomic.prec-1), 1, FALSE);
+
+ /*
+ * Set padding areas in destination.
+ */
+ if (dst->u.atomic.offset>0) {
+ assert (H5T_PAD_ZERO==dst->u.atomic.lsb_pad || H5T_PAD_ONE==dst->u.atomic.lsb_pad);
+ H5T_bit_set (d, 0, dst->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->u.atomic.lsb_pad));
+ }
+ if (dst->u.atomic.offset+dst->u.atomic.prec!=8*dst->size) {
+ assert (H5T_PAD_ZERO==dst->u.atomic.msb_pad || H5T_PAD_ONE==dst->u.atomic.msb_pad);
+ H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec,
+ 8*dst->size - (dst->u.atomic.offset+ dst->u.atomic.prec),
+ (hbool_t)(H5T_PAD_ONE==dst->u.atomic.msb_pad));
}
- } else if (src->u.atomic.prec<dst->u.atomic.prec) {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- src->u.atomic.prec);
- H5T_bit_set (d, dst->u.atomic.offset+src->u.atomic.prec,
- dst->u.atomic.prec-src->u.atomic.prec, FALSE);
- } else {
- H5T_bit_copy (d, dst->u.atomic.offset, s, src->u.atomic.offset,
- dst->u.atomic.prec);
- }
- }
- /*
- * Set padding areas in destination.
- */
- if (dst->u.atomic.offset>0) {
- assert (H5T_PAD_ZERO==dst->u.atomic.lsb_pad || H5T_PAD_ONE==dst->u.atomic.lsb_pad);
- H5T_bit_set (d, 0, dst->u.atomic.offset, (hbool_t)(H5T_PAD_ONE==dst->u.atomic.lsb_pad));
- }
- if (dst->u.atomic.offset+dst->u.atomic.prec!=8*dst->size) {
- assert (H5T_PAD_ZERO==dst->u.atomic.msb_pad || H5T_PAD_ONE==dst->u.atomic.msb_pad);
- H5T_bit_set (d, dst->u.atomic.offset+dst->u.atomic.prec,
- 8*dst->size - (dst->u.atomic.offset+ dst->u.atomic.prec),
- (hbool_t)(H5T_PAD_ONE==dst->u.atomic.msb_pad));
- }
+ /*
+ * Put the destination in the correct byte order. See note at
+ * beginning of loop.
+ */
+ if (H5T_ORDER_BE==dst->u.atomic.order) {
+ half_size = dst->size/2;
+ for (i=0; i<half_size; i++) {
+ uint8_t tmp = d[dst->size-(i+1)];
+ d[dst->size-(i+1)] = d[i];
+ d[i] = tmp;
+ }
+ }
- /*
- * Put the destination in the correct byte order. See note at
- * beginning of loop.
- */
- if (H5T_ORDER_BE==dst->u.atomic.order) {
- half_size = dst->size/2;
- for (i=0; i<half_size; i++) {
- uint8_t tmp = d[dst->size-(i+1)];
- d[dst->size-(i+1)] = d[i];
- d[i] = tmp;
+ /*
+ * If we had used a temporary buffer for the destination then we
+ * should copy the value to the true destination buffer.
+ */
+ if (d==dbuf)
+ HDmemcpy (dp, d, dst->size);
+ if (buf_stride) {
+ sp += direction * buf_stride;
+ dp += direction * buf_stride;
+ } else {
+ sp += direction * src->size;
+ dp += direction * dst->size;
+ }
}
- }
-
- /*
- * If we had used a temporary buffer for the destination then we
- * should copy the value to the true destination buffer.
- */
- if (d==dbuf)
- HDmemcpy (dp, d, dst->size);
- if (buf_stride) {
- sp += direction * buf_stride;
- dp += direction * buf_stride;
- } else {
- sp += direction * src->size;
- dp += direction * dst->size;
- }
- }
-
- break;
+
+ break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ default:
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -2941,313 +2892,224 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
hbool_t carry=0; /*carry after rounding mantissa */
size_t i; /*miscellaneous counters */
hsize_t implied; /*destination implied bits */
+
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_f_f, FAIL);
switch (cdata->command) {
- case H5T_CONV_INIT:
- if (NULL==(src_p=H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL==(dst_p=H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- src = src_p->u.atomic;
- dst = dst_p->u.atomic;
- if (H5T_ORDER_LE!=src.order &&
- H5T_ORDER_BE!=src.order) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported byte order");
- }
- if (H5T_ORDER_LE!=dst.order &&
- H5T_ORDER_BE!=dst.order) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported byte order");
- }
- if (dst_p->size>sizeof(dbuf)) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "destination size is too large");
- }
- if (8*sizeof(expo)-1<src.u.f.esize ||
- 8*sizeof(expo)-1<dst.u.f.esize) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "exponent field is too large");
- }
- cdata->need_bkg = H5T_BKG_NO;
- break;
+ case H5T_CONV_INIT:
+ if (NULL==(src_p=H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL==(dst_p=H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ src = src_p->u.atomic;
+ dst = dst_p->u.atomic;
+ if (H5T_ORDER_LE!=src.order && H5T_ORDER_BE!=src.order)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
+ if (H5T_ORDER_LE!=dst.order && H5T_ORDER_BE!=dst.order)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order");
+ if (dst_p->size>sizeof(dbuf))
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination size is too large");
+ if (8*sizeof(expo)-1<src.u.f.esize || 8*sizeof(expo)-1<dst.u.f.esize)
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "exponent field is too large");
+ cdata->need_bkg = H5T_BKG_NO;
+ break;
- case H5T_CONV_FREE:
- break;
+ case H5T_CONV_FREE:
+ break;
- case H5T_CONV_CONV:
- /* Get the data types */
- if (NULL==(src_p=H5I_object_verify(src_id,H5I_DATATYPE)) ||
- NULL==(dst_p=H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- src = src_p->u.atomic;
- dst = dst_p->u.atomic;
- expo_max = ((hssize_t)1 << dst.u.f.esize) - 1;
-
- /*
- * Do we process the values from beginning to end or vice versa? Also,
- * how many of the elements have the source and destination areas
- * overlapping?
- */
- if (src_p->size==dst_p->size || buf_stride) {
- sp = dp = (uint8_t*)buf;
- direction = 1;
- olap = nelmts;
- } else if (src_p->size>=dst_p->size) {
- double olap_d = HDceil((double)(dst_p->size)/
- (double)(src_p->size-dst_p->size));
- olap = (size_t)olap_d;
- sp = dp = (uint8_t*)buf;
- direction = 1;
- } else {
- double olap_d = HDceil((double)(src_p->size)/
- (double)(dst_p->size-src_p->size));
- olap = (size_t)olap_d;
- sp = (uint8_t*)buf + (nelmts-1) * src_p->size;
- dp = (uint8_t*)buf + (nelmts-1) * dst_p->size;
- direction = -1;
- }
+ case H5T_CONV_CONV:
+ /* Get the data types */
+ if (NULL==(src_p=H5I_object_verify(src_id,H5I_DATATYPE)) ||
+ NULL==(dst_p=H5I_object_verify(dst_id,H5I_DATATYPE)))
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ src = src_p->u.atomic;
+ dst = dst_p->u.atomic;
+ expo_max = ((hssize_t)1 << dst.u.f.esize) - 1;
- /* The conversion loop */
- for (elmtno=0; elmtno<nelmts; elmtno++) {
- /*
- * If the source and destination buffers overlap then use a
- * temporary buffer for the destination.
- */
- if (direction>0) {
- s = sp;
- d = elmtno<olap ? dbuf : dp;
- } else {
- s = sp;
- d = elmtno+olap >= nelmts ? dbuf : dp;
- }
+ /*
+ * Do we process the values from beginning to end or vice versa? Also,
+ * how many of the elements have the source and destination areas
+ * overlapping?
+ */
+ if (src_p->size==dst_p->size || buf_stride) {
+ sp = dp = (uint8_t*)buf;
+ direction = 1;
+ olap = nelmts;
+ } else if (src_p->size>=dst_p->size) {
+ double olap_d = HDceil((double)(dst_p->size)/
+ (double)(src_p->size-dst_p->size));
+ olap = (size_t)olap_d;
+ sp = dp = (uint8_t*)buf;
+ direction = 1;
+ } else {
+ double olap_d = HDceil((double)(src_p->size)/
+ (double)(dst_p->size-src_p->size));
+ olap = (size_t)olap_d;
+ sp = (uint8_t*)buf + (nelmts-1) * src_p->size;
+ dp = (uint8_t*)buf + (nelmts-1) * dst_p->size;
+ direction = -1;
+ }
+
+ /* The conversion loop */
+ for (elmtno=0; elmtno<nelmts; elmtno++) {
+ /*
+ * If the source and destination buffers overlap then use a
+ * temporary buffer for the destination.
+ */
+ if (direction>0) {
+ s = sp;
+ d = elmtno<olap ? dbuf : dp;
+ } else {
+ s = sp;
+ d = elmtno+olap >= nelmts ? dbuf : dp;
+ }
#ifndef NDEBUG
- /* I don't quite trust the overlap calculations yet --rpm */
- if (d==dbuf) {
- assert ((dp>=sp && dp<sp+src_p->size) ||
- (sp>=dp && sp<dp+dst_p->size));
- } else {
- assert ((dp<sp && dp+dst_p->size<=sp) ||
- (sp<dp && sp+src_p->size<=dp));
- }
+ /* I don't quite trust the overlap calculations yet --rpm */
+ if (d==dbuf) {
+ assert ((dp>=sp && dp<sp+src_p->size) ||
+ (sp>=dp && sp<dp+dst_p->size));
+ } else {
+ assert ((dp<sp && dp+dst_p->size<=sp) ||
+ (sp<dp && sp+src_p->size<=dp));
+ }
#endif
-
- /*
- * Put the data in little endian order so our loops aren't so
- * complicated. We'll do all the conversion stuff assuming
- * little endian and then we'll fix the order at the end.
- */
- if (H5T_ORDER_BE==src.order) {
- half_size = src_p->size/2;
- for (i=0; i<half_size; i++) {
- uint8_t tmp = s[src_p->size-(i+1)];
- s[src_p->size-(i+1)] = s[i];
- s[i] = tmp;
- }
- }
-
- /*
- * Check for special cases: +0, -0, +Inf, -Inf, NaN
- */
- if (H5T_bit_find (s, src.u.f.mpos, src.u.f.msize,
- H5T_BIT_LSB, TRUE)<0) {
- if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
- H5T_BIT_LSB, TRUE)<0) {
- /* +0 or -0 */
- H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
- H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE);
- H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
- goto padding;
- } else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
- H5T_BIT_LSB, FALSE)<0) {
- /* +Inf or -Inf */
- H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
- H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
- H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
- goto padding;
- }
- } else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
- H5T_BIT_LSB, FALSE)<0) {
- /*
- * NaN. There are many NaN values, so we just set all bits of
- * the significand.
- */
- H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
- H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
- H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE);
- goto padding;
- }
+
+ /*
+ * Put the data in little endian order so our loops aren't so
+ * complicated. We'll do all the conversion stuff assuming
+ * little endian and then we'll fix the order at the end.
+ */
+ if (H5T_ORDER_BE==src.order) {
+ half_size = src_p->size/2;
+ for (i=0; i<half_size; i++) {
+ uint8_t tmp = s[src_p->size-(i+1)];
+ s[src_p->size-(i+1)] = s[i];
+ s[i] = tmp;
+ }
+ }
- /*
- * Get the exponent as an unsigned quantity from the section of
- * the source bit field where it's located. Don't worry about
- * the exponent bias yet.
- */
- expo = H5T_bit_get_d(s, src.u.f.epos, src.u.f.esize);
-
- /*
- * Set markers for the source mantissa, excluding the leading `1'
- * (might be implied).
- */
- implied = 1;
- mpos = src.u.f.mpos;
- mrsh = 0;
- if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
- if ((bitno=H5T_bit_find(s, src.u.f.mpos, src.u.f.msize,
- H5T_BIT_MSB, TRUE))>0) {
- msize = bitno;
- } else if (0==bitno) {
- msize = 1;
- H5T_bit_set(s, src.u.f.mpos, 1, FALSE);
- }
- } else if (H5T_NORM_IMPLIED==src.u.f.norm) {
- msize = src.u.f.msize;
- } else {
- assert("normalization method not implemented yet" && 0);
- HDabort();
- }
-
- /*
- * The sign for the destination is the same as the sign for the
- * source in all cases.
- */
- H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
+ /*
+ * Check for special cases: +0, -0, +Inf, -Inf, NaN
+ */
+ if (H5T_bit_find (s, src.u.f.mpos, src.u.f.msize,
+ H5T_BIT_LSB, TRUE)<0) {
+ if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
+ H5T_BIT_LSB, TRUE)<0) {
+ /* +0 or -0 */
+ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
+ H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE);
+ H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
+ goto padding;
+ } else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
+ H5T_BIT_LSB, FALSE)<0) {
+ /* +Inf or -Inf */
+ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
+ H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
+ H5T_bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE);
+ goto padding;
+ }
+ } else if (H5T_bit_find (s, src.u.f.epos, src.u.f.esize,
+ H5T_BIT_LSB, FALSE)<0) {
+ /*
+ * NaN. There are many NaN values, so we just set all bits of
+ * the significand.
+ */
+ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
+ H5T_bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE);
+ H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE);
+ goto padding;
+ }
- /*
- * Calculate the true source exponent by adjusting according to
- * the source exponent bias.
- */
- if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
- bitno = H5T_bit_find(s, src.u.f.mpos, src.u.f.msize,
- H5T_BIT_MSB, TRUE);
- assert(bitno>=0);
- expo -= (src.u.f.ebias-1) + (src.u.f.msize-bitno);
- } else if (H5T_NORM_IMPLIED==src.u.f.norm) {
- expo -= src.u.f.ebias;
- } else {
- assert("normalization method not implemented yet" && 0);
- HDabort();
- }
+ /*
+ * Get the exponent as an unsigned quantity from the section of
+ * the source bit field where it's located. Don't worry about
+ * the exponent bias yet.
+ */
+ expo = H5T_bit_get_d(s, src.u.f.epos, src.u.f.esize);
+
+ /*
+ * Set markers for the source mantissa, excluding the leading `1'
+ * (might be implied).
+ */
+ implied = 1;
+ mpos = src.u.f.mpos;
+ mrsh = 0;
+ if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
+ if ((bitno=H5T_bit_find(s, src.u.f.mpos, src.u.f.msize,
+ H5T_BIT_MSB, TRUE))>0) {
+ msize = bitno;
+ } else if (0==bitno) {
+ msize = 1;
+ H5T_bit_set(s, src.u.f.mpos, 1, FALSE);
+ }
+ } else if (H5T_NORM_IMPLIED==src.u.f.norm) {
+ msize = src.u.f.msize;
+ } else {
+ assert("normalization method not implemented yet" && 0);
+ HDabort();
+ }
+
+ /*
+ * The sign for the destination is the same as the sign for the
+ * source in all cases.
+ */
+ H5T_bit_copy (d, dst.u.f.sign, s, src.u.f.sign, 1);
- /*
- * If the destination is not normalized then right shift the
- * mantissa by one.
- */
- if (H5T_NORM_NONE==dst.u.f.norm) {
- mrsh++;
- }
+ /*
+ * Calculate the true source exponent by adjusting according to
+ * the source exponent bias.
+ */
+ if (0==expo || H5T_NORM_NONE==src.u.f.norm) {
+ bitno = H5T_bit_find(s, src.u.f.mpos, src.u.f.msize,
+ H5T_BIT_MSB, TRUE);
+ assert(bitno>=0);
+ expo -= (src.u.f.ebias-1) + (src.u.f.msize-bitno);
+ } else if (H5T_NORM_IMPLIED==src.u.f.norm) {
+ expo -= src.u.f.ebias;
+ } else {
+ assert("normalization method not implemented yet" && 0);
+ HDabort();
+ }
- /*
- * Calculate the destination exponent by adding the destination
- * bias and clipping by the minimum and maximum possible
- * destination exponent values.
- */
- expo += dst.u.f.ebias;
- if (expo < -(hssize_t)(dst.u.f.msize)) {
- /* The exponent is way too small. Result is zero. */
- expo = 0;
- H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
- msize = 0;
-
- } else if (expo<=0) {
- /*
- * The exponent is too small to fit in the exponent field,
- * but by shifting the mantissa to the right we can
- * accomodate that value. The mantissa of course is no
- * longer normalized.
- */
- H5_ASSIGN_OVERFLOW(mrsh,(mrsh+1-expo),hssize_t,size_t);
- /*mrsh += 1-expo;*/
- expo = 0;
-
- } else if (expo>=expo_max) {
- /*
- * The exponent is too large to fit in the available region
- * or it results in the maximum possible value. Use positive
- * or negative infinity instead unless the application
- * specifies something else. Before calling the overflow
- * handler make sure the source buffer we hand it is in the
- * original byte order.
- */
- if (H5T_overflow_g) {
- uint8_t over_src[256];
- assert(src_p->size<=sizeof over_src);
- if (H5T_ORDER_BE==src.order) {
- for (i=0; i<src_p->size; i++) {
- over_src[src_p->size-(i+1)] = s[i];
- }
- } else {
- for (i=0; i<src_p->size; i++) {
- over_src[i] = s[i];
- }
- }
- if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0) {
- goto next;
- }
- }
- expo = expo_max;
- H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
- msize = 0;
- }
+ /*
+ * If the destination is not normalized then right shift the
+ * mantissa by one.
+ */
+ if (H5T_NORM_NONE==dst.u.f.norm)
+ mrsh++;
- /*
- * If the destination mantissa is smaller than the source
- * mantissa then round the source mantissa. Rounding may cause a
- * carry in which case the exponent has to be re-evaluated for
- * overflow. That is, if `carry' is clear then the implied
- * mantissa bit is `1', else it is `10' binary.
- */
- if (msize>0 && mrsh<=dst.u.f.msize && mrsh+msize>dst.u.f.msize) {
- bitno = (ssize_t)(mrsh+msize - dst.u.f.msize);
- assert(bitno>=0 && (size_t)bitno<=msize);
- carry = H5T_bit_inc(s, mpos+bitno-1, 1+msize-bitno);
- if (carry) implied = 2;
- }
- else
- carry=0;
+ /*
+ * Calculate the destination exponent by adding the destination
+ * bias and clipping by the minimum and maximum possible
+ * destination exponent values.
+ */
+ expo += dst.u.f.ebias;
+ if (expo < -(hssize_t)(dst.u.f.msize)) {
+ /* The exponent is way too small. Result is zero. */
+ expo = 0;
+ H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
+ msize = 0;
- /*
- * Write the mantissa to the destination
- */
- if (mrsh>dst.u.f.msize+1) {
- H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
- } else if (mrsh==dst.u.f.msize+1) {
- H5T_bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE);
- H5T_bit_set(d, dst.u.f.mpos, 1, TRUE);
- } else if (mrsh==dst.u.f.msize) {
- H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
- H5T_bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), implied);
- } else {
- if (mrsh>0) {
- H5T_bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh,
- FALSE);
- H5T_bit_set_d(d, dst.u.f.mpos+dst.u.f.msize-mrsh, 2,
- implied);
- }
- if (mrsh+msize>=dst.u.f.msize) {
- H5T_bit_copy(d, dst.u.f.mpos,
- s, (mpos+msize+mrsh-dst.u.f.msize),
- dst.u.f.msize-mrsh);
- } else {
- H5T_bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize),
- s, mpos, msize);
- H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize),
- FALSE);
- }
- }
-
- /* Write the exponent */
- if (carry) {
- expo++;
- if (expo>=expo_max) {
+ } else if (expo<=0) {
+ /*
+ * The exponent is too small to fit in the exponent field,
+ * but by shifting the mantissa to the right we can
+ * accomodate that value. The mantissa of course is no
+ * longer normalized.
+ */
+ H5_ASSIGN_OVERFLOW(mrsh,(mrsh+1-expo),hssize_t,size_t);
+ /*mrsh += 1-expo;*/
+ expo = 0;
+
+ } else if (expo>=expo_max) {
/*
- * The exponent is too large to fit in the available
- * region or it results in the maximum possible value.
- * Use positive or negative infinity instead unless the
- * application specifies something else. Before
- * calling the overflow handler make sure the source
- * buffer we hand it is in the original byte order.
+ * The exponent is too large to fit in the available region
+ * or it results in the maximum possible value. Use positive
+ * or negative infinity instead unless the application
+ * specifies something else. Before calling the overflow
+ * handler make sure the source buffer we hand it is in the
+ * original byte order.
*/
if (H5T_overflow_g) {
uint8_t over_src[256];
@@ -3267,67 +3129,145 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
}
expo = expo_max;
H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
+ msize = 0;
}
- }
- H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t);
- H5T_bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo);
- padding:
+ /*
+ * If the destination mantissa is smaller than the source
+ * mantissa then round the source mantissa. Rounding may cause a
+ * carry in which case the exponent has to be re-evaluated for
+ * overflow. That is, if `carry' is clear then the implied
+ * mantissa bit is `1', else it is `10' binary.
+ */
+ if (msize>0 && mrsh<=dst.u.f.msize && mrsh+msize>dst.u.f.msize) {
+ bitno = (ssize_t)(mrsh+msize - dst.u.f.msize);
+ assert(bitno>=0 && (size_t)bitno<=msize);
+ carry = H5T_bit_inc(s, mpos+bitno-1, 1+msize-bitno);
+ if (carry)
+ implied = 2;
+ }
+ else
+ carry=0;
+
+ /*
+ * Write the mantissa to the destination
+ */
+ if (mrsh>dst.u.f.msize+1) {
+ H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
+ } else if (mrsh==dst.u.f.msize+1) {
+ H5T_bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE);
+ H5T_bit_set(d, dst.u.f.mpos, 1, TRUE);
+ } else if (mrsh==dst.u.f.msize) {
+ H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
+ H5T_bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), implied);
+ } else {
+ if (mrsh>0) {
+ H5T_bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh,
+ FALSE);
+ H5T_bit_set_d(d, dst.u.f.mpos+dst.u.f.msize-mrsh, 2,
+ implied);
+ }
+ if (mrsh+msize>=dst.u.f.msize) {
+ H5T_bit_copy(d, dst.u.f.mpos,
+ s, (mpos+msize+mrsh-dst.u.f.msize),
+ dst.u.f.msize-mrsh);
+ } else {
+ H5T_bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize),
+ s, mpos, msize);
+ H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize),
+ FALSE);
+ }
+ }
+
+ /* Write the exponent */
+ if (carry) {
+ expo++;
+ if (expo>=expo_max) {
+ /*
+ * The exponent is too large to fit in the available
+ * region or it results in the maximum possible value.
+ * Use positive or negative infinity instead unless the
+ * application specifies something else. Before
+ * calling the overflow handler make sure the source
+ * buffer we hand it is in the original byte order.
+ */
+ if (H5T_overflow_g) {
+ uint8_t over_src[256];
+ assert(src_p->size<=sizeof over_src);
+ if (H5T_ORDER_BE==src.order) {
+ for (i=0; i<src_p->size; i++)
+ over_src[src_p->size-(i+1)] = s[i];
+ } else {
+ for (i=0; i<src_p->size; i++)
+ over_src[i] = s[i];
+ }
+ if ((H5T_overflow_g)(src_id, dst_id, over_src, d)>=0)
+ goto next;
+ }
+ expo = expo_max;
+ H5T_bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE);
+ }
+ }
+ H5_CHECK_OVERFLOW(expo,hssize_t,hsize_t);
+ H5T_bit_set_d(d, dst.u.f.epos, dst.u.f.esize, (hsize_t)expo);
+
+ padding:
#ifndef LATER
- /*
- * Set internal padding areas
- */
+ /*
+ * Set internal padding areas
+ */
#endif
- /*
- * Set external padding areas
- */
- if (dst.offset>0) {
- assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad);
- H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad));
- }
- if (dst.offset+dst.prec!=8*dst_p->size) {
- assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad);
- H5T_bit_set (d, dst.offset+dst.prec, 8*dst_p->size - (dst.offset+dst.prec),
- (hbool_t)(H5T_PAD_ONE==dst.msb_pad));
- }
+ /*
+ * Set external padding areas
+ */
+ if (dst.offset>0) {
+ assert (H5T_PAD_ZERO==dst.lsb_pad || H5T_PAD_ONE==dst.lsb_pad);
+ H5T_bit_set (d, 0, dst.offset, (hbool_t)(H5T_PAD_ONE==dst.lsb_pad));
+ }
+ if (dst.offset+dst.prec!=8*dst_p->size) {
+ assert (H5T_PAD_ZERO==dst.msb_pad || H5T_PAD_ONE==dst.msb_pad);
+ H5T_bit_set (d, dst.offset+dst.prec, 8*dst_p->size - (dst.offset+dst.prec),
+ (hbool_t)(H5T_PAD_ONE==dst.msb_pad));
+ }
- /*
- * Put the destination in the correct byte order. See note at
- * beginning of loop.
- */
- if (H5T_ORDER_BE==dst.order) {
- half_size = dst_p->size/2;
- for (i=0; i<half_size; i++) {
- uint8_t tmp = d[dst_p->size-(i+1)];
- d[dst_p->size-(i+1)] = d[i];
- d[i] = tmp;
- }
- }
+ /*
+ * Put the destination in the correct byte order. See note at
+ * beginning of loop.
+ */
+ if (H5T_ORDER_BE==dst.order) {
+ half_size = dst_p->size/2;
+ for (i=0; i<half_size; i++) {
+ uint8_t tmp = d[dst_p->size-(i+1)];
+ d[dst_p->size-(i+1)] = d[i];
+ d[i] = tmp;
+ }
+ }
- /*
- * If we had used a temporary buffer for the destination then we
- * should copy the value to the true destination buffer.
- */
- next:
- if (d==dbuf) HDmemcpy (dp, d, dst_p->size);
- if (buf_stride) {
- sp += direction * buf_stride;
- dp += direction * buf_stride;
- } else {
- sp += direction * src_p->size;
- dp += direction * dst_p->size;
- }
- }
-
- break;
-
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ /*
+ * If we had used a temporary buffer for the destination then we
+ * should copy the value to the true destination buffer.
+ */
+ next:
+ if (d==dbuf)
+ HDmemcpy (dp, d, dst_p->size);
+ if (buf_stride) {
+ sp += direction * buf_stride;
+ dp += direction * buf_stride;
+ } else {
+ sp += direction * src_p->size;
+ dp += direction * dst_p->size;
+ }
+ }
+
+ break;
+
+ default:
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -3362,7 +3302,7 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
size_t nchars=0; /*number of characters copied */
uint8_t *s, *sp, *d, *dp; /*src and dst traversal pointers*/
uint8_t *dbuf=NULL; /*temp buf for overlap convers. */
- herr_t ret_value=FAIL; /*return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_s_s, FAIL);
@@ -3371,22 +3311,15 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- if (8*src->size != src->u.atomic.prec ||
- 8*dst->size != dst->u.atomic.prec) {
+ if (8*src->size != src->u.atomic.prec || 8*dst->size != dst->u.atomic.prec)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision");
- }
- if (0 != src->u.atomic.offset ||
- 0 != dst->u.atomic.offset) {
+ if (0 != src->u.atomic.offset || 0 != dst->u.atomic.offset)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad offset");
- }
- if (H5T_CSET_ASCII != src->u.atomic.u.s.cset ||
- H5T_CSET_ASCII != dst->u.atomic.u.s.cset) {
+ if (H5T_CSET_ASCII != src->u.atomic.u.s.cset || H5T_CSET_ASCII != dst->u.atomic.u.s.cset)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character set");
- }
if (src->u.atomic.u.s.pad<0 || src->u.atomic.u.s.pad>=H5T_NPAD ||
- dst->u.atomic.u.s.pad<0 || dst->u.atomic.u.s.pad>=H5T_NPAD) {
+ dst->u.atomic.u.s.pad<0 || dst->u.atomic.u.s.pad>=H5T_NPAD)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad character padding");
- }
cdata->need_bkg = H5T_BKG_NO;
break;
@@ -3428,10 +3361,8 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
}
/* Allocate the overlap buffer */
- if (NULL==(dbuf=H5MM_malloc(dst->size))) {
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for string conversion");
- }
+ if (NULL==(dbuf=H5MM_malloc(dst->size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for string conversion");
/* The conversion loop. */
for (elmtno=0; elmtno<nelmts; elmtno++) {
@@ -3441,21 +3372,21 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
* temporary buffer for the destination.
*/
if (direction>0) {
- s = sp;
- d = elmtno<olap ? dbuf : dp;
+ s = sp;
+ d = elmtno<olap ? dbuf : dp;
} else {
- s = sp;
- d = elmtno+olap >= nelmts ? dbuf : dp;
+ s = sp;
+ d = elmtno+olap >= nelmts ? dbuf : dp;
}
#ifndef NDEBUG
/* I don't quite trust the overlap calculations yet --rpm */
if (src->size==dst->size || buf_stride) {
- assert(s==d);
+ assert(s==d);
} else if (d==dbuf) {
- assert((dp>=sp && dp<sp+src->size) ||
+ assert((dp>=sp && dp<sp+src->size) ||
(sp>=dp && sp<dp+dst->size));
} else {
- assert((dp<sp && dp+dst->size<=sp) ||
+ assert((dp<sp && dp+dst->size<=sp) ||
(sp<dp && sp+src->size<=dp));
}
#endif
@@ -3500,8 +3431,7 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
case H5T_STR_RESERVED_14:
case H5T_STR_RESERVED_15:
case H5T_STR_ERROR:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "source string padding method not supported");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "source string padding method not supported");
}
/* Terminate or pad the destination */
@@ -3536,8 +3466,7 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
case H5T_STR_RESERVED_14:
case H5T_STR_RESERVED_15:
case H5T_STR_ERROR:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "destination string padding method not supported");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "destination string padding method not supported");
}
/*
@@ -3557,12 +3486,10 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts,
break;
default:
- HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown converson command");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown converson command");
}
- ret_value = SUCCEED;
- done:
+done:
H5MM_xfree(dbuf);
FUNC_LEAVE(ret_value);
}
@@ -3590,12 +3517,14 @@ H5T_conv_schar_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_uchar, FAIL);
- H5T_CONV_su(SCHAR, UCHAR,
- signed char, unsigned char);
+ H5T_CONV_su(SCHAR, UCHAR, signed char, unsigned char);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3621,13 +3550,14 @@ H5T_conv_uchar_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_schar, FAIL);
- H5T_CONV_us(UCHAR, SCHAR,
- unsigned char, signed char,
- SCHAR_MAX);
+ H5T_CONV_us(UCHAR, SCHAR, unsigned char, signed char, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3653,12 +3583,14 @@ H5T_conv_schar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_short, FAIL);
- H5T_CONV_sS(SCHAR, SHORT,
- signed char, short);
+ H5T_CONV_sS(SCHAR, SHORT, signed char, short);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3684,12 +3616,14 @@ H5T_conv_schar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_ushort, FAIL);
- H5T_CONV_sU(SCHAR, USHORT,
- signed char, unsigned short);
+ H5T_CONV_sU(SCHAR, USHORT, signed char, unsigned short);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3715,13 +3649,14 @@ H5T_conv_uchar_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_short, FAIL);
- H5T_CONV_uS(UCHAR, SHORT,
- unsigned char, short,
- SHRT_MAX);
+ H5T_CONV_uS(UCHAR, SHORT, unsigned char, short, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3747,12 +3682,14 @@ H5T_conv_uchar_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_ushort, FAIL);
- H5T_CONV_uU(UCHAR, USHORT,
- unsigned char, unsigned short);
+ H5T_CONV_uU(UCHAR, USHORT, unsigned char, unsigned short);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3777,12 +3714,14 @@ H5T_conv_schar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_int, FAIL);
- H5T_CONV_sS(SCHAR, INT,
- signed char, int);
+ H5T_CONV_sS(SCHAR, INT, signed char, int);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3807,12 +3746,14 @@ H5T_conv_schar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_uint, FAIL);
- H5T_CONV_sU(SCHAR, UINT,
- signed char, unsigned);
+ H5T_CONV_sU(SCHAR, UINT, signed char, unsigned);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3837,13 +3778,14 @@ H5T_conv_uchar_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_int, FAIL);
- H5T_CONV_uS(UCHAR, INT,
- unsigned char, int,
- INT_MAX);
+ H5T_CONV_uS(UCHAR, INT, unsigned char, int, INT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3868,12 +3810,14 @@ H5T_conv_uchar_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_uint, FAIL);
- H5T_CONV_uU(UCHAR, UINT,
- unsigned char, unsigned);
+ H5T_CONV_uU(UCHAR, UINT, unsigned char, unsigned);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3898,12 +3842,14 @@ H5T_conv_schar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_long, FAIL);
- H5T_CONV_sS(SCHAR, LONG,
- signed char, long);
+ H5T_CONV_sS(SCHAR, LONG, signed char, long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3929,12 +3875,14 @@ H5T_conv_schar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_ulong, FAIL);
- H5T_CONV_sU(SCHAR, ULONG,
- signed char, unsigned long);
+ H5T_CONV_sU(SCHAR, ULONG, signed char, unsigned long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3959,13 +3907,14 @@ H5T_conv_uchar_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_long, FAIL);
- H5T_CONV_uS(UCHAR, LONG,
- unsigned char, long,
- LONG_MAX);
+ H5T_CONV_uS(UCHAR, LONG, unsigned char, long, LONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -3991,12 +3940,14 @@ H5T_conv_uchar_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_ulong, FAIL);
- H5T_CONV_uU(UCHAR, ULONG,
- unsigned char, unsigned long);
+ H5T_CONV_uU(UCHAR, ULONG, unsigned char, unsigned long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4022,12 +3973,14 @@ H5T_conv_schar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_llong, FAIL);
- H5T_CONV_sS(SCHAR, LLONG,
- signed char, long_long);
+ H5T_CONV_sS(SCHAR, LLONG, signed char, long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4053,12 +4006,14 @@ H5T_conv_schar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_schar_ullong, FAIL);
- H5T_CONV_sU(SCHAR, ULLONG,
- signed char, unsigned long_long);
+ H5T_CONV_sU(SCHAR, ULLONG, signed char, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4084,13 +4039,14 @@ H5T_conv_uchar_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_llong, FAIL);
- H5T_CONV_uS(UCHAR, LLONG,
- unsigned char, long_long,
- LLONG_MAX);
+ H5T_CONV_uS(UCHAR, LLONG, unsigned char, long_long, LLONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4116,12 +4072,14 @@ H5T_conv_uchar_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uchar_ullong, FAIL);
- H5T_CONV_uU(UCHAR, ULLONG,
- unsigned char, unsigned long_long);
+ H5T_CONV_uU(UCHAR, ULLONG, unsigned char, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4147,13 +4105,14 @@ H5T_conv_short_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_schar, FAIL);
- H5T_CONV_Ss(SHORT, SCHAR,
- short, signed char,
- SCHAR_MIN, SCHAR_MAX);
+ H5T_CONV_Ss(SHORT, SCHAR, short, signed char, SCHAR_MIN, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4179,13 +4138,14 @@ H5T_conv_short_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_uchar, FAIL);
- H5T_CONV_Su(SHORT, UCHAR,
- short, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Su(SHORT, UCHAR, short, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4211,13 +4171,14 @@ H5T_conv_ushort_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_schar, FAIL);
- H5T_CONV_Us(USHORT, SCHAR,
- unsigned short, signed char,
- SCHAR_MAX);
+ H5T_CONV_Us(USHORT, SCHAR, unsigned short, signed char, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4243,13 +4204,14 @@ H5T_conv_ushort_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_uchar, FAIL);
- H5T_CONV_Uu(USHORT, UCHAR,
- unsigned short, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Uu(USHORT, UCHAR, unsigned short, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4275,12 +4237,14 @@ H5T_conv_short_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_ushort, FAIL);
- H5T_CONV_su(SHORT, USHORT,
- short, unsigned short);
+ H5T_CONV_su(SHORT, USHORT, short, unsigned short);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4306,13 +4270,14 @@ H5T_conv_ushort_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_short, FAIL);
- H5T_CONV_us(USHORT, SHORT,
- unsigned short, short,
- SHRT_MAX);
+ H5T_CONV_us(USHORT, SHORT, unsigned short, short, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4338,12 +4303,14 @@ H5T_conv_short_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_int, FAIL);
- H5T_CONV_sS(SHORT, INT,
- short, int);
+ H5T_CONV_sS(SHORT, INT, short, int);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4369,12 +4336,14 @@ H5T_conv_short_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_uint, FAIL);
- H5T_CONV_sU(SHORT, UINT,
- short, unsigned);
+ H5T_CONV_sU(SHORT, UINT, short, unsigned);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4400,13 +4369,14 @@ H5T_conv_ushort_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_int, FAIL);
- H5T_CONV_uS(USHORT, INT,
- unsigned short, int,
- INT_MAX);
+ H5T_CONV_uS(USHORT, INT, unsigned short, int, INT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4432,12 +4402,14 @@ H5T_conv_ushort_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_uint, FAIL);
- H5T_CONV_uU(USHORT, UINT,
- unsigned short, unsigned);
+ H5T_CONV_uU(USHORT, UINT, unsigned short, unsigned);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4463,12 +4435,14 @@ H5T_conv_short_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_long, FAIL);
- H5T_CONV_sS(SHORT, LONG,
- short, long);
+ H5T_CONV_sS(SHORT, LONG, short, long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4494,12 +4468,14 @@ H5T_conv_short_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_ulong, FAIL);
- H5T_CONV_sU(SHORT, ULONG,
- short, unsigned long);
+ H5T_CONV_sU(SHORT, ULONG, short, unsigned long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4525,13 +4501,14 @@ H5T_conv_ushort_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_long, FAIL);
- H5T_CONV_uS(USHORT, LONG,
- unsigned short, long,
- LONG_MAX);
+ H5T_CONV_uS(USHORT, LONG, unsigned short, long, LONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4557,12 +4534,14 @@ H5T_conv_ushort_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_ulong, FAIL);
- H5T_CONV_uU(USHORT, ULONG,
- unsigned short, unsigned long);
+ H5T_CONV_uU(USHORT, ULONG, unsigned short, unsigned long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4588,12 +4567,14 @@ H5T_conv_short_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_llong, FAIL);
- H5T_CONV_sS(SHORT, LLONG,
- short, long_long);
+ H5T_CONV_sS(SHORT, LLONG, short, long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4619,12 +4600,14 @@ H5T_conv_short_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_short_ullong, FAIL);
- H5T_CONV_sU(SHORT, ULLONG,
- short, unsigned long_long);
+ H5T_CONV_sU(SHORT, ULLONG, short, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4650,13 +4633,14 @@ H5T_conv_ushort_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_llong, FAIL);
- H5T_CONV_uS(USHORT, LLONG,
- unsigned short, long_long,
- LLONG_MAX);
+ H5T_CONV_uS(USHORT, LLONG, unsigned short, long_long, LLONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4682,12 +4666,14 @@ H5T_conv_ushort_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ushort_ullong, FAIL);
- H5T_CONV_uU(USHORT, ULLONG,
- unsigned short, unsigned long_long);
+ H5T_CONV_uU(USHORT, ULLONG, unsigned short, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4713,13 +4699,14 @@ H5T_conv_int_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_schar, FAIL);
- H5T_CONV_Ss(INT, SCHAR,
- int, signed char,
- SCHAR_MIN, SCHAR_MAX);
+ H5T_CONV_Ss(INT, SCHAR, int, signed char, SCHAR_MIN, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4745,13 +4732,14 @@ H5T_conv_int_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_uchar, FAIL);
- H5T_CONV_Su(INT, UCHAR,
- int, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Su(INT, UCHAR, int, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4777,13 +4765,14 @@ H5T_conv_uint_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_schar, FAIL);
- H5T_CONV_Us(UINT, SCHAR,
- unsigned, signed char,
- SCHAR_MAX);
+ H5T_CONV_Us(UINT, SCHAR, unsigned, signed char, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4809,13 +4798,14 @@ H5T_conv_uint_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_uchar, FAIL);
- H5T_CONV_Uu(UINT, UCHAR,
- unsigned, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Uu(UINT, UCHAR, unsigned, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4841,13 +4831,14 @@ H5T_conv_int_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_short, FAIL);
- H5T_CONV_Ss(INT, SHORT,
- int, short,
- SHRT_MIN, SHRT_MAX);
+ H5T_CONV_Ss(INT, SHORT, int, short, SHRT_MIN, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4873,13 +4864,14 @@ H5T_conv_int_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_ushort, FAIL);
- H5T_CONV_Su(INT, USHORT,
- int, unsigned short,
- USHRT_MAX);
+ H5T_CONV_Su(INT, USHORT, int, unsigned short, USHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4905,13 +4897,14 @@ H5T_conv_uint_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_short, FAIL);
- H5T_CONV_Us(UINT, SHORT,
- unsigned, short,
- SHRT_MAX);
+ H5T_CONV_Us(UINT, SHORT, unsigned, short, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4937,13 +4930,14 @@ H5T_conv_uint_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_ushort, FAIL);
- H5T_CONV_Uu(UINT, USHORT,
- unsigned, unsigned short,
- USHRT_MAX);
+ H5T_CONV_Uu(UINT, USHORT, unsigned, unsigned short, USHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4968,12 +4962,14 @@ H5T_conv_int_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_uint, FAIL);
- H5T_CONV_su(INT, UINT,
- int, unsigned);
+ H5T_CONV_su(INT, UINT, int, unsigned);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -4998,13 +4994,14 @@ H5T_conv_uint_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_int, FAIL);
- H5T_CONV_us(UINT, INT,
- unsigned, int,
- INT_MAX);
+ H5T_CONV_us(UINT, INT, unsigned, int, INT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5029,12 +5026,14 @@ H5T_conv_int_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_long, FAIL);
- H5T_CONV_sS(INT, LONG,
- int, long);
+ H5T_CONV_sS(INT, LONG, int, long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5059,12 +5058,14 @@ H5T_conv_int_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_ulong, FAIL);
- H5T_CONV_sU(INT, LONG,
- int, unsigned long);
+ H5T_CONV_sU(INT, LONG, int, unsigned long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5089,13 +5090,14 @@ H5T_conv_uint_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_long, FAIL);
- H5T_CONV_uS(UINT, LONG,
- unsigned, long,
- LONG_MAX);
+ H5T_CONV_uS(UINT, LONG, unsigned, long, LONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5120,12 +5122,14 @@ H5T_conv_uint_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_ulong, FAIL);
- H5T_CONV_uU(UINT, ULONG,
- unsigned, unsigned long);
+ H5T_CONV_uU(UINT, ULONG, unsigned, unsigned long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5150,12 +5154,14 @@ H5T_conv_int_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_llong, FAIL);
- H5T_CONV_sS(INT, LLONG,
- int, long_long);
+ H5T_CONV_sS(INT, LLONG, int, long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5180,12 +5186,14 @@ H5T_conv_int_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_int_ullong, FAIL);
- H5T_CONV_sU(INT, ULLONG,
- int, unsigned long_long);
+ H5T_CONV_sU(INT, ULLONG, int, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5210,13 +5218,14 @@ H5T_conv_uint_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_llong, FAIL);
- H5T_CONV_uS(UINT, LLONG,
- unsigned, long_long,
- LLONG_MAX);
+ H5T_CONV_uS(UINT, LLONG, unsigned, long_long, LLONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5242,12 +5251,14 @@ H5T_conv_uint_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_uint_ullong, FAIL);
- H5T_CONV_uU(UINT, ULLONG,
- unsigned, unsigned long_long);
+ H5T_CONV_uU(UINT, ULLONG, unsigned, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5272,13 +5283,14 @@ H5T_conv_long_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_schar, FAIL);
- H5T_CONV_Ss(LONG, SCHAR,
- long, signed char,
- SCHAR_MIN, SCHAR_MAX);
+ H5T_CONV_Ss(LONG, SCHAR, long, signed char, SCHAR_MIN, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5303,13 +5315,14 @@ H5T_conv_long_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_uchar, FAIL);
- H5T_CONV_Su(LONG, UCHAR,
- long, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Su(LONG, UCHAR, long, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5335,13 +5348,14 @@ H5T_conv_ulong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_schar, FAIL);
- H5T_CONV_Us(ULONG, SCHAR,
- unsigned long, signed char,
- SCHAR_MAX);
+ H5T_CONV_Us(ULONG, SCHAR, unsigned long, signed char, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5367,13 +5381,14 @@ H5T_conv_ulong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_uchar, FAIL);
- H5T_CONV_Uu(ULONG, UCHAR,
- unsigned long, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Uu(ULONG, UCHAR, unsigned long, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5398,13 +5413,14 @@ H5T_conv_long_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_short, FAIL);
- H5T_CONV_Ss(LONG, SHORT,
- long, short,
- SHRT_MIN, SHRT_MAX);
+ H5T_CONV_Ss(LONG, SHORT, long, short, SHRT_MIN, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5430,13 +5446,14 @@ H5T_conv_long_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_ushort, FAIL);
- H5T_CONV_Su(LONG, USHORT,
- long, unsigned short,
- USHRT_MAX);
+ H5T_CONV_Su(LONG, USHORT, long, unsigned short, USHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5461,13 +5478,14 @@ H5T_conv_ulong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_short, FAIL);
- H5T_CONV_Us(ULONG, SHORT,
- unsigned long, short,
- SHRT_MAX);
+ H5T_CONV_Us(ULONG, SHORT, unsigned long, short, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5493,13 +5511,14 @@ H5T_conv_ulong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_ushort, FAIL);
- H5T_CONV_Uu(ULONG, USHORT,
- unsigned long, unsigned short,
- USHRT_MAX);
+ H5T_CONV_Uu(ULONG, USHORT, unsigned long, unsigned short, USHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5524,13 +5543,14 @@ H5T_conv_long_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_int, FAIL);
- H5T_CONV_Ss(LONG, INT,
- long, int,
- INT_MIN, INT_MAX);
+ H5T_CONV_Ss(LONG, INT, long, int, INT_MIN, INT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5555,13 +5575,14 @@ H5T_conv_long_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_uint, FAIL);
- H5T_CONV_Su(LONG, UINT,
- long, unsigned,
- UINT_MAX);
+ H5T_CONV_Su(LONG, UINT, long, unsigned, UINT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5586,13 +5607,14 @@ H5T_conv_ulong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_int, FAIL);
- H5T_CONV_Us(ULONG, INT,
- unsigned long, int,
- INT_MAX);
+ H5T_CONV_Us(ULONG, INT, unsigned long, int, INT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5617,13 +5639,14 @@ H5T_conv_ulong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_uint, FAIL);
- H5T_CONV_Uu(ULONG, UINT,
- unsigned long, unsigned,
- UINT_MAX);
+ H5T_CONV_Uu(ULONG, UINT, unsigned long, unsigned, UINT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5648,12 +5671,14 @@ H5T_conv_long_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_ulong, FAIL);
- H5T_CONV_su(LONG, ULONG,
- long, unsigned long);
+ H5T_CONV_su(LONG, ULONG, long, unsigned long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5678,13 +5703,14 @@ H5T_conv_ulong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_long, FAIL);
- H5T_CONV_us(ULONG, LONG,
- unsigned long, long,
- LONG_MAX);
+ H5T_CONV_us(ULONG, LONG, unsigned long, long, LONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5709,12 +5735,14 @@ H5T_conv_long_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_llong, FAIL);
- H5T_CONV_sS(LONG, LLONG,
- long, long_long);
+ H5T_CONV_sS(LONG, LLONG, long, long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5740,12 +5768,14 @@ H5T_conv_long_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_ullong, FAIL);
- H5T_CONV_sU(LONG, ULLONG,
- long, unsigned long_long);
+ H5T_CONV_sU(LONG, ULLONG, long, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5771,13 +5801,14 @@ H5T_conv_ulong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_long_llong, FAIL);
- H5T_CONV_uS(ULONG, LLONG,
- unsigned long, long_long,
- LLONG_MAX);
+ H5T_CONV_uS(ULONG, LLONG, unsigned long, long_long, LLONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5803,12 +5834,14 @@ H5T_conv_ulong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ulong_ullong, FAIL);
- H5T_CONV_uU(ULONG, ULLONG,
- unsigned long, unsigned long_long);
+ H5T_CONV_uU(ULONG, ULLONG, unsigned long, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5834,13 +5867,14 @@ H5T_conv_llong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_schar, FAIL);
- H5T_CONV_Ss(LLONG, SCHAR,
- long_long, signed char,
- SCHAR_MIN, SCHAR_MAX);
+ H5T_CONV_Ss(LLONG, SCHAR, long_long, signed char, SCHAR_MIN, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5866,13 +5900,14 @@ H5T_conv_llong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_uchar, FAIL);
- H5T_CONV_Su(LLONG, UCHAR,
- long_long, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Su(LLONG, UCHAR, long_long, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5898,13 +5933,14 @@ H5T_conv_ullong_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_schar, FAIL);
- H5T_CONV_Us(ULLONG, SCHAR,
- unsigned long_long, signed char,
- SCHAR_MAX);
+ H5T_CONV_Us(ULLONG, SCHAR, unsigned long_long, signed char, SCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5930,13 +5966,14 @@ H5T_conv_ullong_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_uchar, FAIL);
- H5T_CONV_Uu(ULLONG, UCHAR,
- unsigned long_long, unsigned char,
- UCHAR_MAX);
+ H5T_CONV_Uu(ULLONG, UCHAR, unsigned long_long, unsigned char, UCHAR_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5962,13 +5999,14 @@ H5T_conv_llong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_short, FAIL);
- H5T_CONV_Ss(LLONG, SHORT,
- long_long, short,
- SHRT_MIN, SHRT_MAX);
+ H5T_CONV_Ss(LLONG, SHORT, long_long, short, SHRT_MIN, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -5994,13 +6032,14 @@ H5T_conv_llong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_ushort, FAIL);
- H5T_CONV_Su(LLONG, USHORT,
- long_long, unsigned short,
- USHRT_MAX);
+ H5T_CONV_Su(LLONG, USHORT, long_long, unsigned short, USHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6026,13 +6065,14 @@ H5T_conv_ullong_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_short, FAIL);
- H5T_CONV_Us(ULLONG, SHORT,
- unsigned long_long, short,
- SHRT_MAX);
+ H5T_CONV_Us(ULLONG, SHORT, unsigned long_long, short, SHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6058,13 +6098,14 @@ H5T_conv_ullong_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_ushort, FAIL);
- H5T_CONV_Uu(ULLONG, USHORT,
- unsigned long_long, unsigned short,
- USHRT_MAX);
+ H5T_CONV_Uu(ULLONG, USHORT, unsigned long_long, unsigned short, USHRT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6089,13 +6130,14 @@ H5T_conv_llong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_int, FAIL);
- H5T_CONV_Ss(LLONG, INT,
- long_long, int,
- INT_MIN, INT_MAX);
+ H5T_CONV_Ss(LLONG, INT, long_long, int, INT_MIN, INT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6120,13 +6162,14 @@ H5T_conv_llong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_uint, FAIL);
- H5T_CONV_Su(LLONG, UINT,
- long_long, unsigned,
- UINT_MAX);
+ H5T_CONV_Su(LLONG, UINT, long_long, unsigned, UINT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6151,13 +6194,14 @@ H5T_conv_ullong_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_int, FAIL);
- H5T_CONV_Us(ULLONG, INT,
- unsigned long_long, int,
- INT_MAX);
+ H5T_CONV_Us(ULLONG, INT, unsigned long_long, int, INT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6183,13 +6227,14 @@ H5T_conv_ullong_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_uint, FAIL);
- H5T_CONV_Uu(ULLONG, UINT,
- unsigned long_long, unsigned,
- UINT_MAX);
+ H5T_CONV_Uu(ULLONG, UINT, unsigned long_long, unsigned, UINT_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6214,13 +6259,14 @@ H5T_conv_llong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
hsize_t nelmts, size_t buf_stride, size_t UNUSED bkg_stride,
void *buf, void UNUSED *bkg, hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_long, FAIL);
- H5T_CONV_Ss(LLONG, LONG,
- long_long, long,
- LONG_MIN, LONG_MAX);
+ H5T_CONV_Ss(LLONG, LONG, long_long, long, LONG_MIN, LONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6246,13 +6292,14 @@ H5T_conv_llong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_ulong, FAIL);
- H5T_CONV_Su(LLONG, ULONG,
- long_long, unsigned long,
- ULONG_MAX);
+ H5T_CONV_Su(LLONG, ULONG, long_long, unsigned long, ULONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6278,13 +6325,14 @@ H5T_conv_ullong_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_long, FAIL);
- H5T_CONV_Us(ULLONG, LONG,
- unsigned long_long, long,
- LONG_MAX);
+ H5T_CONV_Us(ULLONG, LONG, unsigned long_long, long, LONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6310,13 +6358,14 @@ H5T_conv_ullong_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_ulong, FAIL);
- H5T_CONV_Uu(ULLONG, ULONG,
- unsigned long_long, unsigned long,
- ULONG_MAX);
+ H5T_CONV_Uu(ULLONG, ULONG, unsigned long_long, unsigned long, ULONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6342,12 +6391,14 @@ H5T_conv_llong_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_llong_ullong, FAIL);
- H5T_CONV_su(LLONG, ULLONG,
- long_long, unsigned long_long);
+ H5T_CONV_su(LLONG, ULLONG, long_long, unsigned long_long);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6373,13 +6424,14 @@ H5T_conv_ullong_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
size_t UNUSED bkg_stride, void *buf, void UNUSED *bkg,
hid_t UNUSED dset_xfer_plist)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5T_conv_ullong_llong, FAIL);
- H5T_CONV_us(ULLONG, LLONG,
- unsigned long_long, long_long,
- LLONG_MAX);
+ H5T_CONV_us(ULLONG, LLONG, unsigned long_long, long_long, LLONG_MAX);
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -6414,6 +6466,7 @@ H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
H5T_t *st, *dt; /*type descriptors */
hbool_t src_mv, dst_mv; /*align data? */
double aligned; /*aligned data */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_float_double, FAIL);
@@ -6422,11 +6475,9 @@ H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
cdata->need_bkg = H5T_BKG_NO;
if (NULL==(st=H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL==(dt=H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference data type object ID");
- if (st->size!=sizeof(float) || dt->size!=sizeof(double)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "disagreement about data type size");
- }
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference data type object ID");
+ if (st->size!=sizeof(float) || dt->size!=sizeof(double))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "disagreement about data type size");
CI_ALLOC_PRIV
break;
@@ -6493,11 +6544,11 @@ H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
break;
default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -6535,6 +6586,7 @@ H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
H5T_t *st, *dt; /*type descriptors */
hbool_t src_mv, dst_mv; /*align data? */
double aligned; /*aligned data */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_double_float, FAIL);
@@ -6543,11 +6595,9 @@ H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
cdata->need_bkg = H5T_BKG_NO;
if (NULL==(st=H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL==(dt=H5I_object_verify(dst_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference data type object ID");
- if (st->size!=sizeof(double) || dt->size!=sizeof(float)) {
- HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "disagreement about data type size");
- }
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference data type object ID");
+ if (st->size!=sizeof(double) || dt->size!=sizeof(float))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "disagreement about data type size");
CI_ALLOC_PRIV
break;
@@ -6622,11 +6672,11 @@ H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
break;
default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -6665,6 +6715,7 @@ H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
unsigned mbits=0; /*mantissa bits */
unsigned exponent; /*exponent */
int i; /*counter */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_conv_i32le_f64le, FAIL);
@@ -6682,7 +6733,7 @@ H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
/* The conversion */
if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE)) ||
NULL==H5I_object_verify(dst_id,H5I_DATATYPE))
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
s = (uint8_t*)buf + (buf_stride?buf_stride:4)*(nelmts-1);
d = (uint8_t*)buf + (buf_stride?buf_stride:8)*(nelmts-1);
@@ -6716,8 +6767,7 @@ H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
break;
default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unsupported integer sign method");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported integer sign method");
}
/*
@@ -7013,9 +7063,9 @@ H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
default:
/* Some other command we don't know about yet.*/
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown conversion command");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unknown conversion command");
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c
index 910a4a4..a777631 100644
--- a/src/H5Tvlen.c
+++ b/src/H5Tvlen.c
@@ -122,10 +122,11 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
break;
default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location");
+ HGOTO_ERROR (H5E_DATATYPE, H5E_BADRANGE, FAIL, "invalid VL datatype location");
} /* end switch */
} /* end if */
+done:
FUNC_LEAVE (ret_value);
} /* end H5T_vlen_set_loc() */
@@ -144,19 +145,17 @@ H5T_vlen_set_loc(H5T_t *dt, H5F_t *f, H5T_vlen_loc_t loc)
*
*-------------------------------------------------------------------------
*/
-hssize_t H5T_vlen_seq_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
+hssize_t
+H5T_vlen_seq_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
{
hvl_t *vl=(hvl_t *)vl_addr; /* Pointer to the user's hvl_t information */
- hssize_t ret_value = FAIL; /*return value */
FUNC_ENTER_NOAPI(H5T_vlen_seq_mem_getlen, FAIL);
/* check parameters */
assert(vl);
- ret_value=(hssize_t)vl->len;
-
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE ((hssize_t)vl->len);
} /* end H5T_vlen_seq_mem_getlen() */
@@ -174,7 +173,8 @@ hssize_t H5T_vlen_seq_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
*
*-------------------------------------------------------------------------
*/
-herr_t H5T_vlen_seq_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len)
+herr_t
+H5T_vlen_seq_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len)
{
hvl_t *vl=(hvl_t *)vl_addr; /* Pointer to the user's hvl_t information */
@@ -204,13 +204,15 @@ herr_t H5T_vlen_seq_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t l
*
*-------------------------------------------------------------------------
*/
-herr_t H5T_vlen_seq_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, void *buf, void UNUSED *bg_addr, hsize_t seq_len, hsize_t base_size)
+herr_t
+H5T_vlen_seq_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, void *buf, void UNUSED *bg_addr, hsize_t seq_len, hsize_t base_size)
{
H5MM_allocate_t alloc_func; /* Vlen allocation function */
void *alloc_info; /* Vlen allocation information */
hvl_t *vl=(hvl_t *)vl_addr; /* Pointer to the user's hvl_t information */
size_t len;
H5P_genplist_t *plist; /* Property list */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_vlen_seq_mem_write, FAIL);
@@ -229,19 +231,19 @@ herr_t H5T_vlen_seq_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, vo
/* Get the allocation function & info */
if(TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(plist_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if(alloc_func!=NULL) {
if(NULL==(vl->p=(alloc_func)(len,alloc_info)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
} /* end if */
else { /* Default to system malloc */
if(NULL==(vl->p=H5MM_malloc(len)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
} /* end else */
/* Copy the data into the newly allocated buffer */
@@ -254,7 +256,8 @@ herr_t H5T_vlen_seq_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, vo
/* Set the sequence length */
H5_ASSIGN_OVERFLOW(vl->len,seq_len,hsize_t,size_t);
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5T_vlen_seq_mem_write() */
@@ -272,19 +275,17 @@ herr_t H5T_vlen_seq_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, vo
*
*-------------------------------------------------------------------------
*/
-hssize_t H5T_vlen_str_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
+hssize_t
+H5T_vlen_str_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
{
char *s=*(char **)vl_addr; /* Pointer to the user's hvl_t information */
- hssize_t ret_value = FAIL; /*return value */
FUNC_ENTER_NOAPI(H5T_vlen_str_mem_getlen, FAIL);
/* check parameters */
assert(s);
- ret_value=(hssize_t)HDstrlen(s);
-
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE ( (hssize_t)HDstrlen(s));
} /* end H5T_vlen_str_mem_getlen() */
@@ -302,7 +303,8 @@ hssize_t H5T_vlen_str_mem_getlen(H5F_t UNUSED *f, void *vl_addr)
*
*-------------------------------------------------------------------------
*/
-herr_t H5T_vlen_str_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len)
+herr_t
+H5T_vlen_str_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t len)
{
char *s=*(char **)vl_addr; /* Pointer to the user's hvl_t information */
@@ -332,13 +334,15 @@ herr_t H5T_vlen_str_mem_read(H5F_t UNUSED *f, void *vl_addr, void *buf, size_t l
*
*-------------------------------------------------------------------------
*/
-herr_t H5T_vlen_str_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, void *buf, void UNUSED *bg_addr, hsize_t seq_len, hsize_t base_size)
+herr_t
+H5T_vlen_str_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, void *buf, void UNUSED *bg_addr, hsize_t seq_len, hsize_t base_size)
{
H5MM_allocate_t alloc_func; /* Vlen allocation function */
void *alloc_info; /* Vlen allocation information */
char **s=(char **)vl_addr; /* Pointer to the user's hvl_t information */
size_t len;
H5P_genplist_t *plist; /* Property list */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_vlen_str_mem_write, FAIL);
@@ -354,26 +358,27 @@ herr_t H5T_vlen_str_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, vo
/* Get the allocation function & info */
if(TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(plist_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&alloc_func)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&alloc_info)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if(alloc_func!=NULL) {
if(NULL==(*s=(alloc_func)((size_t)((seq_len+1)*base_size),alloc_info)))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
} /* end if */
else { /* Default to system malloc */
if(NULL==(*s=H5MM_malloc((size_t)((seq_len+1)*base_size))))
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data");
} /* end else */
H5_ASSIGN_OVERFLOW(len,(seq_len*base_size),hsize_t,size_t);
HDmemcpy(*s,buf,len);
(*s)[len]='\0';
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5T_vlen_str_mem_write() */
@@ -391,10 +396,11 @@ herr_t H5T_vlen_str_mem_write(hid_t plist_id, H5F_t UNUSED *f, void *vl_addr, vo
*
*-------------------------------------------------------------------------
*/
-hssize_t H5T_vlen_disk_getlen(H5F_t UNUSED *f, void *vl_addr)
+hssize_t
+H5T_vlen_disk_getlen(H5F_t UNUSED *f, void *vl_addr)
{
uint8_t *vl=(uint8_t *)vl_addr; /* Pointer to the disk VL information */
- hssize_t ret_value = FAIL; /*return value */
+ hssize_t ret_value; /*return value */
FUNC_ENTER_NOAPI(H5T_vlen_disk_getlen, FAIL);
@@ -421,11 +427,13 @@ hssize_t H5T_vlen_disk_getlen(H5F_t UNUSED *f, void *vl_addr)
*
*-------------------------------------------------------------------------
*/
-herr_t H5T_vlen_disk_read(H5F_t *f, void *vl_addr, void *buf, size_t UNUSED len)
+herr_t
+H5T_vlen_disk_read(H5F_t *f, void *vl_addr, void *buf, size_t UNUSED len)
{
uint8_t *vl=(uint8_t *)vl_addr; /* Pointer to the user's hvl_t information */
H5HG_t hobjid;
uint32_t seq_len;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_vlen_disk_read, FAIL);
@@ -445,10 +453,11 @@ herr_t H5T_vlen_disk_read(H5F_t *f, void *vl_addr, void *buf, size_t UNUSED len)
/* Read the VL information from disk */
if(H5HG_read(f,&hobjid,buf)==NULL)
- HRETURN_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "Unable to read VL information");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "Unable to read VL information");
} /* end if */
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5T_vlen_disk_read() */
@@ -470,7 +479,8 @@ herr_t H5T_vlen_disk_read(H5F_t *f, void *vl_addr, void *buf, size_t UNUSED len)
*
*-------------------------------------------------------------------------
*/
-herr_t H5T_vlen_disk_write(hid_t UNUSED plist_id, H5F_t *f, void *vl_addr, void *buf, void *bg_addr, hsize_t seq_len, hsize_t base_size)
+herr_t
+H5T_vlen_disk_write(hid_t UNUSED plist_id, H5F_t *f, void *vl_addr, void *buf, void *bg_addr, hsize_t seq_len, hsize_t base_size)
{
uint8_t *vl=(uint8_t *)vl_addr; /*Pointer to the user's hvl_t information*/
uint8_t *bg=(uint8_t *)bg_addr; /*Pointer to the old data hvl_t */
@@ -478,6 +488,7 @@ herr_t H5T_vlen_disk_write(hid_t UNUSED plist_id, H5F_t *f, void *vl_addr, void
H5HG_t bg_hobjid;
size_t len;
hsize_t bg_seq_len=0;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5T_vlen_disk_write, FAIL);
@@ -499,8 +510,7 @@ herr_t H5T_vlen_disk_write(hid_t UNUSED plist_id, H5F_t *f, void *vl_addr, void
INT32DECODE(bg, bg_hobjid.idx);
/* Free heap object */
if(H5HG_remove(f, &bg_hobjid)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL,
- "Unable to remove heap object");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object");
} /* end if */
} /* end if */
@@ -513,7 +523,7 @@ herr_t H5T_vlen_disk_write(hid_t UNUSED plist_id, H5F_t *f, void *vl_addr, void
/* Write the VL information to disk (allocates space also) */
H5_ASSIGN_OVERFLOW(len,(seq_len*base_size),hsize_t,size_t);
if(H5HG_insert(f,len,buf,&hobjid)<0)
- HRETURN_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write VL information");
+ HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write VL information");
} /* end if */
else
HDmemset(&hobjid,0,sizeof(H5HG_t));
@@ -522,7 +532,8 @@ herr_t H5T_vlen_disk_write(hid_t UNUSED plist_id, H5F_t *f, void *vl_addr, void
H5F_addr_encode(f,&vl,hobjid.addr);
INT32ENCODE(vl,hobjid.idx);
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
} /* end H5T_vlen_disk_write() */
@@ -668,7 +679,7 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED
void *free_info=NULL; /* Vlen free information */
H5T_t *dt = NULL;
H5P_genplist_t *plist; /* Property list */
- herr_t ret_value = FAIL;
+ herr_t ret_value;
FUNC_ENTER_NOAPI(H5T_vlen_reclaim, FAIL);
@@ -677,7 +688,7 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED
/* Check args */
if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
/* Get the default dataset transfer property list if the user didn't provide one */
if (H5P_DEFAULT == plist_id)
@@ -685,18 +696,16 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED
/* Get the free func & information */
if(TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER) || NULL == (plist = H5I_object(plist_id)))
- HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&free_func)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&free_info)<0)
- HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
/* Pull the free function and free info pointer out of the op_data and call the recurse datatype free function */
ret_value=H5T_vlen_reclaim_recurse(elem,dt,free_func,free_info);
-#ifdef LATER
done:
-#endif /* LATER */
FUNC_LEAVE(ret_value);
} /* end H5T_vlen_reclaim() */
diff --git a/src/H5V.c b/src/H5V.c
index db243c0..96bde6b 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -343,24 +343,28 @@ H5V_hyper_eq(int n,
{
hsize_t nelmts1 = 1, nelmts2 = 1;
int i;
+ htri_t ret_value=TRUE; /* Return value */
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5V_hyper_eq);
- if (n <= 0) HRETURN(TRUE);
+ if (n <= 0) HGOTO_DONE(TRUE);
for (i=0; i<n; i++) {
if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0)) {
- HRETURN(FALSE);
+ HGOTO_DONE(FALSE);
}
if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0)) {
- HRETURN(FALSE);
+ HGOTO_DONE(FALSE);
}
- if (0 == (nelmts1 *= (size1 ? size1[i] : 0))) HRETURN(FALSE);
- if (0 == (nelmts2 *= (size2 ? size2[i] : 0))) HRETURN(FALSE);
+ if (0 == (nelmts1 *= (size1 ? size1[i] : 0))) HGOTO_DONE(FALSE);
+ if (0 == (nelmts2 *= (size2 ? size2[i] : 0))) HGOTO_DONE(FALSE);
}
- FUNC_LEAVE(TRUE);
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5V_hyper_disjointp
@@ -386,29 +390,33 @@ H5V_hyper_disjointp(unsigned n,
const hssize_t *offset2, const hsize_t *size2)
{
unsigned u;
+ htri_t ret_value=FALSE; /* Return value */
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5V_hyper_disjointp);
- if (!n || !size1 || !size2) HRETURN(TRUE);
+ if (!n || !size1 || !size2) HGOTO_DONE(TRUE);
for (u=0; u<n; u++) {
assert (size1[u]<HSSIZET_MAX);
assert (size2[u]<HSSIZET_MAX);
if (0==size1[u] || 0==size2[u])
- HRETURN(TRUE);
+ HGOTO_DONE(TRUE);
if (((offset1?offset1[u]:0) < (offset2?offset2[u]:0) &&
((offset1?offset1[u]:0) + (hssize_t)size1[u] <=
(offset2?offset2[u]:0))) ||
((offset2?offset2[u]:0) < (offset1?offset1[u]:0) &&
((offset2?offset2[u]:0) + (hssize_t)size2[u] <=
(offset1?offset1[u]:0)))) {
- HRETURN(TRUE);
+ HGOTO_DONE(TRUE);
}
}
- FUNC_LEAVE(FALSE);
+
+done:
+ FUNC_LEAVE(ret_value);
}
+
/*-------------------------------------------------------------------------
* Function: H5V_hyper_fill
@@ -783,10 +791,8 @@ H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *size,
} else {
H5_CHECK_OVERFLOW(elmt_size,hsize_t,size_t);
HDmemcpy (dst, src, (size_t)elmt_size);
- HRETURN (SUCCEED);
}
-
FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index 156e6bd..ffc17dc 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -98,14 +98,16 @@ __DLL__ hsize_t H5V_array_offset(unsigned n, const hsize_t *total_size,
static H5_inline hsize_t
H5V_vector_reduce_product(unsigned n, const hsize_t *v)
{
- hsize_t ans = 1;
+ hsize_t ret_value = 1;
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5V_vector_reduce_product);
- if (n && !v) HRETURN(0);
- while (n--) ans *= *v++;
- FUNC_LEAVE(ans);
+ if (n && !v) HGOTO_DONE(0);
+ while (n--) ret_value *= *v++;
+
+done:
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
@@ -128,14 +130,19 @@ H5V_vector_reduce_product(unsigned n, const hsize_t *v)
static H5_inline htri_t UNUSED
H5V_vector_zerop_u(int n, const hsize_t *v)
{
+ htri_t ret_value=TRUE; /* Return value */
+
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5V_vector_zerop_u);
- if (!v) HRETURN(TRUE);
- while (n--) {
- if (*v++) HRETURN(FALSE);
- }
- FUNC_LEAVE(TRUE);
+ if (!v)
+ HGOTO_DONE(TRUE);
+ while (n--)
+ if (*v++)
+ HGOTO_DONE(FALSE);
+
+done:
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
@@ -158,14 +165,19 @@ H5V_vector_zerop_u(int n, const hsize_t *v)
static H5_inline htri_t UNUSED
H5V_vector_zerop_s(int n, const hssize_t *v)
{
+ htri_t ret_value=TRUE; /* Return value */
+
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5V_vector_zerop_s);
- if (!v) HRETURN(TRUE);
- while (n--) {
- if (*v++) HRETURN(FALSE);
- }
- FUNC_LEAVE(TRUE);
+ if (!v)
+ HGOTO_DONE(TRUE);
+ while (n--)
+ if (*v++)
+ HGOTO_DONE(FALSE);
+
+done:
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
@@ -190,17 +202,21 @@ H5V_vector_zerop_s(int n, const hssize_t *v)
static H5_inline int UNUSED
H5V_vector_cmp_u (int n, const hsize_t *v1, const hsize_t *v2)
{
+ int ret_value=0; /* Return value */
+
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5V_vector_cmp_u);
- if (v1 == v2) HRETURN(0);
+ if (v1 == v2) HGOTO_DONE(0);
while (n--) {
- if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HRETURN(-1);
- if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HRETURN(1);
+ if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HGOTO_DONE(-1);
+ if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HGOTO_DONE(1);
if (v1) v1++;
if (v2) v2++;
}
- FUNC_LEAVE(0);
+
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -226,17 +242,21 @@ H5V_vector_cmp_u (int n, const hsize_t *v1, const hsize_t *v2)
static H5_inline int UNUSED
H5V_vector_cmp_s (unsigned n, const hssize_t *v1, const hssize_t *v2)
{
+ int ret_value=0; /* Return value */
+
/* Use FUNC_ENTER_NOINIT here to avoid performance issues */
FUNC_ENTER_NOINIT(H5V_vector_cmp_s);
- if (v1 == v2) HRETURN(0);
+ if (v1 == v2) HGOTO_DONE(0);
while (n--) {
- if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HRETURN(-1);
- if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HRETURN(1);
+ if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0)) HGOTO_DONE(-1);
+ if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0)) HGOTO_DONE(1);
if (v1) v1++;
if (v2) v2++;
}
- FUNC_LEAVE(0);
+
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Z.c b/src/H5Z.c
index 3760d31..9fd8e50 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -152,30 +152,25 @@ H5Z_term_interface (void)
herr_t
H5Zregister(H5Z_filter_t id, const char *comment, H5Z_func_t func)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_API(H5Zregister, FAIL);
H5TRACE3("e","Zfsx",id,comment,func);
/* Check args */
- if (id<0 || id>H5Z_FILTER_MAX) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "invalid filter identification number");
- }
- if (id<256) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "unable to modify predefined filters");
- }
- if (!func) {
- HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
- "no function specified");
- }
+ if (id<0 || id>H5Z_FILTER_MAX)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid filter identification number");
+ if (id<256)
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "unable to modify predefined filters");
+ if (!func)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no function specified");
/* Do it */
- if (H5Z_register (id, comment, func)<0) {
- HRETURN_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL,
- "unable to register filter");
- }
+ if (H5Z_register (id, comment, func)<0)
+ HGOTO_ERROR (H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter");
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -198,6 +193,7 @@ herr_t
H5Z_register (H5Z_filter_t id, const char *comment, H5Z_func_t func)
{
size_t i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5Z_register, FAIL);
@@ -212,10 +208,8 @@ H5Z_register (H5Z_filter_t id, const char *comment, H5Z_func_t func)
size_t n = MAX(32, 2*H5Z_table_alloc_g);
H5Z_class_t *table = H5MM_realloc(H5Z_table_g,
n*sizeof(H5Z_class_t));
- if (!table) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to extend filter table");
- }
+ if (!table)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to extend filter table");
H5Z_table_g = table;
H5Z_table_alloc_g = n;
}
@@ -233,7 +227,8 @@ H5Z_register (H5Z_filter_t id, const char *comment, H5Z_func_t func)
H5Z_table_g[i].func = func;
}
- FUNC_LEAVE (SUCCEED);
+done:
+ FUNC_LEAVE (ret_value);
}
@@ -256,6 +251,7 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
size_t cd_nelmts, const unsigned int cd_values[/*cd_nelmts*/])
{
size_t idx, i;
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5Z_append, FAIL);
@@ -268,20 +264,16 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
* Check filter limit. We do it here for early warnings although we may
* decide to relax this restriction in the future.
*/
- if (pline->nfilters>=32) {
- HRETURN_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL,
- "too many filters in pipeline");
- }
+ if (pline->nfilters>=32)
+ HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "too many filters in pipeline");
/* Allocate additional space in the pipeline if it's full */
if (pline->nfilters>=pline->nalloc) {
H5O_pline_t x;
x.nalloc = MAX(32, 2*pline->nalloc);
x.filter = H5MM_realloc(pline->filter, x.nalloc*sizeof(x.filter[0]));
- if (NULL==x.filter) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for filter pipeline");
- }
+ if (NULL==x.filter)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter pipeline");
pline->nalloc = x.nalloc;
pline->filter = x.filter;
}
@@ -294,19 +286,17 @@ H5Z_append(H5O_pline_t *pline, H5Z_filter_t filter, unsigned flags,
pline->filter[idx].cd_nelmts = cd_nelmts;
if (cd_nelmts>0) {
pline->filter[idx].cd_values = H5MM_malloc(cd_nelmts*sizeof(unsigned));
- if (NULL==pline->filter[idx].cd_values) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "memory allocation failed for filter");
- }
- for (i=0; i<cd_nelmts; i++) {
+ if (NULL==pline->filter[idx].cd_values)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for filter");
+ for (i=0; i<cd_nelmts; i++)
pline->filter[idx].cd_values[i] = cd_values[i];
- }
} else {
pline->filter[idx].cd_values = NULL;
}
pline->nfilters++;
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -331,16 +321,17 @@ H5Z_class_t *
H5Z_find(H5Z_filter_t id)
{
size_t i;
+ H5Z_class_t *ret_value=NULL; /* Return value */
FUNC_ENTER_NOAPI(H5Z_find, NULL);
for (i=0; i<H5Z_table_used_g; i++) {
- if (H5Z_table_g[i].id == id) {
- HRETURN(H5Z_table_g+i);
- }
+ if (H5Z_table_g[i].id == id)
+ HGOTO_DONE(H5Z_table_g+i);
}
- FUNC_LEAVE(NULL);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -383,6 +374,7 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, unsigned flags,
#ifdef H5Z_DEBUG
H5_timer_t timer;
#endif
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5Z_pipeline, FAIL);
@@ -404,8 +396,7 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, unsigned flags,
}
if (NULL==(fclass=H5Z_find(pline->filter[idx].id))) {
failed |= (unsigned)1 << idx;
- HRETURN_ERROR(H5E_PLINE, H5E_READERROR, FAIL,
- "required filter is not registered");
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "required filter is not registered");
}
#ifdef H5Z_DEBUG
H5_timer_begin(&timer);
@@ -421,8 +412,7 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, unsigned flags,
#endif
if (0==new_nbytes) {
failed |= (unsigned)1 << idx;
- HRETURN_ERROR(H5E_PLINE, H5E_READERROR, FAIL,
- "filter returned failure");
+ HGOTO_ERROR(H5E_PLINE, H5E_READERROR, FAIL, "filter returned failure");
}
*nbytes = new_nbytes;
}
@@ -438,8 +428,7 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, unsigned flags,
H5E_clear();
continue;
} else {
- HRETURN_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL,
- "required filter is not registered");
+ HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "required filter is not registered");
}
}
#ifdef H5Z_DEBUG
@@ -457,8 +446,7 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, unsigned flags,
if (0==new_nbytes) {
failed |= (unsigned)1 << idx;
if (0==(pline->filter[idx].flags & H5Z_FLAG_OPTIONAL)) {
- HRETURN_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL,
- "filter returned failure");
+ HGOTO_ERROR(H5E_PLINE, H5E_WRITEERROR, FAIL, "filter returned failure");
} else {
H5E_clear();
}
@@ -469,6 +457,8 @@ H5Z_pipeline(H5F_t UNUSED *f, const H5O_pline_t *pline, unsigned flags,
}
*filter_mask = failed;
- FUNC_LEAVE(SUCCEED);
+
+done:
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5detect.c b/src/H5detect.c
index fc61dd6..0f29eb3 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -429,9 +429,10 @@ H5TN_term_interface(void)\n\
herr_t\n\
H5TN_init_interface(void)\n\
{\n\
- H5T_t *dt = NULL;\n\
+ H5T_t *dt = NULL;\n\
+ herr_t ret_value = SUCCEED;\n\
\n\
- FUNC_ENTER_NOAPI(H5TN_init_interface, FAIL);\n");
+ FUNC_ENTER_NOAPI(H5TN_init_interface, FAIL);\n");
for (i = 0; i < nd; i++) {
@@ -442,19 +443,17 @@ H5TN_init_interface(void)\n\
/* The part common to fixed and floating types */
printf("\
- if (NULL==(dt = H5FL_ALLOC (H5T_t,1))) {\n\
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,\n\
- \"memory allocation failed\");\n\
- }\n\
- dt->state = H5T_STATE_IMMUTABLE;\n\
- dt->ent.header = HADDR_UNDEF;\n\
- dt->type = H5T_%s;\n\
- dt->size = %d;\n\
- dt->u.atomic.order = H5T_ORDER_%s;\n\
- dt->u.atomic.offset = %d;\n\
- dt->u.atomic.prec = %d;\n\
- dt->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\
- dt->u.atomic.msb_pad = H5T_PAD_ZERO;\n",
+ if (NULL==(dt = H5FL_ALLOC (H5T_t,1)))\n\
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,\"memory allocation failed\");\n\
+ dt->state = H5T_STATE_IMMUTABLE;\n\
+ dt->ent.header = HADDR_UNDEF;\n\
+ dt->type = H5T_%s;\n\
+ dt->size = %d;\n\
+ dt->u.atomic.order = H5T_ORDER_%s;\n\
+ dt->u.atomic.offset = %d;\n\
+ dt->u.atomic.prec = %d;\n\
+ dt->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\
+ dt->u.atomic.msb_pad = H5T_PAD_ZERO;\n",
d[i].msize ? "FLOAT" : "INTEGER",/*class */
d[i].size, /*size */
d[i].perm[0] ? "BE" : "LE", /*byte order */
@@ -464,19 +463,19 @@ H5TN_init_interface(void)\n\
if (0 == d[i].msize) {
/* The part unique to fixed point types */
printf("\
- dt->u.atomic.u.i.sign = H5T_SGN_%s;\n",
+ dt->u.atomic.u.i.sign = H5T_SGN_%s;\n",
d[i].sign ? "2" : "NONE");
} else {
/* The part unique to floating point types */
printf("\
- dt->u.atomic.u.f.sign = %d;\n\
- dt->u.atomic.u.f.epos = %d;\n\
- dt->u.atomic.u.f.esize = %d;\n\
- dt->u.atomic.u.f.ebias = 0x%08lx;\n\
- dt->u.atomic.u.f.mpos = %d;\n\
- dt->u.atomic.u.f.msize = %d;\n\
- dt->u.atomic.u.f.norm = H5T_NORM_%s;\n\
- dt->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
+ dt->u.atomic.u.f.sign = %d;\n\
+ dt->u.atomic.u.f.epos = %d;\n\
+ dt->u.atomic.u.f.esize = %d;\n\
+ dt->u.atomic.u.f.ebias = 0x%08lx;\n\
+ dt->u.atomic.u.f.mpos = %d;\n\
+ dt->u.atomic.u.f.msize = %d;\n\
+ dt->u.atomic.u.f.norm = H5T_NORM_%s;\n\
+ dt->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
d[i].sign, /*sign location */
d[i].epos, /*exponent loc */
d[i].esize, /*exponent size */
@@ -488,17 +487,22 @@ H5TN_init_interface(void)\n\
/* Atomize the type */
printf("\
- if ((H5T_NATIVE_%s_g = H5I_register (H5I_DATATYPE, dt))<0) {\n\
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,\n\
- \"can't initialize type system (atom registration \"\n\
- \"failure\");\n\
- }\n",
+ if ((H5T_NATIVE_%s_g = H5I_register (H5I_DATATYPE, dt))<0)\n\
+ HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,\"can't initialize type system (atom registration failure\");\n",
d[i].varname);
- printf(" H5T_NATIVE_%s_ALIGN_g = %lu;\n",
+ printf(" H5T_NATIVE_%s_ALIGN_g = %lu;\n",
d[i].varname, (unsigned long)(d[i].align));
}
- printf(" FUNC_LEAVE (SUCCEED);\n}\n");
+ printf("\
+\n\
+done:\n\
+ if(ret_value<0) {\n\
+ if(dt!=NULL)\n\
+ H5FL_FREE(H5T_t,dt);\n\
+ }\n\
+\n\
+ FUNC_LEAVE (ret_value);\n}\n");
}