diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2002-07-31 19:17:12 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2002-07-31 19:17:12 (GMT) |
commit | 5588db111c57b4a60de020e49e3411330bf8cf00 (patch) | |
tree | 326710b2fb5ab935c5a5c76b0a1fd5855d54549e /src | |
parent | 17275779d07c094741039d0c263fdf055c32bfb6 (diff) | |
download | hdf5-5588db111c57b4a60de020e49e3411330bf8cf00.zip hdf5-5588db111c57b4a60de020e49e3411330bf8cf00.tar.gz hdf5-5588db111c57b4a60de020e49e3411330bf8cf00.tar.bz2 |
[svn-r5840] Purpose:
Code cleanup
Description:
Created a new H5I function which combined the some of the functionality of
H5I_get_type and H5I_object: H5I_object_verify.
Using this new function in the library trims another ~200 lines of code off
the library and makes the resulting binaries smaller and faster also.
Platforms tested:
FreeBSD 4.6 (sleipnir)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5A.c | 40 | ||||
-rw-r--r-- | src/H5AC.c | 2 | ||||
-rw-r--r-- | src/H5D.c | 478 | ||||
-rw-r--r-- | src/H5E.c | 2 | ||||
-rw-r--r-- | src/H5Epublic.h | 2 | ||||
-rw-r--r-- | src/H5F.c | 28 | ||||
-rw-r--r-- | src/H5FD.c | 40 | ||||
-rw-r--r-- | src/H5I.c | 193 | ||||
-rw-r--r-- | src/H5Iprivate.h | 1 | ||||
-rw-r--r-- | src/H5P.c | 46 | ||||
-rw-r--r-- | src/H5R.c | 2 | ||||
-rw-r--r-- | src/H5S.c | 24 | ||||
-rw-r--r-- | src/H5Sall.c | 2 | ||||
-rw-r--r-- | src/H5Shyper.c | 32 | ||||
-rw-r--r-- | src/H5Snone.c | 2 | ||||
-rw-r--r-- | src/H5Spoint.c | 6 | ||||
-rw-r--r-- | src/H5Sselect.c | 10 | ||||
-rw-r--r-- | src/H5T.c | 253 | ||||
-rw-r--r-- | src/H5Tconv.c | 181 | ||||
-rw-r--r-- | src/H5Tvlen.c | 2 |
20 files changed, 556 insertions, 790 deletions
@@ -174,14 +174,10 @@ H5Acreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if (!name || !*name) { HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); } - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (type = H5I_object(type_id))) { + if (NULL == (type = H5I_object_verify(type_id, H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type"); - } - if (H5I_DATASPACE != H5I_get_type(space_id) || - NULL == (space = H5I_object(space_id))) { + if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_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) { @@ -561,14 +557,10 @@ H5Awrite(hid_t attr_id, hid_t type_id, const void *buf) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ - if (H5I_ATTR != H5I_get_type(attr_id) || - (NULL == (attr = H5I_object(attr_id)))) { + if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute"); - } - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (mem_type = H5I_object(type_id))) { + 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"); } @@ -715,14 +707,10 @@ H5Aread(hid_t attr_id, hid_t type_id, void *buf) H5TRACE3("e","iix",attr_id,type_id,buf); /* check arguments */ - if (H5I_ATTR != H5I_get_type(attr_id) || - (NULL == (attr = H5I_object(attr_id)))) { + if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute"); - } - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (mem_type = H5I_object(type_id))) { + 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"); } @@ -860,10 +848,8 @@ H5Aget_space(hid_t attr_id) H5TRACE1("i","i",attr_id); /* check arguments */ - if (H5I_ATTR != H5I_get_type(attr_id) || - (NULL == (attr = H5I_object(attr_id)))) { + if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute"); - } /* Copy the attribute's dataspace */ if (NULL==(dst=H5S_copy (attr->ds))) { @@ -917,10 +903,8 @@ H5Aget_type(hid_t attr_id) H5TRACE1("i","i",attr_id); /* check arguments */ - if (H5I_ATTR != H5I_get_type(attr_id) || - (NULL == (attr = H5I_object(attr_id)))) { + if (NULL == (attr = H5I_object_verify(attr_id, H5I_ATTR))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute"); - } /* * Copy the attribute's data type. If the type is a named type then @@ -987,10 +971,8 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) H5TRACE3("Zs","izs",attr_id,buf_size,buf); /* check arguments */ - if (H5I_ATTR != H5I_get_type(attr_id) || - (NULL == (attr = H5I_object(attr_id)))) { + 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"); } @@ -1273,12 +1255,12 @@ H5Aclose(hid_t attr_id) H5TRACE1("e","i",attr_id); /* check arguments */ - if (H5I_ATTR != H5I_get_type(attr_id) || NULL == H5I_object(attr_id)) { + if (NULL == H5I_object_verify(attr_id, H5I_ATTR)) HRETURN_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); } /* H5Aclose() */ @@ -102,7 +102,7 @@ H5AC_init_interface(void) assert(H5P_CLS_DATASET_XFER_g!=(-1)); /* Get the dataset transfer property list class object */ - if (H5I_GENPROP_CLS != H5I_get_type(H5P_CLS_DATASET_XFER_g) || NULL == (xfer_pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) + 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"); /* Create a new dataset transfer property list */ @@ -193,7 +193,7 @@ H5D_init_interface(void) assert(H5P_CLS_DATASET_XFER_g!=(-1)); /* Get the pointer to the dataset transfer class */ - if (H5I_GENPROP_CLS != H5I_get_type(H5P_CLS_DATASET_XFER_g) || NULL == (xfer_pclass = H5I_object(H5P_CLS_DATASET_XFER_g))) + if (NULL == (xfer_pclass = H5I_object_verify(H5P_CLS_DATASET_XFER_g, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -273,7 +273,7 @@ H5D_init_interface(void) assert(H5P_CLS_DATASET_CREATE_g != -1); /* Get the pointer to the dataset creation class */ - if(H5I_GENPROP_CLS != H5I_get_type(H5P_CLS_DATASET_CREATE_g) || NULL == (crt_pclass = H5I_object(H5P_CLS_DATASET_CREATE_g))) + if(NULL == (crt_pclass = H5I_object_verify(H5P_CLS_DATASET_CREATE_g, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -692,44 +692,39 @@ H5Dcreate(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, H5T_t *type = NULL; H5S_t *space = NULL; H5D_t *new_dset = NULL; - hid_t ret_value = FAIL; + hid_t ret_value; FUNC_ENTER_API(H5Dcreate, FAIL); H5TRACE5("i","isiii",loc_id,name,type_id,space_id,plist_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 (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (type = H5I_object(type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type"); - } - if (H5I_DATASPACE != H5I_get_type(space_id) || - NULL == (space = H5I_object(space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } + 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))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type"); + if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); if(H5P_DEFAULT == plist_id) plist_id = H5P_DATASET_CREATE_DEFAULT; - if(H5I_GENPROP_LST != H5I_get_type(plist_id) || - TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not dataset create property list"); + if(H5I_GENPROP_LST != H5I_get_type(plist_id) || TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list"); /* build and open the new dataset */ - if (NULL == (new_dset = H5D_create(loc, name, type, space, plist_id))) { - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to create dataset"); - } + if (NULL == (new_dset = H5D_create(loc, name, type, space, plist_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset"); + /* Register the new dataset to get an ID for it */ - if ((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0) { - H5D_close(new_dset); - HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, - "unable to register dataset"); - } + if ((ret_value = H5I_register(H5I_DATASET, new_dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset"); + +done: + if(ret_value<0) { + if(new_dset!=NULL) + H5D_close(new_dset); + } /* end if */ + FUNC_LEAVE(ret_value); } @@ -759,33 +754,35 @@ H5Dopen(hid_t loc_id, const char *name) { H5G_entry_t *loc = NULL; /*location holding the dataset */ H5D_t *dataset = NULL; /*the dataset */ - hid_t ret_value = FAIL; + hid_t ret_value; FUNC_ENTER_API(H5Dopen, 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"); /* Find the dataset */ - if (NULL == (dataset = H5D_open(loc, name))) { - HRETURN_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "dataset not found"); - } + if (NULL == (dataset = H5D_open(loc, name))) + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "dataset not found"); /* Create an atom for the dataset */ - if ((ret_value = H5I_register(H5I_DATASET, dataset)) < 0) { - H5D_close(dataset); - HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, - "can't register dataset"); - } + if ((ret_value = H5I_register(H5I_DATASET, dataset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register dataset"); + +done: + if(ret_value<0) { + if(dataset!=NULL) + H5D_close(dataset); + } /* end if */ + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5Dclose * @@ -809,26 +806,29 @@ H5Dopen(hid_t loc_id, const char *name) herr_t H5Dclose(hid_t dset_id) { - H5D_t *dset = NULL; /* dataset object to release */ + H5D_t *dset = NULL; /* Dataset object to release */ + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dclose, FAIL); H5TRACE1("e","i",dset_id); /* Check args */ - if (H5I_DATASET != H5I_get_type(dset_id) || - NULL == (dset = H5I_object(dset_id)) || - NULL == dset->ent.file) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); - } + if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (NULL == dset->ent.file) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset"); + /* * Decrement the counter on the dataset. It will be freed if the count * reaches zero. */ - if (H5I_dec_ref(dset_id) < 0) { - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free"); - } - FUNC_LEAVE(SUCCEED); + if (H5I_dec_ref(dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free"); + +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5Dget_space @@ -855,29 +855,28 @@ H5Dget_space(hid_t dset_id) { H5D_t *dset = NULL; H5S_t *space = NULL; - hid_t ret_value = FAIL; + hid_t ret_value; FUNC_ENTER_API(H5Dget_space, FAIL); H5TRACE1("i","i",dset_id); /* Check args */ - if (H5I_DATASET!=H5I_get_type (dset_id) || - NULL==(dset=H5I_object (dset_id))) { - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); - } + if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); /* Read the data space message and return a data space object */ - if (NULL==(space=H5D_get_space (dset))) { - HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to get data space"); - } + if (NULL==(space=H5D_get_space (dset))) + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space"); /* Create an atom */ - if ((ret_value=H5I_register (H5I_DATASPACE, space))<0) { - H5S_close(space); - HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to register data space"); - } + if ((ret_value=H5I_register (H5I_DATASPACE, space))<0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data space"); + +done: + if(ret_value<0) { + if(space!=NULL) + H5S_close(space); + } /* end if */ FUNC_LEAVE (ret_value); } @@ -907,10 +906,8 @@ H5D_get_space(H5D_t *dset) 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"); - } + if (NULL==(space=H5S_read(&(dset->ent)))) + HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to load space info from dataset header"); FUNC_LEAVE(space); } @@ -940,7 +937,7 @@ herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) FUNC_ENTER_API(H5Dget_space_status, FAIL); /* Check arguments */ - if(H5I_DATASET != H5I_get_type(dset_id) || NULL==(dset=H5I_object(dset_id))) + if(NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); /* Read data space address and return */ @@ -1052,32 +1049,30 @@ H5Dget_type(hid_t dset_id) H5TRACE1("i","i",dset_id); /* Check args */ - if (H5I_DATASET!=H5I_get_type (dset_id) || - NULL==(dset=H5I_object (dset_id))) { - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); - } + if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); /* Copy the data type and mark it read-only */ - if (NULL==(copied_type=H5T_copy (dset->type, H5T_COPY_REOPEN))) { - HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to copy the data type"); - } + if (NULL==(copied_type=H5T_copy (dset->type, H5T_COPY_REOPEN))) + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy the data type"); + /* Mark any VL datatypes as being in memory now */ - if (H5T_vlen_mark(copied_type, NULL, H5T_VLEN_MEMORY)<0) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); - } - if (H5T_lock (copied_type, FALSE)<0) { - H5T_close (copied_type); - HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to lock transient data type"); - } + if (H5T_vlen_mark(copied_type, NULL, H5T_VLEN_MEMORY)<0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location"); + + /* Unlock copied type */ + if (H5T_lock (copied_type, FALSE)<0) + HGOTO_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient data type"); /* Create an atom */ - if ((ret_value=H5I_register (H5I_DATATYPE, copied_type))<0) { - H5T_close (copied_type); - HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, - "unable to register data type"); - } + if ((ret_value=H5I_register (H5I_DATATYPE, copied_type))<0) + HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register data type"); + +done: + if(ret_value<0) { + if(copied_type!=NULL) + H5T_close (copied_type); + } /* end if */ FUNC_LEAVE (ret_value); } @@ -1113,35 +1108,45 @@ H5Dget_create_plist(hid_t dset_id) H5O_fill_t copied_fill={NULL,0,NULL}; H5P_genplist_t *dcpl_plist; H5P_genplist_t *new_plist; + hid_t new_dcpl_id = FAIL; hid_t ret_value = FAIL; FUNC_ENTER_API(H5Dget_create_plist, FAIL); H5TRACE1("i","i",dset_id); /* Check args */ - if (H5I_DATASET!=H5I_get_type (dset_id) || NULL==(dset=H5I_object (dset_id))) - HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); if (NULL == (dcpl_plist = H5I_object(dset->dcpl_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"); /* Copy the creation property list */ - if((ret_value = H5P_copy_plist(dcpl_plist)) < 0) - HRETURN_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list"); - if (NULL == (new_plist = H5I_object(ret_value))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + if((new_dcpl_id = H5P_copy_plist(dcpl_plist)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to copy the creation property list"); + if (NULL == (new_plist = H5I_object(new_dcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); /* Get the fill value property */ if(H5P_get(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) - HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fill value"); /* Copy the dataset type into the fill value message */ if(copied_fill.type==NULL) if(NULL==(copied_fill.type=H5T_copy(dset->type, H5T_COPY_TRANSIENT))) - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset data type for fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to copy dataset data type for fill value"); /* Set back the fill value property to property list */ if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &copied_fill) < 0) - HRETURN_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property list fill value"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set property list fill value"); + + /* Set the return value */ + ret_value=new_dcpl_id; + +done: + if(ret_value<0) { + if(new_dcpl_id>0) + H5Pclose(new_dcpl_id); + } /* end if */ FUNC_LEAVE (ret_value); } @@ -1195,59 +1200,51 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, const H5T_t *mem_type = NULL; const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dread, FAIL); H5TRACE6("e","iiiiix",dset_id,mem_type_id,mem_space_id,file_space_id, plist_id,buf); /* check arguments */ - if (H5I_DATASET != H5I_get_type(dset_id) || - NULL == (dset = H5I_object(dset_id)) || - NULL == dset->ent.file) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); - } - if (H5I_DATATYPE != H5I_get_type(mem_type_id) || - NULL == (mem_type = H5I_object(mem_type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } + if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (NULL == dset->ent.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (H5S_ALL != mem_space_id) { - if (H5I_DATASPACE != H5I_get_type(mem_space_id) || - NULL == (mem_space = H5I_object(mem_space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } + if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + /* Check for valid selection */ - if((*mem_space->select.is_valid)(mem_space)!=TRUE) { - HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "selection+offset not within extent"); - } + if((*mem_space->select.is_valid)(mem_space)!=TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); } if (H5S_ALL != file_space_id) { - if (H5I_DATASPACE != H5I_get_type(file_space_id) || - NULL == (file_space = H5I_object(file_space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } + if (NULL == (file_space = H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + /* Check for valid selection */ - if((*file_space->select.is_valid)(file_space)!=TRUE) { - HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "selection+offset not within extent"); - } + if((*file_space->select.is_valid)(file_space)!=TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); } /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || - TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); + if (H5I_GENPROP_LST != H5I_get_type(plist_id) || TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); if (!buf) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); /* read raw data */ if (H5D_read(dset, mem_type, mem_space, file_space, plist_id, buf/*out*/) < 0) - HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data"); + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data"); - FUNC_LEAVE(SUCCEED); +done: + FUNC_LEAVE(ret_value); } /*------------------------------------------------------------------------- @@ -1293,60 +1290,53 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, const H5T_t *mem_type = NULL; const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dwrite, FAIL); H5TRACE6("e","iiiiix",dset_id,mem_type_id,mem_space_id,file_space_id, plist_id,buf); /* check arguments */ - if (H5I_DATASET != H5I_get_type(dset_id) || - NULL == (dset = H5I_object(dset_id)) || - NULL == dset->ent.file) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); - } - if (H5I_DATATYPE != H5I_get_type(mem_type_id) || - NULL == (mem_type = H5I_object(mem_type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } + if (NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (NULL == dset->ent.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (NULL == (mem_type = H5I_object_verify(mem_type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (H5S_ALL != mem_space_id) { - if (H5I_DATASPACE != H5I_get_type(mem_space_id) || - NULL == (mem_space = H5I_object(mem_space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } + if (NULL == (mem_space = H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + /* Check for valid selection */ - if ((*mem_space->select.is_valid)(mem_space)!=TRUE) { - HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "selection+offset not within extent"); - } + if ((*mem_space->select.is_valid)(mem_space)!=TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); } if (H5S_ALL != file_space_id) { - if (H5I_DATASPACE != H5I_get_type(file_space_id) || - NULL == (file_space = H5I_object(file_space_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } + if (NULL == (file_space = H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); + /* Check for valid selection */ - if ((*file_space->select.is_valid)(file_space)!=TRUE) { - HRETURN_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, - "selection+offset not within extent"); - } + if ((*file_space->select.is_valid)(file_space)!=TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent"); } /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || - TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); + if (H5I_GENPROP_LST != H5I_get_type(plist_id) || TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); if (!buf) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer"); /* write raw data */ if (H5D_write(dset, mem_type, mem_space, file_space, plist_id, buf) < 0) - HRETURN_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data"); + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data"); - FUNC_LEAVE(SUCCEED); +done: + FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5Dextend @@ -1368,26 +1358,23 @@ herr_t H5Dextend(hid_t dset_id, const hsize_t *size) { H5D_t *dset = NULL; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dextend, FAIL); H5TRACE2("e","i*h",dset_id,size); /* Check args */ - if (H5I_DATASET!=H5I_get_type(dset_id) || - NULL==(dset=H5I_object(dset_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); - } - if (!size) { - HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified"); - } + if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if (!size) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified"); /* Increase size */ - if (H5D_extend (dset, size)<0) { - HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to extend dataset"); - } + if (H5D_extend (dset, size)<0) + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset"); - FUNC_LEAVE (SUCCEED); +done: + FUNC_LEAVE (ret_value); } @@ -1593,11 +1580,8 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, * Also, only the slowest varying dimension of a simple data space * can be extendible. */ - if ((ndims=H5S_get_simple_extent_dims(space, new_dset->layout.dim, - max_dim))<0) { - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, - "unable to initialize contiguous storage"); - } + if ((ndims=H5S_get_simple_extent_dims(space, new_dset->layout.dim, max_dim))<0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize contiguous storage"); for (i=1; i<ndims; i++) { if (max_dim[i]>new_dset->layout.dim[i]) HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "only the first dimension can be extendible"); @@ -1685,20 +1669,18 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, if(fill.fill_defined == FALSE && fill_time != H5D_FILL_TIME_NEVER) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,NULL, "unable to create dataset"); + /* Write new fill value message */ - if (H5O_modify(&(new_dset->ent), H5O_FILL_NEW, 0, H5O_FLAG_CONSTANT, - &fill) < 0) + if (H5O_modify(&(new_dset->ent), H5O_FILL_NEW, 0, H5O_FLAG_CONSTANT, &fill) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update fill value header message"); - H5O_reset(H5O_FILL, &fill_prop); if(fill.buf && (NULL==H5O_copy(H5O_FILL, &fill, &fill_prop))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT,NULL,"unable to copy fill value"); H5O_reset(H5O_FILL_NEW, &fill); + /* Write old fill value */ - if (fill_prop.buf && H5O_modify(&(new_dset->ent), H5O_FILL, 0, - H5O_FLAG_CONSTANT, &fill_prop) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, - "unable to update fill value header message"); + if (fill_prop.buf && H5O_modify(&(new_dset->ent), H5O_FILL, 0, H5O_FLAG_CONSTANT, &fill_prop) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to update fill value header message"); if(H5P_set(new_plist, H5D_CRT_FILL_VALUE_NAME, &fill_prop) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "can't set fill value"); @@ -1740,8 +1722,7 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, new_dset->layout.addr = HADDR_UNDEF; #else /*H5_HAVE_PARALLEL*/ if (0==efl.nused) { - if(dcpl_layout==H5D_CHUNKED || (dcpl_layout==H5D_CONTIGUOUS && - space_time==H5D_SPACE_ALLOC_EARLY)) { + if(dcpl_layout==H5D_CHUNKED || (dcpl_layout==H5D_CONTIGUOUS && space_time==H5D_SPACE_ALLOC_EARLY)) { if (H5F_arr_create(f, &(new_dset->layout))<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage"); } /* end if */ @@ -1787,8 +1768,7 @@ H5D_create(H5G_entry_t *loc, const char *name, const H5T_t *type, if (H5D_init_storage(new_dset, space)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage"); #else /*H5_HAVE_PARALLEL*/ - if(fill_time==H5D_FILL_TIME_ALLOC && - ((space_time==H5D_SPACE_ALLOC_EARLY && !efl.nused) || (efl.nused))) + if(fill_time==H5D_FILL_TIME_ALLOC && ((space_time==H5D_SPACE_ALLOC_EARLY && !efl.nused) || (efl.nused))) if (H5D_init_storage(new_dset, space)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize storage"); #endif /*H5_HAVE_PARALLEL*/ @@ -1805,6 +1785,7 @@ done: new_dset->ent.file = NULL; H5FL_FREE(H5D_t,new_dset); } + FUNC_LEAVE(ret_value); } @@ -1832,6 +1813,7 @@ htri_t H5D_isa(H5G_entry_t *ent) { htri_t exists; + htri_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI(H5D_isa, FAIL); @@ -1839,25 +1821,24 @@ H5D_isa(H5G_entry_t *ent) /* Data type */ if ((exists=H5O_exists(ent, H5O_DTYPE, 0))<0) { - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to read object header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header"); } else if (!exists) { HRETURN(FALSE); } /* Layout */ if ((exists=H5O_exists(ent, H5O_LAYOUT, 0))<0) { - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to read object header"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to read object header"); } else if (!exists) { HRETURN(FALSE); } - - FUNC_LEAVE(TRUE); +done: + FUNC_LEAVE(ret_value); } + /* *------------------------------------------------------------------------- * Function: H5D_open @@ -1897,13 +1878,12 @@ H5D_open(H5G_entry_t *loc, const char *name) assert (name && *name); /* Find the dataset object */ - if (H5G_find(loc, name, NULL, &ent) < 0) { + if (H5G_find(loc, name, NULL, &ent) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found"); - } + /* 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"); - } /* Success */ ret_value = dataset; @@ -1912,6 +1892,7 @@ done: FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5D_open_oid * @@ -2073,8 +2054,7 @@ H5D_open_oid(H5G_entry_t *ent) * This is especially important for parallel I/O where the B-tree must * be fully populated before I/O can happen. */ - if ((H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR) && - H5D_CHUNKED==dataset->layout.type) { + if ((H5F_get_intent(dataset->ent.file) & H5F_ACC_RDWR) && H5D_CHUNKED==dataset->layout.type) { if (H5D_init_storage(dataset, space)<0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize file storage"); } @@ -2096,6 +2076,7 @@ done: FUNC_LEAVE(ret_value); } + /*------------------------------------------------------------------------- * Function: H5D_close * @@ -2260,7 +2241,7 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); /* Get the dataset transfer property list */ - if (NULL == (dx_plist = H5I_object(dxpl_id))) + if (NULL == (dx_plist = H5I_object_verify(dxpl_id,H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); if (!file_space) { @@ -2674,7 +2655,7 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); /* Get the dataset transfer property list */ - if (NULL == (dx_plist = H5I_object(dxpl_id))) + if (NULL == (dx_plist = H5I_object_verify(dxpl_id,H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation property list"); #ifdef H5_HAVE_PARALLEL @@ -3033,7 +3014,7 @@ done: herr_t H5D_extend (H5D_t *dataset, const hsize_t *size) { - herr_t changed, ret_value=FAIL; + herr_t changed, ret_value=SUCCEED; H5S_t *space = NULL; H5O_fill_t fill; H5P_genplist_t *plist; /* Property list */ @@ -3083,8 +3064,6 @@ H5D_extend (H5D_t *dataset, const hsize_t *size) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize dataset with fill value"); } /* end if */ - ret_value = SUCCEED; - done: H5S_close(space); FUNC_LEAVE (ret_value); @@ -3324,11 +3303,11 @@ H5Dget_storage_size(hid_t dset_id) H5TRACE1("h","i",dset_id); /* Check args */ - if (H5I_DATASET!=H5I_get_type(dset_id) || NULL==(dset=H5I_object(dset_id))) { + if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset"); - } size = H5D_get_storage_size(dset); + FUNC_LEAVE(size); } @@ -3444,24 +3423,24 @@ H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, void *operator_data) { H5S_t *space = NULL; - herr_t ret_value=FAIL; + herr_t ret_value; FUNC_ENTER_API(H5Diterate, FAIL); H5TRACE5("e","xiixx",buf,type_id,space_id,op,operator_data); /* Check args */ if (NULL==op) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid operator"); if (buf==NULL) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer"); if (H5I_DATATYPE != H5I_get_type(type_id)) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype"); - if (H5I_DATASPACE != H5I_get_type(space_id) || - NULL == (space = H5I_object(space_id))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype"); + if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace"); ret_value=H5S_select_iterate(buf,type_id,space,op,operator_data); +done: FUNC_LEAVE(ret_value); } /* end H5Diterate() */ @@ -3486,7 +3465,7 @@ H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op, herr_t H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf) { - herr_t ret_value=FAIL; + herr_t ret_value; FUNC_ENTER_API(H5Dvlen_reclaim, FAIL); H5TRACE4("e","iiix",type_id,space_id,plist_id,buf); @@ -3495,21 +3474,23 @@ H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf) if (H5I_DATATYPE!=H5I_get_type(type_id) || H5I_DATASPACE!=H5I_get_type(space_id) || buf==NULL) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument"); /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; if (TRUE!=H5P_isa_class(plist_id,H5P_DATASET_XFER)) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms"); /* Call H5Diterate with args, etc. */ ret_value=H5Diterate(buf,type_id,space_id,H5T_vlen_reclaim,&plist_id); +done: FUNC_LEAVE(ret_value); } /* end H5Dvlen_reclaim() */ + /*------------------------------------------------------------------------- * Function: H5D_vlen_get_buf_size_alloc * @@ -3574,7 +3555,7 @@ H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, hsize_t UNUSED ndim, hss { H5T_vlen_bufsize_t *vlen_bufsize=(H5T_vlen_bufsize_t *)op_data; H5T_t *dt = NULL; - herr_t ret_value=FAIL; + herr_t ret_value=0; /* The correct return value, if this function succeeds */ FUNC_ENTER_NOAPI(H5D_vlen_get_buf_size, FAIL); @@ -3597,11 +3578,7 @@ H5D_vlen_get_buf_size(void UNUSED *elem, hid_t type_id, hsize_t UNUSED ndim, hss if(H5Dread(vlen_bufsize->dataset_id,type_id,vlen_bufsize->mspace_id,vlen_bufsize->fspace_id,vlen_bufsize->xfer_pid,vlen_bufsize->fl_tbuf)<0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point"); - /* Set the correct return value, if we get this far */ - ret_value=0; - done: - FUNC_LEAVE(ret_value); } /* end H5D_vlen_get_buf_size() */ @@ -3836,11 +3813,11 @@ H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_ /* Check args */ if (buf==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer"); - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space=H5I_object(space_id))) + if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace"); - if (H5I_DATATYPE != H5I_get_type(fill_type_id) || NULL == (fill_type=H5I_object(fill_type_id))) + if (NULL == (fill_type=H5I_object_verify(fill_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype"); - if (H5I_DATATYPE != H5I_get_type(buf_type_id) || NULL == (buf_type=H5I_object(buf_type_id))) + if (NULL == (buf_type=H5I_object_verify(buf_type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype"); /* Fill the selection in the memory buffer */ @@ -3875,22 +3852,23 @@ herr_t H5Dset_extent(hid_t dset_id, const hsize_t *size) { H5D_t *dset = NULL; + herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(H5Dset_extent, FAIL); H5TRACE2("e","i*h",dset_id,size); /* Check args */ - if(H5I_DATASET != H5I_get_type(dset_id) - || NULL == (dset = H5I_object(dset_id))) - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); + if(NULL == (dset = H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); if(!size) - HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified"); /* Private function */ if(H5D_set_extent(dset, size) < 0) - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset"); + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset"); - FUNC_LEAVE(SUCCEED); +done: + FUNC_LEAVE(ret_value); } @@ -3918,7 +3896,7 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size) { hsize_t curr_dims[H5O_LAYOUT_NDIMS]; /* Current dimension sizes */ int rank; /* Dataspace # of dimensions */ - herr_t ret_value = FAIL; + herr_t ret_value = SUCCEED; /* Return value */ H5S_t *space = NULL; H5P_genplist_t *plist; int u; @@ -3977,20 +3955,10 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size) *------------------------------------------------------------------------- */ if(shrink && H5D_CHUNKED == dset->layout.type) { -#if defined (PVN) - H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims, - dset->layout.addr); -#endif - /* Remove excess chunks */ if(H5F_istore_prune_by_extent(dset->ent.file, &dset->layout, space) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to remove chunks "); -#if defined (PVN) - H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims, - dset->layout.addr); -#endif - /* Get the dataset creation property list */ if(NULL == (plist = H5I_object(dset->dcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dset creation property list"); @@ -4000,8 +3968,6 @@ H5D_set_extent(H5D_t *dset, const hsize_t *size) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to initialize chunks "); } /* end if */ - ret_value = SUCCEED; - done: if(space) H5S_close(space); @@ -4035,18 +4001,14 @@ H5Ddebug(hid_t dset_id, unsigned UNUSED flags) H5TRACE2("e","iIu",dset_id,flags); /* Check args */ - if (H5I_DATASET!=H5I_get_type(dset_id) || - NULL==(dset=H5I_object(dset_id))) { + if (NULL==(dset=H5I_object_verify(dset_id, H5I_DATASET))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset"); - } /* Print B-tree information */ if (H5D_CHUNKED==dset->layout.type) { - H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims, - dset->layout.addr); + H5F_istore_dump_btree(dset->ent.file, stdout, dset->layout.ndims, dset->layout.addr); } else if (H5D_CONTIGUOUS==dset->layout.type) { - HDfprintf(stdout, " %-10s %a\n", "Address:", - dset->layout.addr); + HDfprintf(stdout, " %-10s %a\n", "Address:", dset->layout.addr); } FUNC_LEAVE(SUCCEED); @@ -103,9 +103,11 @@ static const H5E_minor_mesg_t H5E_minor_mesg_g[] = { /* Object atom related errors */ {H5E_BADATOM, "Unable to find atom information (already closed?)"}, + {H5E_BADGROUP, "Unable to find ID group information"}, {H5E_CANTREGISTER, "Unable to register new atom"}, {H5E_CANTINC, "Unable to increment reference count"}, {H5E_CANTDEC, "Unable to decrement reference count"}, + {H5E_NOIDS, "Out of IDs for group"}, /* Cache related errors */ {H5E_CANTFLUSH, "Unable to flush data from cache"}, diff --git a/src/H5Epublic.h b/src/H5Epublic.h index 3458aa6..d6f1dc8 100644 --- a/src/H5Epublic.h +++ b/src/H5Epublic.h @@ -143,9 +143,11 @@ typedef enum H5E_minor_t { /* Object atom related errors */ H5E_BADATOM, /*Can't find atom information */ + H5E_BADGROUP, /*Can't find group information */ H5E_CANTREGISTER, /*Can't register new atom */ H5E_CANTINC, /*Can't increment reference count */ H5E_CANTDEC, /*Can't decrement reference count */ + H5E_NOIDS, /*Out of IDs for group */ /* Cache related errors */ H5E_CANTFLUSH, /*Can't flush object from cache */ @@ -240,7 +240,7 @@ H5F_init_interface(void) assert(H5P_CLS_FILE_CREATE_g!=-1); /* Get the pointer to file creation class */ - if(H5I_GENPROP_CLS != H5I_get_type(H5P_CLS_FILE_CREATE_g) || NULL == (crt_pclass = H5I_object(H5P_CLS_FILE_CREATE_g))) + if(NULL == (crt_pclass = H5I_object_verify(H5P_CLS_FILE_CREATE_g, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -323,7 +323,7 @@ H5F_init_interface(void) assert(H5P_CLS_FILE_ACCESS_g!=-1); /* Get the pointer to file creation class */ - if(H5I_GENPROP_CLS != H5I_get_type(H5P_CLS_FILE_ACCESS_g) || NULL == (acs_pclass = H5I_object(H5P_CLS_FILE_ACCESS_g))) + if(NULL == (acs_pclass = H5I_object_verify(H5P_CLS_FILE_ACCESS_g, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -397,7 +397,7 @@ H5F_init_interface(void) assert(H5P_CLS_MOUNT_g!=-1); /* Get the pointer to file mount class */ - if(H5I_GENPROP_CLS != H5I_get_type(H5P_CLS_MOUNT_g) || NULL == (mnt_pclass = H5I_object(H5P_CLS_MOUNT_g))) + if(NULL == (mnt_pclass = H5I_object_verify(H5P_CLS_MOUNT_g, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Get the number of properties in the class */ @@ -600,9 +600,9 @@ H5F_acs_copy(hid_t new_fapl_id, hid_t old_fapl_id, void UNUSED *copy_data) FUNC_ENTER_NOAPI(H5F_acs_copy, FAIL); - if(H5I_GENPROP_LST != H5I_get_type(new_fapl_id) || H5I_GENPROP_LST != H5I_get_type(old_fapl_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if(NULL == (new_plist = H5I_object(new_fapl_id)) || NULL == (old_plist = H5I_object(old_fapl_id))) + if(NULL == (new_plist = H5I_object_verify(new_fapl_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + if(NULL == (old_plist = H5I_object_verify(old_fapl_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); /* Get values from old property list */ @@ -780,7 +780,7 @@ H5Fget_create_plist(hid_t file_id) H5TRACE1("i","i",file_id); /* check args */ - if (H5I_FILE!=H5I_get_type(file_id) || NULL==(file=H5I_object(file_id))) + if (NULL==(file=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); if(NULL == (plist = H5I_object(file->shared->fcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); @@ -828,7 +828,7 @@ H5Fget_access_plist(hid_t file_id) H5TRACE1("i","i",file_id); /* Check args */ - if (H5I_FILE!=H5I_get_type(file_id) || NULL==(f=H5I_object(file_id))) + if (NULL==(f=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); /* Make a copy of the default file access property list */ @@ -905,8 +905,7 @@ H5Fget_obj_count(hid_t file_id, unsigned types, unsigned *obj_id_count) FUNC_ENTER_API(H5Fget_obj_counts, FAIL); H5TRACE3("e","iIu*Iu",file_id,types,obj_id_count); - if( file_id != H5F_OBJ_ALL && (H5I_FILE != H5I_get_type(file_id) || - NULL==(f=H5I_object(file_id))) ) + 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) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type"); @@ -973,8 +972,7 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, hid_t *oid_list) FUNC_ENTER_API(H5Fget_obj_ids, FAIL); H5TRACE3("e","iIu*i",file_id,types,oid_list); - if( file_id != H5F_OBJ_ALL && (H5I_FILE != H5I_get_type(file_id) || - NULL==(f=H5I_object(file_id))) ) + 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) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type"); @@ -2776,7 +2774,7 @@ H5Fclose(hid_t file_id) H5TRACE1("e","i",file_id); /* Check/fix arguments. */ - if (H5I_FILE != H5I_get_type(file_id) || NULL==H5I_object(file_id)) + if (NULL==H5I_object_verify(file_id,H5I_FILE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file atom"); /* @@ -3108,7 +3106,7 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_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(child_id) || NULL==(child=H5I_object(child_id))) + if (NULL==(child=H5I_object_verify(child_id,H5I_FILE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); if(H5P_DEFAULT == plist_id) plist_id = H5P_MOUNT_DEFAULT; @@ -3202,7 +3200,7 @@ H5Freopen(hid_t file_id) FUNC_ENTER_API(H5Freopen, FAIL); H5TRACE1("i","i",file_id); - if (H5I_FILE!=H5I_get_type(file_id) || NULL==(old_file=H5I_object(file_id))) + if (NULL==(old_file=H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file"); /* Get a new "top level" file struct, sharing the same "low level" file struct */ @@ -267,17 +267,12 @@ H5FDunregister(hid_t driver_id) H5TRACE1("e","i",driver_id); /* Check arguments */ - if (H5I_VFL!=H5I_get_type(driver_id) || - NULL==H5I_object(driver_id)) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, - "not a file driver"); - } + if (NULL==H5I_object_verify(driver_id,H5I_VFL)) + HRETURN_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"); - } + if (H5I_dec_ref(driver_id)<0) + HRETURN_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "unable to unregister file driver"); FUNC_LEAVE(SUCCEED); } @@ -518,11 +513,10 @@ H5FD_fapl_copy(hid_t driver_id, const void *old_fapl) FUNC_ENTER_NOAPI(H5FD_fapl_copy, NULL); /* Check args */ - if (H5I_VFL!=H5I_get_type(driver_id) || - NULL==(driver=H5I_object(driver_id))) { + if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver ID"); - } - if (!old_fapl) HRETURN(NULL); /*but no error*/ + if (!old_fapl) + HRETURN(NULL); /*but no error*/ /* Allow the driver to copy or do it ourselves */ if (driver->fapl_copy) { @@ -563,10 +557,8 @@ H5FD_fapl_free(hid_t driver_id, void *fapl) FUNC_ENTER_NOAPI(H5FD_fapl_free, FAIL); /* Check args */ - if (H5I_VFL!=H5I_get_type(driver_id) || - NULL==(driver=H5I_object(driver_id))) { + if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID"); - } /* Allow driver to free or do it ourselves */ if (fapl && driver->fapl_free) { @@ -611,12 +603,10 @@ H5FD_dxpl_copy(hid_t driver_id, const void *old_dxpl) FUNC_ENTER_NOAPI(H5FD_dxpl_copy, NULL); /* Check args */ - if (H5I_VFL!=H5I_get_type(driver_id) || - NULL==(driver=H5I_object(driver_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, - "not a driver ID"); - } - if (!old_dxpl) HRETURN(NULL); /*but no error*/ + if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL))) + HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver ID"); + if (!old_dxpl) + HRETURN(NULL); /*but no error*/ /* Allow the driver to copy or do it ourselves */ if (driver->dxpl_copy) { @@ -657,10 +647,8 @@ H5FD_dxpl_free(hid_t driver_id, void *dxpl) FUNC_ENTER_NOAPI(H5FD_dxpl_free, FAIL); /* Check args */ - if (H5I_VFL!=H5I_get_type(driver_id) || - NULL==(driver=H5I_object(driver_id))) { + if (NULL==(driver=H5I_object_verify(driver_id,H5I_VFL))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID"); - } /* Allow driver to free or do it ourselves */ if (dxpl && driver->dxpl_free) { @@ -793,7 +781,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID"); /* Get driver info */ - if (H5I_VFL!=H5I_get_type(driver_id) || NULL==(driver=H5I_object(driver_id))) + 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"); if (NULL==driver->open) HRETURN_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method"); @@ -189,20 +189,17 @@ H5I_init_group(H5I_type_t grp, size_t hash_size, unsigned reserved, FUNC_ENTER_NOAPI(H5I_init_group, FAIL); /* Check arguments */ - if ((grp <= H5I_BADID || grp >= H5I_NGROUPS) && hash_size > 0) { - HGOTO_DONE(FAIL); - } + if ((grp <= H5I_BADID || grp >= H5I_NGROUPS) && hash_size > 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); #ifdef HASH_SIZE_POWER_2 if (!POWER_OF_TWO(hash_size) || hash_size == 1) - HGOTO_DONE(FAIL); + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid hash size"); #endif /* HASH_SIZE_POWER_2 */ if (H5I_id_group_list_g[grp] == NULL) { /* Allocate the group information for new group */ - if (NULL==(grp_ptr = H5MM_calloc(sizeof(H5I_id_group_t)))) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } + if (NULL==(grp_ptr = H5MM_calloc(sizeof(H5I_id_group_t)))) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); H5I_id_group_list_g[grp] = grp_ptr; } else { /* Get the pointer to the existing group */ @@ -218,16 +215,14 @@ H5I_init_group(H5I_type_t grp, size_t hash_size, unsigned reserved, grp_ptr->nextid = reserved; grp_ptr->free_func = free_func; grp_ptr->id_list = H5MM_calloc(hash_size*sizeof(H5I_id_info_t *)); - if (NULL==grp_ptr->id_list) { - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, - "memory allocation failed"); - } + if (NULL==grp_ptr->id_list) + HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); } /* Increment the count of the times this group has been initialized */ grp_ptr->count++; - done: +done: if (ret_value<0) { /* Error condition cleanup */ if (grp_ptr != NULL) { @@ -267,18 +262,15 @@ H5I_nmembers(H5I_type_t grp) FUNC_ENTER_NOAPI(H5I_nmembers, FAIL); - if (grp<=H5I_BADID || grp>=H5I_NGROUPS) { + if (grp<=H5I_BADID || grp>=H5I_NGROUPS) HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); - } - if (NULL==(grp_ptr=H5I_id_group_list_g[grp]) || grp_ptr->count<=0) { + if (NULL==(grp_ptr=H5I_id_group_list_g[grp]) || grp_ptr->count<=0) HRETURN(0); - } - for (i=0; i<grp_ptr->hash_size; i++) { - for (cur=grp_ptr->id_list[i]; cur; cur=cur->next) { + for (i=0; i<grp_ptr->hash_size; i++) + for (cur=grp_ptr->id_list[i]; cur; cur=cur->next) n++; - } - } + FUNC_LEAVE(n); } @@ -325,23 +317,20 @@ H5I_clear_group(H5I_type_t grp, hbool_t force) FUNC_ENTER_NOAPI(H5I_clear_group, FAIL); - if (grp <= H5I_BADID || grp >= H5I_NGROUPS) { - HGOTO_DONE(FAIL); - } + if (grp <= H5I_BADID || grp >= H5I_NGROUPS) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; - if (grp_ptr == NULL || grp_ptr->count <= 0) { - HGOTO_DONE(FAIL); - } + if (grp_ptr == NULL || grp_ptr->count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); #ifdef IDS_ARE_CACHED /* * Remove atoms from the global atom cache. */ for (i=0; i<ID_CACHE_SIZE; i++) { - if (H5I_cache_g[i] && H5I_GROUP(H5I_cache_g[i]->id) == grp) { + if (H5I_cache_g[i] && H5I_GROUP(H5I_cache_g[i]->id) == grp) H5I_cache_g[i] = NULL; - } } #endif /* IDS_ARE_CACHED */ @@ -470,14 +459,12 @@ H5I_destroy_group(H5I_type_t grp) FUNC_ENTER_NOAPI(H5I_destroy_group, FAIL); - if (grp <= H5I_BADID || grp >= H5I_NGROUPS) { - HGOTO_DONE(FAIL); - } + if (grp <= H5I_BADID || grp >= H5I_NGROUPS) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; - if (grp_ptr == NULL || grp_ptr->count <= 0) { - HGOTO_DONE(FAIL); - } + if (grp_ptr == NULL || grp_ptr->count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); /* * Decrement the number of users of the atomic group. If this is the @@ -534,16 +521,13 @@ H5I_register(H5I_type_t grp, void *object) FUNC_ENTER_NOAPI(H5I_register, FAIL); /* Check arguments */ - if (grp <= H5I_BADID || grp >= H5I_NGROUPS) { - HGOTO_DONE(FAIL); - } + if (grp <= H5I_BADID || grp >= H5I_NGROUPS) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; - if (grp_ptr == NULL || grp_ptr->count <= 0) { - HGOTO_DONE(FAIL); - } - if ((id_ptr = H5FL_ALLOC(H5I_id_info_t,0)) == NULL) { - HGOTO_DONE(FAIL); - } + if (grp_ptr == NULL || grp_ptr->count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); + if ((id_ptr = H5FL_ALLOC(H5I_id_info_t,0)) == NULL) + HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed"); /* Create the struct & it's ID */ new_id = H5I_MAKE(grp, grp_ptr->nextid); @@ -554,9 +538,8 @@ H5I_register(H5I_type_t grp, void *object) /* hash bucket already full, prepend to front of chain */ hash_loc = grp_ptr->nextid % (unsigned) grp_ptr->hash_size; - if (grp_ptr->id_list[hash_loc] != NULL) { + if (grp_ptr->id_list[hash_loc] != NULL) id_ptr->next = grp_ptr->id_list[hash_loc]; - } /* Insert into the group */ grp_ptr->id_list[hash_loc] = id_ptr; @@ -586,28 +569,29 @@ H5I_register(H5I_type_t grp, void *object) */ for (i=grp_ptr->reserved; i<ID_MASK; i++) { /* Handle end of range by wrapping to beginning */ - if (grp_ptr->nextid>(unsigned)ID_MASK) { + if (grp_ptr->nextid>(unsigned)ID_MASK) grp_ptr->nextid = grp_ptr->reserved; - } /* new ID to check for */ next_id = H5I_MAKE(grp, grp_ptr->nextid); hash_loc = H5I_LOC (grp_ptr->nextid, grp_ptr->hash_size); curr_id = grp_ptr->id_list[hash_loc]; - if (curr_id == NULL) break; /* Ha! this is not likely... */ + if (curr_id == NULL) + break; /* Ha! this is not likely... */ while (curr_id) { - if (curr_id->id == next_id) break; + if (curr_id->id == next_id) + break; curr_id = curr_id->next; } - if (!curr_id) break; /* must not have found a match */ + if (!curr_id) + break; /* must not have found a match */ grp_ptr->nextid++; } - if (i>=(unsigned)ID_MASK) { + if (i>=(unsigned)ID_MASK) /* All the IDs are gone! */ - HGOTO_DONE(FAIL); - } + HGOTO_ERROR(H5E_ATOM, H5E_NOIDS, FAIL, "no IDs available in group"); } ret_value = new_id; @@ -651,6 +635,44 @@ H5I_object(hid_t id) /*------------------------------------------------------------------------- + * Function: H5I_object_verify + * + * Purpose: Find an object pointer for the specified ID, verifying that + * its in a particular group. + * + * Return: Success: Non-null object pointer associated with the + * specified ID. + * + * Failure: NULL + * + * Programmer: Quincey Koziol + * Wednesday, July 31, 2002 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +void * +H5I_object_verify(hid_t id, H5I_type_t id_type) +{ + H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ + void *ret_value = NULL; /*return value */ + + FUNC_ENTER_NOAPI(H5I_object_verify, NULL); + + assert(id_type>=H5I_FILE && id_type<H5I_NGROUPS); + + /* Verify that the group of the ID is correct & lookup the ID */ + if(id_type == H5I_GROUP(id) && NULL!=(id_ptr = H5I_find_id(id))) { + /* Get the object pointer to return */ + ret_value = id_ptr->obj_ptr; + } /* end if */ + + FUNC_LEAVE(ret_value); +} /* H5I_object_verify() */ + + +/*------------------------------------------------------------------------- * Function: H5I_get_type * * Purpose: Given an object ID return the group (type) to which it @@ -715,10 +737,8 @@ H5Iget_type(hid_t id) ret_value = H5I_get_type(id); - if (ret_value <= H5I_BADID || ret_value >= H5I_NGROUPS || - NULL==H5I_object(id)) { + if (ret_value <= H5I_BADID || ret_value >= H5I_NGROUPS || NULL==H5I_object(id)) HGOTO_DONE(H5I_BADID); - } done: FUNC_LEAVE(ret_value); @@ -760,16 +780,16 @@ H5I_remove(hid_t id) /* Check arguments */ grp = H5I_GROUP(id); if (grp <= H5I_BADID || grp >= H5I_NGROUPS) - HGOTO_DONE(NULL); + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; if (grp_ptr == NULL || grp_ptr->count <= 0) - HGOTO_DONE(NULL); + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid group"); /* Get the bucket in which the ID is located */ hash_loc = (unsigned) H5I_LOC(id, grp_ptr->hash_size); curr_id = grp_ptr->id_list[hash_loc]; if (curr_id == NULL) - HGOTO_DONE(NULL); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID"); last_id = NULL; while (curr_id != NULL) { @@ -799,13 +819,13 @@ H5I_remove(hid_t id) H5FL_FREE(H5I_id_info_t,curr_id); } else { /* couldn't find the ID in the proper place */ - HGOTO_DONE(NULL); + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID"); } /* Decrement the number of IDs in the group */ (grp_ptr->ids)--; - done: +done: FUNC_LEAVE(ret_value); } @@ -860,9 +880,8 @@ H5I_dec_ref(hid_t id) /* Check arguments */ grp_ptr = H5I_id_group_list_g[grp]; - if (grp_ptr == NULL || grp_ptr->count <= 0) { - HRETURN(FAIL); - } + if (grp_ptr == NULL || grp_ptr->count <= 0) + HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid group number"); /* General lookup of the ID */ if ((id_ptr=H5I_find_id(id))) { @@ -918,12 +937,15 @@ H5I_inc_ref(hid_t id) FUNC_ENTER_NOAPI(H5I_inc_ref, FAIL); /* Check arguments */ - if (id<0) HRETURN(FAIL); + if (id<0) + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID"); grp_ptr = H5I_id_group_list_g[grp]; - if (!grp_ptr || grp_ptr->count<=0) HRETURN(FAIL); + if (!grp_ptr || grp_ptr->count<=0) + HRETURN_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid group"); /* General lookup of the ID */ - if (NULL==(id_ptr=H5I_find_id(id))) HRETURN(FAIL); + if (NULL==(id_ptr=H5I_find_id(id))) + HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID"); id_ptr->count++; FUNC_LEAVE(id_ptr->count); @@ -966,26 +988,23 @@ H5I_search(H5I_type_t grp, H5I_search_func_t func, const void *key) FUNC_ENTER_NOAPI(H5I_search, NULL); /* Check arguments */ - if (grp <= H5I_BADID || grp >= H5I_NGROUPS) { - HGOTO_DONE(NULL); - } + if (grp <= H5I_BADID || grp >= H5I_NGROUPS) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; - if (grp_ptr == NULL || grp_ptr->count <= 0) { - HGOTO_DONE(NULL); - } + if (grp_ptr == NULL || grp_ptr->count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid group"); /* Start at the beginning of the array */ for (i=0; i<grp_ptr->hash_size; i++) { id_ptr = grp_ptr->id_list[i]; while (id_ptr) { - if ((*func)(id_ptr->obj_ptr, id_ptr->id, key)) { + if ((*func)(id_ptr->obj_ptr, id_ptr->id, key)) HGOTO_DONE(id_ptr->obj_ptr); /*found the item*/ - } id_ptr = id_ptr->next; } } - done: +done: FUNC_LEAVE(ret_value); } @@ -1022,13 +1041,11 @@ H5I_find_id(hid_t id) /* Check arguments */ grp = H5I_GROUP(id); - if (grp <= H5I_BADID || grp >= H5I_NGROUPS) { - HGOTO_DONE(NULL); - } + if (grp <= H5I_BADID || grp >= H5I_NGROUPS) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid group number"); grp_ptr = H5I_id_group_list_g[grp]; - if (grp_ptr == NULL || grp_ptr->count <= 0) { - HGOTO_DONE(NULL); - } + if (grp_ptr == NULL || grp_ptr->count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid group"); #ifdef IDS_ARE_CACHED /* @@ -1057,13 +1074,13 @@ H5I_find_id(hid_t id) /* Get the bucket in which the ID is located */ hash_loc = (unsigned)H5I_LOC(id, grp_ptr->hash_size); id_ptr = grp_ptr->id_list[hash_loc]; - if (id_ptr == NULL) { - HGOTO_DONE(NULL); - } + if (id_ptr == NULL) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "invalid ID"); /* Scan the bucket's linked list for a match */ while (id_ptr) { - if (id_ptr->id == id) break; + if (id_ptr->id == id) + break; id_ptr = id_ptr->next; } ret_value = id_ptr; @@ -1073,7 +1090,7 @@ H5I_find_id(hid_t id) H5I_cache_g[ID_CACHE_SIZE-1] = id_ptr; #endif /* IDS_ARE_CACHED */ - done: +done: FUNC_LEAVE(ret_value); } diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index a928590..0589cc6 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -130,6 +130,7 @@ __DLL__ herr_t H5I_clear_group(H5I_type_t grp, hbool_t force); __DLL__ herr_t H5I_destroy_group(H5I_type_t grp); __DLL__ hid_t H5I_register(H5I_type_t grp, void *object); __DLL__ void *H5I_object(hid_t id); +__DLL__ void *H5I_object_verify(hid_t id, H5I_type_t id_type); __DLL__ H5I_type_t H5I_get_type(hid_t id); __DLL__ void *H5I_remove(hid_t id); __DLL__ void *H5I_search(H5I_type_t grp, H5I_search_func_t func, @@ -29,6 +29,7 @@ /* Default file driver - see H5Pget_driver() */ #include "H5FDsec2.h" /* Posix unbuffered I/O file driver */ +/* Pablo mask */ #define PABLO_MASK H5P_mask /* Is the interface initialized? */ @@ -1809,7 +1810,7 @@ H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_drive FUNC_ENTER_NOAPI(H5P_set_driver, FAIL); - if (H5I_VFL!=H5I_get_type(new_driver_id) || NULL==H5I_object(new_driver_id)) + if (NULL==H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID"); if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) { @@ -1911,9 +1912,9 @@ H5Pset_driver(hid_t plist_id, hid_t new_driver_id, const void *new_driver_info) H5TRACE3("e","iix",plist_id,new_driver_id,new_driver_info); /* Check arguments */ - if(H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if (H5I_VFL!=H5I_get_type(new_driver_id) || NULL==H5I_object(new_driver_id)) + if (NULL==H5I_object_verify(new_driver_id, H5I_VFL)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file driver ID"); /* Set the driver */ @@ -2021,7 +2022,7 @@ H5Pget_driver(hid_t plist_id) FUNC_ENTER_API(H5Pget_driver, FAIL); H5TRACE1("i","i",plist_id); - if(H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); ret_value = H5P_get_driver(plist); @@ -2113,7 +2114,7 @@ H5Pget_driver_info(hid_t plist_id) FUNC_ENTER_API(H5Pget_driver_info, NULL); - if(H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list"); if((ret_value=H5P_get_driver_info(plist))==NULL) @@ -3265,8 +3266,7 @@ H5Pset_fill_value(hid_t plist_id, hid_t type_id, const void *value) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset fill value"); if(value) { - if (H5I_DATATYPE!=H5I_get_type(type_id) || - NULL==(type=H5I_object(type_id))) + if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Set the fill value */ @@ -3332,7 +3332,7 @@ H5Pget_fill_value(hid_t plist_id, hid_t type_id, void *value/*out*/) /* Check arguments */ if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset creation proprety list"); - if (H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(type=H5I_object(type_id))) + if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (!value) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,"no fill value output buffer"); @@ -5358,7 +5358,7 @@ hid_t H5Pcreate(hid_t cls_id) FUNC_ENTER_API(H5Pcreate, FAIL); /* Check arguments. */ - if (H5I_GENPROP_CLS != H5I_get_type(cls_id) || NULL == (pclass = H5I_object(cls_id))) + if (NULL == (pclass = H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); /* Create the new property list */ @@ -5725,7 +5725,7 @@ herr_t H5Pregister(hid_t cls_id, const char *name, size_t size, void *def_value, FUNC_ENTER_API(H5Pregister, FAIL); /* Check arguments. */ - if (H5I_GENPROP_CLS != H5I_get_type(cls_id) || NULL == (pclass = H5I_object(cls_id))) + if (NULL == (pclass = H5I_object_verify(cls_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid class name"); @@ -6012,7 +6012,7 @@ herr_t H5Pinsert(hid_t plist_id, const char *name, size_t size, void *value, FUNC_ENTER_API(H5Pinsert, FAIL); /* Check arguments. */ - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); @@ -6148,7 +6148,7 @@ herr_t H5Pset(hid_t plist_id, const char *name, void *value) FUNC_ENTER_API(H5Pset, FAIL); /* Check arguments. */ - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); @@ -6524,7 +6524,7 @@ hid_t H5Pget_class(hid_t plist_id) FUNC_ENTER_API(H5Pget_class, FAIL); /* Check arguments. */ - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Retrieve the property list class */ @@ -7096,9 +7096,9 @@ htri_t H5P_isa_class(hid_t plist_id, hid_t pclass_id) FUNC_ENTER_NOAPI(H5P_isa_class, FAIL); /* Check arguments. */ - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); - if (H5I_GENPROP_CLS != H5I_get_type(pclass_id) || NULL == (pclass = H5I_object(pclass_id))) + if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Compare the property list's class against the other class */ @@ -7311,7 +7311,7 @@ H5P_iterate_plist(hid_t plist_id, int *idx, H5P_iterate_t iter_func, void *iter_ assert(iter_func); /* Get the property list object */ - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Iterate through the properties in the property list */ @@ -7385,7 +7385,7 @@ H5P_iterate_pclass(hid_t pclass_id, int *idx, H5P_iterate_t iter_func, void *ite assert(iter_func); /* Get the property list object */ - if (H5I_GENPROP_CLS != H5I_get_type(pclass_id) || NULL == (pclass = H5I_object(pclass_id))) + if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Iterate through the properties in the property list */ @@ -7809,7 +7809,7 @@ herr_t H5Pget(hid_t plist_id, const char *name, void * value) FUNC_ENTER_API(H5Pget, FAIL); /* Check arguments. */ - if(H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if(NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); @@ -7954,7 +7954,7 @@ herr_t H5Premove(hid_t plist_id, const char *name) FUNC_ENTER_API(H5Premove, FAIL); /* Check arguments. */ - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); @@ -8327,7 +8327,7 @@ herr_t H5Punregister(hid_t pclass_id, const char *name) FUNC_ENTER_API(H5Punregister, FAIL); /* Check arguments. */ - if (H5I_GENPROP_CLS != H5I_get_type(pclass_id) || NULL == (pclass = H5I_object(pclass_id))) + if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list class"); if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid property name"); @@ -8428,7 +8428,7 @@ herr_t H5Pclose(hid_t plist_id) HGOTO_DONE(SUCCEED); /* Check arguments. */ - if (H5I_GENPROP_LST != H5I_get_type(plist_id) || NULL == (plist = H5I_object(plist_id))) + if (NULL == (plist = H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list"); /* Close the property list */ @@ -8507,7 +8507,7 @@ char *H5Pget_class_name(hid_t pclass_id) FUNC_ENTER_API(H5Pget_class_name, NULL); /* Check arguments. */ - if (H5I_GENPROP_CLS != H5I_get_type(pclass_id) || NULL == (pclass = H5I_object(pclass_id))) + if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property class"); /* Get the property list class name */ @@ -8582,7 +8582,7 @@ hid_t H5Pget_class_parent(hid_t pclass_id) FUNC_ENTER_API(H5Pget_class_parent, FAIL); /* Check arguments. */ - if (H5I_GENPROP_CLS != H5I_get_type(pclass_id) || NULL == (pclass = H5I_object(pclass_id))) + if (NULL == (pclass = H5I_object_verify(pclass_id, H5I_GENPROP_CLS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property class"); /* Retrieve the property class's parent */ @@ -299,7 +299,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t HRETURN_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"); - if (space_id!=(-1) && (H5I_DATASPACE!=H5I_get_type (space_id) || NULL==(space=H5I_object (space_id)))) + if (space_id!=(-1) && (NULL==(space=H5I_object_verify(space_id,H5I_DATASPACE)))) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); /* Create reference */ @@ -469,7 +469,7 @@ H5Sclose(hid_t space_id) H5TRACE1("e","i",space_id); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == H5I_object(space_id)) + if (NULL == H5I_object_verify(space_id,H5I_DATASPACE)) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* When the reference count reaches zero the resources are freed */ @@ -540,7 +540,7 @@ H5Scopy(hid_t space_id) H5TRACE1("i","i",space_id); /* Check args */ - if (H5I_DATASPACE!=H5I_get_type (space_id) || NULL==(src=H5I_object (space_id))) + if (NULL==(src=H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Copy */ @@ -580,9 +580,9 @@ H5Sextent_copy(hid_t dst_id,hid_t src_id) H5TRACE2("e","ii",dst_id,src_id); /* Check args */ - if (H5I_DATASPACE!=H5I_get_type (src_id) || NULL==(src=H5I_object (src_id))) + if (NULL==(src=H5I_object_verify(src_id, H5I_DATASPACE))) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - if (H5I_DATASPACE!=H5I_get_type (dst_id) || NULL==(dst=H5I_object (dst_id))) + if (NULL==(dst=H5I_object_verify(dst_id, H5I_DATASPACE))) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Copy */ @@ -767,7 +767,7 @@ H5Sget_simple_extent_npoints(hid_t space_id) H5TRACE1("Hs","i",space_id); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (ds = H5I_object(space_id))) + if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "not a data space"); ret_value = H5S_get_simple_extent_npoints(ds); @@ -868,7 +868,7 @@ H5Sget_simple_extent_ndims(hid_t space_id) H5TRACE1("Is","i",space_id); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (ds = H5I_object(space_id))) + if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); ret_value = H5S_get_simple_extent_ndims(ds); @@ -960,7 +960,7 @@ H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, H5TRACE3("Is","ixx",space_id,dims,maxdims); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (ds = H5I_object(space_id))) + if (NULL == (ds = H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace"); ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims); @@ -1258,7 +1258,7 @@ H5Sis_simple(hid_t space_id) H5TRACE1("b","i",space_id); /* Check args and all the boring stuff. */ - if ((space = H5I_object(space_id)) == NULL) + if ((space = H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); ret_value = H5S_is_simple(space); @@ -1304,7 +1304,7 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], H5TRACE4("e","iIs*[a1]h*[a1]h",space_id,rank,dims,max); /* Check args */ - if ((space = H5I_object(space_id)) == NULL) + if ((space = H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) HRETURN_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"); @@ -1733,7 +1733,7 @@ H5Sget_simple_extent_type(hid_t sid) H5TRACE1("Sc","i",sid); /* Check arguments */ - if (H5I_DATASPACE != H5I_get_type(sid) || NULL == (space = H5I_object(sid))) + if (NULL == (space = H5I_object_verify(sid, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5S_NO_CLASS, "not a dataspace"); ret_value=H5S_get_simple_extent_type(space); @@ -1765,7 +1765,7 @@ H5Sset_extent_none(hid_t space_id) H5TRACE1("e","i",space_id); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space = H5I_object(space_id))) + if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); /* Clear the previous extent from the dataspace */ @@ -1803,7 +1803,7 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset) H5TRACE2("e","i*Hs",space_id,offset); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space = H5I_object(space_id))) + if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space"); if (offset == NULL) HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified"); diff --git a/src/H5Sall.c b/src/H5Sall.c index 16686e2..0d30339 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -543,7 +543,7 @@ herr_t H5Sselect_all (hid_t spaceid) FUNC_ENTER_API(H5Sselect_all, FAIL); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Call internal routine to do the work */ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 4be5952..64bf457 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -1315,7 +1315,7 @@ H5Sget_select_hyper_nblocks(hid_t spaceid) H5TRACE1("Hs","i",spaceid); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_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"); @@ -1999,7 +1999,7 @@ H5Sget_select_hyper_blocklist(hid_t spaceid, hsize_t startblock, hsize_t numbloc /* Check args */ if(buf==NULL) HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_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"); @@ -4186,10 +4186,8 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[], H5TRACE6("e","iSs*Hs*h*h*h",space_id,op,start,stride,count,block); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || - NULL == (space=H5I_object(space_id))) { + if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_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"); @@ -4726,10 +4724,8 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[], H5TRACE6("e","iSs*Hs*h*h*h",space_id,op,start,stride,count,block); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || - NULL == (space=H5I_object(space_id))) { + if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_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"); @@ -4784,10 +4780,8 @@ H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[], H5TRACE6("i","iSs*Hs*h*h*h",space_id,op,start,stride,count,block); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || - NULL == (space=H5I_object(space_id))) { + if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } if(start==NULL || count==NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified"); @@ -4894,14 +4888,10 @@ H5Scombine_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) H5TRACE3("i","iSsi",space1_id,op,space2_id); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space1_id) || - NULL == (space1=H5I_object(space1_id))) { + if (NULL == (space1=H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } - if (H5I_DATASPACE != H5I_get_type(space2_id) || - NULL == (space2=H5I_object(space2_id))) { + if (NULL == (space2=H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); @@ -5008,14 +4998,10 @@ H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) H5TRACE3("e","iSsi",space1_id,op,space2_id); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space1_id) || - NULL == (space1=H5I_object(space1_id))) { + if (NULL == (space1=H5I_object_verify(space1_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } - if (H5I_DATASPACE != H5I_get_type(space2_id) || - NULL == (space2=H5I_object(space2_id))) { + if (NULL == (space2=H5I_object_verify(space2_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); - } if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID)) HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); diff --git a/src/H5Snone.c b/src/H5Snone.c index eee07bd..f9abe49 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -517,7 +517,7 @@ herr_t H5Sselect_none (hid_t spaceid) FUNC_ENTER_API(H5Sselect_none, FAIL); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); /* Change to "none" selection */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 780ba75..c8e25cd 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -541,7 +541,7 @@ H5Sget_select_elem_npoints(hid_t spaceid) H5TRACE1("Hs","i",spaceid); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_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"); @@ -839,7 +839,7 @@ H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, hsize_t numpoint /* Check args */ if(buf==NULL) HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_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"); @@ -1073,7 +1073,7 @@ H5Sselect_elements (hid_t spaceid, H5S_seloper_t op, size_t num_elem, FUNC_ENTER_API(H5Sselect_elements, FAIL); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_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"); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index b37c2b6..18b5ca7 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -148,7 +148,7 @@ H5Sget_select_npoints(hid_t spaceid) H5TRACE1("Hs","i",spaceid); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); ret_value = (*space->select.get_npoints)(space); @@ -187,7 +187,7 @@ H5Sselect_valid(hid_t spaceid) H5TRACE1("b","i",spaceid); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space"); ret_value = (*space->select.is_valid)(space); @@ -295,7 +295,7 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t *start, hsize_t *end) /* Check args */ if(start==NULL || end==NULL) HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer"); - if (H5I_DATASPACE != H5I_get_type(spaceid) || NULL == (space=H5I_object(spaceid))) + if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space"); ret_value = (*space->select.bounds)(space,start,end); @@ -381,7 +381,7 @@ H5S_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t op, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate I/O offset vector array"); /* Get the datatype size */ - if (NULL==(dt=H5I_object(type_id))) + if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype"); if((elmt_size=H5T_get_size(dt))==0) HGOTO_ERROR(H5E_DATATYPE, H5E_BADSIZE, FAIL, "datatype size invalid"); @@ -496,7 +496,7 @@ H5Sget_select_type(hid_t space_id) H5TRACE1("St","i",space_id); /* Check args */ - if (H5I_DATASPACE != H5I_get_type(space_id) || NULL == (space = H5I_object(space_id))) + if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE))) HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5S_SEL_ERROR, "not a data space"); FUNC_LEAVE(space->select.type); @@ -2238,10 +2238,8 @@ H5Tcommit(hid_t loc_id, const char *name, hid_t type_id) if (!name || !*name) { HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name"); } - if (H5I_DATATYPE!=H5I_get_type (type_id) || - NULL==(type=H5I_object (type_id))) { + if (NULL==(type=H5I_object_verify(type_id, H5I_DATATYPE))) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } /* Commit the type */ if (H5T_commit (loc, name, type)<0) { @@ -2278,10 +2276,8 @@ H5Tcommitted(hid_t type_id) H5TRACE1("b","i",type_id); /* Check arguments */ - if (H5I_DATATYPE!=H5I_get_type (type_id) || - NULL==(type=H5I_object (type_id))) { + if (NULL==(type=H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } FUNC_LEAVE (H5T_STATE_OPEN==type->state || H5T_STATE_NAMED==type->state); } @@ -2378,10 +2374,8 @@ H5Tclose(hid_t type_id) H5TRACE1("e","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -2424,12 +2418,10 @@ H5Tequal(hid_t type1_id, hid_t type2_id) H5TRACE2("b","ii",type1_id,type2_id); /* check args */ - if (H5I_DATATYPE != H5I_get_type(type1_id) || - NULL == (dt1 = H5I_object(type1_id)) || - H5I_DATATYPE != H5I_get_type(type2_id) || - NULL == (dt2 = H5I_object(type2_id))) { + 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"); - } + ret_value = (0 == H5T_cmp(dt1, dt2)) ? TRUE : FALSE; FUNC_LEAVE(ret_value); @@ -2469,10 +2461,8 @@ H5Tlock(hid_t type_id) H5TRACE1("e","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); @@ -2512,10 +2502,8 @@ H5Tget_class(hid_t type_id) H5TRACE1("Tt","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type"); - } FUNC_LEAVE(H5T_get_class(dt)); } @@ -2582,10 +2570,8 @@ H5Tdetect_class(hid_t type, H5T_class_t cls) H5TRACE2("b","iTt",type,cls); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type) || - NULL == (dt = H5I_object(type))) { + 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"); } @@ -2678,7 +2664,7 @@ H5Tget_size(hid_t type_id) H5TRACE1("z","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || NULL == (dt = H5I_object(type_id))) + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type"); /* size */ @@ -2725,10 +2711,8 @@ H5Tset_size(hid_t type_id, size_t size) H5TRACE2("e","iz",type_id,size); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -2785,12 +2769,11 @@ H5Tget_order(hid_t type_id) H5TRACE1("To","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR, - "not a data type"); - } - if (dt->parent) dt = dt->parent; /*defer to parent*/ + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) + HRETURN_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"); @@ -2829,10 +2812,8 @@ H5Tset_order(hid_t type_id, H5T_order_t order) H5TRACE2("e","iTo",type_id,order); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -2888,10 +2869,8 @@ H5Tget_precision(hid_t type_id) H5TRACE1("z","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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, @@ -2944,10 +2923,8 @@ H5Tset_precision(hid_t type_id, size_t prec) H5TRACE2("e","iz",type_id,prec); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3014,10 +2991,8 @@ H5Tget_offset(hid_t type_id) H5TRACE1("Is","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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, @@ -3080,10 +3055,8 @@ H5Tset_offset(hid_t type_id, size_t offset) H5TRACE2("e","iz",type_id,offset); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3133,10 +3106,8 @@ H5Tget_pad(hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/) H5TRACE3("e","ixx",type_id,lsb,msb); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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, @@ -3177,10 +3148,8 @@ H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb) H5TRACE3("e","iTpTp",type_id,lsb,msb); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3233,11 +3202,8 @@ H5Tget_sign(hid_t type_id) H5TRACE1("Ts","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR, - "not an integer data type"); - } + 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, @@ -3276,10 +3242,8 @@ H5Tset_sign(hid_t type_id, H5T_sign_t sign) H5TRACE2("e","iTs",type_id,sign); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3336,11 +3300,10 @@ H5Tget_fields(hid_t type_id, size_t *spos/*out*/, H5TRACE6("e","ixxxxx",type_id,spos,epos,esize,mpos,msize); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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 (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"); @@ -3389,10 +3352,8 @@ H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize, H5TRACE6("e","izzzzz",type_id,spos,epos,esize,mpos,msize); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3467,10 +3428,8 @@ H5Tget_ebias(hid_t type_id) H5TRACE1("z","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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, @@ -3509,10 +3468,8 @@ H5Tset_ebias(hid_t type_id, size_t ebias) H5TRACE2("e","iz",type_id,ebias); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3558,11 +3515,8 @@ H5Tget_norm(hid_t type_id) H5TRACE1("Tn","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR, - "not a data type"); - } + 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, @@ -3602,10 +3556,8 @@ H5Tset_norm(hid_t type_id, H5T_norm_t norm) H5TRACE2("e","iTn",type_id,norm); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3655,11 +3607,8 @@ H5Tget_inpad(hid_t type_id) H5TRACE1("Tp","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR, - "not a data type"); - } + 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, @@ -3701,10 +3650,8 @@ H5Tset_inpad(hid_t type_id, H5T_pad_t pad) H5TRACE2("e","iTp",type_id,pad); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3754,11 +3701,8 @@ H5Tget_cset(hid_t type_id) H5TRACE1("Tc","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { - HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR, - "not a data type"); - } + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) + HRETURN_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*/ @@ -3808,10 +3752,8 @@ H5Tset_cset(hid_t type_id, H5T_cset_t cset) H5TRACE2("e","iTc",type_id,cset); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3872,10 +3814,8 @@ H5Tget_strpad(hid_t type_id) H5TRACE1("Tz","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_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*/ @@ -3936,10 +3876,8 @@ H5Tset_strpad(hid_t type_id, H5T_str_t strpad) H5TRACE2("e","iTz",type_id,strpad); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -3998,10 +3936,8 @@ H5Tget_nmembers(hid_t type_id) H5TRACE1("Is","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } if (H5T_COMPOUND==dt->type) { ret_value = dt->u.compnd.nmembs; @@ -4046,10 +3982,8 @@ H5Tget_member_name(hid_t type_id, int membno) FUNC_ENTER_API(H5Tget_member_name, NULL); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); - } switch (dt->type) { case H5T_COMPOUND: @@ -4108,7 +4042,7 @@ H5Tget_member_index(hid_t type_id, const char *name) /* Check arguments */ assert(name); - if(H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id))) + if(NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Locate member by name */ @@ -4167,11 +4101,9 @@ H5Tget_member_offset(hid_t type_id, int membno) H5TRACE2("z","iIs",type_id,membno); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id)) || - H5T_COMPOUND != dt->type) { + 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"); } @@ -4209,8 +4141,7 @@ H5Tget_member_class(hid_t type_id, int membno) H5TRACE2("Tt","iIs",type_id,membno); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id)) || H5T_COMPOUND != dt->type) + 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"); if (membno < 0 || membno >= dt->u.compnd.nmembs) HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, H5T_NO_CLASS, "invalid member number"); @@ -4256,11 +4187,8 @@ H5Tget_member_type(hid_t type_id, int membno) H5TRACE2("i","iIs",type_id,membno); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id)) || - H5T_COMPOUND != dt->type) { + 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"); } @@ -4317,21 +4245,17 @@ H5Tinsert(hid_t parent_id, const char *name, size_t offset, hid_t member_id) /* Check args */ if (parent_id==member_id) HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "can't insert compound datatype within itself"); - if (H5I_DATATYPE != H5I_get_type(parent_id) || - NULL == (parent = H5I_object(parent_id)) || - H5T_COMPOUND != parent->type) { + 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"); } - if (H5I_DATATYPE != H5I_get_type(member_id) || - NULL == (member = H5I_object(member_id))) { + if (NULL == (member = H5I_object_verify(member_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - } /* Insert */ if (H5T_insert(parent, name, offset, member) < 0) { @@ -4367,11 +4291,9 @@ H5Tpack(hid_t type_id) H5TRACE1("e","i",type_id); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id)) || - H5T_COMPOUND != dt->type) { + 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"); } @@ -4414,11 +4336,9 @@ H5Tenum_create(hid_t parent_id) H5TRACE1("i","i",parent_id); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(parent_id) || - NULL==(parent=H5I_object(parent_id)) || - H5T_INTEGER!=parent->type) { + 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"); - } /* Build new type */ if (NULL==(dt = H5FL_ALLOC(H5T_t,1))) { @@ -4470,10 +4390,8 @@ H5Tenum_insert(hid_t type, const char *name, void *value) H5TRACE3("e","isx",type,name,value); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(type) || - NULL==(dt=H5I_object(type))) { + 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"); @@ -4521,10 +4439,8 @@ H5Tget_super(hid_t type) FUNC_ENTER_API(H5Tget_super, FAIL); H5TRACE1("i","i",type); - if (H5I_DATATYPE!=H5I_get_type(type) || - NULL==(dt=H5I_object(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"); } @@ -4567,10 +4483,8 @@ H5Tget_member_value(hid_t type, int membno, void *value/*out*/) FUNC_ENTER_API(H5Tget_member_value, FAIL); H5TRACE3("i","iIsx",type,membno,value); - if (H5I_DATATYPE!=H5I_get_type(type) || - NULL==(dt=H5I_object(type))) { + 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"); @@ -4619,10 +4533,8 @@ H5Tenum_nameof(hid_t type, void *value, char *name/*out*/, size_t size) H5TRACE4("e","ixxz",type,value,name,size); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(type) || - NULL==(dt=H5I_object(type))) { + 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"); @@ -4669,10 +4581,8 @@ H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/) H5TRACE3("e","isx",type,name,value); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(type) || - NULL==(dt=H5I_object(type))) { + 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"); @@ -4775,7 +4685,7 @@ H5Tvlen_create(hid_t base_id) H5TRACE1("i","i",base_id); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(base_id) || NULL==(base=H5I_object(base_id))) + if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype"); /* Create up VL datatype */ @@ -4813,10 +4723,8 @@ H5Tset_tag(hid_t type_id, const char *tag) H5TRACE2("e","is",type_id,tag); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || - NULL == (dt = H5I_object(type_id))) { + 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"); } @@ -4858,7 +4766,7 @@ H5Tget_tag(hid_t type_id) FUNC_ENTER_API(H5Tget_tag, NULL); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(type_id) || NULL == (dt = H5I_object(type_id))) + if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type"); if (dt->parent) @@ -5077,9 +4985,9 @@ H5Tregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid function persistence"); if (!name || !*name) HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "conversion must have a name for debugging"); - if (H5I_DATATYPE!=H5I_get_type(src_id) || NULL==(src=H5I_object(src_id))) + if (NULL==(src=H5I_object_verify(src_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); - if (H5I_DATATYPE!=H5I_get_type(dst_id) || NULL==(dst=H5I_object(dst_id))) + if (NULL==(dst=H5I_object_verify(dst_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); if (!func) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function specified"); @@ -5205,12 +5113,9 @@ H5Tunregister(H5T_pers_t pers, const char *name, hid_t src_id, hid_t dst_id, H5TRACE5("e","Tesiix",pers,name,src_id,dst_id,func); /* Check arguments */ - if (src_id>0 && (H5I_DATATYPE!=H5I_get_type(src_id) || - NULL==(src=H5I_object(src_id)))) { + 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 && (H5I_DATATYPE!=H5I_get_type(dst_id) || - NULL==(dst=H5I_object(dst_id)))) { + 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"); } @@ -5252,12 +5157,9 @@ H5Tfind(hid_t src_id, hid_t dst_id, H5T_cdata_t **pcdata) H5TRACE3("x","iix",src_id,dst_id,pcdata); /* Check args */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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"); @@ -5313,11 +5215,10 @@ H5Tconvert(hid_t src_id, hid_t dst_id, hsize_t nelmts, void *buf, H5TRACE6("e","iihxxi",src_id,dst_id,nelmts,buf,background,plist_id); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(src_id) || NULL==(src=H5I_object(src_id)) || - H5I_DATATYPE!=H5I_get_type(dst_id) || NULL==(dst=H5I_object(dst_id)) || - (H5P_DEFAULT!=plist_id && TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER))) { + 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"); - } /* Find the conversion function */ if (NULL==(tpath=H5T_path_find(src, dst, NULL, NULL))) { @@ -7939,7 +7840,7 @@ H5Tarray_create(hid_t base_id, int ndims, const hsize_t dim[/* ndims */], for(i=0; i<ndims; i++) if(!(dim[i]>0)) HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "zero-sized dimension specified"); - if (H5I_DATATYPE!=H5I_get_type(base_id) || NULL==(base=H5I_object(base_id))) + if (NULL==(base=H5I_object_verify(base_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype"); /* Create the actual array datatype */ @@ -8050,7 +7951,7 @@ H5Tget_array_ndims(hid_t type_id) H5TRACE1("Is","i",type_id); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id))) + if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_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"); @@ -8088,7 +7989,7 @@ H5Tget_array_dims(hid_t type_id, hsize_t dims[], int perm[]) H5TRACE3("e","i*h*Is",type_id,dims,perm); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id))) + if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_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"); diff --git a/src/H5Tconv.c b/src/H5Tconv.c index beeb7bf..f15acf7 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -283,8 +283,8 @@ H5FL_BLK_DEFINE_STATIC(array_seq); case H5T_CONV_INIT: \ /* Sanity check and initialize statistics */ \ cdata->need_bkg = H5T_BKG_NO; \ - if (NULL==(st=H5I_object(src_id)) || \ - NULL==(dt=H5I_object(dst_id))) { \ + 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"); \ } \ @@ -483,12 +483,9 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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 || @@ -533,12 +530,9 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, case H5T_CONV_CONV: /* The conversion */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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"); - } buf_stride = buf_stride ? buf_stride : src->size; switch (src->size) { @@ -879,12 +873,9 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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 || @@ -924,12 +915,9 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, case H5T_CONV_CONV: /* The conversion */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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"); - } buf_stride = buf_stride ? buf_stride : src->size; md = src->size / 2; @@ -991,12 +979,9 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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, @@ -1015,12 +1000,9 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, case H5T_CONV_CONV: /* Get the data types */ - if (H5I_DATATYPE!=H5I_get_type (src_id) || - NULL==(src=H5I_object (src_id)) || - H5I_DATATYPE!=H5I_get_type (dst_id) || - NULL==(dst=H5I_object (dst_id))) { + 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, @@ -1368,12 +1350,9 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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); @@ -1398,12 +1377,9 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, /* * Conversion. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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); @@ -1613,12 +1589,9 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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); @@ -1687,12 +1660,9 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, /* * Conversion. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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"); - } /* Update cached data if necessary */ if (cdata->recalc && H5T_conv_struct_init (src, dst, cdata)<0) { @@ -2001,12 +1971,9 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, * the `priv' field of `cdata' with information about the underlying * integer conversion. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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) { @@ -2031,12 +1998,9 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, break; case H5T_CONV_CONV: - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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); @@ -2205,12 +2169,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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_VLEN==src->type); assert (H5T_VLEN==dst->type); @@ -2227,12 +2188,9 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, /* * Conversion. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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 @@ -2492,12 +2450,9 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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_ARRAY==src->type); assert (H5T_ARRAY==dst->type); @@ -2526,12 +2481,9 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, /* * Conversion. */ - if (H5I_DATATYPE != H5I_get_type(src_id) || - NULL == (src = H5I_object(src_id)) || - H5I_DATATYPE != H5I_get_type(dst_id) || - NULL == (dst = H5I_object(dst_id))) { + 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 @@ -2651,12 +2603,9 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (H5I_DATATYPE!=H5I_get_type (src_id) || - NULL==(src=H5I_object (src_id)) || - H5I_DATATYPE!=H5I_get_type (dst_id) || - NULL==(dst=H5I_object (dst_id))) { + 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, @@ -2679,12 +2628,9 @@ H5T_conv_i_i (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, case H5T_CONV_CONV: /* Get the data types */ - if (H5I_DATATYPE!=H5I_get_type (src_id) || - NULL==(src=H5I_object (src_id)) || - H5I_DATATYPE!=H5I_get_type (dst_id) || - NULL==(dst=H5I_object (dst_id))) { + 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, @@ -3000,12 +2946,9 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (H5I_DATATYPE!=H5I_get_type (src_id) || - NULL==(src_p=H5I_object (src_id)) || - H5I_DATATYPE!=H5I_get_type (dst_id) || - NULL==(dst_p=H5I_object (dst_id))) { + 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 && @@ -3035,12 +2978,9 @@ H5T_conv_f_f (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, case H5T_CONV_CONV: /* Get the data types */ - if (H5I_DATATYPE!=H5I_get_type (src_id) || - NULL==(src_p=H5I_object (src_id)) || - H5I_DATATYPE!=H5I_get_type (dst_id) || - NULL==(dst_p=H5I_object (dst_id))) { + 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; @@ -3428,12 +3368,9 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, switch (cdata->command) { case H5T_CONV_INIT: - if (H5I_DATATYPE!=H5I_get_type(src_id) || - NULL==(src=H5I_object(src_id)) || - H5I_DATATYPE!=H5I_get_type(dst_id) || - NULL==(dst=H5I_object(dst_id))) { + 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) { HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision"); @@ -3458,12 +3395,9 @@ H5T_conv_s_s (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, case H5T_CONV_CONV: /* Get the data types */ - if (H5I_DATATYPE!=H5I_get_type(src_id) || - NULL==(src=H5I_object(src_id)) || - H5I_DATATYPE!=H5I_get_type(dst_id) || - NULL==(dst=H5I_object(dst_id))) { + 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, @@ -6486,11 +6420,9 @@ H5T_conv_float_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, switch (cdata->command) { case H5T_CONV_INIT: cdata->need_bkg = H5T_BKG_NO; - if (NULL==(st=H5I_object(src_id)) || - NULL==(dt=H5I_object(dst_id))) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to dereference data type object ID"); - } + 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"); @@ -6609,11 +6541,9 @@ H5T_conv_double_float (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, switch (cdata->command) { case H5T_CONV_INIT: cdata->need_bkg = H5T_BKG_NO; - if (NULL==(st=H5I_object(src_id)) || - NULL==(dt=H5I_object(dst_id))) { - HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, - "unable to dereference data type object ID"); - } + 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"); @@ -6750,12 +6680,9 @@ H5T_conv_i32le_f64le (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, case H5T_CONV_CONV: /* The conversion */ - if (H5I_DATATYPE!=H5I_get_type (src_id) || - NULL==(src=H5I_object (src_id)) || - H5I_DATATYPE!=H5I_get_type (dst_id) || - NULL==H5I_object (dst_id)) { + 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"); - } s = (uint8_t*)buf + (buf_stride?buf_stride:4)*(nelmts-1); d = (uint8_t*)buf + (buf_stride?buf_stride:8)*(nelmts-1); diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 78e5b68..910a4a4 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -676,7 +676,7 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, hsize_t UNUSED ndim, hssize_t UNUSED assert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ - if (H5I_DATATYPE!=H5I_get_type(type_id) || NULL==(dt=H5I_object(type_id))) + if (NULL==(dt=H5I_object_verify(type_id,H5I_DATATYPE))) HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type"); /* Get the default dataset transfer property list if the user didn't provide one */ |