summaryrefslogtreecommitdiffstats
path: root/src/H5R.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5R.c')
-rw-r--r--src/H5R.c151
1 files changed, 62 insertions, 89 deletions
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);