From 7705120f1e627ce60274225720e06d18a7062e85 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 14 Oct 2020 17:26:14 -0500 Subject: More merges from 1.10 comments and inits --- src/H5.c | 3 + src/H5A.c | 222 ++++++------- src/H5AC.c | 9 +- src/H5ACpublic.h | 35 +- src/H5Adense.c | 4 +- src/H5Aint.c | 75 ++--- src/H5Atest.c | 22 +- src/H5B2.c | 3 +- src/H5B2test.c | 34 +- src/H5CS.c | 20 +- src/H5D.c | 450 ++++++++++++-------------- src/H5Dbtree.c | 29 +- src/H5Dchunk.c | 73 ++--- src/H5Dcompact.c | 6 +- src/H5Dcontig.c | 34 +- src/H5Ddbg.c | 21 +- src/H5Ddeprec.c | 116 +++---- src/H5Defl.c | 15 +- src/H5Dfill.c | 2 +- src/H5Dint.c | 456 ++++++++++---------------- src/H5Dio.c | 82 +++-- src/H5Dlayout.c | 58 ++-- src/H5Dmpio.c | 15 +- src/H5Doh.c | 16 +- src/H5Dpkg.h | 18 +- src/H5Dprivate.h | 12 +- src/H5Dselect.c | 2 +- src/H5Dtest.c | 10 +- src/H5E.c | 413 ++++++++++++------------ src/H5Edeprec.c | 98 +++--- src/H5Eint.c | 247 +++++++------- src/H5Epkg.h | 2 +- src/H5F.c | 639 +++++++++++++++---------------------- src/H5FD.c | 938 ++++++++++++++++++++++++------------------------------ src/H5FDcore.c | 7 +- src/H5FDhdfs.c | 2 +- src/H5FDint.c | 10 +- src/H5FL.c | 94 ++---- src/H5FS.c | 22 +- src/H5FSsection.c | 4 +- src/H5FStest.c | 2 +- src/H5Faccum.c | 8 +- src/H5Fcwfs.c | 2 +- src/H5Fdbg.c | 3 +- src/H5Fefc.c | 4 +- src/H5Ffake.c | 4 +- src/H5Fint.c | 582 +++++++++++++-------------------- src/H5Fmount.c | 24 +- src/H5Fmpi.c | 8 +- src/H5Fpkg.h | 16 +- src/H5Fprivate.h | 2 +- src/H5Fpublic.h | 4 +- src/H5Fsuper.c | 4 +- src/H5Ftest.c | 12 +- src/H5G.c | 119 +++---- src/H5Gcache.c | 12 +- src/H5Gcompact.c | 18 +- src/H5Gdense.c | 16 +- src/H5Gdeprec.c | 13 +- src/H5Gint.c | 10 +- src/H5Glink.c | 10 + src/H5Gloc.c | 33 +- src/H5Gname.c | 10 +- src/H5Gobj.c | 24 +- src/H5Goh.c | 22 +- src/H5Gstab.c | 6 +- src/H5Gtest.c | 16 +- src/H5Gtraverse.c | 25 +- src/H5HF.c | 14 +- src/H5HFbtree2.c | 26 +- src/H5HFdblock.c | 6 +- src/H5HFhdr.c | 3 +- src/H5HFhuge.c | 4 +- src/H5HFiblock.c | 29 +- src/H5HFsection.c | 24 +- src/H5HFspace.c | 10 +- src/H5HFtiny.c | 16 +- src/H5HGcache.c | 26 +- src/H5HGpkg.h | 6 +- src/H5HLcache.c | 29 +- src/H5HLdbg.c | 22 +- src/H5HLint.c | 6 +- src/H5I.c | 127 ++++---- src/H5Itest.c | 20 +- src/H5L.c | 103 +++--- src/H5Lexternal.c | 102 +++--- src/H5MFaggr.c | 13 +- src/H5MFpkg.h | 6 +- src/H5O.c | 83 ++--- src/H5Oainfo.c | 21 +- src/H5Oalloc.c | 14 +- src/H5Oattr.c | 13 +- src/H5TS.c | 172 +++++++++- src/H5TSprivate.h | 11 + src/H5dbg.c | 24 +- src/H5detect.c | 25 -- src/H5err.txt | 6 +- 97 files changed, 2882 insertions(+), 3406 deletions(-) diff --git a/src/H5.c b/src/H5.c index 4a60858..e927910 100644 --- a/src/H5.c +++ b/src/H5.c @@ -951,6 +951,9 @@ H5is_library_threadsafe(hbool_t *is_ts) * NOTE: The main purpose of this is for handling Win32 thread cleanup * on thread/process detach. * + * Only enabled when the shared Windows library is built with + * thread safety enabled. + * * Return: TRUE on success, FALSE on failure * *------------------------------------------------------------------------- diff --git a/src/H5A.c b/src/H5A.c index 58f5f51..e6bc017 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -186,72 +186,78 @@ H5A_term_interface(void) /*-------------------------------------------------------------------------- NAME - H5Acreate2 - PURPOSE - Creates an attribute on an object - USAGE - hid_t H5Acreate2(loc_id, attr_name, type_id, space_id, acpl_id, - aapl_id) - hid_t loc_id; IN: Object (dataset or group) to be attached to - const char *attr_name; IN: Name of attribute to locate and open - hid_t type_id; IN: ID of datatype for attribute - hid_t space_id; IN: ID of dataspace for attribute - hid_t acpl_id; IN: ID of creation property list (currently not used) - hid_t aapl_id; IN: Attribute access property list - RETURNS - Non-negative on success/Negative on failure - - DESCRIPTION - This function creates an attribute which is attached to the object - specified with 'loc_id'. The name specified with 'attr_name' for - each attribute for an object must be unique for that object. The 'type_id' - and 'space_id' are created with the H5T and H5S interfaces respectively. - The 'aapl_id' property list is currently unused, but will be used in the - future for optional attribute access properties. The attribute ID returned - from this function must be released with H5Aclose or resource leaks will - develop. - ---------------------------------------------------------------------------*/ -/* ARGSUSED */ + * Function: H5Acreate2 + * + * Purpose: Creates an attribute on an object + * + * Usage: + * hid_t H5Acreate2(loc_id, attr_name, type_id, space_id, acpl_id, + * aapl_id) + * + * Description: This function creates an attribute which is attached to the + * object specified with 'loc_id'. The name specified with + * 'attr_name' for each attribute for an object must be unique + * for that object. The 'type_id' and 'space_id' are created + * with the H5T and H5S interfaces respectively. The 'aapl_id' + * property list is currently unused, but will be used in the + * future for optional attribute access properties. The + * attribute ID returned from this function must be released + * with H5Aclose or resource leaks will develop. + * + * Parameters: + * hid_t loc_id; IN: Object (dataset or group) to be attached to + * const char *attr_name; IN: Name of attribute to locate and open + * hid_t type_id; IN: ID of datatype for attribute + * hid_t space_id; IN: ID of dataspace for attribute + * hid_t acpl_id; IN: ID of creation property list (currently not used) + * hid_t aapl_id; IN: Attribute access property list + * + * Return: Success: An ID for the created attribute + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id) { - H5A_t * attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t * type; /* Datatype to use for attribute */ - H5S_t * space; /* Dataspace to use for attribute */ - hid_t ret_value; /* Return value */ + H5A_t * attr = NULL; /* Attribute created */ + H5G_loc_t loc; /* Object location */ + H5T_t * type; /* Datatype to use for attribute */ + H5S_t * space; /* Dataspace to use for attribute */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "i*siiii", loc_id, attr_name, type_id, space_id, acpl_id, aapl_id); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") if (!attr_name || !*attr_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no attribute name") if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Go do the real work for attaching the attribute to the dataset */ if (NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ if ((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Cleanup on failure */ - if (ret_value < 0 && attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + if (H5I_INVALID_HID == ret_value) + if (attr && H5A_close(attr) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ @@ -273,7 +279,7 @@ done: hid_t aapl_id; IN: Attribute access property list hid_t lapl_id; IN: Link access property list RETURNS - Non-negative on success/Negative on failure + Non-negative on success/H5I_INVALID_HID on failure DESCRIPTION This function creates an attribute which is attached to the object @@ -286,39 +292,38 @@ done: develop. --------------------------------------------------------------------------*/ -/* ARGSUSED */ hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, hid_t lapl_id) { - H5A_t * attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5T_t * type; /* Datatype to use for attribute */ - H5S_t * space; /* Dataspace to use for attribute */ - hid_t ret_value; /* Return value */ - - FUNC_ENTER_API(FAIL) + H5A_t * attr = NULL; /* Attribute created */ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + H5T_t * type; /* Datatype to use for attribute */ + H5S_t * space; /* Dataspace to use for attribute */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE8("i", "i*s*siiiii", loc_id, obj_name, attr_name, type_id, space_id, acpl_id, aapl_id, lapl_id); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") if (!obj_name || !*obj_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") if (!attr_name || !*attr_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no attribute name") if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -327,22 +332,23 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid /* Find the object's location */ if (H5G_loc_find(&loc, obj_name, &obj_loc /*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, H5I_INVALID_HID, "object not found") loc_found = TRUE; /* Go do the real work for attaching the attribute to the dataset */ if (NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ if ((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Release resources */ if (loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - if (ret_value < 0 && attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") + if (H5I_INVALID_HID == ret_value) + if (attr && H5A_close(attr) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Acreate_by_name() */ @@ -358,7 +364,7 @@ done: const char *attr_name; IN: Name of attribute to locate and open hid_t aapl_id; IN: Attribute access property list RETURNS - ID of attribute on success, negative on failure + ID of attribute on success, H5I_INVALID_HID on failure DESCRIPTION This function opens an existing attribute for access. The attribute @@ -369,39 +375,41 @@ done: hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t H5_ATTR_UNUSED aapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t * attr = NULL; /* Attribute opened */ - hid_t ret_value; + H5G_loc_t loc; /* Object location */ + H5A_t * attr = NULL; /* Attribute opened */ + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, attr_name, aapl_id); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!attr_name || !*attr_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") + if (!attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if (!*attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Read in attribute from object header */ if (NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to load attribute info from object header for attribute: '%s'", attr_name) /* Finish initializing attribute */ if (H5A_open_common(&loc, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to initialize attribute") /* Register the attribute and get an ID for it */ if ((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Cleanup on failure */ - if (ret_value < 0) + if (H5I_INVALID_HID == ret_value) if (attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) } /* H5Aopen() */ @@ -779,20 +787,20 @@ ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) { H5A_t * my_attr; /* Attribute object for ID */ - ssize_t ret_value; + ssize_t ret_value = -1; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf); /* check arguments */ if (NULL == (my_attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an attribute") if (!buf && buf_size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "buf cannot be NULL if buf_size is non-zero") - /* Call private function in turn */ + /* Get the attribute name */ if (0 > (ret_value = H5A_get_name(my_attr, buf_size, buf))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute name") done: FUNC_LEAVE_API(ret_value) @@ -984,7 +992,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: - /* Cleanup on failure */ + /* Release resources */ if (attr && H5A_close(attr) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") @@ -1051,12 +1059,12 @@ done: } /* end H5Aget_info_by_idx() */ /*------------------------------------------------------------------------- - * Function: H5Arename + * Function: H5Arename * * Purpose: Rename an attribute * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Raymond Lu * October 23, 2002 @@ -1071,7 +1079,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, old_name, new_name); - /* check arguments */ + /* Check arguments */ if (!old_name || !new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "name is nil") if (H5I_ATTR == H5I_get_type(loc_id)) @@ -1082,7 +1090,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) H5G_loc_t loc; /* Object location */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Call private attribute rename routine */ if (H5O_attr_rename(loc.oloc, H5AC_dxpl_id, old_name, new_name) < 0) @@ -1094,12 +1102,12 @@ done: } /* H5Arename() */ /*------------------------------------------------------------------------- - * Function: H5Arename_by_name + * Function: H5Arename_by_name * * Purpose: Rename an attribute * - * Return: Success: Non-negative - * Failure: Negative + * Return: Success: Non-negative + * Failure: Negative * * Programmer: Quincey Koziol * February 20, 2007 @@ -1136,7 +1144,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, if (H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* Call private attribute rename routine */ + /* Rename the attribute */ if (H5A_rename_by_name(loc, obj_name, old_attr_name, new_attr_name, lapl_id, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ @@ -1285,7 +1293,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_i FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, obj_name, idx_type, order, idx, op, op_data, lapl_id); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (H5G_loc(loc_id, &loc) < 0) @@ -1364,7 +1372,7 @@ H5Adelete(hid_t loc_id, const char *name) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (H5G_loc(loc_id, &loc) < 0) @@ -1409,7 +1417,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, obj_name, attr_name, lapl_id); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (H5G_loc(loc_id, &loc) < 0) @@ -1544,7 +1552,7 @@ H5Aclose(hid_t attr_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", attr_id); - /* check arguments */ + /* Check arguments */ if (NULL == H5I_object_verify(attr_id, H5I_ATTR)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") @@ -1579,7 +1587,7 @@ H5Aexists(hid_t obj_id, const char *attr_name) FUNC_ENTER_API(FAIL) H5TRACE2("t", "i*s", obj_id, attr_name); - /* check arguments */ + /* Check arguments */ if (H5I_ATTR == H5I_get_type(obj_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") if (H5G_loc(obj_id, &loc) < 0) diff --git a/src/H5AC.c b/src/H5AC.c index 3cafb85..d4cb1bd 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -372,6 +372,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) HDcompile_assert(NELMTS(H5AC_entry_type_names) == H5AC_NTYPES); HDcompile_assert(H5C__MAX_NUM_TYPE_IDS == H5AC_NTYPES); + /* Validate configurations */ if (H5AC_validate_config(config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad cache configuration") @@ -391,7 +392,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "can't get mpi size") if (NULL == (aux_ptr = H5FL_CALLOC(H5AC_aux_t))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate H5AC auxiliary structure.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "Can't allocate H5AC auxiliary structure") aux_ptr->magic = H5AC__H5AC_AUX_T_MAGIC; aux_ptr->mpi_comm = mpi_comm; @@ -423,10 +424,10 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) if (mpi_rank == 0) { if (NULL == (aux_ptr->d_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create dirtied entry list.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create dirtied entry list") if (NULL == (aux_ptr->c_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cleaned entry list.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create cleaned entry list") } /* end if */ /* construct the candidate slist for all processes. @@ -434,7 +435,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) * will use it in the case of a flush. */ if (NULL == (aux_ptr->candidate_slist_ptr = H5SL_create(H5SL_TYPE_HADDR, NULL))) - HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create candidate entry list.") + HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "can't create candidate entry list") if (aux_ptr != NULL) { if (aux_ptr->mpi_rank == 0) { diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h index 2cd628c..266a666 100644 --- a/src/H5ACpublic.h +++ b/src/H5ACpublic.h @@ -74,32 +74,35 @@ extern "C" { * open_trace_file: Boolean field indicating whether the trace_file_name * field should be used to open a trace file for the cache. * - * The trace file is a debugging feature that allow the capture of - * top level metadata cache requests for purposes of debugging and/or - * optimization. This field should normally be set to FALSE, as - * trace file collection imposes considerable overhead. * - * This field should only be set to TRUE when the trace_file_name - * contains the full path of the desired trace file, and either - * there is no open trace file on the cache, or the close_trace_file - * field is also TRUE. + * The trace file is a debuging feature that allow the capture of + * top level metadata cache requests for purposes of debugging and/or + * optimization. This field should normally be set to FALSE, as + * trace file collection imposes considerable overhead. + * + * This field should only be set to TRUE when the trace_file_name + * contains the full path of the desired trace file, and either + * there is no open trace file on the cache, or the close_trace_file + * field is also TRUE. * * close_trace_file: Boolean field indicating whether the current trace * file (if any) should be closed. * - * See the above comments on the open_trace_file field. This field - * should be set to FALSE unless there is an open trace file on the - * cache that you wish to close. + * + * See the above comments on the open_trace_file field. This field + * should be set to FALSE unless there is an open trace file on the + * cache that you wish to close. * * trace_file_name: Full path of the trace file to be opened if the * open_trace_file field is TRUE. * - * In the parallel case, an ascii representation of the mpi rank of - * the process will be appended to the file name to yield a unique - * trace file name for each process. * - * The length of the path must not exceed H5AC__MAX_TRACE_FILE_NAME_LEN - * characters. + * In the parallel case, an ascii representation of the mpi rank of + * the process will be appended to the file name to yield a unique + * trace file name for each process. + * + * The length of the path must not exceed H5AC__MAX_TRACE_FILE_NAME_LEN + * characters. * * evictions_enabled: Boolean field used to either report the current * evictions enabled status of the cache, or to set the cache's diff --git a/src/H5Adense.c b/src/H5Adense.c index 27731ca..2d1850b 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -282,9 +282,7 @@ H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) FUNC_ENTER_STATIC_NOERR - /* - * Check arguments. - */ + /* Check arguments */ HDassert(attr); HDassert(user_attr); diff --git a/src/H5Aint.c b/src/H5Aint.c index 46d545e..efab1c2 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -32,14 +32,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ /****************/ /* Local Macros */ @@ -233,11 +233,10 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, const H5S_ * (to maintain ref. count incr/decr similarity with "shared message" * type of datatype sharing) */ - if (H5T_committed(attr->shared->dt)) { + if (H5T_committed(attr->shared->dt)) /* Increment the reference count on the shared datatype */ if (H5T_link(attr->shared->dt, 1, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, NULL, "unable to adjust shared datatype link count") - } /* end if */ /* Compute the size of pieces on disk. This is either the size of the * datatype and dataspace messages themselves, or the size of the "shared" @@ -268,6 +267,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, const H5S_ if (H5O_attr_create(&(attr->oloc), dxpl_id, attr) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, NULL, "unable to create attribute in object header") + /* Set return value */ ret_value = attr; done: @@ -336,9 +336,9 @@ done: /*------------------------------------------------------------------------- * Function: H5A_open_by_idx * - * Purpose: Open an attribute according to its index order + * Purpose: Open an attribute according to its index order * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * April 2, 1998 @@ -686,12 +686,11 @@ done: /*------------------------------------------------------------------------- * Function: H5A_get_space * - * Return: Success: dataspace + * Purpose: Returns dataspace of the attribute. * - * Failure: NULL + * Return: Success: A valid ID for the dataspace of an attribute * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Failure: H5I_INVALID_ID * *------------------------------------------------------------------------- */ @@ -706,23 +705,19 @@ H5A_get_space(H5A_t *attr) /* Copy the attribute's dataspace */ if (NULL == (ret_value = H5S_copy(attr->shared->ds, FALSE, TRUE))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to copy dataspace") + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy dataspace") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_get_space() */ /*------------------------------------------------------------------------- - * Function: H5A_get_type + * Function: H5A_get_type * - * Purpose: Returns datatype of the dataset. + * Purpose: Returns datatype of an attribute * - * Return: Success: datatype - * - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Return: Success: A datatype of an attribute + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -740,8 +735,7 @@ H5A_get_type(H5A_t *attr) if (H5T_patch_file(attr->shared->dt, attr->oloc.file) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to patch datatype's file pointer") - /* - * Copy the attribute's datatype. If the type is a named type then + /* Copy the attribute's datatype. If the type is a named type then * reopen the type before returning it to the user. Make the type * read-only. */ @@ -958,7 +952,7 @@ done: * Purpose: Frees all memory associated with an attribute, but does not * free the H5A_t structure (which should be done in H5T_close). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Monday, November 15, 2004 @@ -997,11 +991,11 @@ done: } /* end H5A_free() */ /*------------------------------------------------------------------------- - * Function: H5A_close + * Function: H5A_close * * Purpose: Frees an attribute and all associated memory. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Monday, December 8, 1997 @@ -1137,12 +1131,11 @@ H5A_type(const H5A_t *attr) } /* end H5A_type() */ /*------------------------------------------------------------------------- - * Function: H5A_exists_by_name + * Function: H5A_exists_by_name * - * Purpose: Private version of H5Aexists_by_name + * Purpose: Private version of H5Aexists_by_name * - * Return: Success: TRUE/FALSE - * Failure: Negative + * Return: TRUE/FALSE/FAIL * * Programmer: Quincey Koziol * Thursday, November 1, 2007 @@ -1242,7 +1235,7 @@ done: } /* end H5A__compact_build_table_cb() */ /*------------------------------------------------------------------------- - * Function: H5A_compact_build_table + * Function: H5A_compact_build_table * * Purpose: Builds a table containing a sorted list of attributes for * an object @@ -1716,8 +1709,7 @@ done: * Purpose: Retrieves the "attribute info" message for an object. Also * sets the number of attributes correctly, if it isn't set up yet. * - * Return: Success: TRUE/FALSE whether message was found & retrieved - * Failure: FAIL if error occurred + * Return: TRUE/FALSE/FAIL * * Programmer: Quincey Koziol * Mar 11 2007 @@ -2124,7 +2116,7 @@ done: * an object may have a reference attribute that points to the * object itself. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Peter Cao * March 6, 2005 @@ -2315,14 +2307,13 @@ done: } /* end H5A_dense_post_copy_file_all */ /*------------------------------------------------------------------------- - * Function: H5A_rename_by_name + * Function: H5A_rename_by_name * * Purpose: Private version of H5Arename_by_name * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * February 20, 2007 * *------------------------------------------------------------------------- diff --git a/src/H5Atest.c b/src/H5Atest.c index 2aade87..3c3313e 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -30,12 +30,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMprivate.h" /* Shared object header messages */ /****************/ /* Local Macros */ @@ -66,12 +66,11 @@ /*******************/ /*------------------------------------------------------------------------- - * Function: H5A_is_shared_test + * Function: H5A_is_shared_test * * Purpose: Check if an attribute is shared * - * Return: Success: Non-negative - * Failure: Negative + * Return: TRUE/FALSE/FAIL * * Programmer: Quincey Koziol * Dec 19, 2006 @@ -98,12 +97,11 @@ done: } /* end H5A_is_shared_test() */ /*------------------------------------------------------------------------- - * Function: H5A_get_shared_rc_test + * Function: H5A_get_shared_rc_test * * Purpose: Retrieve the refcount for a shared attribute * - * Return: Success: Non-negative - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Dec 19, 2006 diff --git a/src/H5B2.c b/src/H5B2.c index 1d18488..efc2ea6 100644 --- a/src/H5B2.c +++ b/src/H5B2.c @@ -368,11 +368,10 @@ H5B2_iterate(H5B2_t *bt2, hid_t dxpl_id, H5B2_operator_t op, void *op_data) hdr = bt2->hdr; /* Iterate through records */ - if (hdr->root.node_nrec > 0) { + if (hdr->root.node_nrec > 0) /* Iterate through nodes */ if ((ret_value = H5B2_iterate_node(hdr, dxpl_id, hdr->depth, &hdr->root, op, op_data)) < 0) HERROR(H5E_BTREE, H5E_CANTLIST, "node iteration failed"); - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* H5B2_iterate() */ diff --git a/src/H5B2test.c b/src/H5B2test.c index 0a11a75..f5420c9 100644 --- a/src/H5B2test.c +++ b/src/H5B2test.c @@ -110,9 +110,9 @@ H5FL_DEFINE_STATIC(H5B2_test_ctx_t); static void * H5B2_test_crt_context(void *_f) { - H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ - H5B2_test_ctx_t *ctx; /* Callback context structure */ - void * ret_value; /* Return value */ + H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5B2_test_ctx_t *ctx; /* Callback context structure */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -358,12 +358,11 @@ H5B2_get_root_addr_test(H5B2_t *bt2, haddr_t *root_addr) } /* H5B2_get_root_addr_test() */ /*------------------------------------------------------------------------- - * Function: H5B2_get_node_info_test + * Function: H5B2_get_node_info_test * - * Purpose: Determine information about a node holding a record in the B-tree + * Purpose: Determine information about a node holding a record in the B-tree * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Thursday, August 31, 2006 @@ -480,15 +479,16 @@ done: } /* H5B2_get_node_info_test() */ /*------------------------------------------------------------------------- - * Function: H5B2_get_node_depth_test + * Function: H5B2_get_node_depth_test * - * Purpose: Determine the depth of a node holding a record in the B-tree + * Purpose: Determine the depth of a node holding a record in the B-tree * - * Note: Just a simple wrapper around the H5B2_get_node_info_test() routine + * Note: Just a simple wrapper around the H5B2_get_node_info_test() routine * - * Return: Success: non-negative depth of the node where the record - * was found - * Failure: negative + * Return: Success: Non-negative depth of the node where the record + * was found + * + * Failure: -1 * * Programmer: Quincey Koziol * Saturday, August 26, 2006 @@ -498,17 +498,17 @@ done: int H5B2_get_node_depth_test(H5B2_t *bt2, hid_t dxpl_id, void *udata) { - H5B2_node_info_test_t ninfo; /* Node information */ - int ret_value; /* Return information */ + H5B2_node_info_test_t ninfo; /* Node information */ + int ret_value = -1; /* Return information */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Check arguments. */ HDassert(bt2); /* Get information abou the node */ if (H5B2_get_node_info_test(bt2, dxpl_id, udata, &ninfo) < 0) - HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "error looking up node info") + HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, (-1), "error looking up node info") /* Set return value */ ret_value = ninfo.depth; diff --git a/src/H5CS.c b/src/H5CS.c index ddedcdc..fe5cef5 100644 --- a/src/H5CS.c +++ b/src/H5CS.c @@ -66,8 +66,6 @@ H5CS_t H5CS_stack_g[1]; * Programmer: Quincey Koziol * February 6, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static H5CS_t * @@ -113,8 +111,6 @@ H5CS_get_stack(void) * Programmer: Quincey Koziol * Thursday, February 6, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -135,11 +131,7 @@ H5CS_print_stack(const H5CS_t *fstack, FILE *stream) HDfprintf(stream, "HDF5-DIAG: Function stack from %s ", H5_lib_vers_info_g); /* try show the process or thread id in multiple processes cases*/ -#ifdef H5_HAVE_THREADSAFE - HDfprintf(stream, "thread %lu.", HDpthread_self_ulong()); -#else /* H5_HAVE_THREADSAFE */ - HDfprintf(stream, "thread 0."); -#endif /* H5_HAVE_THREADSAFE */ + HDfprintf(stream, "thread %" PRIu64 ".", H5TS_thread_id()); if (fstack && fstack->nused > 0) HDfprintf(stream, " Back trace follows."); HDfputc('\n', stream); @@ -191,14 +183,12 @@ H5CS_print(FILE *stream) * Programmer: Quincey Koziol * Thursday, February 6, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t H5CS_push(const char *func_name) { - H5CS_t *fstack = H5CS_get_my_stack(); + H5CS_t *fstack = H5CS_get_my_stack(); /* Current function stack for library */ /* Don't push this function on the function stack... :-) */ FUNC_ENTER_NOAPI_NOERR_NOFS @@ -227,8 +217,6 @@ H5CS_push(const char *func_name) * Programmer: Quincey Koziol * Thursday, February 6, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -259,8 +247,6 @@ H5CS_pop(void) * Programmer: Quincey Koziol * Tuesday, August 9, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -293,8 +279,6 @@ H5CS_copy_stack(H5CS_t *new_stack) * Programmer: Quincey Koziol * Tuesday, August 9, 2005 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5D.c b/src/H5D.c index 6265e5d..e3e9095 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -23,11 +23,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ @@ -106,31 +106,28 @@ H5D__term_pub_interface(void) } /* H5D__term_pub_interface() */ /*------------------------------------------------------------------------- - * Function: H5Dcreate2 + * Function: H5Dcreate2 * - * Purpose: Creates a new dataset named NAME at LOC_ID, opens the - * dataset for access, and associates with that dataset constant - * and initial persistent properties including the type of each - * datapoint as stored in the file (TYPE_ID), the size of the - * dataset (SPACE_ID), and other initial miscellaneous - * properties (DCPL_ID). + * Purpose: Creates a new dataset named NAME at LOC_ID, opens the + * dataset for access, and associates with that dataset constant + * and initial persistent properties including the type of each + * datapoint as stored in the file (TYPE_ID), the size of the + * dataset (SPACE_ID), and other initial miscellaneous + * properties (DCPL_ID). * - * All arguments are copied into the dataset, so the caller is - * allowed to derive new types, dataspaces, and creation - * parameters from the old ones and reuse them in calls to - * create other datasets. + * All arguments are copied into the dataset, so the caller is + * allowed to derive new types, dataspaces, and creation + * parameters from the old ones and reuse them in calls to + * create other datasets. * - * Return: Success: The object ID of the new dataset. At this - * point, the dataset is ready to receive its - * raw data. Attempting to read raw data from - * the dataset will probably return the fill - * value. The dataset should be closed when the - * caller is no longer interested in it. + * Return: Success: The object ID of the new dataset. At this + * point, the dataset is ready to receive its + * raw data. Attempting to read raw data from + * the dataset will probably return the fill + * value. The dataset should be closed when the + * caller is no longer interested in it. * - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, April 5, 2007 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -138,126 +135,126 @@ hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t * dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value; /* Return value */ + H5G_loc_t loc; /* Object location to insert dataset into */ + H5D_t * dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); /* Check arguments */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") if (H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") - /* Get correct property list */ + /* Get link creation property list */ if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "lcpl_id is not a link creation property list") - /* Get correct property list */ + /* Get dataset creation property list */ if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, + "dcpl_id is not a dataset create property list ID") /* Get correct property list */ if (H5P_DEFAULT == dapl_id) dapl_id = H5P_DATASET_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset access property list") /* Create the new dataset & get its ID */ if (NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") + + /* Get an ID for the dataset */ if ((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: - if (ret_value < 0) + if (H5I_INVALID_HID == ret_value) if (dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate2() */ /*------------------------------------------------------------------------- - * Function: H5Dcreate_anon + * Function: H5Dcreate_anon * - * Purpose: Creates a new dataset named NAME at LOC_ID, opens the - * dataset for access, and associates with that dataset constant - * and initial persistent properties including the type of each - * datapoint as stored in the file (TYPE_ID), the size of the - * dataset (SPACE_ID), and other initial miscellaneous - * properties (DCPL_ID). + * Purpose: Creates a new dataset named NAME at LOC_ID, opens the + * dataset for access, and associates with that dataset constant + * and initial persistent properties including the type of each + * datapoint as stored in the file (TYPE_ID), the size of the + * dataset (SPACE_ID), and other initial miscellaneous + * properties (DCPL_ID). * - * All arguments are copied into the dataset, so the caller is - * allowed to derive new types, dataspaces, and creation - * parameters from the old ones and reuse them in calls to - * create other datasets. + * All arguments are copied into the dataset, so the caller is + * allowed to derive new types, dataspaces, and creation + * parameters from the old ones and reuse them in calls to + * create other datasets. * * The resulting ID should be linked into the file with * H5Olink or it will be deleted when closed. * - * Return: Success: The object ID of the new dataset. At this - * point, the dataset is ready to receive its - * raw data. Attempting to read raw data from - * the dataset will probably return the fill - * value. The dataset should be linked into - * the group hierarchy before being closed or - * it will be deleted. The dataset should be - * closed when the caller is no longer interested - * in it. - * - * Failure: FAIL + * Return: Success: The object ID of the new dataset. At this + * point, the dataset is ready to receive its + * raw data. Attempting to read raw data from + * the dataset will probably return the fill + * value. The dataset should be linked into + * the group hierarchy before being closed or + * it will be deleted. The dataset should be + * closed when the caller is no longer interested + * in it. * - * Programmer: James Laird - * Tuesday, January 24, 2006 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t * dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value; /* Return value */ + H5G_loc_t loc; /* Object location to insert dataset into */ + H5D_t * dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id); /* Check arguments */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") if (H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") /* Get correct property list */ if (H5P_DEFAULT == dapl_id) dapl_id = H5P_DATASET_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset access property list") /* build and open the new dataset */ if (NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Register the new dataset to get an ID for it */ if ((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: /* Release the dataset's object header, if it was created */ @@ -266,36 +263,34 @@ done: /* Get the new dataset's object location */ if (NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get object location of dataset") + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get object location of dataset") /* Decrement refcount on dataset's object header in memory */ if (H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on newly created object") - } /* end if */ + } /* Cleanup on failure */ - if (ret_value < 0) + if (H5I_INVALID_HID == ret_value) if (dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate_anon() */ /*------------------------------------------------------------------------- - * Function: H5Dopen2 + * Function: H5Dopen2 * - * Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns - * its ID. The dataset should be close when the caller is no - * longer interested in it. + * Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns + * its ID. The dataset should be close when the caller is no + * longer interested in it. * * Takes a dataset access property list * - * Return: Success: A new dataset ID - * Failure: FAIL + * Return: Success: Object ID of the dataset * - * Programmer: James Laird - * Thursday, July 27, 2006 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -310,22 +305,22 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl to use to open datset */ - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, dapl_id); /* Check args */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Get correct property list */ if (H5P_DEFAULT == dapl_id) dapl_id = H5P_DATASET_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset access property list") /* Set up dataset location to fill in */ dset_loc.oloc = &oloc; @@ -334,49 +329,46 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) /* Find the dataset object */ if (H5G_loc_find(&loc, name, &dset_loc, dapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, H5I_INVALID_HID, "not found") loc_found = TRUE; /* Check that the object found is the correct type */ if (H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "can't get object type") if (obj_type != H5O_TYPE_DATASET) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, H5I_INVALID_HID, "not a dataset") /* Open the dataset */ if (NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "can't open dataset") /* Register an atom for the dataset */ if ((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: - if (ret_value < 0) { + if (H5I_INVALID_HID == ret_value) { if (dset) { if (H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") } /* end if */ else { if (loc_found && H5G_loc_free(&dset_loc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") } /* end else */ - } /* end if */ + } FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ /*------------------------------------------------------------------------- - * Function: H5Dclose + * Function: H5Dclose * - * Purpose: Closes access to a dataset (DATASET_ID) and releases - * resources used by it. It is illegal to subsequently use that - * same dataset ID in calls to other dataset functions. + * Purpose: Closes access to a dataset and releases resources used by + * it. It is illegal to subsequently use that same dataset + * ID in calls to other dataset functions. * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -392,8 +384,7 @@ H5Dclose(hid_t dset_id) if (NULL == H5I_object_verify(dset_id, H5I_DATASET)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - /* - * Decrement the counter on the dataset. It will be freed if the count + /* Decrement the counter on the dataset. It will be freed if the count * reaches zero. * * Pass in TRUE for the 3rd parameter to tell the function to remove @@ -408,52 +399,44 @@ done: } /* end H5Dclose() */ /*------------------------------------------------------------------------- - * Function: H5Dget_space - * - * Purpose: Returns a copy of the file dataspace for a dataset. + * Function: H5Dget_space * - * Return: Success: ID for a copy of the dataspace. The data - * space should be released by calling - * H5Sclose(). + * Purpose: Returns a copy of the file dataspace for a dataset. * - * Failure: FAIL + * Return: Success: ID for a copy of the dataspace. The data + * space should be released by calling + * H5Sclose(). * - * Programmer: Robb Matzke - * Wednesday, January 28, 1998 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5Dget_space(hid_t dset_id) { - H5D_t *dset = NULL; - hid_t ret_value; + H5D_t *dset = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") if ((ret_value = H5D_get_space(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to get dataspace") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Dget_space() */ /*------------------------------------------------------------------------- - * Function: H5Dget_space_status - * - * Purpose: Returns the status of dataspace allocation. + * Function: H5Dget_space_status * - * Return: - * Success: Non-negative + * Purpose: Returns the status of dataspace allocation. * - * Failture: Negative - * - * Programmer: Raymond Lu + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -461,14 +444,14 @@ herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) { H5D_t *dset = NULL; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Ds", dset_id, allocation); - /* Check arguments */ + /* Check args */ if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") /* Read dataspace address and return */ if (H5D__get_space_status(dset, allocation, H5AC_ind_dxpl_id) < 0) @@ -476,166 +459,161 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) done: FUNC_LEAVE_API(ret_value) -} +} /* H5Dget_space_status() */ /*------------------------------------------------------------------------- - * Function: H5Dget_type + * Function: H5Dget_type * - * Purpose: Returns a copy of the file datatype for a dataset. + * Purpose: Returns a copy of the file datatype for a dataset. * - * Return: Success: ID for a copy of the datatype. The data - * type should be released by calling - * H5Tclose(). + * Return: Success: ID for a copy of the datatype. The data + * type should be released by calling + * H5Tclose(). * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, February 3, 1998 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5Dget_type(hid_t dset_id) { + H5D_t *dset; /* Dataset */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - H5D_t *dset; /* Dataset */ - hid_t ret_value; /* Return value */ - - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") if ((ret_value = H5D_get_type(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to get dataspace") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_type() */ /*------------------------------------------------------------------------- - * Function: H5Dget_create_plist + * Function: H5Dget_create_plist * - * Purpose: Returns a copy of the dataset creation property list. + * Purpose: Returns a copy of the dataset creation property list. * - * Return: Success: ID for a copy of the dataset creation - * property list. The template should be - * released by calling H5P_close(). + * Return: Success: ID for a copy of the dataset creation + * property list. The template should be + * released by calling H5P_close(). * - * Failure: FAIL + * Failure: H5I_INVALID_HID * - * Programmer: Robb Matzke - * Tuesday, February 3, 1998 + * Programmer: Robb Matzke + * Tuesday, February 3, 1998 * *------------------------------------------------------------------------- */ hid_t H5Dget_create_plist(hid_t dset_id) { - H5D_t *dataset; /* Dataset structure */ - hid_t ret_value = SUCCEED; /* Return value */ + H5D_t *dataset; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ if (NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") + /* Get the dataset creation property list */ if ((ret_value = H5D_get_create_plist(dataset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get creation plist") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset creation properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_create_plist() */ /*------------------------------------------------------------------------- - * Function: H5Dget_access_plist + * Function: H5Dget_access_plist * - * Purpose: Returns a copy of the dataset creation property list. + * Purpose: Returns a copy of the dataset access property list. * * Description: H5Dget_access_plist returns the dataset access property - * list identifier of the specified dataset. + * list identifier of the specified dataset. * - * The chunk cache parameters in the returned property lists will be - * those used by the dataset. If the properties in the file access - * property list were used to determine the dataset’s chunk cache - * configuration, then those properties will be present in the - * returned dataset access property list. If the dataset does not - * use a chunked layout, then the chunk cache properties will be set - * to the default. The chunk cache properties in the returned list - * are considered to be “set”, and any use of this list will override - * the corresponding properties in the file’s file access property - * list. + * The chunk cache parameters in the returned property lists will be + * those used by the dataset. If the properties in the file access + * property list were used to determine the dataset’s chunk cache + * configuration, then those properties will be present in the + * returned dataset access property list. If the dataset does not + * use a chunked layout, then the chunk cache properties will be set + * to the default. The chunk cache properties in the returned list + * are considered to be “set”, and any use of this list will override + * the corresponding properties in the file’s file access property + * list. * - * All link access properties in the returned list will be set to the - * default values. + * All link access properties in the returned list will be set to the + * default values. * - * Return: Success: ID for a copy of the dataset access - * property list. The template should be - * released by calling H5Pclose(). + * Return: Success: ID for a copy of the dataset access + * property list. The template should be + * released by calling H5Pclose(). * - * Failure: FAIL + * Failure: H5I_INVALID_HID * - * Programmer: Neil Fortner - * Wednesday, October 29, 2008 + * Programmer: Neil Fortner + * Wednesday, October 29, 2008 * *------------------------------------------------------------------------- */ hid_t H5Dget_access_plist(hid_t dset_id) { - H5D_t *dset; /* Dataset structure */ - hid_t ret_value; /* Return value */ + H5D_t *dset; /* Dataset structure */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") + /* Get the dataset access property list */ if ((ret_value = H5D_get_access_plist(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get access plist") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset access properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Dget_access_plist() */ /*------------------------------------------------------------------------- - * Function: H5Dget_storage_size + * Function: H5Dget_storage_size * - * Purpose: Returns the amount of storage that is required for the - * dataset. For chunked datasets this is the number of allocated - * chunks times the chunk size. + * Purpose: Returns the amount of storage that is required for the + * dataset. For chunked datasets this is the number of allocated + * chunks times the chunk size. * - * Return: Success: The amount of storage space allocated for the - * dataset, not counting meta data. The return - * value may be zero if no data has been stored. + * Return: Success: The amount of storage space allocated for the + * dataset, not counting meta data. The return + * value may be zero if no data has been stored. * - * Failure: Zero - * - * Programmer: Robb Matzke - * Wednesday, April 21, 1999 + * Failure: Zero * *------------------------------------------------------------------------- */ hsize_t H5Dget_storage_size(hid_t dset_id) { - H5D_t * dset; /* Dataset to query */ - hsize_t ret_value; /* Return value */ + H5D_t * dset; /* Dataset to query */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", dset_id); /* Check args */ if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier") - /* Set return value */ + /* Get the storage size */ if (H5D__get_storage_size(dset, H5AC_ind_dxpl_id, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of dataset's storage") @@ -644,24 +622,21 @@ done: } /* end H5Dget_storage_size() */ /*------------------------------------------------------------------------- - * Function: H5Dget_offset - * - * Purpose: Returns the address of dataset in file. + * Function: H5Dget_offset * - * Return: Success: the address of dataset + * Purpose: Returns the address of dataset in file. * - * Failure: HADDR_UNDEF + * Return: Success: The address of dataset * - * Programmer: Raymond Lu - * November 6, 2002 + * Failure: HADDR_UNDEF (can also be a valid return value!) * *------------------------------------------------------------------------- */ haddr_t H5Dget_offset(hid_t dset_id) { - H5D_t * dset; /* Dataset to query */ - haddr_t ret_value; /* Return value */ + H5D_t * dset; /* Dataset to query */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_API(HADDR_UNDEF) H5TRACE1("a", "i", dset_id); @@ -670,7 +645,7 @@ H5Dget_offset(hid_t dset_id) if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a dataset") - /* Set return value */ + /* Get the offset */ ret_value = H5D__get_offset(dset); done: @@ -678,9 +653,9 @@ done: } /* end H5Dget_offset() */ /*------------------------------------------------------------------------- - * Function: H5Diterate + * Function: H5Diterate * - * Purpose: This routine iterates over all the elements selected in a memory + * Purpose: This routine iterates over all the elements selected in a memory * buffer. The callback function is called once for each element selected * in the dataspace. The selection in the dataspace is modified so * that any elements already iterated over are removed from the selection @@ -727,11 +702,11 @@ done: * indicating failure. The iterator can be restarted at the next * element. * - * Return: Returns the return value of the last operator if it was non-zero, + * Return: Returns the return value of the last operator if it was non-zero, * or zero if all elements were processed. Otherwise returns a * negative value. * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Friday, June 11, 1999 * *------------------------------------------------------------------------- @@ -817,9 +792,9 @@ done: } /* end H5Dvlen_reclaim() */ /*------------------------------------------------------------------------- - * Function: H5Dvlen_get_buf_size + * Function: H5Dvlen_get_buf_size * - * Purpose: This routine checks the number of bytes required to store the VL + * Purpose: This routine checks the number of bytes required to store the VL * data from the dataset, using the space_id for the selection in the * dataset on disk and the type_id for the memory representation of the * VL data, in memory. The *size value is modified according to how many @@ -833,9 +808,9 @@ done: * Kinda kludgy, but easier than the other method of trying to figure out * the sizes without actually reading the data in... - QAK * - * Return: Non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, August 11, 1999 * *------------------------------------------------------------------------- @@ -930,16 +905,13 @@ done: } /* end H5Dvlen_get_buf_size() */ /*------------------------------------------------------------------------- - * Function: H5Dset_extent + * Function: H5Dset_extent * - * Purpose: Modifies the dimensions of a dataset. - * Can change to a smaller dimension. + * Purpose: Modifies the dimensions of a dataset. + * Can change to a smaller dimension. * * Return: Non-negative on success, negative on failure * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * April 9, 2002 - * *------------------------------------------------------------------------- */ herr_t @@ -968,7 +940,7 @@ done: /*------------------------------------------------------------------------- * Function: H5Dget_chunk_storage_size * - * Purpose: Returns the size of an allocated of chunk. + * Purpose: Returns the size of an allocated chunk. * * Return: Non-negative on success, negative on failure * @@ -981,7 +953,7 @@ herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_nbytes) { H5D_t *dset = NULL; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*h*h", dset_id, offset, chunk_nbytes); @@ -997,7 +969,7 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n if (H5D_CHUNKED != dset->shared->layout.type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - /* Call private function */ + /* Get the dataset creation property list */ if (H5D__get_chunk_storage_size(dset, H5AC_ind_dxpl_id, offset, chunk_nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") diff --git a/src/H5Dbtree.c b/src/H5Dbtree.c index eda8eae..f890cd5 100644 --- a/src/H5Dbtree.c +++ b/src/H5Dbtree.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Robb Matzke +/* Programmer: Robb Matzke * Wednesday, October 8, 1997 * * Purpose: v1 B-tree indexed (chunked) I/O functions. The chunks are @@ -298,10 +298,10 @@ done: static int H5D__btree_cmp2(void *_lt_key, void *_udata, void *_rt_key) { - H5D_btree_key_t * lt_key = (H5D_btree_key_t *)_lt_key; - H5D_btree_key_t * rt_key = (H5D_btree_key_t *)_rt_key; - H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *)_udata; - int ret_value; + H5D_btree_key_t * lt_key = (H5D_btree_key_t *)_lt_key; + H5D_btree_key_t * rt_key = (H5D_btree_key_t *)_rt_key; + H5D_chunk_common_ud_t *udata = (H5D_chunk_common_ud_t *)_udata; + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -406,7 +406,6 @@ H5D__btree_cmp3(void *_lt_key, void *_udata, void *_rt_key) * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static htri_t H5D__btree_found(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, haddr_t addr, const void *_lt_key, void *_udata) @@ -467,7 +466,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static H5B_ins_t H5D__btree_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t H5_ATTR_UNUSED *rt_key_changed, @@ -479,7 +477,7 @@ H5D__btree_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key, hbool_t H5D_chunk_ud_t * udata = (H5D_chunk_ud_t *)_udata; int cmp; unsigned u; - H5B_ins_t ret_value; + H5B_ins_t ret_value = H5B_INS_ERROR; /* Return value */ FUNC_ENTER_STATIC @@ -578,13 +576,11 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * March 28, 2002 * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static H5B_ins_t H5D__btree_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key /*in,out */, hbool_t *lt_key_changed /*out */, void H5_ATTR_UNUSED *_udata /*in,out */, @@ -694,7 +690,6 @@ H5D__btree_encode_key(const H5B_shared_t *shared, uint8_t *raw, const void *_key * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5D__btree_debug_key(FILE *stream, int indent, int fwidth, const void *_key, const void *_udata) { @@ -873,8 +868,7 @@ H5D__btree_idx_is_space_alloc(const H5O_storage_chunk_t *storage) /*------------------------------------------------------------------------- * Function: H5D__btree_idx_insert * - * Purpose: Create the chunk it if it doesn't exist, or reallocate the - * chunk if its size changed. + * Purpose: Insert chunk entry into the indexing structure. * * Return: Non-negative on success/Negative on failure * @@ -962,7 +956,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static int H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const void *_lt_key, haddr_t addr, const void H5_ATTR_UNUSED *_rt_key, void *_udata) @@ -970,7 +963,7 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, H5D_btree_it_ud_t * udata = (H5D_btree_it_ud_t *)_udata; /* User data */ const H5D_btree_key_t *lt_key = (const H5D_btree_key_t *)_lt_key; /* B-tree key for chunk */ H5D_chunk_rec_t chunk_rec; /* Generic chunk record for callback */ - int ret_value; /* Return value */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR @@ -1009,8 +1002,8 @@ H5D__btree_idx_iterate_cb(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, static int H5D__btree_idx_iterate(const H5D_chk_idx_info_t *idx_info, H5D_chunk_cb_func_t chunk_cb, void *chunk_udata) { - H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ - int ret_value; /* Return value */ + H5D_btree_it_ud_t udata; /* User data for B-tree iterator callback */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 6847e42..7e651bb 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -11,11 +11,11 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Thursday, April 24, 2008 * * Purpose: Abstract indexed (chunked) I/O functions. The logical - * multi-dimensional data space is regularly partitioned into + * multi-dimensional dataspace is regularly partitioned into * same-sized "chunks", the first of which is aligned with the * logical origin. The chunks are indexed by different methods, * that map a chunk index to disk address. Each chunk can be @@ -374,9 +374,9 @@ done: /*------------------------------------------------------------------------- * Function: H5D__chunk_direct_read * - * Purpose: Internal routine to read a chunk directly from the file. + * Purpose: Internal routine to read a chunk directly from the file. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Matthew Strong (GE Healthcare) * 14 February 2016 @@ -480,9 +480,9 @@ done: /*------------------------------------------------------------------------- * Function: H5D__get_chunk_storage_size * - * Purpose: Internal routine to read the storage size of a chunk on disk. + * Purpose: Internal routine to read the storage size of a chunk on disk. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Matthew Strong (GE Healthcare) * 20 October 2016 @@ -948,22 +948,20 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf if ((file_space_normalized = H5S_hyper_normalize_offset((H5S_t *)file_space, old_offset)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset") - /* Decide the number of chunks in each dimension*/ - for (u = 0; u < f_ndims; u++) { + /* Decide the number of chunks in each dimension */ + for (u = 0; u < f_ndims; u++) /* Keep the size of the chunk dimensions as hsize_t for various routines */ fm->chunk_dim[u] = fm->layout->u.chunk.dim[u]; - } /* end for */ #ifdef H5_HAVE_PARALLEL /* Calculate total chunk in file map*/ fm->select_chunk = NULL; if (io_info->using_mpi_vfd) { H5_CHECK_OVERFLOW(fm->layout->u.chunk.nchunks, hsize_t, size_t); - if (fm->layout->u.chunk.nchunks) { + if (fm->layout->u.chunk.nchunks) if (NULL == (fm->select_chunk = (H5D_chunk_info_t **)H5MM_calloc( (size_t)fm->layout->u.chunk.nchunks * sizeof(H5D_chunk_info_t *)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") - } } /* end if */ #endif /* H5_HAVE_PARALLEL */ @@ -1004,10 +1002,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HDassert(fm->single_space); /* Allocate the single chunk information */ - if (NULL == dataset->shared->cache.chunk.single_chunk_info) { + if (NULL == dataset->shared->cache.chunk.single_chunk_info) if (NULL == (dataset->shared->cache.chunk.single_chunk_info = H5FL_MALLOC(H5D_chunk_info_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") - } /* end if */ fm->single_chunk_info = dataset->shared->cache.chunk.single_chunk_info; HDassert(fm->single_chunk_info); @@ -1023,10 +1020,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf hbool_t sel_hyper_flag; /* Whether file selection is a hyperslab */ /* Initialize skip list for chunk selections */ - if (NULL == dataset->shared->cache.chunk.sel_chunks) { + if (NULL == dataset->shared->cache.chunk.sel_chunks) if (NULL == (dataset->shared->cache.chunk.sel_chunks = H5SL_create(H5SL_TYPE_HSIZE, NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't create skip list for chunk selections") - } /* end if */ fm->sel_chunks = dataset->shared->cache.chunk.sel_chunks; HDassert(fm->sel_chunks); @@ -1121,10 +1117,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf fm->mchunk_tmpl = tmp_mspace; /* Create temporary datatypes for selection iteration */ - if (!file_type) { + if (!file_type) if (NULL == (file_type = H5T_copy(dataset->shared->type, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, FAIL, "unable to copy file datatype") - } /* end if */ /* Create selection iterator for memory selection */ if (0 == (elmt_size = H5T_get_size(mem_type))) @@ -1165,12 +1160,10 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf done: /* Release the [potentially partially built] chunk mapping information if an error occurs */ if (ret_value < 0) { - if (tmp_mspace && !fm->mchunk_tmpl) { + if (tmp_mspace && !fm->mchunk_tmpl) if (H5S_close(tmp_mspace) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "can't release memory chunk dataspace template") - } /* end if */ - if (H5D__chunk_io_term(fm) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release chunk mapping") } /* end if */ @@ -1434,7 +1427,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t hsize_t sel_points; /* Number of elements in file selection */ hsize_t start_coords[H5O_LAYOUT_NDIMS]; /* Starting coordinates of selection */ hsize_t coords[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ - hsize_t end[H5O_LAYOUT_NDIMS]; /* Current coordinates of chunk */ + hsize_t end[H5O_LAYOUT_NDIMS]; /* Final coordinates of chunk */ hsize_t chunk_index; /* Index of chunk */ int curr_dim; /* Current dimension to increment */ unsigned u; /* Local index variable */ @@ -1838,7 +1831,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, unsigned ndims, const hsize_t *coords, void *_fm) @@ -1872,11 +1864,10 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u HGOTO_ERROR(H5E_DATASPACE, H5E_NOTFOUND, FAIL, "can't locate chunk in skip list") /* Check if the chunk already has a memory space */ - if (NULL == chunk_info->mspace) { + if (NULL == chunk_info->mspace) /* Copy the template memory chunk dataspace */ if (NULL == (chunk_info->mspace = H5S_copy(fm->mchunk_tmpl, FALSE, FALSE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file space") - } /* end else */ /* Update the "last chunk seen" information */ fm->last_index = chunk_index; @@ -2895,10 +2886,10 @@ H5D__chunk_cache_prune(const H5D_t *dset, hid_t dxpl_id, const H5D_dxpl_cache_t { const H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); size_t total = rdcc->nbytes_max; - const int nmeth = 2; /*number of methods */ - int w[1]; /*weighting as an interval */ - H5D_rdcc_ent_t * p[2], *cur; /*list pointers */ - H5D_rdcc_ent_t * n[2]; /*list next pointers */ + const int nmeth = 2; /* Number of methods */ + int w[1]; /* Weighting as an interval */ + H5D_rdcc_ent_t * p[2], *cur; /* List pointers */ + H5D_rdcc_ent_t * n[2]; /* List next pointers */ int nerrors = 0; /* Accumulated error count during preemptions */ herr_t ret_value = SUCCEED; /* Return value */ @@ -3031,6 +3022,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t rel FUNC_ENTER_PACKAGE + /* Sanity checks */ HDassert(io_info); HDassert(io_info->dxpl_cache); HDassert(io_info->store); @@ -3165,7 +3157,7 @@ H5D__chunk_lock(const H5D_io_info_t *io_info, H5D_chunk_ud_t *udata, hbool_t rel if (ent) { /* - * The chunk is not at the beginning of the cache; move it backward + * If the chunk is not at the beginning of the cache; move it backward * by one slot. This is how we implement the LRU preemption * algorithm. */ @@ -3296,6 +3288,7 @@ H5D__chunk_unlock(const H5D_io_info_t *io_info, const H5D_chunk_ud_t *udata, hbo FUNC_ENTER_PACKAGE + /* Sanity check */ HDassert(io_info); HDassert(udata); @@ -3365,7 +3358,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static int H5D__chunk_allocated_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { @@ -3413,11 +3405,10 @@ H5D__chunk_allocated(H5D_t *dset, hid_t dxpl_id, hsize_t *nbytes) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't fill dxpl cache") /* Search for cached chunks that haven't been written out */ - for (ent = rdcc->head; ent; ent = ent->next) { + for (ent = rdcc->head; ent; ent = ent->next) /* Flush the chunk out to disk, to make certain the size is correct later */ if (H5D__chunk_flush_entry(dset, dxpl_id, dxpl_cache, ent, FALSE) < 0) HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "cannot flush indexed storage buffer") - } /* end for */ /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; @@ -3670,7 +3661,8 @@ H5D__chunk_allocate(const H5D_t *dset, hid_t dxpl_id, hbool_t full_overwrite, hs /* Check to make sure the buffer is large enough. It is * possible (though ill-advised) for the filter to shrink the - * buffer. */ + * buffer. + */ if (fb_info.fill_buf_size < orig_chunk_size) { if (NULL == (fb_info.fill_buf = H5D__chunk_realloc(fb_info.fill_buf, orig_chunk_size, pline))) @@ -3983,8 +3975,8 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * March 26, 2002 + * Programmer: Pedro Vicente + * March 26, 2002 * *------------------------------------------------------------------------- */ @@ -4101,7 +4093,7 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Programmer: Pedro Vicente * Algorithm: Robb Matzke * March 27, 2002 * @@ -5321,7 +5313,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static int H5D__chunk_dump_index_cb(const H5D_chunk_rec_t *chunk_rec, void *_udata) { @@ -5525,10 +5516,10 @@ H5D__chunk_stats(const H5D_t *dset, hbool_t headers) miss_rate = 0.0; } if (miss_rate > 100) { - sprintf(ascii, "%7d%%", (int)(miss_rate + 0.5)); + HDsprintf(ascii, "%7d%%", (int)(miss_rate + 0.5)); } else { - sprintf(ascii, "%7.2f%%", miss_rate); + HDsprintf(ascii, "%7.2f%%", miss_rate); } HDfprintf(H5DEBUG(AC), " %-18s %8u %8u %7s %8d+%-9ld\n", "raw data chunks", rdcc->nhits, @@ -5613,8 +5604,8 @@ H5D__nonexistent_readvv(const H5D_io_info_t *io_info, size_t chunk_max_nseq, siz size_t chunk_len_arr[], hsize_t chunk_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_chunk_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value; /* Return value */ + H5D_chunk_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 9183df4..5d1268d 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Raymond Lu + * Programmer: Raymond Lu * August 5, 2002 * * Purpose: Compact dataset I/O functions. These routines are similar @@ -267,7 +267,7 @@ H5D__compact_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t * size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -309,7 +309,7 @@ H5D__compact_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t size_t dset_size_arr[], hsize_t dset_offset_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_size_arr[], hsize_t mem_offset_arr[]) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index c301f45..622e425 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, September 28, 2000 * * Purpose: @@ -30,17 +30,17 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5VMprivate.h" /* Vector and array functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VMprivate.h" /* Vector and array functions */ /****************/ /* Local Macros */ @@ -364,7 +364,6 @@ done: * *------------------------------------------------------------------------- */ -/* ARGSUSED */ static herr_t H5D__contig_construct(H5F_t *f, H5D_t *dset) { @@ -387,7 +386,7 @@ H5D__contig_construct(H5F_t *f, H5D_t *dset) /* * The maximum size of the dataset cannot exceed the storage size. - * Also, only the slowest varying dimension of a simple data space + * Also, only the slowest varying dimension of a simple dataspace * can be extendible (currently only for external data storage). */ @@ -446,7 +445,7 @@ done: hbool_t H5D__contig_is_space_alloc(const H5O_storage_t *storage) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -843,7 +842,7 @@ H5D__contig_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *d size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1175,7 +1174,7 @@ H5D__contig_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t * size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - ssize_t ret_value; /* Return value (Size of sequence in bytes) */ + ssize_t ret_value = -1; /* Return value (Size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -1421,6 +1420,7 @@ H5D__contig_copy(H5F_t *f_src, const H5O_storage_contig_t *storage_src, H5F_t *f HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for copy buffer") } /* end if */ + /* Loop over copying data */ addr_src = storage_src->addr; addr_dst = storage_dst->addr; diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index 4658fa2..69d3c99 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -23,10 +23,10 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ @@ -73,17 +73,12 @@ H5D__init_dbg_interface(void) } /* H5D__init_dbg_interface() */ /*------------------------------------------------------------------------- - * Function: H5Ddebug + * Function: H5Ddebug * - * Purpose: Prints various information about a dataset. This function is - * not to be documented in the API at this time. + * Purpose: Prints various information about a dataset. This function is + * not to be documented in the API at this time. * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Wednesday, April 28, 1999 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 13fe91e..12d9542 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -15,7 +15,7 @@ * * Created: H5Ddeprec.c * April 5 2007 - * Quincey Koziol + * Quincey Koziol * * Purpose: Deprecated functions from the H5D interface. These * functions are here for compatibility purposes and may be @@ -120,28 +120,28 @@ H5D__term_deprec_interface(void) #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- - * Function: H5Dcreate1 + * Function: H5Dcreate1 * - * Purpose: Creates a new dataset named NAME at LOC_ID, opens the - * dataset for access, and associates with that dataset constant - * and initial persistent properties including the type of each - * datapoint as stored in the file (TYPE_ID), the size of the - * dataset (SPACE_ID), and other initial miscellaneous - * properties (DCPL_ID). + * Purpose: Creates a new dataset named NAME at LOC_ID, opens the + * dataset for access, and associates with that dataset constant + * and initial persistent properties including the type of each + * datapoint as stored in the file (TYPE_ID), the size of the + * dataset (SPACE_ID), and other initial miscellaneous + * properties (DCPL_ID). * - * All arguments are copied into the dataset, so the caller is - * allowed to derive new types, data spaces, and creation - * parameters from the old ones and reuse them in calls to - * create other datasets. + * All arguments are copied into the dataset, so the caller is + * allowed to derive new types, data spaces, and creation + * parameters from the old ones and reuse them in calls to + * create other datasets. * - * Return: Success: The object ID of the new dataset. At this - * point, the dataset is ready to receive its - * raw data. Attempting to read raw data from - * the dataset will probably return the fill - * value. The dataset should be closed when - * the caller is no longer interested in it. + * Return: Success: The object ID of the new dataset. At this + * point, the dataset is ready to receive its + * raw data. Attempting to read raw data from + * the dataset will probably return the fill + * value. The dataset should be closed when + * the caller is no longer interested in it. * - * Failure: FAIL + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Wednesday, December 3, 1997 @@ -151,56 +151,56 @@ H5D__term_deprec_interface(void) hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t * dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value; /* Return value */ + H5G_loc_t loc; /* Object location to insert dataset into */ + H5D_t * dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, dcpl_id); /* Check arguments */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") if (H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") if (NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") if (H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not dataset create property list ID") /* Build and open the new dataset */ if (NULL == (dset = H5D__create_named(&loc, name, type_id, space, H5P_LINK_CREATE_DEFAULT, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Register the new dataset to get an ID for it */ if ((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: - if (ret_value < 0) + if (H5I_INVALID_HID == ret_value) if (dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate1() */ /*------------------------------------------------------------------------- - * Function: H5Dopen1 + * Function: H5Dopen1 * - * Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns - * its ID. The dataset should be close when the caller is no - * longer interested in it. + * Purpose: Finds a dataset named NAME at LOC_ID, opens it, and returns + * its ID. The dataset should be close when the caller is no + * longer interested in it. * - * Note: Deprecated in favor of H5Dopen2 + * Note: Deprecated in favor of H5Dopen2 * - * Return: Success: A new dataset ID - * Failure: FAIL + * Return: Success: A new dataset ID + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, December 4, 1997 @@ -219,16 +219,16 @@ H5Dopen1(hid_t loc_id, const char *name) hbool_t loc_found = FALSE; /* Location at 'name' found */ hid_t dapl_id = H5P_DATASET_ACCESS_DEFAULT; /* dapl to use to open dataset */ hid_t dxpl_id = H5AC_ind_dxpl_id; /* dxpl to use to open datset */ - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Set up dataset location to fill in */ dset_loc.oloc = &oloc; @@ -237,32 +237,32 @@ H5Dopen1(hid_t loc_id, const char *name) /* Find the dataset object */ if (H5G_loc_find(&loc, name, &dset_loc, H5P_DEFAULT, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, H5I_INVALID_HID, "not found") loc_found = TRUE; /* Check that the object found is the correct type */ if (H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "can't get object type") if (obj_type != H5O_TYPE_DATASET) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, H5I_INVALID_HID, "not a dataset") /* Open the dataset */ if (NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "can't open dataset") /* Register an atom for the dataset */ if ((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: if (ret_value < 0) { if (dset != NULL) { if (H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") } /* end if */ else { if (loc_found && H5G_loc_free(&dset_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") } /* end else */ } /* end if */ @@ -270,15 +270,15 @@ done: } /* end H5Dopen1() */ /*------------------------------------------------------------------------- - * Function: H5Dextend + * Function: H5Dextend * - * Purpose: This function makes sure that the dataset is at least of size - * SIZE. The dimensionality of SIZE is the same as the data - * space of the dataset being changed. + * Purpose: This function makes sure that the dataset is at least of size + * SIZE. The dimensionality of SIZE is the same as the data + * space of the dataset being changed. * - * Note: Deprecated in favor of H5Dset_extent + * Note: Deprecated in favor of H5Dset_extent * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke * Friday, January 30, 1998 @@ -296,7 +296,7 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) /* Check args */ if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") if (!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") diff --git a/src/H5Defl.c b/src/H5Defl.c index 6b721ea..08d118f 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Thursday, September 30, 2004 */ @@ -125,7 +125,7 @@ H5D__efl_construct(H5F_t *f, H5D_t *dset) /* * The maximum size of the dataset cannot exceed the storage size. - * Also, only the slowest varying dimension of a simple data space + * Also, only the slowest varying dimension of a simple dataspace * can be extendible (currently only for external data storage). */ @@ -315,9 +315,6 @@ done: * Programmer: Robb Matzke * Wednesday, March 4, 1998 * - * Modifications: - * Robb Matzke, 1999-07-28 - * The ADDR argument is passed by value. *------------------------------------------------------------------------- */ static herr_t @@ -443,8 +440,8 @@ H5D__efl_readvv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dset size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_efl_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value; /* Return value (Total size of sequence in bytes) */ + H5D_efl_readvv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC @@ -524,8 +521,8 @@ H5D__efl_writevv(const H5D_io_info_t *io_info, size_t dset_max_nseq, size_t *dse size_t dset_len_arr[], hsize_t dset_off_arr[], size_t mem_max_nseq, size_t *mem_curr_seq, size_t mem_len_arr[], hsize_t mem_off_arr[]) { - H5D_efl_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ - ssize_t ret_value; /* Return value (Total size of sequence in bytes) */ + H5D_efl_writevv_ud_t udata; /* User data for H5VM_opvv() operator */ + ssize_t ret_value = -1; /* Return value (Total size of sequence in bytes) */ FUNC_ENTER_STATIC diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 92cb96c..41e0b14 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -15,7 +15,7 @@ * * Created: H5Dfill.c * Jun 19 2007 - * Quincey Koziol + * Quincey Koziol * * Purpose: Fill value operations for datasets * diff --git a/src/H5Dint.c b/src/H5Dint.c index d0c6488..fc47eff 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -23,14 +23,14 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -110,17 +110,13 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ }}; /*------------------------------------------------------------------------- - * Function: H5D_init + * Function: H5D_init * - * Purpose: Initialize the interface from some other layer. + * Purpose: Initialize the interface from some other layer. * - * Return: Success: non-negative - * - * Failure: negative - * - * Programmer: Quincey Koziol - * Saturday, March 4, 2000 + * Return: Success: non-negative * + * Failure: negative *------------------------------------------------------------------------- */ herr_t @@ -137,7 +133,7 @@ done: /*-------------------------------------------------------------------------- NAME - H5D__init_interface -- Initialize interface-specific information + H5D__init_interface -- Initialize interface-specific information USAGE herr_t H5D__init_interface() @@ -199,14 +195,9 @@ done: * * Purpose: Terminate this interface. * - * Return: Success: Positive if anything was done that might + * Return: Success: Positive if anything was done that might * affect other interfaces; zero otherwise. - * - * Failure: Negative. - * - * Programmer: Robb Matzke - * Friday, November 20, 1998 - * + * Failure: Negative. *------------------------------------------------------------------------- */ int @@ -387,26 +378,22 @@ done: } /* H5D__get_dxpl_cache() */ /*------------------------------------------------------------------------- - * Function: H5D__create_named - * - * Purpose: Internal routine to create a new dataset. + * Function: H5D__create_named * - * Return: Success: Non-NULL, pointer to new dataset object. + * Purpose: Internal routine to create a new dataset. * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Thursday, April 5, 2007 + * Return: Success: Non-NULL, pointer to new dataset object. * + * Failure: NULL *------------------------------------------------------------------------- */ H5D_t * H5D__create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H5S_t *space, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id) { - H5O_obj_create_t ocrt_info; /* Information for object creation */ - H5D_obj_create_t dcrt_info; /* Information for dataset creation */ - H5D_t * ret_value; /* Return value */ + H5O_obj_create_t ocrt_info; /* Information for object creation */ + H5D_obj_create_t dcrt_info; /* Information for dataset creation */ + H5D_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -450,11 +437,7 @@ done: * * Return: * Success: Non-negative - * * Failture: Negative - * - * Programmer: Raymond Lu - * *------------------------------------------------------------------------- */ herr_t @@ -511,25 +494,20 @@ done: } /* end H5D__get_space_status() */ /*------------------------------------------------------------------------- - * Function: H5D__new - * - * Purpose: Creates a new, empty dataset structure - * - * Return: Success: Pointer to a new dataset descriptor. + * Function: H5D__new * - * Failure: NULL - * - * Programmer: Quincey Koziol - * Monday, October 12, 1998 + * Purpose: Creates a new, empty dataset structure * + * Return: Success: Pointer to a new dataset descriptor. + * Failure: NULL *------------------------------------------------------------------------- */ static H5D_shared_t * H5D__new(hid_t dcpl_id, hid_t dapl_id, hbool_t creating, hbool_t vl_type) { - H5D_shared_t * new_dset = NULL; /* New dataset object */ - H5P_genplist_t *plist; /* Property list created */ - H5D_shared_t * ret_value; /* Return value */ + H5D_shared_t * new_dset = NULL; /* New dataset object */ + H5P_genplist_t *plist; /* Property list created */ + H5D_shared_t * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -586,17 +564,13 @@ done: } /* end H5D__new() */ /*------------------------------------------------------------------------- - * Function: H5D__init_type + * Function: H5D__init_type * - * Purpose: Copy a datatype for a dataset's use, performing all the + * Purpose: Copy a datatype for a dataset's use, performing all the * necessary adjustments, etc. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, June 24, 2004 - * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ static herr_t @@ -632,7 +606,8 @@ H5D__init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, const H5T_t *type) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy datatype") /* Convert a datatype (if committed) to a transient type if the committed datatype's file - location is different from the file location where the dataset will be created */ + * location is different from the file location where the dataset will be created. + */ if (H5T_convert_committed_datatype(dset->shared->type, file) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't get shared datatype info") @@ -664,17 +639,13 @@ done: } /* end H5D__init_type() */ /*------------------------------------------------------------------------- - * Function: H5D__init_space + * Function: H5D__init_space * - * Purpose: Copy a dataspace for a dataset's use, performing all the + * Purpose: Copy a dataspace for a dataset's use, performing all the * necessary adjustments, etc. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Tuesday, July 24, 2007 - * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ static herr_t @@ -711,16 +682,12 @@ done: } /* end H5D__init_space() */ /*------------------------------------------------------------------------- - * Function: H5D__update_oh_info + * Function: H5D__update_oh_info * - * Purpose: Create and fill object header for dataset - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Bill Wendling - * Thursday, October 31, 2002 + * Purpose: Create and fill object header for dataset * + * Return: Success: SUCCEED + * Failure: FAIL *------------------------------------------------------------------------- */ static herr_t @@ -783,9 +750,8 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) fill_prop->fill_defined = TRUE; } - else if (fill_status == H5D_FILL_VALUE_UNDEFINED) { + else if (fill_status == H5D_FILL_VALUE_UNDEFINED) fill_prop->fill_defined = FALSE; - } else HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to determine if fill value is defined") @@ -919,9 +885,6 @@ done: * should be used. * * Return: SUCCEED/FAIL - * - * Programmer: Steffen Kiess - * October 16, 2015 *-------------------------------------------------------------------------- */ static herr_t @@ -938,6 +901,7 @@ H5D_build_extfile_prefix(const H5D_t *dset, hid_t dapl_id, char **extfile_prefix FUNC_ENTER_NOAPI_NOINIT + /* Sanity checks */ HDassert(dset); HDassert(dset->oloc.file); @@ -1003,12 +967,7 @@ done: * affecting the dataset. * * Return: Success: Pointer to a new dataset - * - * Failure: NULL - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 - * + * Failure: NULL *------------------------------------------------------------------------- */ H5D_t * @@ -1020,7 +979,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ H5G_loc_t dset_loc; /* Dataset location */ - H5D_t * ret_value; /* Return value */ + H5D_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1209,17 +1168,13 @@ done: /* *------------------------------------------------------------------------- - * Function: H5D_open + * Function: H5D_open * - * Purpose: Checks if dataset is already open, or opens a dataset for + * Purpose: Checks if dataset is already open, or opens a dataset for * access. * - * Return: Success: Dataset ID - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Friday, December 20, 2002 - * + * Return: Success: Dataset ID + * Failure: FAIL *------------------------------------------------------------------------- */ H5D_t * @@ -1331,15 +1286,11 @@ done: } /* end H5D_open() */ /*------------------------------------------------------------------------- - * Function: H5D__open_oid + * Function: H5D__open_oid * - * Purpose: Opens a dataset for access. - * - * Return: Dataset pointer on success, NULL on failure - * - * Programmer: Quincey Koziol - * Monday, October 12, 1998 + * Purpose: Opens a dataset for access. * + * Return: Dataset pointer on success, NULL on failure *------------------------------------------------------------------------- */ static herr_t @@ -1488,17 +1439,13 @@ done: } /* end H5D__open_oid() */ /*------------------------------------------------------------------------- - * Function: H5D_close - * - * Purpose: Insures that all data has been saved to the file, closes the - * dataset object header, and frees all resources used by the - * descriptor. + * Function: H5D_close * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Purpose: Insures that all data has been saved to the file, closes the + * dataset object header, and frees all resources used by the + * descriptor. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1520,6 +1467,7 @@ H5D_close(H5D_t *dataset) dataset->shared->fo_count--; if (dataset->shared->fo_count == 0) { + /* Flush the dataset's information. Continue to close even if it fails. */ if (H5D__flush_real(dataset, H5AC_dxpl_id) < 0) HDONE_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "unable to flush cached dataset info") @@ -1610,8 +1558,8 @@ H5D_close(H5D_t *dataset) * above). */ dataset->oloc.file = NULL; + dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); - dataset->shared = H5FL_FREE(H5D_shared_t, dataset->shared); } /* end if */ else { /* Decrement the ref. count for this object in the top file */ @@ -1646,16 +1594,12 @@ done: } /* end H5D_close() */ /*------------------------------------------------------------------------- - * Function: H5D_oloc - * - * Purpose: Returns a pointer to the object location for a dataset. + * Function: H5D_oloc * - * Return: Success: Ptr to location - * Failure: NULL - * - * Programmer: Robb Matzke - * Friday, April 24, 1998 + * Purpose: Returns a pointer to the object location for a dataset. * + * Return: Success: Ptr to location + * Failure: NULL *------------------------------------------------------------------------- */ H5O_loc_t * @@ -1668,16 +1612,12 @@ H5D_oloc(H5D_t *dataset) } /* end H5D_oloc() */ /*------------------------------------------------------------------------- - * Function: H5D_nameof - * - * Purpose: Returns a pointer to the group hier. path for a dataset. - * - * Return: Success: Ptr to entry - * Failure: NULL + * Function: H5D_nameof * - * Programmer: Quincey Koziol - * Monday, September 12, 2005 + * Purpose: Returns a pointer to the group hier. path for a dataset. * + * Return: Success: Ptr to entry + * Failure: NULL *------------------------------------------------------------------------- */ H5G_name_t * @@ -1690,17 +1630,13 @@ H5D_nameof(H5D_t *dataset) } /* end H5D_nameof() */ /*------------------------------------------------------------------------- - * Function: H5D_typeof + * Function: H5D_typeof * - * Purpose: Returns a pointer to the dataset's datatype. The datatype - * is not copied. - * - * Return: Success: Ptr to the dataset's datatype, uncopied. - * Failure: NULL - * - * Programmer: Robb Matzke - * Thursday, June 4, 1998 + * Purpose: Returns a pointer to the dataset's datatype. The datatype + * is not copied. * + * Return: Success: Ptr to the dataset's datatype, uncopied. + * Failure: NULL *------------------------------------------------------------------------- */ H5T_t * @@ -1717,15 +1653,11 @@ H5D_typeof(const H5D_t *dset) } /* end H5D_typeof() */ /*------------------------------------------------------------------------- - * Function: H5D__alloc_storage - * - * Purpose: Allocate storage for the raw data of a dataset. + * Function: H5D__alloc_storage * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Friday, January 16, 1998 + * Purpose: Allocate storage for the raw data of a dataset. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -1884,17 +1816,13 @@ done: } /* end H5D__alloc_storage() */ /*------------------------------------------------------------------------- - * Function: H5D__init_storage - * - * Purpose: Initialize the data for a new dataset. If a selection is - * defined for SPACE then initialize only that part of the - * dataset. - * - * Return: Non-negative on success/Negative on failure + * Function: H5D__init_storage * - * Programmer: Robb Matzke - * Monday, October 5, 1998 + * Purpose: Initialize the data for a new dataset. If a selection is + * defined for SPACE then initialize only that part of the + * dataset. * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ static herr_t @@ -1957,16 +1885,12 @@ done: } /* end H5D__init_storage() */ /*------------------------------------------------------------------------- - * Function: H5D__get_storage_size + * Function: H5D__get_storage_size * - * Purpose: Determines how much space has been reserved to store the raw - * data of a dataset. - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Robb Matzke - * Wednesday, April 21, 1999 + * Purpose: Determines how much space has been reserved to store the raw + * data of a dataset. * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2012,15 +1936,12 @@ done: /*------------------------------------------------------------------------- * Function: H5D__get_offset * - * Purpose: Private function for H5D__get_offset. Returns the address + * Purpose: Private function for H5Dget_offset(). Returns the address * of dataset in file. * - * Return: Success: the address of dataset - * - * Failure: HADDR_UNDEF + * Return: Success: The address of dataset * - * Programmer: Raymond Lu - * November 6, 2002 + * Failure: HADDR_UNDEF (but also a valid value) * *------------------------------------------------------------------------- */ @@ -2040,7 +1961,8 @@ H5D__get_offset(const H5D_t *dset) case H5D_CONTIGUOUS: /* If dataspace hasn't been allocated or dataset is stored in - * an external file, the value will be HADDR_UNDEF. */ + * an external file, the value will be HADDR_UNDEF. + */ if (dset->shared->dcpl_cache.efl.nused == 0 || H5F_addr_defined(dset->shared->layout.storage.u.contig.addr)) /* Return the absolute dataset offset from the beginning of file. */ @@ -2051,25 +1973,21 @@ H5D__get_offset(const H5D_t *dset) case H5D_NLAYOUTS: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "unknown dataset layout type") - } /*lint !e788 All appropriate cases are covered */ + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__get_offset() */ /*------------------------------------------------------------------------- - * Function: H5D_vlen_reclaim + * Function: H5D_vlen_reclaim * - * Purpose: Frees the buffers allocated for storing variable-length data - * in memory. Only frees the VL data in the selection defined in the - * dataspace. The dataset transfer property list is required to find the - * correct allocation/free methods for the VL data in the buffer. - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, November 22, 2005 + * Purpose: Frees the buffers allocated for storing variable-length data + * in memory. Only frees the VL data in the selection defined in the + * dataspace. The dataset transfer property list is required to find the + * correct allocation/free methods for the VL data in the buffer. * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2108,25 +2026,21 @@ done: } /* end H5D_vlen_reclaim() */ /*------------------------------------------------------------------------- - * Function: H5D__vlen_get_buf_size_alloc - * - * Purpose: This routine makes certain there is enough space in the temporary - * buffer for the new data to read in. All the VL data read in is actually - * placed in this buffer, overwriting the previous data. Needless to say, - * this data is not actually usable. + * Function: H5D__vlen_get_buf_size_alloc * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, August 17, 1999 + * Purpose: This routine makes certain there is enough space in the temporary + * buffer for the new data to read in. All the VL data read in is actually + * placed in this buffer, overwriting the previous data. Needless to say, + * this data is not actually usable. * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ void * H5D__vlen_get_buf_size_alloc(size_t size, void *info) { H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)info; - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -2141,14 +2055,14 @@ H5D__vlen_get_buf_size_alloc(size_t size, void *info) } /* end H5D__vlen_get_buf_size_alloc() */ /*------------------------------------------------------------------------- - * Function: H5D__vlen_get_buf_size + * Function: H5D__vlen_get_buf_size * - * Purpose: This routine checks the number of bytes required to store a single - * element from a dataset in memory, creating a selection with just the - * single element selected to read in the element and using a custom memory - * allocator for any VL data encountered. - * The *size value is modified according to how many bytes are - * required to store the element in memory. + * Purpose: This routine checks the number of bytes required to store a single + * element from a dataset in memory, creating a selection with just the + * single element selected to read in the element and using a custom memory + * allocator for any VL data encountered. + * The *size value is modified according to how many bytes are + * required to store the element in memory. * * Implementation: This routine actually performs the read with a custom * memory manager which basically just counts the bytes requested and @@ -2158,14 +2072,9 @@ H5D__vlen_get_buf_size_alloc(size_t size, void *info) * Kinda kludgy, but easier than the other method of trying to figure out * the sizes without actually reading the data in... - QAK * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, August 17, 1999 - * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ -/* ARGSUSED */ herr_t H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, const hsize_t *point, void *op_data) @@ -2202,15 +2111,11 @@ done: } /* end H5D__vlen_get_buf_size() */ /*------------------------------------------------------------------------- - * Function: H5D__check_filters + * Function: H5D__check_filters * - * Purpose: Check if the filters have be initialized for the dataset - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Thursday, October 11, 2007 + * Purpose: Check if the filters have be initialized for the dataset * + * Return: Non-negative on success/Negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2255,16 +2160,12 @@ done: } /* end H5D__check_filters() */ /*------------------------------------------------------------------------- - * Function: H5D__set_extent - * - * Purpose: Based on H5D_extend, allows change to a lower dimension, - * calls H5S_set_extent and H5D__chunk_prune_by_extent instead + * Function: H5D__set_extent * - * Return: Non-negative on success, negative on failure - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * April 9, 2002 + * Purpose: Based on H5D_extend, allows change to a lower dimension, + * calls H5S_set_extent and H5D__chunk_prune_by_extent instead * + * Return: Non-negative on success, negative on failure *------------------------------------------------------------------------- */ herr_t @@ -2328,7 +2229,7 @@ H5D__set_extent(H5D_t *dset, const hsize_t *size, hid_t dxpl_id) */ /* Update the index values for the cached chunks for this dataset */ if (H5D_CHUNKED == dset->shared->layout.type) { - /* Update the cached chunk info */ + /* Set the cached chunk info */ if (H5D__chunk_set_info(dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to update # of chunks") if (H5D__chunk_update_cache(dset, dxpl_id) < 0) @@ -2364,16 +2265,12 @@ done: } /* end H5D__set_extent() */ /*------------------------------------------------------------------------- - * Function: H5D__flush_sieve_buf - * - * Purpose: Flush any dataset sieve buffer info cached in memory - * - * Return: Success: Non-negative - * Failure: Negative + * Function: H5D__flush_sieve_buf * - * Programmer: Quincey Koziol - * July 27, 2009 + * Purpose: Flush any dataset sieve buffer info cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -2406,16 +2303,12 @@ done: } /* end H5D__flush_sieve_buf() */ /*------------------------------------------------------------------------- - * Function: H5D__flush_real - * - * Purpose: Flush any dataset information cached in memory - * - * Return: Success: Non-negative - * Failure: Negative + * Function: H5D__flush_real * - * Programmer: Quincey Koziol - * December 6, 2007 + * Purpose: Flush any dataset information cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -2508,16 +2401,12 @@ H5D__mark(const H5D_t *dataset, hid_t H5_ATTR_UNUSED dxpl_id, unsigned flags) } /* end H5D__mark() */ /*------------------------------------------------------------------------- - * Function: H5D__flush_cb - * - * Purpose: Flush any dataset information cached in memory + * Function: H5D__flush_cb * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * November 8, 2007 + * Purpose: Flush any dataset information cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ static int @@ -2544,16 +2433,12 @@ done: } /* end H5D__flush_cb() */ /*------------------------------------------------------------------------- - * Function: H5D_flush - * - * Purpose: Flush any dataset information cached in memory - * - * Return: Success: Non-negative - * Failure: Negative + * Function: H5D_flush * - * Programmer: Ray Lu - * August 14, 2002 + * Purpose: Flush any dataset information cached in memory * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -2580,19 +2465,14 @@ done: } /* end H5D_flush() */ /*------------------------------------------------------------------------- - * Function: H5D_get_create_plist + * Function: H5D_get_create_plist * - * Purpose: Private function for H5Dget_create_plist + * Purpose: Private function for H5Dget_create_plist * - * Return: Success: ID for a copy of the dataset creation + * Return: Success: ID for a copy of the dataset creation * property list. The template should be * released by calling H5P_close(). - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Tuesday, February 3, 1998 - * + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t @@ -2602,7 +2482,7 @@ H5D_get_create_plist(H5D_t *dset) H5P_genplist_t *new_plist; /* Copy of dataset's DCPL */ H5O_fill_t copied_fill; /* Fill value to tweak */ hid_t new_dcpl_id = FAIL; - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2699,18 +2579,13 @@ done: } /* end H5D_get_create_plist() */ /*------------------------------------------------------------------------- - * Function: H5D_get_access_plist - * - * Purpose: Returns a copy of the dataset access property list. + * Function: H5D_get_access_plist * - * Return: Success: ID for a copy of the dataset access - * property list. - * - * Failure: FAIL - * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Purpose: Returns a copy of the dataset access property list. * + * Return: Success: ID for a copy of the dataset access + * property list. + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t @@ -2772,40 +2647,34 @@ H5D_get_access_plist(H5D_t *dset) ret_value = new_dapl_id; done: - if (ret_value < 0) { + if (ret_value < 0) if (new_dapl_id > 0) if (H5I_dec_app_ref(new_dapl_id) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_access_plist() */ /*------------------------------------------------------------------------- - * Function: H5D_get_space - * - * Purpose: Returns and ID for the dataspace of the dataset. + * Function: H5D_get_space * - * Return: Success: ID for dataspace - * - * Failure: FAIL - * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Purpose: Returns and ID for the dataspace of the dataset. * + * Return: Success: ID for dataspace + * Failure: FAIL *------------------------------------------------------------------------- */ hid_t H5D_get_space(H5D_t *dset) { H5S_t *space = NULL; - hid_t ret_value = FAIL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI_NOINIT - /* Read the data space message and return a data space object */ + /* Read the dataspace message and return a dataspace object */ if (NULL == (space = H5S_copy(dset->shared->space, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space") + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") /* Create an atom */ if ((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) @@ -2821,16 +2690,12 @@ done: } /* end H5D_get_space() */ /*------------------------------------------------------------------------- - * Function: H5D_get_type + * Function: H5D_get_type * - * Purpose: Returns and ID for the datatype of the dataset. + * Purpose: Returns and ID for the datatype of the dataset. * - * Return: Success: ID for datatype - * - * Failure: FAIL - * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Return: Success: ID for datatype + * Failure: FAIL * *------------------------------------------------------------------------- */ @@ -2862,10 +2727,9 @@ H5D_get_type(H5D_t *dset) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: - if (ret_value < 0) { + if (ret_value < 0) if (dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5D_get_type() */ diff --git a/src/H5Dio.c b/src/H5Dio.c index a5025fe..39dcb5e 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -84,30 +84,30 @@ H5FL_BLK_DEFINE(type_conv); /*------------------------------------------------------------------------- * Function: H5Dread * - * Purpose: Reads (part of) a DSET from the file into application - * memory BUF. The part of the dataset to read is defined with - * MEM_SPACE_ID and FILE_SPACE_ID. The data points are - * converted from their file type to the MEM_TYPE_ID specified. - * Additional miscellaneous data transfer properties can be - * passed to this function with the PLIST_ID argument. + * Purpose: Reads (part of) a DSET from the file into application + * memory BUF. The part of the dataset to read is defined with + * MEM_SPACE_ID and FILE_SPACE_ID. The data points are + * converted from their file type to the MEM_TYPE_ID specified. + * Additional miscellaneous data transfer properties can be + * passed to this function with the PLIST_ID argument. * - * The FILE_SPACE_ID can be the constant H5S_ALL which indicates - * that the entire file data space is to be referenced. + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates + * that the entire file dataspace is to be referenced. * - * The MEM_SPACE_ID can be the constant H5S_ALL in which case - * the memory data space is the same as the file data space - * defined when the dataset was created. + * The MEM_SPACE_ID can be the constant H5S_ALL in which case + * the memory dataspace is the same as the file dataspace + * defined when the dataset was created. * - * The number of elements in the memory data space must match - * the number of elements in the file data space. + * The number of elements in the memory dataspace must match + * the number of elements in the file dataspace. * - * The PLIST_ID can be the constant H5P_DEFAULT in which - * case the default data transfer properties are used. + * The PLIST_ID can be the constant H5P_DEFAULT in which + * case the default data transfer properties are used. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * *------------------------------------------------------------------------- */ @@ -219,31 +219,31 @@ done: /*------------------------------------------------------------------------- * Function: H5Dwrite * - * Purpose: Writes (part of) a DSET from application memory BUF to the - * file. The part of the dataset to write is defined with the - * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points - * are converted from their current type (MEM_TYPE_ID) to their - * file datatype. Additional miscellaneous data transfer - * properties can be passed to this function with the - * PLIST_ID argument. + * Purpose: Writes (part of) a DSET from application memory BUF to the + * file. The part of the dataset to write is defined with the + * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points + * are converted from their current type (MEM_TYPE_ID) to their + * file datatype. Additional miscellaneous data transfer + * properties can be passed to this function with the + * PLIST_ID argument. * - * The FILE_SPACE_ID can be the constant H5S_ALL which indicates - * that the entire file data space is to be referenced. + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates + * that the entire file dataspace is to be referenced. * - * The MEM_SPACE_ID can be the constant H5S_ALL in which case - * the memory data space is the same as the file data space - * defined when the dataset was created. + * The MEM_SPACE_ID can be the constant H5S_ALL in which case + * the memory dataspace is the same as the file dataspace + * defined when the dataset was created. * - * The number of elements in the memory data space must match - * the number of elements in the file data space. + * The number of elements in the memory dataspace must match + * the number of elements in the file dataspace. * - * The PLIST_ID can be the constant H5P_DEFAULT in which - * case the default data transfer properties are used. + * The PLIST_ID can be the constant H5P_DEFAULT in which + * case the default data transfer properties are used. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 + * Programmer: Robb Matzke + * Thursday, December 4, 1997 * *------------------------------------------------------------------------- */ @@ -261,7 +261,7 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiii*x", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); - /* check arguments */ + /* Get dataset pointer and ensure it's associated with a file */ if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if (NULL == dset->oloc.file) @@ -994,8 +994,7 @@ H5D__typeinfo_init(const H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t type_info->dst_type_id = mem_type_id; } /* end else */ - /* - * Locate the type conversion function and data space conversion + /* Locate the type conversion function and dataspace conversion * functions, and set up the element numbering information. If a data * type conversion is necessary then register datatype atoms. Data type * conversion is necessary if the user has set the `need_bkg' to a high @@ -1066,8 +1065,7 @@ H5D__typeinfo_init(const H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t if (type_info->request_nelmts == 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "temporary buffer max size is too small") - /* - * Get a temporary buffer for type conversion unless the app has already + /* Get a temporary buffer for type conversion unless the app has already * supplied one through the xfer properties. Instead of allocating a * buffer which is the exact size, we allocate the target size. The * malloc() is usually less resource-intensive if we allocate/free the diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 71f64ba..7187590 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -20,10 +20,10 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLprivate.h" /* Local heaps */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLprivate.h" /* Local heaps */ /****************/ /* Local Macros */ @@ -50,15 +50,15 @@ /*******************/ /*------------------------------------------------------------------------- - * Function: H5D__layout_set_io_ops + * Function: H5D__layout_set_io_ops * - * Purpose: Set the I/O operation function pointers for a dataset, + * Purpose: Set the I/O operation function pointers for a dataset, * according to the dataset's layout * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * Thursday, March 20, 2008 + * Programmer: Quincey Koziol + * Thursday, March 20, 2008 * *------------------------------------------------------------------------- */ @@ -121,7 +121,7 @@ done: size_t H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t include_compact_data) { - size_t ret_value; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE @@ -134,6 +134,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ switch (layout->type) { case H5D_COMPACT: + /* This information only present in older versions of message */ /* Size of raw data */ ret_value += 2; if (include_compact_data) @@ -141,6 +142,7 @@ H5D__layout_meta_size(const H5F_t *f, const H5O_layout_t *layout, hbool_t includ break; case H5D_CONTIGUOUS: + /* This information only present in older versions of message */ ret_value += H5F_SIZEOF_ADDR(f); /* Address of data */ ret_value += H5F_SIZEOF_SIZE(f); /* Length of data */ break; @@ -168,15 +170,15 @@ done: } /* end H5D__layout_meta_size() */ /*------------------------------------------------------------------------- - * Function: H5D__layout_oh_create + * Function: H5D__layout_oh_create * - * Purpose: Create layout/pline/efl information for dataset + * Purpose: Create layout/pline/efl information for dataset * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * - * Programmer: Quincey Koziol - * Monday, July 27, 2009 + * Programmer: Quincey Koziol + * Monday, July 27, 2009 * *------------------------------------------------------------------------- */ @@ -298,15 +300,15 @@ done: } /* end H5D__layout_oh_create() */ /*------------------------------------------------------------------------- - * Function: H5D__layout_oh_read + * Function: H5D__layout_oh_read * - * Purpose: Read layout/pline/efl information for dataset + * Purpose: Read layout/pline/efl information for dataset * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * - * Programmer: Quincey Koziol - * Monday, July 27, 2009 + * Programmer: Quincey Koziol + * Monday, July 27, 2009 * *------------------------------------------------------------------------- */ @@ -441,15 +443,15 @@ done: } /* end H5D__layout_oh_read() */ /*------------------------------------------------------------------------- - * Function: H5D__layout_oh_write + * Function: H5D__layout_oh_write * - * Purpose: Write layout/pline/efl information for dataset + * Purpose: Write layout information for dataset * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: SUCCEED + * Failure: FAIL * - * Programmer: Quincey Koziol - * Monday, July 27, 2009 + * Programmer: Quincey Koziol + * Monday, July 27, 2009 * *------------------------------------------------------------------------- */ diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index de60f6c..a2a5514 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -133,7 +133,7 @@ static herr_t H5D__mpio_get_sum_chunk(const H5D_io_info_t *io_info, const H5D_ch * Purpose: Checks if an direct I/O transfer is possible between memory and * the file. * - * Return: Sauccess: Non-negative: TRUE or FALSE + * Return: Success: Non-negative: TRUE or FALSE * Failure: Negative * * Programmer: Quincey Koziol @@ -758,11 +758,6 @@ done: * Programmer: Muqun Yang * Monday, Feb. 13th, 2006 * - * Modification: - * - Set H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME and H5D_MPIO_ACTUAL_IO_MODE_NAME - * dxpl in this. - * Programmer: Jonathan Kim - * Date: 2012-10-10 *------------------------------------------------------------------------- */ static herr_t @@ -1101,12 +1096,6 @@ done: * Programmer: Muqun Yang * Monday, Feb. 13th, 2006 * - * Modification: - * - Set H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME dxpl in this to go along with - * setting H5D_MPIO_ACTUAL_IO_MODE_NAME dxpl at the bottom. - * Programmer: Jonathan Kim - * Date: 2012-10-10 - * *------------------------------------------------------------------------- */ static herr_t @@ -1473,7 +1462,7 @@ done: static int H5D__cmp_chunk_addr(const void *chunk_addr_info1, const void *chunk_addr_info2) { - haddr_t addr1, addr2; + haddr_t addr1 = HADDR_UNDEF, addr2 = HADDR_UNDEF; FUNC_ENTER_STATIC_NOERR diff --git a/src/H5Doh.c b/src/H5Doh.c index 87cffd7..286ba41 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -95,7 +95,7 @@ H5FL_DEFINE(H5D_copy_file_ud_t); static void * H5O__dset_get_copy_file_udata(void) { - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -259,9 +259,9 @@ done: static void * H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) { - H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */ - H5D_t * dset = NULL; /* New dataset created */ - void * ret_value; /* Return value */ + H5D_obj_create_t *crt_info = (H5D_obj_create_t *)_crt_info; /* Dataset creation parameters */ + H5D_t * dset = NULL; /* New dataset created */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -308,8 +308,8 @@ done: static H5O_loc_t * H5O__dset_get_oloc(hid_t obj_id) { - H5D_t * dset; /* Dataset opened */ - H5O_loc_t *ret_value; /* Return value */ + H5D_t * dset; /* Dataset opened */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -337,10 +337,6 @@ done: * Programmer: Vailin Choi * July 11, 2007 * - * Modification:Raymond Lu - * 5 February, 2010 - * I added the call to H5O_msg_reset after H5D_chunk_bh_info - * to free the PLINE. *------------------------------------------------------------------------- */ static herr_t diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index a730531..678c062 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -12,12 +12,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol - * Monday, April 14, 2003 + * Programmer: Quincey Koziol + * Monday, April 14, 2003 * - * Purpose: This file contains declarations which are visible only within - * the H5D package. Source files outside the H5D package should - * include H5Dprivate.h instead. + * Purpose: This file contains declarations which are visible only within + * the H5D package. Source files outside the H5D package should + * include H5Dprivate.h instead. */ #ifndef H5D_PACKAGE #error "Do not include this file outside the H5D package!" @@ -30,10 +30,10 @@ #include "H5Dprivate.h" /* Other private headers needed by this file */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Gprivate.h" /* Groups */ -#include "H5SLprivate.h" /* Skip lists */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Gprivate.h" /* Groups */ +#include "H5SLprivate.h" /* Skip lists */ +#include "H5Tprivate.h" /* Datatypes */ /**************************/ /* Package Private Macros */ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index d1d1bfa..ce94f9c 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -21,10 +21,10 @@ #include "H5Dpublic.h" /* Private headers needed by this file */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5Sprivate.h" /* Dataspaces */ -#include "H5Zprivate.h" /* Data filters */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Zprivate.h" /* Data filters */ /**************************/ /* Library Private Macros */ @@ -32,8 +32,8 @@ /* * Feature: Define H5D_DEBUG on the compiler command line if you want to - * debug dataset I/O. NDEBUG must not be defined in order for this - * to have any effect. + * debug dataset I/O. NDEBUG must not be defined in order for this + * to have any effect. */ #ifdef NDEBUG #undef H5D_DEBUG diff --git a/src/H5Dselect.c b/src/H5Dselect.c index 6169f5f..1a3a0b5 100644 --- a/src/H5Dselect.c +++ b/src/H5Dselect.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Thursday, September 30, 2004 * * Purpose: Dataspace I/O functions. diff --git a/src/H5Dtest.c b/src/H5Dtest.c index ea17072..4a167cd 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Thursday, May 27, 2004 * * Purpose: Dataset testing functions. @@ -27,10 +27,10 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ diff --git a/src/H5E.c b/src/H5E.c index ccd60cb..13e75b8 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -51,11 +51,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Epkg.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -134,13 +134,11 @@ static const H5I_class_t H5I_ERRSTK_CLS[1] = {{ }}; /*------------------------------------------------------------------------- - * Function: H5E_init + * Function: H5E_init * - * Purpose: Initialize the interface from some other layer. + * Purpose: Initialize the interface from some other layer. * - * Return: Success: non-negative - * - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tuesday, June 29, 2004 @@ -252,14 +250,14 @@ done: } /* end H5E_init_interface() */ /*------------------------------------------------------------------------- - * Function: H5E_term_interface + * Function: H5E_term_interface * - * Purpose: Terminates the H5E interface + * Purpose: Terminates the H5E interface * - * Return: Success: Positive if anything is done that might - * affect other interfaces; zero otherwise. + * Return: Success: Positive if anything is done that might + * affect other interfaces; zero otherwise. * - * Failure: Negative. + * Failure: Negative * * Programmer: Raymond Lu * Tuesday, July 22, 2003 @@ -328,14 +326,14 @@ H5E_term_interface(void) #ifdef H5_HAVE_THREADSAFE /*------------------------------------------------------------------------- - * Function: H5E_get_stack + * Function: H5E_get_stack * - * Purpose: Support function for H5E_get_my_stack() to initialize and + * Purpose: Support function for H5E_get_my_stack() to initialize and * acquire per-thread error stack. * - * Return: Success: error stack (H5E_t *) + * Return: Success: Pointer to an error stack struct (H5E_t *) * - * Failure: NULL + * Failure: NULL * * Programmer: Chee Wai LEE * April 24, 2000 @@ -345,7 +343,7 @@ H5E_term_interface(void) H5E_t * H5E_get_stack(void) { - H5E_t *estack; + H5E_t *estack = NULL; FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -354,10 +352,13 @@ H5E_get_stack(void) if (!estack) { /* No associated value with current thread - create one */ #ifdef H5_HAVE_WIN_THREADS - estack = (H5E_t *)LocalAlloc( - LPTR, sizeof(H5E_t)); /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ + /* Win32 has to use LocalAlloc to match the LocalFree in DllMain */ + estack = (H5E_t *)LocalAlloc(LPTR, sizeof(H5E_t)); #else - estack = (H5E_t *)H5FL_MALLOC(H5E_t); + /* Use HDmalloc here since this has to match the HDfree in the + * destructor and we want to avoid the codestack there. + */ + estack = (H5E_t *)HDmalloc(sizeof(H5E_t)); #endif /* H5_HAVE_WIN_THREADS */ HDassert(estack); @@ -378,11 +379,11 @@ H5E_get_stack(void) #endif /* H5_HAVE_THREADSAFE */ /*------------------------------------------------------------------------- - * Function: H5E_free_class + * Function: H5E_free_class * - * Purpose: Private function to free an error class. + * Purpose: Private function to free an error class. * - * Return: Non-negative value on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Friday, January 22, 2009 @@ -407,11 +408,12 @@ H5E_free_class(H5E_cls_t *cls) } /* end H5E_free_class() */ /*------------------------------------------------------------------------- - * Function: H5Eregister_class + * Function: H5Eregister_class * - * Purpose: Registers an error class. + * Purpose: Registers an error class. * - * Return: Non-negative value as class ID on success/Negative on failure + * Return: Success: An ID for the error class + * Failure: H5I_INVALID_HID * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -421,34 +423,35 @@ H5E_free_class(H5E_cls_t *cls) hid_t H5Eregister_class(const char *cls_name, const char *lib_name, const char *version) { - H5E_cls_t *cls; /* Pointer to error class */ - hid_t ret_value; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*s*s*s", cls_name, lib_name, version); /* Check arguments */ if (cls_name == NULL || lib_name == NULL || version == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid string") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid string") /* Create the new error class object */ if (NULL == (cls = H5E_register_class(cls_name, lib_name, version))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, FAIL, "can't create error class") + HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error class") /* Register the new error class to get an ID for it */ if ((ret_value = H5I_register(H5I_ERROR_CLASS, cls, TRUE)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error class") + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register error class") done: FUNC_LEAVE_API(ret_value) } /* end H5Eregister_class() */ /*------------------------------------------------------------------------- - * Function: H5E_register_class + * Function: H5E_register_class * - * Purpose: Private function to register an error class. + * Purpose: Private function to register an error class. * - * Return: Non-negative value as class ID on success/Negative on failure + * Return: Success: Pointer to an error class struct + * Failure: NULL * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -458,8 +461,8 @@ done: static H5E_cls_t * H5E_register_class(const char *cls_name, const char *lib_name, const char *version) { - H5E_cls_t *cls = NULL; /* Pointer to error class */ - H5E_cls_t *ret_value; /* Return value */ + H5E_cls_t *cls = NULL; /* Pointer to error class */ + H5E_cls_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -492,13 +495,13 @@ done: } /* end H5E_register_class() */ /*------------------------------------------------------------------------- - * Function: H5Eunregister_class + * Function: H5Eunregister_class * - * Purpose: Closes an error class. + * Purpose: Closes an error class. * - * Return: Non-negative value on success/Negative on failure + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 11, 2003 * *------------------------------------------------------------------------- @@ -527,11 +530,11 @@ done: } /* end H5Eunregister_class() */ /*------------------------------------------------------------------------- - * Function: H5E_unregister_class + * Function: H5E_unregister_class * - * Purpose: Private function to close an error class. + * Purpose: Private function to close an error class. * - * Return: Non-negative value on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -561,12 +564,12 @@ done: } /* end H5E_unregister_class() */ /*------------------------------------------------------------------------- - * Function: H5Eget_class_name + * Function: H5Eget_class_name * - * Purpose: Retrieves error class name. + * Purpose: Retrieves error class name. * - * Return: Non-negative for name length if succeeds(zero means no name); - * otherwise returns negative value. + * Return: Success: Name length (zero means no name) + * Failure: -1 * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -576,31 +579,31 @@ done: ssize_t H5Eget_class_name(hid_t class_id, char *name, size_t size) { - H5E_cls_t *cls; /* Pointer to error class */ - ssize_t ret_value; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + ssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", class_id, name, size); /* Get the error class */ if (NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error class ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a error class ID") /* Retrieve the class name */ if ((ret_value = H5E_get_class_name(cls, name, size)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get error class name") + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get error class name") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_class_name() */ /*------------------------------------------------------------------------- - * Function: H5E_get_class_name + * Function: H5E_get_class_name * - * Purpose: Private function to retrieve error class name. + * Purpose: Private function to retrieve error class name. * - * Return: Non-negative for name length if succeeds(zero means no name); - * otherwise returns negative value. + * Return: Success: Name length (zero means no name) + * Failure: -1 * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -610,7 +613,7 @@ done: static ssize_t H5E_get_class_name(const H5E_cls_t *cls, char *name, size_t size) { - ssize_t len; /* Length of error class's name */ + ssize_t len = -1; /* Length of error class's name */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -669,11 +672,11 @@ done: } /* end H5E_close_msg_cb() */ /*------------------------------------------------------------------------- - * Function: H5Eclose_msg + * Function: H5Eclose_msg * - * Purpose: Closes a major or minor error. + * Purpose: Closes a major or minor error. * - * Return: Non-negative value on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -701,11 +704,11 @@ done: } /* end H5Eclose_msg() */ /*------------------------------------------------------------------------- - * Function: H5E_close_msg + * Function: H5E_close_msg * - * Purpose: Private function to close an error messge. + * Purpose: Private function to close an error messge. * - * Return: Non-negative value on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -729,11 +732,12 @@ H5E_close_msg(H5E_msg_t *err) } /* end H5E_close_msg() */ /*------------------------------------------------------------------------- - * Function: H5Ecreate_msg + * Function: H5Ecreate_msg * - * Purpose: Creates a major or minor error, returns an ID. + * Purpose: Creates a major or minor error, returns an ID. * - * Return: Non-negative value on success/Negative on failure + * Return: Success: An error ID + * Failure: H5I_INVALID_HID * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -743,41 +747,42 @@ H5E_close_msg(H5E_msg_t *err) hid_t H5Ecreate_msg(hid_t class_id, H5E_type_t msg_type, const char *msg_str) { - H5E_cls_t *cls; /* Pointer to error class */ - H5E_msg_t *msg; /* Pointer to new error message */ - hid_t ret_value; /* Return value */ + H5E_cls_t *cls; /* Pointer to error class */ + H5E_msg_t *msg; /* Pointer to new error message */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iEt*s", class_id, msg_type, msg_str); /* Check arguments */ if (msg_type != H5E_MAJOR && msg_type != H5E_MINOR) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid message type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "not a valid message type") if (msg_str == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "message is NULL") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "message is NULL") /* Get the error class */ if (NULL == (cls = (H5E_cls_t *)H5I_object_verify(class_id, H5I_ERROR_CLASS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error class ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an error class ID") /* Create the new error message object */ if (NULL == (msg = H5E_create_msg(cls, msg_type, msg_str))) - HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, FAIL, "can't create error message") + HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error message") /* Register the new error class to get an ID for it */ if ((ret_value = H5I_register(H5I_ERROR_MSG, msg, TRUE)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register error message") done: FUNC_LEAVE_API(ret_value) } /* end H5Ecreate_msg() */ /*------------------------------------------------------------------------- - * Function: H5E_create_msg + * Function: H5E_create_msg * - * Purpose: Private function to create a major or minor error. + * Purpose: Private function to create a major or minor error. * - * Return: Non-negative value on success/Negative on failure + * Return: Success: Pointer to a message struct + * Failure: NULL * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -787,8 +792,8 @@ done: static H5E_msg_t * H5E_create_msg(H5E_cls_t *cls, H5E_type_t msg_type, const char *msg_str) { - H5E_msg_t *msg = NULL; /* Pointer to new error message */ - H5E_msg_t *ret_value; /* Return value */ + H5E_msg_t *msg = NULL; /* Pointer to new error message */ + H5E_msg_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -819,12 +824,12 @@ done: } /* end H5E_create_msg() */ /*------------------------------------------------------------------------- - * Function: H5Eget_msg + * Function: H5Eget_msg * - * Purpose: Retrieves an error message. + * Purpose: Retrieves an error message. * - * Return: Non-negative for message length if succeeds(zero means no message); - * otherwise returns negative value. + * Return: Success: Message length (zero means no message) + * Failure: -1 * * Programmer: Raymond Lu * Friday, July 14, 2003 @@ -834,30 +839,31 @@ done: ssize_t H5Eget_msg(hid_t msg_id, H5E_type_t *type, char *msg_str, size_t size) { - H5E_msg_t *msg; /* Pointer to error message */ - ssize_t ret_value; /* Return value */ + H5E_msg_t *msg; /* Pointer to error message */ + ssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE4("Zs", "i*Et*sz", msg_id, type, msg_str, size); /* Get the message object */ if (NULL == (msg = (H5E_msg_t *)H5I_object_verify(msg_id, H5I_ERROR_MSG))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error message ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a error message ID") /* Get the message's text */ if ((ret_value = H5E_get_msg(msg, type, msg_str, size)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get error message text") + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get error message text") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_msg() */ /*------------------------------------------------------------------------- - * Function: H5Ecreate_stack + * Function: H5Ecreate_stack * - * Purpose: Creates a new, empty, error stack. + * Purpose: Creates a new, empty, error stack. * - * Return: Non-negative value as stack ID on success/Negative on failure + * Return: Success: An error stack ID + * Failure: H5I_INVALID_HID * * Programmer: Quincey Koziol * Thursday, November 1, 2007 @@ -867,34 +873,35 @@ done: hid_t H5Ecreate_stack(void) { - H5E_t *stk; /* Error stack */ - hid_t ret_value; /* Return value */ + H5E_t *stk; /* Error stack */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE0("i", ""); /* Allocate a new error stack */ if (NULL == (stk = H5FL_CALLOC(H5E_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Set the "automatic" error reporting info to the library default */ H5E_set_default_auto(stk); /* Register the stack */ if ((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't create error stack") + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't create error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Ecreate_stack() */ /*------------------------------------------------------------------------- - * Function: H5Eget_current_stack + * Function: H5Eget_current_stack * - * Purpose: Registers current error stack, returns object handle for it, + * Purpose: Registers current error stack, returns object handle for it, * clears it. * - * Return: Non-negative value as stack ID on success/Negative on failure + * Return: Success: An error stack ID + * Failure: H5I_INVALID_HID * * Programmer: Raymond Lu * Friday, July 14, 2003 @@ -904,31 +911,32 @@ done: hid_t H5Eget_current_stack(void) { - H5E_t *stk; /* Error stack */ - hid_t ret_value; /* Return value */ + H5E_t *stk; /* Error stack */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(FAIL) + FUNC_ENTER_API_NOCLEAR(H5I_INVALID_HID) H5TRACE0("i", ""); /* Get the current stack */ if (NULL == (stk = H5E_get_current_stack())) - HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, FAIL, "can't create error stack") + HGOTO_ERROR(H5E_ERROR, H5E_CANTCREATE, H5I_INVALID_HID, "can't create error stack") /* Register the stack */ if ((ret_value = H5I_register(H5I_ERROR_STACK, stk, TRUE)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't create error stack") + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, H5I_INVALID_HID, "can't create error stack") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_current_stack() */ /*------------------------------------------------------------------------- - * Function: H5E_get_current_stack + * Function: H5E_get_current_stack * - * Purpose: Private function to register an error stack. + * Purpose: Private function to register an error stack. * - * Return: Non-negative value as class ID on success/Negative on failure + * Return: Success: Pointer to an error class struct + * Failure: NULL * * Programmer: Raymond Lu * Friday, July 11, 2003 @@ -941,7 +949,7 @@ H5E_get_current_stack(void) H5E_t * current_stack; /* Pointer to the current error stack */ H5E_t * estack_copy = NULL; /* Pointer to new error stack to return */ unsigned u; /* Local index variable */ - H5E_t * ret_value; /* Return value */ + H5E_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1001,21 +1009,16 @@ done: } /* end H5E_get_current_stack() */ /*------------------------------------------------------------------------- - * Function: H5Eset_current_stack + * Function: H5Eset_current_stack * - * Purpose: Replaces current stack with specified stack. This closes the - * stack ID also. + * Purpose: Replaces current stack with specified stack. This closes the + * stack ID also. * - * Return: Non-negative value on success/Negative on failure + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 15, 2003 * - * Modification: - * Raymond Lu - * 7 September 2010 - * Also closes the stack to avoid potential problem (bug 1799) - * *------------------------------------------------------------------------- */ herr_t @@ -1048,11 +1051,11 @@ done: } /* end H5Eset_current_stack() */ /*------------------------------------------------------------------------- - * Function: H5E_set_current_stack + * Function: H5E_set_current_stack * - * Purpose: Private function to replace an error stack. + * Purpose: Private function to replace an error stack. * - * Return: Non-negative value on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Friday, July 15, 2003 @@ -1112,13 +1115,13 @@ done: } /* end H5E_set_current_stack() */ /*------------------------------------------------------------------------- - * Function: H5Eclose_stack + * Function: H5Eclose_stack * - * Purpose: Closes an error stack. + * Purpose: Closes an error stack. * - * Return: Non-negative value on success/Negative on failure + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 14, 2003 * *------------------------------------------------------------------------- @@ -1149,11 +1152,11 @@ done: } /* end H5Eclose_stack() */ /*------------------------------------------------------------------------- - * Function: H5E_close_stack + * Function: H5E_close_stack * - * Purpose: Private function to close an error stack. + * Purpose: Private function to close an error stack. * - * Return: Non-negative value on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Friday, July 14, 2003 @@ -1178,11 +1181,12 @@ H5E_close_stack(H5E_t *estack) } /* end H5E_close_stack() */ /*------------------------------------------------------------------------- - * Function: H5Eget_num + * Function: H5Eget_num * - * Purpose: Retrieves the number of error message. + * Purpose: Retrieves the number of error messages. * - * Return: Non-negative value on success/Negative on failure + * Return: Success: The number of errors + * Failure: -1 * * Programmer: Raymond Lu * Friday, July 15, 2003 @@ -1196,14 +1200,14 @@ H5Eget_num(hid_t error_stack_id) ssize_t ret_value; /* Return value */ /* Don't clear the error stack! :-) */ - FUNC_ENTER_API_NOCLEAR(FAIL) + FUNC_ENTER_API_NOCLEAR((-1)) H5TRACE1("Zs", "i", error_stack_id); /* Need to check for errors */ if (error_stack_id == H5E_DEFAULT) { if (NULL == (estack = H5E_get_my_stack())) /*lint !e506 !e774 Make lint 'constant value Boolean' in - non-threaded case */ - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get current error stack") + non-threaded case */ + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get current error stack") } /* end if */ else { /* Only clear the error stack if it's not the default stack */ @@ -1211,23 +1215,24 @@ H5Eget_num(hid_t error_stack_id) /* Get the error stack to operate on */ if (NULL == (estack = (H5E_t *)H5I_object_verify(error_stack_id, H5I_ERROR_STACK))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a error stack ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an error stack ID") } /* end else */ /* Get the number of errors on stack */ if ((ret_value = H5E_get_num(estack)) < 0) - HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, FAIL, "can't get number of errors") + HGOTO_ERROR(H5E_ERROR, H5E_CANTGET, (-1), "can't get number of errors") done: FUNC_LEAVE_API(ret_value) } /* end H5Eget_num() */ /*------------------------------------------------------------------------- - * Function: H5E_get_num + * Function: H5E_get_num * - * Purpose: Private function to retrieve number of errors in error stack. + * Purpose: Private function to retrieve number of errors in error stack. * - * Return: Non-negative value on success/Negative on failure + * Return: Success: The number of errors + * Failure: -1 (can't fail at this time) * * Programmer: Raymond Lu * Friday, July 15, 2003 @@ -1245,13 +1250,13 @@ H5E_get_num(const H5E_t *estack) } /* end H5E_get_num() */ /*------------------------------------------------------------------------- - * Function: H5Epop + * Function: H5Epop * - * Purpose: Deletes some error messages from the top of error stack. + * Purpose: Deletes some error messages from the top of error stack. * - * Return: Non-negative value on success/Negative on failure + * Return: Non-negative value on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Friday, July 16, 2003 * *------------------------------------------------------------------------- @@ -1294,22 +1299,22 @@ done: } /* end H5Epop() */ /*------------------------------------------------------------------------- - * Function: H5Epush2 + * Function: H5Epush2 * - * Purpose: Pushes a new error record onto error stack for the current - * thread. The error has major and minor IDs MAJ_ID and - * MIN_ID, the name of a function where the error was detected, - * the name of the file where the error was detected, the - * line within that file, and an error description string. The - * function name, file name, and error description strings must - * be statically allocated. + * Purpose: Pushes a new error record onto error stack for the current + * thread. The error has major and minor IDs MAJ_ID and + * MIN_ID, the name of a function where the error was detected, + * the name of the file where the error was detected, the + * line within that file, and an error description string. The + * function name, file name, and error description strings must + * be statically allocated. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Monday, October 18, 1999 * - * Notes: Basically a new public API wrapper around the H5E_push_stack + * Notes: Basically a new public API wrapper around the H5E_push_stack * function. * *------------------------------------------------------------------------- @@ -1349,7 +1354,7 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid */ /* Format the description */ - va_start(ap, fmt); + HDva_start(ap, fmt); va_started = TRUE; #ifdef H5_HAVE_VASPRINTF @@ -1365,8 +1370,8 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ while ((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { /* shutdown & restart the va_list */ - va_end(ap); - va_start(ap, fmt); + HDva_end(ap); + HDva_start(ap, fmt); /* Release the previous description, it's too small */ H5MM_xfree(tmp); @@ -1384,21 +1389,29 @@ H5Epush2(hid_t err_stack, const char *file, const char *func, unsigned line, hid done: if (va_started) - va_end(ap); + HDva_end(ap); +#ifdef H5_HAVE_VASPRINTF + /* Memory was allocated with HDvasprintf so it needs to be freed + * with HDfree + */ + if (tmp) + HDfree(tmp); +#else /* H5_HAVE_VASPRINTF */ if (tmp) H5MM_xfree(tmp); +#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_API(ret_value) } /* end H5Epush2() */ /*------------------------------------------------------------------------- - * Function: H5Eclear2 + * Function: H5Eclear2 * - * Purpose: Clears the error stack for the specified error stack. + * Purpose: Clears the error stack for the specified error stack. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Raymond Lu + * Programmer: Raymond Lu * Wednesday, July 16, 2003 * *------------------------------------------------------------------------- @@ -1433,16 +1446,16 @@ done: } /* end H5Eclear2() */ /*------------------------------------------------------------------------- - * Function: H5Eprint2 + * Function: H5Eprint2 * - * Purpose: Prints the error stack in some default way. This is just a - * convenience function for H5Ewalk() with a function that - * prints error messages. Users are encouraged to write there - * own more specific error handlers. + * Purpose: Prints the error stack in some default way. This is just a + * convenience function for H5Ewalk() with a function that + * prints error messages. Users are encouraged to write their + * own more specific error handlers. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, February 27, 1998 * *------------------------------------------------------------------------- @@ -1480,14 +1493,14 @@ done: } /* end H5Eprint2() */ /*------------------------------------------------------------------------- - * Function: H5Ewalk2 + * Function: H5Ewalk2 * - * Purpose: Walks the error stack for the current thread and calls some - * function for each error along the way. + * Purpose: Walks the error stack for the current thread and calls some + * function for each error along the way. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, February 27, 1998 * *------------------------------------------------------------------------- @@ -1528,23 +1541,18 @@ done: } /* end H5Ewalk2() */ /*------------------------------------------------------------------------- - * Function: H5Eget_auto2 + * Function: H5Eget_auto2 * - * Purpose: Returns the current settings for the automatic error stack - * traversal function and its data for specific error stack. - * Either (or both) arguments may be null in which case the - * value is not returned. + * Purpose: Returns the current settings for the automatic error stack + * traversal function and its data for specific error stack. + * Either (or both) arguments may be null in which case the + * value is not returned. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative value on success/Negative on failure * * Programmer: Robb Matzke * Saturday, February 28, 1998 * - * Modification:Raymond Lu - * 4 October 2010 - * If the printing function isn't the default H5Eprint1 or 2, - * and H5Eset_auto1 has been called to set the old style - * printing function, a call to H5Eget_auto2 should fail. *------------------------------------------------------------------------- */ herr_t @@ -1583,28 +1591,25 @@ done: } /* end H5Eget_auto2() */ /*------------------------------------------------------------------------- - * Function: H5Eset_auto2 + * Function: H5Eset_auto2 * - * Purpose: Turns on or off automatic printing of errors for certain + * Purpose: Turns on or off automatic printing of errors for certain * error stack. When turned on (non-null FUNC pointer) any * API function which returns an error indication will first * call FUNC passing it CLIENT_DATA as an argument. * - * The default values before this function is called are - * H5Eprint2() with client data being the standard error stream, - * stderr. + * The default values before this function is called are + * H5Eprint2() with client data being the standard error stream, + * stderr. * - * Automatic stack traversal is always in the H5E_WALK_DOWNWARD - * direction. + * Automatic stack traversal is always in the H5E_WALK_DOWNWARD + * direction. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative value on success/Negative on failure * * Programmer: Robb Matzke * Friday, February 27, 1998 * - * Modification:Raymond Lu - * 4 October 2010 - * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on. *------------------------------------------------------------------------- */ herr_t @@ -1651,14 +1656,14 @@ done: } /* end H5Eset_auto2() */ /*------------------------------------------------------------------------- - * Function: H5Eauto_is_v2 + * Function: H5Eauto_is_v2 * - * Purpose: Determines if the error auto reporting function for an + * Purpose: Determines if the error auto reporting function for an * error stack conforms to the H5E_auto_stack_t typedef * or the H5E_auto_t typedef. The IS_STACK parameter is set * to 1 for the first case and 0 for the latter case. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative value on success/Negative on failure * * Programmer: Quincey Koziol * Wednesday, September 8, 2004 diff --git a/src/H5Edeprec.c b/src/H5Edeprec.c index a7f2aca..8bd5c70 100644 --- a/src/H5Edeprec.c +++ b/src/H5Edeprec.c @@ -15,7 +15,7 @@ * * Created: H5Edeprec.c * April 11 2007 - * Quincey Koziol + * Quincey Koziol * * Purpose: Deprecated functions from the H5E interface. These * functions are here for compatibility purposes and may be @@ -37,11 +37,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Epkg.h" /* Error handling */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5MMprivate.h" /* Memory management */ /****************/ /* Local Macros */ @@ -117,12 +117,12 @@ H5E__term_deprec_interface(void) #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- - * Function: H5Eget_major + * Function: H5Eget_major * - * Purpose: Retrieves a major error message. + * Purpose: Retrieves a major error message. * - * Return: Returns message if succeeds. - * otherwise returns NULL. + * Return: Success: Pointer to the message + * Failure: NULL * * Programmer: Raymond Lu * Friday, July 14, 2003 @@ -169,12 +169,12 @@ done: } /* end H5Eget_major() */ /*------------------------------------------------------------------------- - * Function: H5Eget_minor + * Function: H5Eget_minor * - * Purpose: Retrieves a minor error message. + * Purpose: Retrieves a minor error message. * - * Return: Returns message if succeeds. - * otherwise returns NULL. + * Return: Success: Pointer to the message + * Failure: NULL * * Programmer: Raymond Lu * Friday, July 14, 2003 @@ -221,19 +221,19 @@ done: } /* end H5Eget_minor() */ /*------------------------------------------------------------------------- - * Function: H5Epush1 + * Function: H5Epush1 * - * Purpose: This function definition is for backward compatibility only. + * Purpose: This function definition is for backward compatibility only. * It doesn't have error stack and error class as parameters. * The old definition of major and minor is casted as HID_T * in H5Epublic.h * - * Notes: Basically a public API wrapper around the H5E_push2 + * Notes: Basically a public API wrapper around the H5E_push2 * function. For backward compatibility, it maintains the * same parameter as the old function, in contrary to * H5Epush2. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Tuesday, Sep 16, 2003 @@ -258,12 +258,12 @@ done: } /* end H5Epush1() */ /*------------------------------------------------------------------------- - * Function: H5Eclear1 + * Function: H5Eclear1 * - * Purpose: This function is for backward compatibility. + * Purpose: This function is for backward compatibility. * Clears the error stack for the specified error stack. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Wednesday, July 16, 2003 @@ -288,15 +288,15 @@ done: } /* end H5Eclear1() */ /*------------------------------------------------------------------------- - * Function: H5Eprint1 + * Function: H5Eprint1 * - * Purpose: This function is for backward compatibility. + * Purpose: This function is for backward compatibility. * Prints the error stack in some default way. This is just a - * convenience function for H5Ewalk() with a function that - * prints error messages. Users are encouraged to write there - * own more specific error handlers. + * convenience function for H5Ewalk() with a function that + * prints error messages. Users are encouraged to write there + * own more specific error handlers. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Sep 16, 2003 @@ -326,13 +326,13 @@ done: } /* end H5Eprint1() */ /*------------------------------------------------------------------------- - * Function: H5Ewalk1 + * Function: H5Ewalk1 * - * Purpose: This function is for backward compatibility. + * Purpose: This function is for backward compatibility. * Walks the error stack for the current thread and calls some - * function for each error along the way. + * function for each error along the way. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Sep 16, 2003 @@ -365,24 +365,19 @@ done: } /* end H5Ewalk1() */ /*------------------------------------------------------------------------- - * Function: H5Eget_auto1 + * Function: H5Eget_auto1 * - * Purpose: This function is for backward compatibility. + * Purpose: This function is for backward compatibility. * Returns the current settings for the automatic error stack - * traversal function and its data for specific error stack. - * Either (or both) arguments may be null in which case the - * value is not returned. + * traversal function and its data for specific error stack. + * Either (or both) arguments may be null in which case the + * value is not returned. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Sep 16, 2003 * - * Modification:Raymond Lu - * 4 October 2010 - * If the printing function isn't the default H5Eprint1 or 2, - * and H5Eset_auto2 has been called to set the new style - * printing function, a call to H5Eget_auto1 should fail. *------------------------------------------------------------------------- */ herr_t @@ -416,29 +411,26 @@ done: } /* end H5Eget_auto1() */ /*------------------------------------------------------------------------- - * Function: H5Eset_auto1 + * Function: H5Eset_auto1 * - * Purpose: This function is for backward compatibility. + * Purpose: This function is for backward compatibility. * Turns on or off automatic printing of errors for certain * error stack. When turned on (non-null FUNC pointer) any * API function which returns an error indication will first * call FUNC passing it CLIENT_DATA as an argument. * - * The default values before this function is called are - * H5Eprint1() with client data being the standard error stream, - * stderr. + * The default values before this function is called are + * H5Eprint1() with client data being the standard error stream, + * stderr. * - * Automatic stack traversal is always in the H5E_WALK_DOWNWARD - * direction. + * Automatic stack traversal is always in the H5E_WALK_DOWNWARD + * direction. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * * Programmer: Raymond Lu * Sep 16, 2003 * - * Modification:Raymond Lu - * 4 October 2010 - * If the FUNC is H5Eprint2, put the IS_DEFAULT flag on. *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5Eint.c b/src/H5Eint.c index 18138d5..3474808 100644 --- a/src/H5Eint.c +++ b/src/H5Eint.c @@ -15,7 +15,7 @@ * * Created: H5Eint.c * April 11 2007 - * Quincey Koziol + * Quincey Koziol * * Purpose: General use, "internal" routines for error handling. * @@ -34,10 +34,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Epkg.h" /* Error handling */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Epkg.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5TSprivate.h" /* Thread stuff */ /****************/ /* Local Macros */ @@ -124,12 +125,12 @@ H5E_init_int_interface(void) } /* H5E_init_int_interface() */ /*------------------------------------------------------------------------- - * Function: H5E_get_msg + * Function: H5E_get_msg * - * Purpose: Private function to retrieve an error message. + * Purpose: Private function to retrieve an error message. * - * Return: Non-negative for name length if succeeds(zero means no name); - * otherwise returns negative value. + * Return: Success: Message length (zero means no message) + * Failure: -1 * * Programmer: Raymond Lu * Friday, July 14, 2003 @@ -139,7 +140,7 @@ H5E_init_int_interface(void) ssize_t H5E_get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) { - ssize_t len; /* Length of error message */ + ssize_t len = -1; /* Length of error message */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -167,32 +168,32 @@ H5E_get_msg(const H5E_msg_t *msg, H5E_type_t *type, char *msg_str, size_t size) #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- - * Function: H5E_walk1_cb + * Function: H5E_walk1_cb * - * Purpose: This function is for backward compatibility. + * Purpose: This function is for backward compatibility. * This is a default error stack traversal callback function - * that prints error messages to the specified output stream. - * This function is for backward compatibility with v1.6. - * It is not meant to be called directly but rather as an - * argument to the H5Ewalk() function. This function is called - * also by H5Eprint(). Application writers are encouraged to - * use this function as a model for their own error stack - * walking functions. + * that prints error messages to the specified output stream. + * This function is for backward compatibility with v1.6. + * It is not meant to be called directly but rather as an + * argument to the H5Ewalk() function. This function is called + * also by H5Eprint(). Application writers are encouraged to + * use this function as a model for their own error stack + * walking functions. * - * N is a counter for how many times this function has been - * called for this particular traversal of the stack. It always - * begins at zero for the first error on the stack (either the - * top or bottom error, or even both, depending on the traversal - * direction and the size of the stack). + * N is a counter for how many times this function has been + * called for this particular traversal of the stack. It always + * begins at zero for the first error on the stack (either the + * top or bottom error, or even both, depending on the traversal + * direction and the size of the stack). * - * ERR_DESC is an error description. It contains all the - * information about a particular error. + * ERR_DESC is an error description. It contains all the + * information about a particular error. * - * CLIENT_DATA is the same pointer that was passed as the - * CLIENT_DATA argument of H5Ewalk(). It is expected to be a - * file pointer (or stderr if null). + * CLIENT_DATA is the same pointer that was passed as the + * CLIENT_DATA argument of H5Ewalk(). It is expected to be a + * file pointer (or stderr if null). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Thursday, May 11, 2006 @@ -269,10 +270,8 @@ H5E_walk1_cb(int n, H5E_error1_t *err_desc, void *client_data) else HDfprintf(stream, "thread 0"); } /* end block */ -#elif defined(H5_HAVE_THREADSAFE) - HDfprintf(stream, "thread %lu", (unsigned long)HDpthread_self_ulong()); #else - HDfprintf(stream, "thread 0"); + HDfprintf(stream, "thread %" PRIu64, H5TS_thread_id()); #endif HDfprintf(stream, ":\n"); } /* end if */ @@ -294,30 +293,30 @@ done: #endif /* H5_NO_DEPRECATED_SYMBOLS */ /*------------------------------------------------------------------------- - * Function: H5E_walk2_cb + * Function: H5E_walk2_cb * - * Purpose: This is a default error stack traversal callback function - * that prints error messages to the specified output stream. - * It is not meant to be called directly but rather as an - * argument to the H5Ewalk2() function. This function is - * called also by H5Eprint2(). Application writers are - * encouraged to use this function as a model for their own - * error stack walking functions. + * Purpose: This is a default error stack traversal callback function + * that prints error messages to the specified output stream. + * It is not meant to be called directly but rather as an + * argument to the H5Ewalk2() function. This function is + * called also by H5Eprint2(). Application writers are + * encouraged to use this function as a model for their own + * error stack walking functions. * - * N is a counter for how many times this function has been - * called for this particular traversal of the stack. It always - * begins at zero for the first error on the stack (either the - * top or bottom error, or even both, depending on the traversal - * direction and the size of the stack). + * N is a counter for how many times this function has been + * called for this particular traversal of the stack. It always + * begins at zero for the first error on the stack (either the + * top or bottom error, or even both, depending on the traversal + * direction and the size of the stack). * - * ERR_DESC is an error description. It contains all the - * information about a particular error. + * ERR_DESC is an error description. It contains all the + * information about a particular error. * - * CLIENT_DATA is the same pointer that was passed as the - * CLIENT_DATA argument of H5Ewalk(). It is expected to be a - * file pointer (or stderr if null). + * CLIENT_DATA is the same pointer that was passed as the + * CLIENT_DATA argument of H5Ewalk(). It is expected to be a + * file pointer (or stderr if null). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Friday, December 12, 1997 @@ -399,10 +398,8 @@ H5E_walk2_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data) else HDfprintf(stream, "thread 0"); } /* end block */ -#elif defined(H5_HAVE_THREADSAFE) - HDfprintf(stream, "thread %lu", (unsigned long)HDpthread_self_ulong()); #else - HDfprintf(stream, "thread 0"); + HDfprintf(stream, "thread %" PRIu64, H5TS_thread_id()); #endif HDfprintf(stream, ":\n"); } /* end if */ @@ -423,15 +420,15 @@ done: } /* end H5E_walk2_cb() */ /*------------------------------------------------------------------------- - * Function: H5E_print + * Function: H5E_print * - * Purpose: Private function to print the error stack in some default + * Purpose: Private function to print the error stack in some default * way. This is just a convenience function for H5Ewalk() and * H5Ewalk2() with a function that prints error messages. - * Users are encouraged to write there own more specific error + * Users are encouraged to write their own more specific error * handlers. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Friday, February 27, 1998 @@ -482,29 +479,29 @@ done: } /* end H5E_print() */ /*------------------------------------------------------------------------- - * Function: H5E_walk + * Function: H5E_walk * - * Purpose: Private function for H5Ewalk. + * Purpose: Private function for H5Ewalk. * Walks the error stack, calling the specified function for - * each error on the stack. The DIRECTION argument determines - * whether the stack is walked from the inside out or the - * outside in. The value H5E_WALK_UPWARD means begin with the - * most specific error and end at the API; H5E_WALK_DOWNWARD - * means to start at the API and end at the inner-most function - * where the error was first detected. - * - * The function pointed to by STACK_FUNC will be called for - * each error record in the error stack. It's arguments will - * include an index number (beginning at zero regardless of - * stack traversal direction), an error stack entry, and the - * CLIENT_DATA pointer passed to H5E_print. - * - * The function FUNC is also provided for backward compatibility. - * When BK_COMPATIBLE is set to be TRUE, FUNC is used to be - * compatible with older library. If BK_COMPATIBLE is FALSE, - * STACK_FUNC is used. - * - * Return: Non-negative on success/Negative on failure + * each error on the stack. The DIRECTION argument determines + * whether the stack is walked from the inside out or the + * outside in. The value H5E_WALK_UPWARD means begin with the + * most specific error and end at the API; H5E_WALK_DOWNWARD + * means to start at the API and end at the inner-most function + * where the error was first detected. + * + * The function pointed to by STACK_FUNC will be called for + * each error record in the error stack. It's arguments will + * include an index number (beginning at zero regardless of + * stack traversal direction), an error stack entry, and the + * CLIENT_DATA pointer passed to H5E_print. + * + * The function FUNC is also provided for backward compatibility. + * When BK_COMPATIBLE is set to be TRUE, FUNC is used to be + * compatible with older library. If BK_COMPATIBLE is FALSE, + * STACK_FUNC is used. + * + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Friday, December 12, 1997 @@ -595,14 +592,14 @@ done: } /* end H5E_walk() */ /*------------------------------------------------------------------------- - * Function: H5E_get_auto + * Function: H5E_get_auto * - * Purpose: Private function to return the current settings for the + * Purpose: Private function to return the current settings for the * automatic error stack traversal function and its data * for specific error stack. Either (or both) arguments may * be null in which case the value is not returned. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * July 18, 2003 @@ -626,22 +623,22 @@ H5E_get_auto(const H5E_t *estack, H5E_auto_op_t *op, void **client_data) } /* end H5E_get_auto2() */ /*------------------------------------------------------------------------- - * Function: H5E_set_auto + * Function: H5E_set_auto * - * Purpose: Private function to turn on or off automatic printing of + * Purpose: Private function to turn on or off automatic printing of * errors for certain error stack. When turned on (non-null * FUNC pointer) any API function which returns an error * indication will first call FUNC passing it CLIENT_DATA * as an argument. * - * The default values before this function is called are - * H5Eprint2() with client data being the standard error stream, - * stderr. + * The default values before this function is called are + * H5Eprint2() with client data being the standard error stream, + * stderr. * - * Automatic stack traversal is always in the H5E_WALK_DOWNWARD - * direction. + * Automatic stack traversal is always in the H5E_WALK_DOWNWARD + * direction. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Friday, February 27, 1998 @@ -663,11 +660,11 @@ H5E_set_auto(H5E_t *estack, const H5E_auto_op_t *op, void *client_data) } /* end H5E_set_auto() */ /*------------------------------------------------------------------------- - * Function: H5E_printf_stack + * Function: H5E_printf_stack * - * Purpose: Printf-like wrapper around H5E_push_stack. + * Purpose: Printf-like wrapper around H5E__push_stack. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tuesday, August 12, 2008 @@ -708,7 +705,7 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin */ /* Start the variable-argument parsing */ - va_start(ap, fmt); + HDva_start(ap, fmt); va_started = TRUE; #ifdef H5_HAVE_VASPRINTF @@ -724,8 +721,8 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin /* If the description doesn't fit into the initial buffer size, allocate more space and try again */ while ((desc_len = HDvsnprintf(tmp, (size_t)tmp_len, fmt, ap)) > (tmp_len - 1)) { /* shutdown & restart the va_list */ - va_end(ap); - va_start(ap, fmt); + HDva_end(ap); + HDva_start(ap, fmt); /* Release the previous description, it's too small */ H5MM_xfree(tmp); @@ -743,27 +740,35 @@ H5E_printf_stack(H5E_t *estack, const char *file, const char *func, unsigned lin done: if (va_started) - va_end(ap); + HDva_end(ap); +#ifdef H5_HAVE_VASPRINTF + /* Memory was allocated with HDvasprintf so it needs to be freed + * with HDfree + */ + if (tmp) + HDfree(tmp); +#else /* H5_HAVE_VASPRINTF */ if (tmp) H5MM_xfree(tmp); +#endif /* H5_HAVE_VASPRINTF */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5E_printf_stack() */ /*------------------------------------------------------------------------- - * Function: H5E_push_stack + * Function: H5E_push_stack * - * Purpose: Pushes a new error record onto error stack for the current - * thread. The error has major and minor IDs MAJ_ID and - * MIN_ID, the name of a function where the error was detected, - * the name of the file where the error was detected, the - * line within that file, and an error description string. The - * function name, file name, and error description strings must - * be statically allocated (the FUNC_ENTER() macro takes care of - * the function name and file name automatically, but the - * programmer is responsible for the description string). + * Purpose: Pushes a new error record onto error stack for the current + * thread. The error has major and minor IDs MAJ_ID and + * MIN_ID, the name of a function where the error was detected, + * the name of the file where the error was detected, the + * line within that file, and an error description string. The + * function name, file name, and error description strings must + * be statically allocated (the FUNC_ENTER() macro takes care of + * the function name and file name automatically, but the + * programmer is responsible for the description string). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Friday, December 12, 1997 @@ -838,12 +843,12 @@ done: } /* end H5E_push_stack() */ /*------------------------------------------------------------------------- - * Function: H5E_clear_entries + * Function: H5E_clear_entries * - * Purpose: Private function to clear the error stack entries for the + * Purpose: Private function to clear the error stack entries for the * specified error stack. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Wednesday, August 6, 2003 @@ -893,12 +898,12 @@ done: } /* end H5E_clear_entries() */ /*------------------------------------------------------------------------- - * Function: H5E_clear_stack + * Function: H5E_clear_stack * - * Purpose: Private function to clear the error stack for the + * Purpose: Private function to clear the error stack for the * specified error stack. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Wednesday, July 16, 2003 @@ -929,12 +934,12 @@ done: } /* end H5E_clear_stack() */ /*------------------------------------------------------------------------- - * Function: H5E_pop + * Function: H5E_pop * - * Purpose: Private function to delete some error messages from the top + * Purpose: Private function to delete some error messages from the top * of error stack. * - * Return: Non-negative value on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Raymond Lu * Friday, July 16, 2003 @@ -961,13 +966,13 @@ done: } /* end H5E_pop() */ /*------------------------------------------------------------------------- - * Function: H5E_dump_api_stack + * Function: H5E_dump_api_stack * - * Purpose: Private function to dump the error stack during an error in + * Purpose: Private function to dump the error stack during an error in * an API function if a callback function is defined for the * current error stack. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Wednesday, August 6, 2003 diff --git a/src/H5Epkg.h b/src/H5Epkg.h index 3014d21..0056e9c 100644 --- a/src/H5Epkg.h +++ b/src/H5Epkg.h @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, April 11, 2007 * * Purpose: This file contains declarations which are visible only within diff --git a/src/H5F.c b/src/H5F.c index 1cc6ab3..4391741 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -23,20 +23,20 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ /* Local Macros */ @@ -175,97 +175,86 @@ H5F_term_interface(void) } /* end H5F_term_interface() */ /*------------------------------------------------------------------------- - * Function: H5Fget_create_plist + * Function: H5Fget_create_plist * - * Purpose: Get an atom for a copy of the file-creation property list for - * this file. This function returns an atom with a copy of the - * properties used to create a file. - * - * Return: Success: template ID - * - * Failure: FAIL - * - * Programmer: Unknown + * Purpose: Get an atom for a copy of the file-creation property list for + * this file. This function returns an atom with a copy of the + * properties used to create a file. * + * Return: Success: Object ID for a copy of the file creation + * property list. + * Failure: H5I_INVALID_HID *------------------------------------------------------------------------- */ hid_t H5Fget_create_plist(hid_t file_id) { - H5F_t * file; /* File info */ - H5P_genplist_t *plist; /* Property list */ - hid_t ret_value; /* Return value */ + H5F_t * file; /* File info */ + H5P_genplist_t *plist; /* Property list */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* check args */ if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") if (NULL == (plist = (H5P_genplist_t *)H5I_object(file->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file creation property list") - /* Create the property list object to return */ + /* Retrieve the file creation property list */ if ((ret_value = H5P_copy_plist(plist, TRUE)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy file creation properties") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_create_plist() */ /*------------------------------------------------------------------------- - * Function: H5Fget_access_plist + * Function: H5Fget_access_plist * - * Purpose: Returns a copy of the file access property list of the - * specified file. + * Purpose: Returns a copy of the file access property list of the + * specified file. * * NOTE: Make sure that, if you are going to overwrite * information in the copied property list that was * previously opened and assigned to the property list, then * you must close it before overwriting the values. * - * Return: Success: Object ID for a copy of the file access - * property list. - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Wednesday, February 18, 1998 - * + * Return: Success: Object ID for a copy of the file access + * property list. + * Failure: H5I_INVALID_HID *------------------------------------------------------------------------- */ hid_t H5Fget_access_plist(hid_t file_id) { - H5F_t *f; /* File info */ - hid_t ret_value; /* Return value */ + H5F_t *f; /* File info */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* Check args */ if (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Retrieve the file's access property list */ if ((ret_value = H5F_get_access_plist(f, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_access_plist() */ /*------------------------------------------------------------------------- - * Function: H5Fget_obj_count - * - * Purpose: Public function returning the number of opened object IDs - * (files, datasets, groups and datatypes) in the same file. + * Function: H5Fget_obj_count * - * Return: Non-negative on success; negative on failure. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 + * Purpose: Public function returning the number of opened object IDs + * (files, datasets, groups and datatypes) in the same file. * + * Return: Success: The number of opened object IDs + * Failure: -1 *------------------------------------------------------------------------- */ ssize_t @@ -273,22 +262,22 @@ H5Fget_obj_count(hid_t file_id, unsigned types) { H5F_t * f = NULL; /* File to query */ size_t obj_count = 0; /* Number of opened objects */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE2("Zs", "iIu", file_id, types); /* Check arguments */ if (file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file id") if (0 == (types & H5F_OBJ_ALL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not an object type") /* Perform the query */ if (H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, (-1), "H5F_get_obj_count failed") - /* Set the return value */ + /* Set return value */ ret_value = (ssize_t)obj_count; done: @@ -296,21 +285,12 @@ done: } /* end H5Fget_obj_count() */ /*------------------------------------------------------------------------- - * Function: H5Fget_object_ids - * - * Purpose: Public function to return a list of opened object IDs. - * - * Return: Non-negative on success; negative on failure. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 + * Function: H5Fget_object_ids * - * Modification: - * Raymond Lu - * 24 September 2008 - * Changed the return value to ssize_t and MAX_OBJTS to size_t to - * accommadate potential large number of objects. + * Purpose: Public function to return a list of opened object IDs. * + * Return: Success: The number of IDs in oid_list + * Failure: -1 *------------------------------------------------------------------------- */ ssize_t @@ -318,22 +298,22 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) { H5F_t * f = NULL; /* File to query */ size_t obj_id_count = 0; /* Number of open objects */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE4("Zs", "iIuz*i", file_id, types, max_objs, oid_list); /* Check arguments */ if (file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file id") if (0 == (types & H5F_OBJ_ALL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not an object type") if (!oid_list) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "object ID list is NULL") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "object ID list is NULL") /* Perform the query */ if (H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_id_count) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, (-1), "H5F_get_obj_ids failed") /* Set the return value */ ret_value = (ssize_t)obj_id_count; @@ -348,57 +328,47 @@ done: * Purpose: Returns a pointer to the file handle of the low-level file * driver. * - * Return: Success: non-negative value. - * Failure: negative. - * - * Programmer: Raymond Lu - * Sep. 16, 2002 - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t -H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) +H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) { H5F_t *file; /* File to query */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ii**x", file_id, fapl, file_handle); + H5TRACE3("e", "ii**x", file_id, fapl_id, file_handle); /* Check args */ if (!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer") - /* Get the file */ + /* Get the file object */ if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Retrieve the VFD handle for the file */ - if (H5F_get_vfd_handle(file, fapl, file_handle) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + if (H5F_get_vfd_handle(file, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get VFD handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_vfd_handle() */ /*------------------------------------------------------------------------- - * Function: H5Fis_hdf5 - * - * Purpose: Check the file signature to detect an HDF5 file. - * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. + * Function: H5Fis_hdf5 * - * Return: Success: TRUE/FALSE + * Purpose: Check the file signature to detect an HDF5 file. * - * Failure: Negative + * Bugs: This function is not robust: it only uses the default file + * driver when attempting to open the file when in fact it + * should use all known file drivers. * - * Programmer: Unknown + * Return: Success: TRUE/FALSE + * Failure: -1 (includes file does not exist) * - * Modifications: - * Robb Matzke, 1999-08-02 - * Rewritten to use the virtual file layer. *------------------------------------------------------------------------- */ htri_t @@ -418,72 +388,68 @@ H5Fis_hdf5(const char *name) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable open file") done: - FUNC_LEAVE_API(ret_value) } /* end H5Fis_hdf5() */ /*------------------------------------------------------------------------- - * Function: H5Fcreate - * - * Purpose: This is the primary function for creating HDF5 files . The - * flags parameter determines whether an existing file will be - * overwritten or not. All newly created files are opened for - * both reading and writing. All flags may be combined with the - * bit-wise OR operator (`|') to change the behavior of the file - * create call. - * - * The more complex behaviors of a file's creation and access - * are controlled through the file-creation and file-access - * property lists. The value of H5P_DEFAULT for a template - * value indicates that the library should use the default - * values for the appropriate template. - * - * See also: H5Fpublic.h for the list of supported flags. H5Ppublic.h for - * the list of file creation and file access properties. - * - * Return: Success: A file ID - * - * Failure: FAIL - * - * Programmer: Unknown - * + * Function: H5Fcreate + * + * Purpose: This is the primary function for creating HDF5 files . The + * flags parameter determines whether an existing file will be + * overwritten or not. All newly created files are opened for + * both reading and writing. All flags may be combined with the + * bit-wise OR operator (`|') to change the behavior of the file + * create call. + * + * The more complex behaviors of a file's creation and access + * are controlled through the file-creation and file-access + * property lists. The value of H5P_DEFAULT for a template + * value indicates that the library should use the default + * values for the appropriate template. + * + * See also: H5Fpublic.h for the list of supported flags. H5Ppublic.h for + * the list of file creation and file access properties. + * + * Return: Success: A file ID + * Failure: H5I_INVALID_HID *------------------------------------------------------------------------- */ hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t *new_file = NULL; /*file struct for new file */ - hid_t ret_value; /*return value */ + H5F_t *new_file = NULL; /* File struct for new file */ + hid_t ret_value; /* return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id); /* Check/fix arguments */ if (!filename || !*filename) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name") + /* In this routine, we only accept the following flags: * H5F_ACC_EXCL and H5F_ACC_TRUNC */ if (flags & ~(H5F_ACC_EXCL | H5F_ACC_TRUNC)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid flags") + /* The H5F_ACC_EXCL and H5F_ACC_TRUNC flags are mutually exclusive */ if ((flags & H5F_ACC_EXCL) && (flags & H5F_ACC_TRUNC)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "mutually exclusive flags for file creation") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "mutually exclusive flags for file creation") /* Check file creation property list */ if (H5P_DEFAULT == fcpl_id) fcpl_id = H5P_FILE_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(fcpl_id, H5P_FILE_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file create property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file create property list") /* Check the file access property list */ if (H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file access property list") - /* - * Adjust bit flags by turning on the creation bit and making sure that + /* Adjust bit flags by turning on the creation bit and making sure that * the EXCL or TRUNC bit is set. All newly-created files are opened for * reading and writing. */ @@ -491,15 +457,13 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; - /* - * Create a new file or truncate an existing file. - */ + /* Create a new file or truncate an existing file */ if (NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file") /* Get an atom for the file */ if ((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file") /* Keep this ID in file object structure */ new_file->file_id = ret_value; @@ -507,101 +471,74 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) done: if (ret_value < 0 && new_file) if (H5F_close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file") FUNC_LEAVE_API(ret_value) } /* end H5Fcreate() */ /*------------------------------------------------------------------------- - * Function: H5Fopen - * - * Purpose: This is the primary function for accessing existing HDF5 - * files. The FLAGS argument determines whether writing to an - * existing file will be allowed or not. All flags may be - * combined with the bit-wise OR operator (`|') to change the - * behavior of the file open call. The more complex behaviors - * of a file's access are controlled through the file-access - * property list. - * - * See Also: H5Fpublic.h for a list of possible values for FLAGS. + * Function: H5Fopen * - * Return: Success: A file ID + * Purpose: This is the primary function for accessing existing HDF5 + * files. The FLAGS argument determines whether writing to an + * existing file will be allowed or not. All flags may be + * combined with the bit-wise OR operator (`|') to change the + * behavior of the file open call. The more complex behaviors + * of a file's access are controlled through the file-access + * property list. * - * Failure: FAIL + * See Also: H5Fpublic.h for a list of possible values for FLAGS. * - * Programmer: Unknown - * - * Modifications: - * Robb Matzke, 1997-07-18 - * File struct creation and destruction is through H5F_new() and - * H5F_dest(). Reading the root symbol table entry is done with - * H5G_decode(). - * - * Robb Matzke, 1997-09-23 - * Most of the work is now done by H5F_open() since H5Fcreate() - * and H5Fopen() originally contained almost identical code. - * - * Robb Matzke, 1998-02-18 - * Added better error checking for the flags and the file access - * property list. It used to be possible to make the library - * dump core by passing an object ID that was not a file access - * property list. - * - * Robb Matzke, 1999-08-02 - * The file access property list is passed to the H5F_open() as - * object IDs. + * Return: Success: A file ID + * Failure: H5I_INVALID_HID *------------------------------------------------------------------------- */ hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - H5F_t *new_file = NULL; /*file struct for new file */ - hid_t ret_value; /*return value */ + H5F_t *new_file = NULL; /* file struct for new file */ + hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*sIui", filename, flags, fapl_id); - /* Check/fix arguments. */ + /* Check arguments */ if (!filename || !*filename) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file name") /* Reject undefined flags (~H5F_ACC_PUBLIC_FLAGS) and the H5F_ACC_TRUNC & H5F_ACC_EXCL flags */ if ((flags & ~H5F_ACC_PUBLIC_FLAGS) || (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags") if (H5P_DEFAULT == fapl_id) fapl_id = H5P_FILE_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not file access property list") /* Open the file */ if (NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") - /* Get an atom for the file */ + /* Get an ID for the file */ if ((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") /* Keep this ID in file object structure */ new_file->file_id = ret_value; done: if (ret_value < 0 && new_file && H5F_try_close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") - + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file") FUNC_LEAVE_API(ret_value) } /* end H5Fopen() */ /*------------------------------------------------------------------------- - * Function: H5Fflush - * - * Purpose: Flushes all outstanding buffers of a file to disk but does - * not remove them from the cache. The OBJECT_ID can be a file, - * dataset, group, attribute, or named data type. - * - * Return: Non-negative on success/Negative on failure + * Function: H5Fflush * - * Programmer: Robb Matzke - * Thursday, August 6, 1998 + * Purpose: Flushes all outstanding buffers of a file to disk but does + * not remove them from the cache. The OBJECT_ID can be a file, + * dataset, group, attribute, or named data type. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -609,7 +546,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) { H5F_t * f = NULL; /* File to flush */ H5O_loc_t *oloc = NULL; /* Object location for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFs", object_id, scope); @@ -677,7 +614,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) /* Flush the file */ /* - * Nothing to do if the file is read only. This determination is + * Nothing to do if the file is read only. This determination is * made at the shared open(2) flags level, implying that opening a * file twice, once for read-only and once for read-write, and then * calling H5Fflush() with the read-only handle, still causes data @@ -702,24 +639,17 @@ done: } /* end H5Fflush() */ /*------------------------------------------------------------------------- - * Function: H5Fclose - * - * Purpose: This function closes the file specified by FILE_ID by - * flushing all data to storage, and terminating access to the - * file through FILE_ID. If objects (e.g., datasets, groups, - * etc.) are open in the file then the underlying storage is not - * closed until those objects are closed; however, all data for - * the file and the open objects is flushed. - * - * Return: Success: Non-negative + * Function: H5Fclose * - * Failure: Negative - * - * Programmer: Robb Matzke - * Saturday, February 20, 1999 - * - * Modifications: + * Purpose: This function closes the file specified by FILE_ID by + * flushing all data to storage, and terminating access to the + * file through FILE_ID. If objects (e.g., datasets, groups, + * etc.) are open in the file then the underlying storage is not + * closed until those objects are closed; however, all data for + * the file and the open objects is flushed. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -732,7 +662,7 @@ H5Fclose(hid_t file_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); - /* Check/fix arguments. */ + /* Check arguments */ if (H5I_FILE != H5I_get_type(file_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") @@ -762,41 +692,36 @@ done: } /* end H5Fclose() */ /*------------------------------------------------------------------------- - * Function: H5Freopen + * Function: H5Freopen * - * Purpose: Reopen a file. The new file handle which is returned points - * to the same file as the specified file handle. Both handles - * share caches and other information. The only difference - * between the handles is that the new handle is not mounted - * anywhere and no files are mounted on it. - * - * Return: Success: New file ID - * - * Failure: FAIL - * - * Programmer: Robb Matzke - * Friday, October 16, 1998 + * Purpose: Reopen a file. The new file handle which is returned points + * to the same file as the specified file handle. Both handles + * share caches and other information. The only difference + * between the handles is that the new handle is not mounted + * anywhere and no files are mounted on it. * + * Return: Success: New file ID + * Failure: H5I_INVALID_HID *------------------------------------------------------------------------- */ hid_t H5Freopen(hid_t file_id) { - H5F_t *old_file = NULL; - H5F_t *new_file = NULL; - hid_t ret_value; + H5F_t *old_file = NULL; + H5F_t *new_file = NULL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* Check arguments */ if (NULL == (old_file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Get a new "top level" file struct, sharing the same "low level" file struct */ if (NULL == (new_file = H5F_new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file") /* Duplicate old file's names */ new_file->open_name = H5MM_xstrdup(old_file->open_name); @@ -804,7 +729,7 @@ H5Freopen(hid_t file_id) new_file->extpath = H5MM_xstrdup(old_file->extpath); if ((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") /* Keep this ID in file object structure */ new_file->file_id = ret_value; @@ -812,22 +737,19 @@ H5Freopen(hid_t file_id) done: if (ret_value < 0 && new_file) if (H5F_dest(new_file, H5AC_dxpl_id, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "can't close file") FUNC_LEAVE_API(ret_value) } /* end H5Freopen() */ /*------------------------------------------------------------------------- - * Function: H5Fget_intent + * Function: H5Fget_intent * - * Purpose: Public API to retrieve the file's 'intent' flags passed + * Purpose: Public API to retrieve the file's 'intent' flags passed * during H5Fopen() * - * Return: Non-negative on success/negative on failure - * - * Programmer: James Laird - * August 23, 2006 - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -865,13 +787,8 @@ done: * * Purpose: Retrieves the amount of free space in the file. * - * Return: Success: Amount of free space for type - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Oct 6, 2003 - * + * Return: Success: Amount of free space for type + * Failure: -1 *------------------------------------------------------------------------- */ hssize_t @@ -881,16 +798,16 @@ H5Fget_freespace(hid_t file_id) hsize_t tot_space; /* Amount of free space in the file */ hssize_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Hs", "i", file_id); - /* Check args */ + /* Get the file object */ if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Go get the actual amount of free space in the file */ if (H5MF_get_freespace(file, H5AC_ind_dxpl_id, &tot_space, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to check free space for file") ret_value = (hssize_t)tot_space; @@ -903,15 +820,10 @@ done: * * Purpose: Retrieves the file size of the HDF5 file. This function * is called after an existing file is opened in order - * to learn the true size of the underlying file. + * to learn the true size of the underlying file. * * Return: Success: Non-negative * Failure: Negative - * - * Programmer: David Pitt - * david.pitt@bigpond.com - * Apr 27, 2004 - * *------------------------------------------------------------------------- */ herr_t @@ -932,6 +844,7 @@ H5Fget_filesize(hid_t file_id, hsize_t *size) /* Go get the actual file size */ if (HADDR_UNDEF == (eof = H5FD_get_eof(file->shared->lf))) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + base_addr = H5FD_get_base_addr(file->shared->lf); if (size) @@ -945,59 +858,55 @@ done: * Function: H5Fget_file_image * * Purpose: If a buffer is provided (via the buf_ptr argument) and is - * big enough (size in buf_len argument), load *buf_ptr with - * an image of the open file whose ID is provided in the - * file_id parameter, and return the number of bytes copied - * to the buffer. + * big enough (size in buf_len argument), load *buf_ptr with + * an image of the open file whose ID is provided in the + * file_id parameter, and return the number of bytes copied + * to the buffer. * - * If the buffer exists, but is too small to contain an image - * of the indicated file, return a negative number. + * If the buffer exists, but is too small to contain an image + * of the indicated file, return a negative number. * - * Finally, if no buffer is provided, return the size of the - * buffer needed. This value is simply the eoa of the target - * file. + * Finally, if no buffer is provided, return the size of the + * buffer needed. This value is simply the eoa of the target + * file. * - * Note that any user block is skipped. + * Note that any user block is skipped. * - * Also note that the function may not be used on files - * opened with either the split/multi file driver or the - * family file driver. + * Also note that the function may not be used on files + * opened with either the split/multi file driver or the + * family file driver. * - * In the former case, the sparse address space makes the - * get file image operation impractical, due to the size of - * the image typically required. + * In the former case, the sparse address space makes the + * get file image operation impractical, due to the size of + * the image typically required. * - * In the case of the family file driver, the problem is - * the driver message in the super block, which will prevent - * the image being opened with any driver other than the - * family file driver -- which negates the purpose of the - * operation. This can be fixed, but no resources for - * this now. - * - * Return: Success: Bytes copied / number of bytes needed. - * Failure: negative value - * - * Programmer: John Mainzer - * 11/15/11 + * In the case of the family file driver, the problem is + * the driver message in the super block, which will prevent + * the image being opened with any driver other than the + * family file driver -- which negates the purpose of the + * operation. This can be fixed, but no resources for + * this now. * + * Return: Success: Bytes copied / number of bytes needed + * Failure: -1 *------------------------------------------------------------------------- */ ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) { H5F_t * file; /* File object for file ID */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len); /* Check args */ if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID") /* call private get_file_image function */ if ((ret_value = H5F_get_file_image(file, buf_ptr, buf_len)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file image") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image") done: FUNC_LEAVE_API(ret_value) @@ -1007,18 +916,14 @@ done: * Function: H5Fget_mdc_config * * Purpose: Retrieves the current automatic cache resize configuration - * from the metadata cache, and return it in *config_ptr. - * - * Note that the version field of *config_Ptr must be correctly - * filled in by the caller. This allows us to adapt for - * obsolete versions of the structure. - * - * Return: Success: SUCCEED - * Failure: FAIL + * from the metadata cache, and return it in *config_ptr. * - * Programmer: John Mainzer - * 3/24/05 + * Note that the version field of *config_Ptr must be correctly + * filled in by the caller. This allows us to adapt for + * obsolete versions of the structure. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1048,15 +953,11 @@ done: * Function: H5Fset_mdc_config * * Purpose: Sets the current metadata cache automatic resize - * configuration, using the contents of the instance of - * H5AC_cache_config_t pointed to by config_ptr. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 + * configuration, using the contents of the instance of + * H5AC_cache_config_t pointed to by config_ptr. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1068,11 +969,11 @@ H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); - /* Check args */ + /* Get the file object */ if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* set the resize configuration */ + /* Set the metadata cache configuration */ if (H5AC_set_cache_auto_resize_config(file->shared->cache, config_ptr) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed.") @@ -1084,16 +985,12 @@ done: * Function: H5Fget_mdc_hit_rate * * Purpose: Retrieves the current hit rate from the metadata cache. - * This rate is the overall hit rate since the last time - * the hit rate statistics were reset either manually or - * automatically. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 + * This rate is the overall hit rate since the last time + * the hit rate statistics were reset either manually or + * automatically. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1106,13 +1003,12 @@ H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) H5TRACE2("e", "i*d", file_id, hit_rate_ptr); /* Check args */ - if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - if (NULL == hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer") + if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - /* Go get the current hit rate */ + /* Get the current hit rate */ if (H5AC_get_cache_hit_rate(file->shared->cache, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") @@ -1124,17 +1020,13 @@ done: * Function: H5Fget_mdc_size * * Purpose: Retrieves the maximum size, minimum clean size, current - * size, and current number of entries from the metadata - * cache associated with the specified file. If any of - * the ptr parameters are NULL, the associated datum is - * not returned. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 + * size, and current number of entries from the metadata + * cache associated with the specified file. If any of + * the ptr parameters are NULL, the associated datum is + * not returned. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1152,11 +1044,10 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - /* Go get the size data */ + /* Get the size data */ if (H5AC_get_cache_size(file->shared->cache, max_size_ptr, min_clean_size_ptr, cur_size_ptr, &cur_num_entries) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - if (cur_num_entries_ptr != NULL) *cur_num_entries_ptr = (int)cur_num_entries; @@ -1168,20 +1059,16 @@ done: * Function: H5Freset_mdc_hit_rate_stats * * Purpose: Reset the hit rate statistic whose current value can - * be obtained via the H5Fget_mdc_hit_rate() call. Note - * that this statistic will also be reset once per epoch - * by the automatic cache resize code if it is enabled. - * - * It is probably a bad idea to call this function unless - * you are controlling cache size from your program instead - * of using our cache size control code. + * be obtained via the H5Fget_mdc_hit_rate() call. Note + * that this statistic will also be reset once per epoch + * by the automatic cache resize code if it is enabled. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * 3/24/05 + * It is probably a bad idea to call this function unless + * you are controlling cache size from your program instead + * of using our cache size control code. * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t @@ -1193,7 +1080,7 @@ H5Freset_mdc_hit_rate_stats(hid_t file_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); - /* Check args */ + /* Get the file object */ if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") @@ -1209,22 +1096,19 @@ done: * Function: H5Fget_name * * Purpose: Gets the name of the file to which object OBJ_ID belongs. - * If `name' is non-NULL then write up to `size' bytes into that + * If 'name' is non-NULL then write up to 'size' bytes into that * buffer and always return the length of the entry name. - * Otherwise `size' is ignored and the function does not store the name, - * just returning the number of characters required to store the name. - * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) - * is unchanged and the function returns a negative value. - * - * Note: This routine returns the name that was used to open the file, - * not the actual name after resolving symlinks, etc. + * Otherwise `size' is ignored and the function does not store + * the name, just returning the number of characters required to + * store the name. If an error occurs then the buffer pointed to + * by 'name' (NULL or non-NULL) is unchanged and the function + * returns a negative value. * - * Return: Success: The length of the file name - * Failure: Negative - * - * Programmer: Raymond Lu - * June 29, 2004 + * Note: This routine returns the name that was used to open the file, + * not the actual name after resolving symlinks, etc. * + * Return: Success: The length of the file name + * Failure: -1 *------------------------------------------------------------------------- */ ssize_t @@ -1232,9 +1116,9 @@ H5Fget_name(hid_t obj_id, char *name /*out*/, size_t size) { H5F_t * f; /* Top file in mount hierarchy */ size_t len; - ssize_t ret_value; + ssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", obj_id, name, size); /* For file IDs, get the file object directly */ @@ -1250,7 +1134,7 @@ H5Fget_name(hid_t obj_id, char *name /*out*/, size_t size) /* Get symbol table entry */ if (H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a valid object ID") f = loc.oloc->file; } /* end else */ @@ -1271,10 +1155,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Fget_info - * 1. Get storage size for superblock extension if there is one + * 1. Get storage size for superblock extension if there is one * 2. Get the amount of btree and heap storage for entries * in the SOHM table if there is one. - * Consider success when there is no superblock extension and/or SOHM table + * Consider success when there is no superblock extension and/or SOHM table * * Return: Success: non-negative on success * Failure: Negative @@ -1338,11 +1222,8 @@ done: * provided file, potentially closing any cached files * unless they are held open from somewhere\ else. * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Neil Fortner; December 30, 2010 - * + * Return: Success: Non-negative + * Failure: Negative *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5FD.c b/src/H5FD.c index 4e9528e..bf75e73 100644 --- a/src/H5FD.c +++ b/src/H5FD.c @@ -32,25 +32,25 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5FDcore.h" /* Files stored entirely in memory */ -#include "H5FDfamily.h" /* File families */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5FDcore.h" /* Files stored entirely in memory */ +#include "H5FDfamily.h" /* File families */ #include "H5FDlog.h" /* sec2 driver with I/O logging (for debugging) */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5FDmulti.h" /* Usage-partitioned file family */ -#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5FDmulti.h" /* Usage-partitioned file family */ +#include "H5FDsec2.h" /* POSIX unbuffered file I/O */ +#include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Windows buffered I/O */ +#include "H5FDwindows.h" /* Windows buffered I/O */ #endif -#include "H5FDdirect.h" /* Direct file I/O */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5FDdirect.h" /* Direct file I/O */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ @@ -170,20 +170,15 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_term_interface * - * Purpose: Terminate this interface: free all memory and reset global - * variables to their initial values. Release all ID groups - * associated with this interface. + * Purpose: Terminate this interface: free all memory and reset global + * variables to their initial values. Release all ID groups + * associated with this interface. * - * Return: Success: Positive if anything was done that might - * have affected other interfaces; zero - * otherwise. + * Return: Success: Positive if anything was done that might + * have affected other interfaces; zero + * otherwise. * - * Failure: Never fails. - * - * Programmer: Robb Matzke - * Friday, February 19, 1999 - * - * Modifications: + * Failure: Never fails. * *------------------------------------------------------------------------- */ @@ -235,18 +230,11 @@ H5FD_term_interface(void) /*------------------------------------------------------------------------- * Function: H5FD_free_cls * - * Purpose: Frees a file driver class struct and returns an indication of - * success. This function is used as the free callback for the - * virtual file layer object identifiers (cf H5FD_init_interface). + * Purpose: Frees a file driver class struct and returns an indication of + * success. This function is used as the free callback for the + * virtual file layer object identifiers (cf H5FD_init_package). * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Monday, July 26, 1999 - * - * Modifications: + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -263,54 +251,49 @@ H5FD_free_cls(H5FD_class_t *cls) /*------------------------------------------------------------------------- * Function: H5FDregister * - * Purpose: Registers a new file driver as a member of the virtual file - * driver class. Certain fields of the class struct are - * required and that is checked here so it doesn't have to be - * checked every time the field is accessed. - * - * Return: Success: A file driver ID which is good until the - * library is closed or the driver is - * unregistered. + * Purpose: Registers a new file driver as a member of the virtual file + * driver class. Certain fields of the class struct are + * required and that is checked here so it doesn't have to be + * checked every time the field is accessed. * - * Failure: A negative value. + * Return: Success: A file driver ID which is good until the + * library is closed or the driver is + * unregistered. * - * Programmer: Robb Matzke - * Monday, July 26, 1999 - * - * Modifications: - * Copied guts of function into H5FD_register - * Quincey Koziol - * Friday, January 30, 2004 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5FDregister(const H5FD_class_t *cls) { - hid_t ret_value; H5FD_mem_t type; + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*x", cls); /* Check arguments */ if (!cls) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null class pointer is disallowed") if (!cls->open || !cls->close) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`open' and/or `close' methods are not defined") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'open' and/or 'close' methods are not defined") if (!cls->get_eoa || !cls->set_eoa) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eoa' and/or `set_eoa' methods are not defined") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'get_eoa' and/or 'set_eoa' methods are not defined") if (!cls->get_eof) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`get_eof' method is not defined") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "'get_eof' method is not defined") if (!cls->read || !cls->write) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "`read' and/or `write' method is not defined") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, + "'read' and/or 'write' method is not defined") for (type = H5FD_MEM_DEFAULT; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) if (cls->fl_map[type] < H5FD_MEM_NOLIST || cls->fl_map[type] >= H5FD_MEM_NTYPES) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid free-list mapping") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid free-list mapping") /* Create the new class ID */ if ((ret_value = H5FD_register(cls, sizeof(H5FD_class_t), TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register file driver ID") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID") done: FUNC_LEAVE_API(ret_value) @@ -319,27 +302,16 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_register * - * Purpose: Registers a new file driver as a member of the virtual file - * driver class. Certain fields of the class struct are - * required and that is checked here so it doesn't have to be - * checked every time the field is accessed. + * Purpose: Registers a new file driver as a member of the virtual file + * driver class. Certain fields of the class struct are + * required and that is checked here so it doesn't have to be + * checked every time the field is accessed. * - * Return: Success: A file driver ID which is good until the - * library is closed or the driver is - * unregistered. + * Return: Success: A file driver ID which is good until the + * library is closed or the driver is + * unregistered. * - * Failure: A negative value. - * - * Programmer: Robb Matzke - * Monday, July 26, 1999 - * - * Modifications: - * Broke into public and internal routines & added 'size' - * parameter to internal routine, which allows us to create - * sub-classes of H5FD_class_t for internal support (see the - * MPI drivers, etc.) - * Quincey Koziol - * January 30, 2004 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -349,11 +321,11 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref) const H5FD_class_t *cls = (const H5FD_class_t *)_cls; H5FD_class_t * saved = NULL; H5FD_mem_t type; - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) - /* Check arguments */ + /* Sanity checks */ HDassert(cls); HDassert(cls->open && cls->close); HDassert(cls->get_eoa && cls->set_eoa); @@ -364,15 +336,16 @@ H5FD_register(const void *_cls, size_t size, hbool_t app_ref) /* Copy the class structure so the caller can reuse or free it */ if (NULL == (saved = (H5FD_class_t *)H5MM_malloc(size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for file driver class struct") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, + "memory allocation failed for file driver class struct") HDmemcpy(saved, cls, size); /* Create the new class ID */ if ((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register file driver ID") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register file driver ID") done: - if (ret_value < 0) + if (H5I_INVALID_HID == ret_value) if (saved) H5MM_xfree(saved); @@ -382,17 +355,12 @@ done: /*------------------------------------------------------------------------- * Function: H5FDunregister * - * Purpose: Removes a driver ID from the library. This in no way affects - * file access property lists which have been defined to use - * this driver or files which are already opened under this - * driver. + * Purpose: Removes a driver ID from the library. This in no way affects + * file access property lists which have been defined to use + * this driver or files which are already opened under this + * driver. * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Monday, July 26, 1999 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -419,20 +387,17 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_get_class * - * Purpose: Obtains a pointer to the driver struct containing all the - * callback pointers, etc. The PLIST_ID argument can be a file - * access property list, a data transfer property list, or a - * file driver identifier. + * Purpose: Obtains a pointer to the driver struct containing all the + * callback pointers, etc. The PLIST_ID argument can be a file + * access property list, a data transfer property list, or a + * file driver identifier. * - * Return: Success: Ptr to the driver information. The pointer is - * only valid as long as the driver remains - * registered or some file or property list - * exists which references the driver. + * Return: Success: Ptr to the driver information. The pointer is + * only valid as long as the driver remains + * registered or some file or property list + * exists which references the driver. * - * Failure: NULL - * - * Programmer: Robb Matzke - * Friday, August 20, 1999 + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -469,18 +434,13 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_sb_size * - * Purpose: Obtains the number of bytes required to store the driver file - * access data in the HDF5 superblock. - * - * Return: Success: Number of bytes required. - * - * Failure: 0 if an error occurs or if the driver has no - * data to store in the superblock. + * Purpose: Obtains the number of bytes required to store the driver file + * access data in the HDF5 superblock. * - * Programmer: Robb Matzke - * Monday, August 16, 1999 + * Return: Success: Number of bytes required. May be zero if the + * driver has no data to store in the superblock. * - * Modifications: + * Failure: This function cannot indicate errors. * *------------------------------------------------------------------------- */ @@ -491,8 +451,11 @@ H5FD_sb_size(H5FD_t *file) FUNC_ENTER_NOAPI(0) - HDassert(file && file->cls); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); + /* Dispatch to driver */ if (file->cls->sb_size) ret_value = (file->cls->sb_size)(file); @@ -503,21 +466,14 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_sb_encode * - * Purpose: Encode driver-specific data into the output arguments. The - * NAME is a nine-byte buffer which should get an - * eight-character driver name and/or version followed by a null - * terminator. The BUF argument is a buffer to receive the - * encoded driver-specific data. The size of the BUF array is - * the size returned by the H5FD_sb_size() call. + * Purpose: Encode driver-specific data into the output arguments. The + * NAME is a nine-byte buffer which should get an + * eight-character driver name and/or version followed by a null + * terminator. The BUF argument is a buffer to receive the + * encoded driver-specific data. The size of the BUF array is + * the size returned by the H5FD_sb_size() call. * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Monday, August 16, 1999 - * - * Modifications: + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -528,24 +484,24 @@ H5FD_sb_encode(H5FD_t *file, char *name /*out*/, uint8_t *buf) FUNC_ENTER_NOAPI(FAIL) - HDassert(file && file->cls); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); + + /* Dispatch to driver */ if (file->cls->sb_encode && (file->cls->sb_encode)(file, name /*out*/, buf /*out*/) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_encode request failed") done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_sb_encode() */ /*------------------------------------------------------------------------- * Function: H5FD_sb_decode * - * Purpose: Decodes the driver information block. - * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Decodes the driver information block. * - * Programmer: Robb Matzke - * Monday, August 16, 1999 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -556,7 +512,11 @@ H5FD_sb_decode(H5FD_t *file, const char *name, const uint8_t *buf) FUNC_ENTER_NOAPI(FAIL) - HDassert(file && file->cls); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); + + /* Dispatch to driver */ if (file->cls->sb_decode && (file->cls->sb_decode)(file, name, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver sb_decode request failed") @@ -657,26 +617,22 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_fapl_get * - * Purpose: Gets the file access property list associated with a file. - * Usually the file will copy what it needs from the original - * file access property list when the file is created. The - * purpose of this function is to create a new file access - * property list based on the settings in the file, which may - * have been modified from the original file access property - * list. + * Purpose: Gets the file access property list associated with a file. + * Usually the file will copy what it needs from the original + * file access property list when the file is created. The + * purpose of this function is to create a new file access + * property list based on the settings in the file, which may + * have been modified from the original file access property + * list. * - * Return: Success: Pointer to a new file access property list - * with all members copied. If the file is - * closed then this property list lives on, and - * vice versa. + * Return: Success: Pointer to a new file access property list + * with all members copied. If the file is + * closed then this property list lives on, and + * vice versa. * - * Failure: NULL, including when the file has no - * properties. + * This can be NULL if the file has no properties. * - * Programmer: Robb Matzke - * Friday, August 13, 1999 - * - * Modifications: + * Failure: This function cannot indicate errors. * *------------------------------------------------------------------------- */ @@ -687,8 +643,11 @@ H5FD_fapl_get(H5FD_t *file) FUNC_ENTER_NOAPI(NULL) + /* Sanity checks */ HDassert(file); + HDassert(file->cls); + /* Dispatch to driver */ if (file->cls->fapl_get) ret_value = (file->cls->fapl_get)(file); @@ -816,55 +775,50 @@ done: /*------------------------------------------------------------------------- * Function: H5FDopen * - * Purpose: Opens a file named NAME for the type(s) of access described - * by the bit vector FLAGS according to a file access property - * list FAPL_ID (which may be the constant H5P_DEFAULT). The - * file should expect to handle format addresses in the range [0, - * MAXADDR] (if MAXADDR is the undefined address then the caller - * doesn't care about the address range). + * Purpose: Opens a file named NAME for the type(s) of access described + * by the bit vector FLAGS according to a file access property + * list FAPL_ID (which may be the constant H5P_DEFAULT). The + * file should expect to handle format addresses in the range [0, + * MAXADDR] (if MAXADDR is the undefined address then the caller + * doesn't care about the address range). * - * Possible values for the FLAGS bits are: + * Possible values for the FLAGS bits are: * - * H5F_ACC_RDWR: Open the file for read and write access. If - * this bit is not set then open the file for - * read only access. It is permissible to open a - * file for read and write access when only read - * access is requested by the library (the - * library will never attempt to write to a file - * which it opened with only read access). + * H5F_ACC_RDWR: Open the file for read and write access. If + * this bit is not set then open the file for + * read only access. It is permissible to open a + * file for read and write access when only read + * access is requested by the library (the + * library will never attempt to write to a file + * which it opened with only read access). * - * H5F_ACC_CREATE: Create the file if it doesn't already exist. - * However, see H5F_ACC_EXCL below. + * H5F_ACC_CREATE: Create the file if it doesn't already exist. + * However, see H5F_ACC_EXCL below. * - * H5F_ACC_TRUNC: Truncate the file if it already exists. This - * is equivalent to deleting the file and then - * creating a new empty file. + * H5F_ACC_TRUNC: Truncate the file if it already exists. This + * is equivalent to deleting the file and then + * creating a new empty file. * - * H5F_ACC_EXCL: When used with H5F_ACC_CREATE, if the file - * already exists then the open should fail. - * Note that this is unsupported/broken with - * some file drivers (e.g., sec2 across nfs) and - * will contain a race condition when used to - * perform file locking. + * H5F_ACC_EXCL: When used with H5F_ACC_CREATE, if the file + * already exists then the open should fail. + * Note that this is unsupported/broken with + * some file drivers (e.g., sec2 across nfs) and + * will contain a race condition when used to + * perform file locking. * - * The MAXADDR is the maximum address which will be requested by - * the library during an allocation operation. Usually this is - * the same value as the MAXADDR field of the class structure, - * but it can be smaller if the driver is being used under some - * other driver. + * The MAXADDR is the maximum address which will be requested by + * the library during an allocation operation. Usually this is + * the same value as the MAXADDR field of the class structure, + * but it can be smaller if the driver is being used under some + * other driver. * - * Note that when the driver `open' callback gets control that - * the public part of the file struct (the H5FD_t part) will be - * incomplete and will be filled in after that callback returns. + * Note that when the driver 'open' callback gets control that + * the public part of the file struct (the H5FD_t part) will be + * incomplete and will be filled in after that callback returns. * - * Return: Success: Pointer to a new file driver struct. + * Return: Success: Pointer to a new file driver struct. * - * Failure: NULL - * - * Programmer: Robb Matzke - * Tuesday, July 27, 1999 - * - * Modifications: + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -882,6 +836,7 @@ H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) else if (TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + /* Call private function */ if (NULL == (ret_value = H5FD_open(name, flags, fapl_id, maxaddr))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, NULL, "unable to open file") @@ -892,21 +847,11 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_open * - * Purpose: Private version of H5FDopen() - * - * Return: Success: Pointer to a new file driver struct - * - * Failure: NULL + * Purpose: Private version of H5FDopen() * - * Programmer: Robb Matzke - * Wednesday, August 4, 1999 - * - * Modifications: + * Return: Success: Pointer to a new file driver struct * - * Raymond Lu - * Tuesday, Oct 23, 2001 - * Changed the file access list to the new generic property - * list. + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -919,11 +864,11 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) H5P_genplist_t * plist; /* Property list pointer */ unsigned long driver_flags = 0; /* File-inspecific driver feature flags */ H5FD_file_image_info_t file_image_info; /* Initial file image */ - H5FD_t * ret_value; /* Return value */ + H5FD_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) - /* Sanity check */ + /* Sanity checks */ if (0 == maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "zero format address range") @@ -1000,17 +945,13 @@ done: /*------------------------------------------------------------------------- * Function: H5FDclose * - * Purpose: Closes the file by calling the driver `close' callback, which - * should free all driver-private data and free the file struct. - * Note that the public part of the file struct (the H5FD_t part) - * will be all zero during the driver close callback like during - * the `open' callback. + * Purpose: Closes the file by calling the driver 'close' callback, which + * should free all driver-private data and free the file struct. + * Note that the public part of the file struct (the H5FD_t part) + * will be all zero during the driver close callback like during + * the 'open' callback. * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Robb Matzke - * Tuesday, July 27, 1999 + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1022,9 +963,13 @@ H5FDclose(H5FD_t *file) FUNC_ENTER_API(FAIL) H5TRACE1("e", "*x", file); - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") + /* Call private function */ if (H5FD_close(file) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") @@ -1035,13 +980,9 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_close * - * Purpose: Private version of H5FDclose() - * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Private version of H5FDclose() * - * Programmer: Robb Matzke - * Wednesday, August 4, 1999 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1053,16 +994,16 @@ H5FD_close(H5FD_t *file) FUNC_ENTER_NOAPI(FAIL) - /* check args */ - HDassert(file && file->cls); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); /* Prepare to close file by clearing all public fields */ driver = file->cls; if (H5I_dec_ref(file->driver_id) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close driver ID") - /* - * Dispatch to the driver for actual close. If the driver fails to + /* Dispatch to the driver for actual close. If the driver fails to * close the file then the file will be in an unusable state. */ HDassert(driver->close); @@ -1076,63 +1017,54 @@ done: /*------------------------------------------------------------------------- * Function: H5FDcmp * - * Purpose: Compare the keys of two files using the file driver callback - * if the files belong to the same driver, otherwise sort the - * files by driver class pointer value. + * Purpose: Compare the keys of two files using the file driver callback + * if the files belong to the same driver, otherwise sort the + * files by driver class pointer value. * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: Must never fail. If both file handles are - * invalid then they compare equal. If one file - * handle is invalid then it compares less than - * the other. If both files belong to the same - * driver and the driver doesn't provide a - * comparison callback then the file pointers - * themselves are compared. - * - * Programmer: Robb Matzke - * Tuesday, July 27, 1999 - * - * Modifications: + * Failure: Must never fail. If both file handles are + * invalid then they compare equal. If one file + * handle is invalid then it compares less than + * the other. If both files belong to the same + * driver and the driver doesn't provide a + * comparison callback then the file pointers + * themselves are compared. * *------------------------------------------------------------------------- */ int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2) { - int ret_value; + int ret_value = -1; - FUNC_ENTER_API(-1) /*return value is arbitrary*/ + FUNC_ENTER_API(-1) /* return value is arbitrary */ H5TRACE2("Is", "*x*x", f1, f2); + /* Call private function */ ret_value = H5FD_cmp(f1, f2); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5FDcmp() */ /*------------------------------------------------------------------------- * Function: H5FD_cmp * - * Purpose: Private version of H5FDcmp() + * Purpose: Private version of H5FDcmp() * - * Return: Success: A value like strcmp() + * Return: Success: A value like strcmp() * - * Failure: Must never fail. - * - * Programmer: Robb Matzke - * Wednesday, August 4, 1999 - * - * Modifications: + * Failure: Must never fail. * *------------------------------------------------------------------------- */ int H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) { - int ret_value; + int ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI(-1) /*return value is arbitrary*/ + FUNC_ENTER_NOAPI(-1) /* return value is arbitrary */ if ((!f1 || !f1->cls) && (!f2 || !f2->cls)) HGOTO_DONE(0) @@ -1154,40 +1086,42 @@ H5FD_cmp(const H5FD_t *f1, const H5FD_t *f2) HGOTO_DONE(0) } + /* Dispatch to driver */ ret_value = (f1->cls->cmp)(f1, f2); done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_cmp() */ /*------------------------------------------------------------------------- * Function: H5FDquery * - * Purpose: Query a VFL driver for its feature flags. (listed in H5FDpublic.h) - * - * Return: Success: non-negative - * - * Failure: negative + * Purpose: Query a VFL driver for its feature flags. (listed in H5FDpublic.h) * - * Programmer: Quincey Koziol - * Friday, August 25, 2000 - * - * Modifications: + * Return: Success: 0 + * Failure: -1 * *------------------------------------------------------------------------- */ int -H5FDquery(const H5FD_t *f, unsigned long *flags /*out*/) +H5FDquery(const H5FD_t *file, unsigned long *flags /*out*/) { - int ret_value; + int ret_value = 0; - FUNC_ENTER_API(FAIL) - H5TRACE2("Is", "*xx", f, flags); + FUNC_ENTER_API((-1)) + H5TRACE2("Is", "*xx", file, flags); - HDassert(f); - HDassert(flags); + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "file class pointer cannot be NULL") + if (!flags) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "flags parameter cannot be NULL") - ret_value = H5FD_query(f, flags); + /* Call private function */ + if (H5FD_query(file, flags) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, (-1), "unable to query feature flags") done: FUNC_LEAVE_API(ret_value) @@ -1196,33 +1130,33 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_query * - * Purpose: Private version of H5FDquery() - * - * Return: Success: non-negative - * - * Failure: negative + * Purpose: Private version of H5FDquery() * - * Programmer: Quincey Koziol - * Friday, August 25, 2000 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static int -H5FD_query(const H5FD_t *f, unsigned long *flags /*out*/) +H5FD_query(const H5FD_t *file, unsigned long *flags /*out*/) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_NOAPI(FAIL) - HDassert(f); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); HDassert(flags); - /* Check for query driver and call it */ - if (f->cls->query) - ret_value = (f->cls->query)(f, flags); + /* Dispatch to driver (if available) */ + if (file->cls->query) { + if ((file->cls->query)(file, flags) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "unable to query feature flags") + } else *flags = 0; +done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_query() */ @@ -1264,12 +1198,12 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/) /*------------------------------------------------------------------------- * Function: H5FDalloc * - * Purpose: Allocates SIZE bytes of memory from the FILE. The memory will - * be used according to the allocation class TYPE. First we try - * to satisfy the request from one of the free lists, according - * to the free list map provided by the driver. The free list - * array has one entry for each request type and the value of - * that array element can be one of four possibilities: + * Purpose: Allocates SIZE bytes of memory from the FILE. The memory will + * be used according to the allocation class TYPE. First we try + * to satisfy the request from one of the free lists, according + * to the free list map provided by the driver. The free list + * array has one entry for each request type and the value of + * that array element can be one of four possibilities: * * It can be the constant H5FD_MEM_DEFAULT (or zero) which * indicates that the identity mapping is used. In other @@ -1285,18 +1219,15 @@ H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags /*out*/) * It can be the constant H5FD_MEM_NOLIST which means that * no free list should be used for this type of request. * - * If the request cannot be satisfied from a free list then - * either the driver's `alloc' callback is invoked (if one was - * supplied) or the end-of-address marker is extended. The - * `alloc' callback is always called with the same arguments as - * the H5FDalloc(). + * If the request cannot be satisfied from a free list then + * either the driver's 'alloc' callback is invoked (if one was + * supplied) or the end-of-address marker is extended. The + * 'alloc' callback is always called with the same arguments as + * the H5FDalloc(). * - * Return: Success: The format address of the new file memory. + * Return: Success: The format address of the new file memory. * - * Failure: The undefined address HADDR_UNDEF - * - * Programmer: Robb Matzke - * Tuesday, July 27, 1999 + * Failure: The undefined address HADDR_UNDEF * *------------------------------------------------------------------------- */ @@ -1308,9 +1239,11 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) FUNC_ENTER_API(HADDR_UNDEF) H5TRACE4("a", "*xMtih", file, type, dxpl_id, size); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid request type") if (size == 0) @@ -1320,7 +1253,7 @@ H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size) else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a data transfer property list") - /* Do the real work */ + /* Call private function */ if (HADDR_UNDEF == (ret_value = H5FD_alloc_real(file, dxpl_id, type, size, NULL, NULL))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "unable to allocate file memory") @@ -1334,21 +1267,14 @@ done: /*------------------------------------------------------------------------- * Function: H5FDfree * - * Purpose: Frees format addresses starting with ADDR and continuing for - * SIZE bytes in the file FILE. The type of space being freed is - * specified by TYPE, which is mapped to a free list as - * described for the H5FDalloc() function above. If the request - * doesn't map to a free list then either the application `free' - * callback is invoked (if defined) or the memory is leaked. - * - * Return: Success: Non-negative - * - * Failure: Negative + * Purpose: Frees format addresses starting with ADDR and continuing for + * SIZE bytes in the file FILE. The type of space being freed is + * specified by TYPE, which is mapped to a free list as + * described for the H5FDalloc() function above. If the request + * doesn't map to a free list then either the application 'free' + * callback is invoked (if defined) or the memory is leaked. * - * Programmer: Robb Matzke - * Wednesday, July 28, 1999 - * - * Modifications: + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1360,9 +1286,11 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz FUNC_ENTER_API(FAIL) H5TRACE5("e", "*xMtiah", file, type, dxpl_id, addr, size); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid request type") if (H5P_DEFAULT == dxpl_id) @@ -1370,7 +1298,7 @@ H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t siz else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") - /* Do the real work */ + /* Call private function */ /* (Note compensating for base address addition in internal routine) */ if (H5FD_free_real(file, dxpl_id, type, addr - file->base_addr, size) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "file deallocation request failed") @@ -1382,14 +1310,11 @@ done: /*------------------------------------------------------------------------- * Function: H5FDget_eoa * - * Purpose: Returns the address of the first byte after the last - * allocated memory in the file. - * - * Return: Success: First byte after allocated memory. - * Failure: HADDR_UNDEF + * Purpose: Returns the address of the first byte after the last + * allocated memory in the file. * - * Programmer: Robb Matzke - * Friday, July 30, 1999 + * Return: Success: First byte after allocated memory. + * Failure: HADDR_UNDEF * *------------------------------------------------------------------------- */ @@ -1401,13 +1326,15 @@ H5FDget_eoa(H5FD_t *file, H5FD_mem_t type) FUNC_ENTER_API(HADDR_UNDEF) H5TRACE2("a", "*xMt", file, type); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file type") - /* The real work */ + /* Call private function */ if (HADDR_UNDEF == (ret_value = H5FD_get_eoa(file, type))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eoa request failed") @@ -1419,26 +1346,23 @@ done: } /* end H5FDget_eoa() */ /*------------------------------------------------------------------------- - * Function: H5FDset_eoa - * - * Purpose: Set the end-of-address marker for the file. The ADDR is the - * address of the first byte past the last allocated byte of the - * file. This function is called from two places: + * Function: H5FDset_eoa * - * It is called after an existing file is opened in order to - * "allocate" enough space to read the superblock and then - * to "allocate" the entire hdf5 file based on the contents - * of the superblock. + * Purpose: Set the end-of-address marker for the file. The ADDR is the + * address of the first byte past the last allocated byte of the + * file. This function is called from two places: * - * It is called during file memory allocation if the - * allocation request cannot be satisfied from the free list - * and the driver didn't supply an allocation callback. + * It is called after an existing file is opened in order to + * "allocate" enough space to read the superblock and then + * to "allocate" the entire hdf5 file based on the contents + * of the superblock. * - * Return: Success: Non-negative - * Failure: Negative, no side effect + * It is called during file memory allocation if the + * allocation request cannot be satisfied from the free list + * and the driver didn't supply an allocation callback. * - * Programmer: Robb Matzke - * Friday, July 30, 1999 + * Return: Success: Non-negative + * Failure: Negative, no side effect * *------------------------------------------------------------------------- */ @@ -1450,15 +1374,17 @@ H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t addr) FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xMta", file, type, addr); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") if (type < H5FD_MEM_DEFAULT || type >= H5FD_MEM_NTYPES) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file type") if (!H5F_addr_defined(addr) || addr > file->maxaddr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid end-of-address value") - /* The real work */ + /* Call private function */ /* (Note compensating for base address addition in internal routine) */ if (H5FD_set_eoa(file, type, addr - file->base_addr) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "file set eoa request failed") @@ -1470,26 +1396,21 @@ done: /*------------------------------------------------------------------------- * Function: H5FDget_eof * - * Purpose: Returns the end-of-file address, which is the greater of the - * end-of-format address and the actual EOF marker. This - * function is called after an existing file is opened in order - * for the library to learn the true size of the underlying file - * and to determine whether the hdf5 data has been truncated. + * Purpose: Returns the end-of-file address, which is the greater of the + * end-of-format address and the actual EOF marker. This + * function is called after an existing file is opened in order + * for the library to learn the true size of the underlying file + * and to determine whether the hdf5 data has been truncated. * - * It is also used when a file is first opened to learn whether - * the file is empty or not. + * It is also used when a file is first opened to learn whether + * the file is empty or not. * - * It is permissible for the driver to return the maximum address - * for the file size if the file is not empty. + * It is permissible for the driver to return the maximum address + * for the file size if the file is not empty. * - * Return: Success: The EOF address. + * Return: Success: The EOF address. * - * Failure: HADDR_UNDEF - * - * Programmer: Robb Matzke - * Thursday, July 29, 1999 - * - * Modifications: + * Failure: HADDR_UNDEF * *------------------------------------------------------------------------- */ @@ -1502,10 +1423,12 @@ H5FDget_eof(H5FD_t *file) H5TRACE1("a", "*x", file); /* Check arguments */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "invalid file pointer") + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, HADDR_UNDEF, "file class pointer cannot be NULL") - /* The real work */ + /* Call private function */ if (HADDR_UNDEF == (ret_value = H5FD_get_eof(file))) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "file get eof request failed") @@ -1519,23 +1442,21 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_get_maxaddr * - * Purpose: Private version of H5FDget_eof() - * - * Return: Success: The maximum address allowed in the file. - * Failure: HADDR_UNDEF + * Purpose: Private version of H5FDget_eof() * - * Programmer: Quincey Koziol - * Thursday, January 3, 2008 + * Return: Success: The maximum address allowed in the file. + * Failure: HADDR_UNDEF * *------------------------------------------------------------------------- */ haddr_t H5FD_get_maxaddr(const H5FD_t *file) { - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) + /* Sanity checks */ HDassert(file); /* Set return value */ @@ -1548,13 +1469,9 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_get_feature_flags * - * Purpose: Retrieve the feature flags for the VFD - * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Retrieve the feature flags for the VFD * - * Programmer: Quincey Koziol - * Tuesday, January 8, 2008 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1563,6 +1480,7 @@ H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags) { FUNC_ENTER_NOAPI_NOINIT_NOERR + /* Sanity checks */ HDassert(file); HDassert(feature_flags); @@ -1575,13 +1493,9 @@ H5FD_get_feature_flags(const H5FD_t *file, unsigned long *feature_flags) /*------------------------------------------------------------------------- * Function: H5FD_get_fs_type_map * - * Purpose: Retrieve the free space type mapping for the VFD + * Purpose: Retrieve the free space type mapping for the VFD * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Thursday, January 17, 2008 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1592,8 +1506,9 @@ H5FD_get_fs_type_map(const H5FD_t *file, H5FD_mem_t *type_map) FUNC_ENTER_NOAPI(FAIL) - /* Sanity check */ - HDassert(file && file->cls); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); HDassert(type_map); /* Check for VFD class providing a type map retrieval rouine */ @@ -1613,19 +1528,17 @@ done: /*------------------------------------------------------------------------- * Function: H5FDread * - * Purpose: Reads SIZE bytes from FILE beginning at address ADDR - * according to the data transfer property list DXPL_ID (which may - * be the constant H5P_DEFAULT). The result is written into the - * buffer BUF. + * Purpose: Reads SIZE bytes from FILE beginning at address ADDR + * according to the data transfer property list DXPL_ID (which may + * be the constant H5P_DEFAULT). The result is written into the + * buffer BUF. * - * Return: Success: Non-negative. The read result is written into - * the BUF buffer which should be allocated by - * the caller. + * Return: Success: Non-negative + * The read result is written into the BUF buffer + * which should be allocated by the caller. * - * Failure: Negative. The contents of BUF is undefined. - * - * Programmer: Robb Matzke - * Thursday, July 29, 1999 + * Failure: Negative + * The contents of BUF are undefined. * *------------------------------------------------------------------------- */ @@ -1638,23 +1551,25 @@ H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiazx", file, type, dxpl_id, addr, size, buf); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") + if (!buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") - if (!buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null result buffer") /* Get the DXPL plist object for DXPL ID */ if (NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - /* Do the real work */ + /* Call private function */ /* (Note compensating for base address addition in internal routine) */ if (H5FD_read(file, dxpl, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_READERROR, FAIL, "file read request failed") @@ -1666,17 +1581,12 @@ done: /*------------------------------------------------------------------------- * Function: H5FDwrite * - * Purpose: Writes SIZE bytes to FILE beginning at address ADDR according - * to the data transfer property list DXPL_ID (which may be the - * constant H5P_DEFAULT). The bytes to be written come from the - * buffer BUF. + * Purpose: Writes SIZE bytes to FILE beginning at address ADDR according + * to the data transfer property list DXPL_ID (which may be the + * constant H5P_DEFAULT). The bytes to be written come from the + * buffer BUF. * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Thursday, July 29, 1999 + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1689,22 +1599,25 @@ H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t siz FUNC_ENTER_API(FAIL) H5TRACE6("e", "*xMtiaz*x", file, type, dxpl_id, addr, size, buf); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") + if (!buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "result buffer parameter can't be NULL") + /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") - if (!buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null buffer") /* Get the DXPL plist object for DXPL ID */ if (NULL == (dxpl = (H5P_genplist_t *)H5I_object(dxpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - /* The real work */ + /* Call private function */ /* (Note compensating for base address addition in internal routine) */ if (H5FD_write(file, dxpl, type, addr - file->base_addr, size, buf) < 0) HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "file write request failed") @@ -1716,19 +1629,10 @@ done: /*------------------------------------------------------------------------- * Function: H5FDflush * - * Purpose: Notify driver to flush all cached data. If the driver has no - * flush method then nothing happens. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Robb Matzke - * Thursday, July 29, 1999 + * Purpose: Notify driver to flush all cached data. If the driver has no + * flush method then nothing happens. * - * Modifications: - * Quincey Koziol, May 20, 2002 - * Added 'closing' parameter + * Return: Non-negative on success/Negative on failureL * *------------------------------------------------------------------------- */ @@ -1740,9 +1644,12 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing) FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xiIu", file, dxpl_id, closing); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") + if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) @@ -1754,18 +1661,14 @@ H5FDflush(H5FD_t *file, hid_t dxpl_id, unsigned closing) done: FUNC_LEAVE_API(ret_value) -} +} /* end H5FDflush() */ /*------------------------------------------------------------------------- * Function: H5FD_flush * - * Purpose: Private version of H5FDflush() - * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Private version of H5FDflush() * - * Programmer: Robb Matzke - * Wednesday, August 4, 1999 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1776,8 +1679,11 @@ H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing) FUNC_ENTER_NOAPI(FAIL) - HDassert(file && file->cls); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); + /* Dispatch to driver */ if (file->cls->flush && (file->cls->flush)(file, dxpl_id, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed") @@ -1788,13 +1694,9 @@ done: /*------------------------------------------------------------------------- * Function: H5FDtruncate * - * Purpose: Notify driver to truncate the file back to the allocated size. + * Purpose: Notify driver to truncate the file back to the allocated size. * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Thursday, January 31, 2008 + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ @@ -1806,32 +1708,30 @@ H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) FUNC_ENTER_API(FAIL) H5TRACE3("e", "*xib", file, dxpl_id, closing); - /* Check args */ - if (!file || !file->cls) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file pointer") + /* Check arguments */ + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") if (H5P_DEFAULT == dxpl_id) dxpl_id = H5P_DATASET_XFER_DEFAULT; else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data transfer property list") - /* Do the real work */ + /* Call private function */ if (H5FD_truncate(file, dxpl_id, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "file flush request failed") done: FUNC_LEAVE_API(ret_value) -} +} /* end H5FDtruncate() */ /*------------------------------------------------------------------------- * Function: H5FD_truncate * - * Purpose: Private version of H5FDtruncate() - * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Private version of H5FDtruncate() * - * Programmer: Quincey Koziol - * Thursday, January 31, 2008 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1842,8 +1742,11 @@ H5FD_truncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing) FUNC_ENTER_NOAPI(FAIL) - HDassert(file && file->cls); + /* Sanity checks */ + HDassert(file); + HDassert(file->cls); + /* Dispatch to driver */ if (file->cls->truncate && (file->cls->truncate)(file, dxpl_id, closing) < 0) HGOTO_ERROR(H5E_VFL, H5E_CANTUPDATE, FAIL, "driver truncate request failed") @@ -1854,14 +1757,11 @@ done: /*------------------------------------------------------------------------- * Function: H5FD_get_fileno * - * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value - * (Mainly added to stop non-file routines from poking about in the - * H5FD_t data structure) + * Purpose: Quick and dirty routine to retrieve the file's 'fileno' value + * (Mainly added to stop non-file routines from poking about in the + * H5FD_t data structure) * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * March 27, 2002 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1870,6 +1770,7 @@ H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum) { FUNC_ENTER_NOAPI_NOINIT_NOERR + /* Sanity checks */ HDassert(file); HDassert(filenum); @@ -1885,59 +1786,62 @@ H5FD_get_fileno(const H5FD_t *file, unsigned long *filenum) * Purpose: Returns a pointer to the file handle of low-level virtual * file driver. * - * Return: Non-negative if succeed; negative otherwise. - * - * Programmer: Raymond Lu - * Sep. 16, 2002 - * - * Modifications: + * Return: Non-negative on success/Negative on failure * *-------------------------------------------------------------------------- */ herr_t -H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle) +H5FDget_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle) { - herr_t ret_value; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) - H5TRACE3("e", "*xi**x", file, fapl, file_handle); + H5TRACE3("e", "*xi**x", file, fapl_id, file_handle); /* Check arguments */ - HDassert(file); - HDassert(file_handle); - - ret_value = H5FD_get_vfd_handle(file, fapl, file_handle); + if (!file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file pointer cannot be NULL") + if (!file->cls) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file class pointer cannot be NULL") + if (!file_handle) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file handle parameter cannot be NULL") + + /* Call private function */ + if (H5FD_get_vfd_handle(file, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: + if (FAIL == ret_value) + *file_handle = NULL; + FUNC_LEAVE_API(ret_value) } /* end H5FDget_vfd_handle() */ /*-------------------------------------------------------------------------- * Function: H5FD_get_vfd_handle * - * Purpose: Retrieve the file handle for file driver. + * Purpose: Private version of H5FDget_vfd_handle() * - * Return: Non-negative if succeed; negative if fails. - * - * Programmer: Raymond Lu - * Sep. 16, 2002 + * Return: SUCCEED/FAIL * *-------------------------------------------------------------------------- */ herr_t -H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl, void **file_handle) +H5FD_get_vfd_handle(H5FD_t *file, hid_t fapl_id, void **file_handle) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* Sanity check */ + /* Sanity checks */ HDassert(file); + HDassert(file->cls); HDassert(file_handle); + /* Dispatch to driver */ if (NULL == file->cls->get_handle) HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "file driver has no `get_vfd_handle' method") - if ((file->cls->get_handle)(file, fapl, file_handle) < 0) + if ((file->cls->get_handle)(file, fapl_id, file_handle) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file handle for file driver") done: @@ -1949,10 +1853,7 @@ done: * * Purpose: Set the base address for the file * - * Return: Non-negative if succeed; negative if fails. - * - * Programmer: Quincey Koziol - * Jan. 17, 2008 + * Return: SUCCEED (Can't fail) * *-------------------------------------------------------------------------- */ @@ -1961,6 +1862,7 @@ H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr) { FUNC_ENTER_NOAPI_NOINIT_NOERR + /* Sanity checks */ HDassert(file); HDassert(H5F_addr_defined(base_addr)); @@ -1975,11 +1877,8 @@ H5FD_set_base_addr(H5FD_t *file, haddr_t base_addr) * * Purpose: Get the base address for the file * - * Return: Success: The absolute base address of the file - * Failure: The undefined address (HADDR_UNDEF) - * - * Programmer: Quincey Koziol - * Sept. 10, 2009 + * Return: Success: The absolute base address of the file + * (Can't fail) * *-------------------------------------------------------------------------- */ @@ -1988,6 +1887,7 @@ H5FD_get_base_addr(const H5FD_t *file) { FUNC_ENTER_NOAPI_NOINIT_NOERR + /* Sanity checks */ HDassert(file); /* Return the file's base address */ @@ -2002,7 +1902,7 @@ H5FD_get_base_addr(const H5FD_t *file) * can't use the file to get the driver, the driver ID is passed * in as a parameter. * - * Return: SUCCEED/FAIL + * Return: Non-negative on success/Negative on failure * *------------------------------------------------------------------------- */ diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 0896620..fad26ec 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -235,7 +235,7 @@ H5FD_core_add_dirty_region(H5FD_core_t *file, haddr_t start, haddr_t end) * just update an existing one instead. */ create_new_node = FALSE; - } + } /* end if */ /* Remove any old nodes that are no longer needed */ while (a_item && a_item->start > start) { @@ -1337,9 +1337,8 @@ H5FD_core_flush(H5FD_t *_file, hid_t H5_ATTR_UNUSED dxpl_id, unsigned H5_ATTR_UN } /* end if */ /* Otherwise, write the entire file out at once */ - else - if (H5FD_core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) - HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") + else if (H5FD_core_write_to_bstore(file, (haddr_t)0, (size_t)file->eof) != SUCCEED) + HGOTO_ERROR(H5E_VFL, H5E_WRITEERROR, FAIL, "unable to write to backing store") file->dirty = FALSE; } diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index b6004a1..d5a375d 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -289,7 +289,7 @@ static herr_t H5FD_hdfs_truncate(H5FD_t *_file, hid_t dxpl_id, hbool_t closing) static herr_t H5FD_hdfs_lock(H5FD_t *_file, hbool_t rw); static herr_t H5FD_hdfs_unlock(H5FD_t *_file); -static herr_t H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t *fa); +static herr_t H5FD_hdfs_validate_config(const H5FD_hdfs_fapl_t *fa); static const H5FD_class_t H5FD_hdfs_g = { "hdfs", /* name */ diff --git a/src/H5FDint.c b/src/H5FDint.c index 9706a66..4f0f5a5 100644 --- a/src/H5FDint.c +++ b/src/H5FDint.c @@ -32,11 +32,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FDpkg.h" /* File Drivers */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FDpkg.h" /* File Drivers */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ diff --git a/src/H5FL.c b/src/H5FL.c index 8c110ed..d9cb5c6 100644 --- a/src/H5FL.c +++ b/src/H5FL.c @@ -185,7 +185,7 @@ H5FL_init_interface(void) static void * H5FL_malloc(size_t mem_size) { - void *ret_value; /* return value*/ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -258,8 +258,7 @@ done: * * Purpose: Release an object & put on free list * - * Return: Success: Non-negative - * Failure: Negative + * Return: Always returns NULL * * Programmer: Quincey Koziol * Friday, March 24, 2000 @@ -353,7 +352,7 @@ done: void * H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -427,7 +426,7 @@ done: void * H5FL_reg_calloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to object to return */ FUNC_ENTER_NOAPI(NULL) @@ -505,10 +504,6 @@ H5FL_reg_gc_list(H5FL_reg_head_t *head) * Programmer: Quincey Koziol * Friday, March 24, 2000 * - * Modifications: - * Broke into two parts, one for looping over all the free lists and - * another for freeing each list - QAK 7/25/00 - * *------------------------------------------------------------------------- */ static herr_t @@ -629,7 +624,7 @@ H5FL_reg_term(void) static H5FL_blk_node_t * H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size) { - H5FL_blk_node_t *temp; /* Temp. pointer to node in the native list */ + H5FL_blk_node_t *temp = NULL; /* Temp. pointer to node in the native list */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -687,8 +682,8 @@ H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size) static H5FL_blk_node_t * H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size) { - H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */ - H5FL_blk_node_t *ret_value; + H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */ + H5FL_blk_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -775,8 +770,8 @@ done: htri_t H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - htri_t ret_value; /* Return value */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -812,9 +807,9 @@ done: void * H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { - H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ - H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ - void * ret_value; /* Pointer to the block to return to the user */ + H5FL_blk_node_t *free_list; /* The free list of nodes of correct size */ + H5FL_blk_list_t *temp; /* Temp. ptr to the new native list allocated */ + void * ret_value = NULL; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(NULL) @@ -900,7 +895,7 @@ done: void * H5FL_blk_calloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to the block to return to the user */ + void *ret_value = NULL; /* Pointer to the block to return to the user */ FUNC_ENTER_NOAPI(NULL) @@ -988,7 +983,7 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block) HDmemset(temp, 255, free_size + sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE); #endif /* H5FL_DEBUG */ - /* check if there is a free list for native blocks of this size */ + /* Check if there is a free list for native blocks of this size */ if ((free_list = H5FL_blk_find_list(&(head->head), free_size)) == NULL) { /* No free list available, create a new list node and insert it to the queue */ free_list = H5FL_blk_create_list(&(head->head), free_size); @@ -1230,8 +1225,8 @@ H5FL_blk_term(void) tmp = H5FL_blk_gc_head.first->next; #ifdef H5FL_DEBUG - printf("H5FL_blk_term: head->name=%s, head->allocated=%d\n", H5FL_blk_gc_head.first->pq->name, - (int)H5FL_blk_gc_head.first->pq->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.first->pq->name, + (int)H5FL_blk_gc_head.first->pq->allocated); #endif /* H5FL_DEBUG */ /* Check if the list has allocations outstanding */ @@ -1402,9 +1397,9 @@ done: void * H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem) { - H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ - void * ret_value; /* Pointer to object to return */ - size_t mem_size; /* Size of memory block being recycled */ + H5FL_arr_list_t *new_obj; /* Pointer to the new free list node allocated */ + size_t mem_size; /* Size of memory block being recycled */ + void * ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1474,7 +1469,7 @@ done: void * H5FL_arr_calloc(H5FL_arr_head_t *head, size_t elem) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1509,7 +1504,7 @@ done: void * H5FL_arr_realloc(H5FL_arr_head_t *head, void *obj, size_t new_elem) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1685,8 +1680,8 @@ H5FL_arr_term(void) /* Check if the list has allocations outstanding */ #ifdef H5FL_DEBUG - printf("H5FL_arr_term: head->name=%s, head->allocated=%d\n", H5FL_arr_gc_head.first->list->name, - (int)H5FL_arr_gc_head.first->list->allocated); + HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.first->list->name, + (int)H5FL_arr_gc_head.first->list->allocated); #endif /* H5FL_DEBUG */ if (H5FL_arr_gc_head.first->list->allocated > 0) { /* Add free list to the list of nodes with allocations open still */ @@ -1763,7 +1758,7 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj) void * H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1794,7 +1789,7 @@ done: void * H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1825,7 +1820,7 @@ done: void * H5FL_seq_realloc(H5FL_seq_head_t *head, void *obj, size_t new_elem H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ FUNC_ENTER_NOAPI(NULL) @@ -1851,19 +1846,14 @@ done: * Programmer: Quincey Koziol * Wednesday, February 2, 2005 * - * Modifications: - * Neil Fortner - * Friday, December 19, 2008 - * Totally rewritten to support new factory implementation - * *------------------------------------------------------------------------- */ H5FL_fac_head_t * H5FL_fac_init(size_t size) { - H5FL_fac_gc_node_t *new_node = NULL; /* Pointer to the node for the new list to garbage collect */ - H5FL_fac_head_t * factory = NULL; /* Pointer to new block factory */ - H5FL_fac_head_t * ret_value; /* Return value */ + H5FL_fac_gc_node_t *new_node = NULL; /* Pointer to the node for the new list to garbage collect */ + H5FL_fac_head_t * factory = NULL; /* Pointer to new block factory */ + H5FL_fac_head_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1927,11 +1917,6 @@ done: * Programmer: Quincey Koziol * Wednesday, February 2, 2005 * - * Modifications: - * Neil Fortner - * Friday, December 19, 2008 - * Totally rewritten to support new factory implementation - * *------------------------------------------------------------------------- */ void * @@ -2015,11 +2000,6 @@ done: * Programmer: Quincey Koziol * Wednesday, February 2, 2005 * - * Modifications: - * Neil Fortner - * Friday, December 19, 2008 - * Totally rewritten to support new factory implementation - * *------------------------------------------------------------------------- */ void * @@ -2091,17 +2071,12 @@ done: * Programmer: Quincey Koziol * Wednesday, February 2, 2005 * - * Modifications: - * Neil Fortner - * Friday, December 19, 2008 - * Totally rewritten to support new factory implementation - * *------------------------------------------------------------------------- */ void * H5FL_fac_calloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS) { - void *ret_value; /* Pointer to object to return */ + void *ret_value = NULL; /* Pointer to the block to return */ /* NOINIT OK here because this must be called after H5FL_fac_init -NAF */ FUNC_ENTER_NOAPI_NOINIT @@ -2219,11 +2194,6 @@ done: * Programmer: Quincey Koziol * Wednesday, February 2, 2005 * - * Modifications: - * Neil Fortner - * Friday, December 19, 2008 - * Totally rewritten to support new factory implementation - * *------------------------------------------------------------------------- */ herr_t @@ -2383,10 +2353,6 @@ done: * Programmer: Quincey Koziol * Wednesday, August 2, 2000 * - * Modifications: Neil Fortner - * Wednesday, April 8, 2009 - * Added support for factory free lists - * *------------------------------------------------------------------------- */ herr_t diff --git a/src/H5FS.c b/src/H5FS.c index 42e9234..c082bdf 100644 --- a/src/H5FS.c +++ b/src/H5FS.c @@ -30,11 +30,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FSpkg.h" /* File free space */ -#include "H5MFprivate.h" /* File memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FSpkg.h" /* File free space */ +#include "H5MFprivate.h" /* File memory management */ /****************/ /* Local Macros */ @@ -512,9 +512,9 @@ done: H5FS_t * H5FS_new(const H5F_t *f, size_t nclasses, const H5FS_section_class_t *classes[], void *cls_init_udata) { - H5FS_t *fspace = NULL; /* Free space manager */ - size_t u; /* Local index variable */ - H5FS_t *ret_value; /* Return value */ + H5FS_t *fspace = NULL; /* Free space manager */ + size_t u; /* Local index variable */ + H5FS_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -610,8 +610,7 @@ H5FS_size(const H5F_t *f, const H5FS_t *fspace, hsize_t *meta_size) * * Purpose: Increment reference count on free space header * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * February 7, 2008 @@ -650,8 +649,7 @@ done: * * Purpose: Decrement reference count on free space header * - * Return: Success: non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * February 7, 2008 diff --git a/src/H5FSsection.c b/src/H5FSsection.c index 43213f0..7cfe9a2 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -111,8 +111,8 @@ H5FL_DEFINE(H5FS_sinfo_t); H5FS_sinfo_t * H5FS_sinfo_new(H5F_t *f, H5FS_t *fspace) { - H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ - H5FS_sinfo_t *ret_value; /* Return value */ + H5FS_sinfo_t *sinfo = NULL; /* Section information struct created */ + H5FS_sinfo_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5FStest.c b/src/H5FStest.c index de2d447..1b1a090 100644 --- a/src/H5FStest.c +++ b/src/H5FStest.c @@ -103,7 +103,7 @@ H5FS_get_cparam_test(const H5FS_t *frsp, H5FS_create_t *cparam) int H5FS_cmp_cparam_test(const H5FS_create_t *cparam1, const H5FS_create_t *cparam2) { - int ret_value = SUCCEED; /* Return value */ + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5Faccum.c b/src/H5Faccum.c index 6fd4392..1dd8924 100644 --- a/src/H5Faccum.c +++ b/src/H5Faccum.c @@ -15,7 +15,7 @@ * * Created: H5Faccum.c * Jan 10 2008 - * Quincey Koziol + * Quincey Koziol * * Purpose: File metadata "accumulator" routines. (Used to * cache small metadata I/Os and group them into a @@ -94,7 +94,6 @@ H5FL_BLK_DEFINE_STATIC(meta_accum); * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jan 10 2008 * *------------------------------------------------------------------------- @@ -267,7 +266,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jun 11 2009 * *------------------------------------------------------------------------- @@ -412,7 +410,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jan 10 2008 * *------------------------------------------------------------------------- @@ -849,7 +846,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jan 10 2008 * *------------------------------------------------------------------------- @@ -1016,7 +1012,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jan 10 2008 * *------------------------------------------------------------------------- @@ -1058,7 +1053,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jan 10 2008 * *------------------------------------------------------------------------- diff --git a/src/H5Fcwfs.c b/src/H5Fcwfs.c index 7241430..0478a10 100644 --- a/src/H5Fcwfs.c +++ b/src/H5Fcwfs.c @@ -12,7 +12,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Tuesday, July 19, 2011 * * Purpose: Each file has a small cache of global heap collections called diff --git a/src/H5Fdbg.c b/src/H5Fdbg.c index b437352..a24e679 100644 --- a/src/H5Fdbg.c +++ b/src/H5Fdbg.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* Programmer: Quincey Koziol +/* Programmer: Quincey Koziol * Wednesday, July 9, 2003 * * Purpose: File object debugging functions. @@ -37,7 +37,6 @@ * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Aug 1 1997 * *------------------------------------------------------------------------- diff --git a/src/H5Fefc.c b/src/H5Fefc.c index ebbc911..52183bd 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -87,8 +87,8 @@ H5FL_DEFINE_STATIC(H5F_efc_t); H5F_efc_t * H5F_efc_create(unsigned max_nfiles) { - H5F_efc_t *efc = NULL; /* EFC object */ - H5F_efc_t *ret_value; /* Return value */ + H5F_efc_t *efc = NULL; /* EFC object */ + H5F_efc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Ffake.c b/src/H5Ffake.c index 1d7633e..4bdc431 100644 --- a/src/H5Ffake.c +++ b/src/H5Ffake.c @@ -63,8 +63,8 @@ H5F_init_fake_interface(void) H5F_t * H5F_fake_alloc(uint8_t sizeof_size) { - H5F_t *f = NULL; /* Pointer to fake file struct */ - H5F_t *ret_value; /* Return value */ + H5F_t *f = NULL; /* Pointer to fake file struct */ + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5Fint.c b/src/H5Fint.c index 761c387..37766bf 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -23,33 +23,33 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /* Predefined file drivers */ -#include "H5FDcore.h" /*temporary in-memory files */ -#include "H5FDfamily.h" /*family of files */ -#include "H5FDlog.h" /* sec2 driver with logging, for debugging */ -#include "H5FDmpi.h" /* MPI-based file drivers */ -#include "H5FDmulti.h" /*multiple files partitioned by mem usage */ -#include "H5FDsec2.h" /*Posix unbuffered I/O */ -#include "H5FDstdio.h" /* Standard C buffered I/O */ +#include "H5FDcore.h" /* temporary in-memory files */ +#include "H5FDfamily.h" /* family of files */ +#include "H5FDlog.h" /* sec2 driver with logging, for debugging */ +#include "H5FDmpi.h" /* MPI-based file drivers */ +#include "H5FDmulti.h" /* multiple files partitioned by mem usage */ +#include "H5FDsec2.h" /* Posix unbuffered I/O */ +#include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS -#include "H5FDwindows.h" /* Windows buffered I/O */ +#include "H5FDwindows.h" /* Windows buffered I/O */ #endif -#include "H5FDdirect.h" /*Linux direct I/O */ +#include "H5FDdirect.h" /* Linux direct I/O */ /****************/ /* Local Macros */ @@ -107,14 +107,14 @@ H5FL_DEFINE(H5F_t); H5FL_DEFINE(H5F_file_t); /*------------------------------------------------------------------------- - * Function: H5F_init_interface + * Function: H5F_init_interface * - * Purpose: Initialize interface-specific information. + * Purpose: Initialize interface-specific information. * - * Return: Success: non-negative - * Failure: negative + * Return: Success: non-negative + * Failure: negative * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, November 20, 1998 * *------------------------------------------------------------------------- @@ -130,26 +130,19 @@ H5F_init_interface(void) } /* end H5F_init_interface() */ /*------------------------------------------------------------------------- - * Function: H5F_get_access_plist + * Function: H5F_get_access_plist * - * Purpose: Returns a copy of the file access property list of the - * specified file. + * Purpose: Returns a copy of the file access property list of the + * specified file. * * NOTE: Make sure that, if you are going to overwrite * information in the copied property list that was * previously opened and assigned to the property list, then * you must close it before overwriting the values. * - * Return: Success: Object ID for a copy of the file access - * property list. - * - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Wednesday, May 25, 2005 - * - * Modifications: - * + * Return: Success: Object ID for a copy of the file access + * property list. + * Failure: H5I_INVALID_HID *------------------------------------------------------------------------- */ hid_t @@ -159,75 +152,76 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) H5P_genplist_t *old_plist; /* Old property list */ void * driver_info = NULL; unsigned efc_size = 0; - hid_t ret_value = SUCCEED; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Check args */ HDassert(f); /* Make a copy of the default file access property list */ if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") if ((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy file access property list") + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, H5I_INVALID_HID, "can't copy file access property list") if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Copy properties of the file access property list */ if (H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set initial metadata cache resize config.") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, + "can't set initial metadata cache resize config.") if (H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache number of slots") if (H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache byte size") if (H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set preempt read chunks") if (H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment threshold") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment threshold") if (H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set alignment") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment") if (H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set garbage collect reference") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set garbage collect reference") if (H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache size") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set metadata cache size") if (H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't sieve buffer size") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't sieve buffer size") if (H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'small data' cache size") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set 'small data' cache size") if (H5P_set(new_plist, H5F_ACS_LATEST_FORMAT_NAME, &(f->shared->latest_format)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set 'latest format' flag") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set 'latest format' flag") if (f->shared->efc) efc_size = H5F_efc_max_nfiles(f->shared->efc); if (H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set elink file cache size") /* * Since we're resetting the driver ID and info, close them if they * exist in this new property list. */ if (H5P_facc_close(ret_value, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information") + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, H5I_INVALID_HID, "can't free the old driver information") /* Increment the reference count on the driver ID and insert it into the property list */ if (H5I_inc_ref(f->shared->lf->driver_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver") + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VFL driver") if (H5P_set(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &(f->shared->lf->driver_id)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver ID") /* Set the driver "info" in the property list */ driver_info = H5FD_fapl_get(f->shared->lf); if (driver_info != NULL && H5P_set(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver info") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver info") /* Set the file close degree appropriately */ if (f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") } else if (f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) { - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") } done: @@ -235,16 +229,12 @@ done: } /* end H5F_get_access_plist() */ /*------------------------------------------------------------------------- - * Function: H5F_get_obj_count + * Function: H5F_get_obj_count * - * Purpose: Private function return the number of opened object IDs - * (files, datasets, groups, datatypes) in the same file. + * Purpose: Private function return the number of opened object IDs + * (files, datasets, groups, datatypes) in the same file. * * Return: SUCCEED on success, FAIL on failure. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 - * *------------------------------------------------------------------------- */ herr_t @@ -271,10 +261,6 @@ done: * Purpose: Private function to return a list of opened object IDs. * * Return: Non-negative on success; can't fail. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 - * *------------------------------------------------------------------------- */ herr_t @@ -297,16 +283,13 @@ done: } /* end H5F_get_obj_ids() */ /*--------------------------------------------------------------------------- - * Function: H5F_get_objects + * Function: H5F_get_objects * - * Purpose: This function is called by H5F_get_obj_count or - * H5F_get_obj_ids to get number of object IDs and/or a - * list of opened object IDs (in return value). - * Return: Non-negative on success; Can't fail. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 + * Purpose: This function is called by H5F_get_obj_count or + * H5F_get_obj_ids to get number of object IDs and/or a + * list of opened object IDs (in return value). * + * Return: SUCCEED/FAIL *--------------------------------------------------------------------------- */ herr_t @@ -367,7 +350,7 @@ H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_ olist.obj_type = H5I_GROUP; if (H5I_iterate(H5I_GROUP, H5F_get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(3)") - } /* end if */ + } } /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), @@ -402,26 +385,22 @@ done: } /* end H5F_get_objects() */ /*------------------------------------------------------------------------- - * Function: H5F_get_objects_cb + * Function: H5F_get_objects_cb * - * Purpose: H5F_get_objects' callback function. It verifies if an - * object is in the file, and either count it or put its ID - * on the list. + * Purpose: H5F_get_objects' callback function. It verifies if an + * object is in the file, and either count it or put its ID + * on the list. * * Return: H5_ITER_STOP if the array of object IDs is filled up. * H5_ITER_CONT otherwise. - * - * Programmer: Raymond Lu - * Wednesday, Dec 5, 2001 - * *------------------------------------------------------------------------- */ static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) { H5F_olist_t *olist = (H5F_olist_t *)key; /* Alias for search info */ - int ret_value = H5_ITER_CONT; /* Return value */ hbool_t add_obj = FALSE; + int ret_value = H5_ITER_CONT; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -437,9 +416,9 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) (!olist->file_info.ptr.shared || (olist->file_info.ptr.shared && ((H5F_t *)obj_ptr)->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; - } + } /* end if */ } /* end if */ - else { /* either count opened object IDs or put the IDs on the list */ + else { /* Either count opened object IDs or put the IDs on the list */ H5O_loc_t *oloc; /* Group entry info for object */ switch (olist->obj_type) { @@ -505,7 +484,8 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) /* Check if we've filled up the array. Return H5_ITER_STOP only if * we have filled up the array. Otherwise return H5_ITER_CONT(RET_VALUE is * preset to H5_ITER_CONT) because H5I_iterate needs the return value of - * H5_ITER_CONT to continue the iteration. */ + * H5_ITER_CONT to continue the iteration. + */ if (olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ } @@ -515,31 +495,23 @@ done: } /* end H5F_get_objects_cb() */ /*------------------------------------------------------------------------- - * Function: H5F_is_hdf5 - * - * Purpose: Check the file signature to detect an HDF5 file. - * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. + * Function: H5F_is_hdf5 * - * Return: Success: TRUE/FALSE + * Purpose: Check the file signature to detect an HDF5 file. * - * Failure: Negative + * Bugs: This function is not robust: it only uses the default file + * driver when attempting to open the file when in fact it + * should use all known file drivers. * - * Programmer: Unknown - * - * Modifications: - * Robb Matzke, 1999-08-02 - * Rewritten to use the virtual file layer. + * Return: TRUE/FALSE/FAIL *------------------------------------------------------------------------- */ htri_t H5F_is_hdf5(const char *name) { - H5FD_t *file = NULL; /* Low-level file struct */ - haddr_t sig_addr; /* Addess of hdf5 file signature */ - htri_t ret_value; /* Return value */ + H5FD_t *file = NULL; /* Low-level file struct */ + haddr_t sig_addr = HADDR_UNDEF; /* Addess of hdf5 file signature */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -562,42 +534,37 @@ done: } /* end H5F_is_hdf5() */ /*------------------------------------------------------------------------- - * Function: H5F_new - * - * Purpose: Creates a new file object and initializes it. The - * H5Fopen and H5Fcreate functions then fill in various - * fields. If SHARED is a non-null pointer then the shared info - * to which it points has the reference count incremented. - * Otherwise a new, empty shared info struct is created and - * initialized with the specified file access property list. - * - * Errors: + * Function: H5F_new * - * Return: Success: Ptr to a new file struct. + * Purpose: Creates a new file object and initializes it. The + * H5Fopen and H5Fcreate functions then fill in various fields. + * If SHARED is a non-null pointer then the shared info + * to which it points has the reference count incremented. + * Otherwise a new, empty shared info struct is created and + * initialized with the specified file access property list. * - * Failure: NULL + * Return: Success: Pointer to a new file struct * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jul 18 1997 + * Failure: NULL * *------------------------------------------------------------------------- */ H5F_t * H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL, *ret_value; + H5F_t *f = NULL; + H5F_t *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT if (NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = -1; + f->file_id = H5I_INVALID_HID; if (shared) { HDassert(lf == NULL); f->shared = shared; - } /* end if */ + } else { H5P_genplist_t *plist; /* Property list */ unsigned efc_size; /* External file cache size */ @@ -726,27 +693,22 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_file_t, f->shared); - } /* end if */ + } f = H5FL_FREE(H5F_t, f); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_new() */ /*------------------------------------------------------------------------- - * Function: H5F_dest - * - * Purpose: Destroys a file structure. This function flushes the cache - * but doesn't do any other cleanup other than freeing memory - * for the file struct. The shared info for the file is freed - * only when its reference count reaches zero. - * - * Return: Non-negative on success/Negative on failure + * Function: H5F_dest * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jul 18 1997 + * Purpose: Destroys a file structure. This function flushes the cache + * but doesn't do any other cleanup other than freeing memory + * for the file struct. The shared info for the file is freed + * only when its reference count reaches zero. * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -888,49 +850,45 @@ H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) } /* end H5F_dest() */ /*------------------------------------------------------------------------- - * Function: H5F_open - * - * Purpose: Opens (or creates) a file. This function understands the - * following flags which are similar in nature to the Posix - * open(2) flags. - * - * H5F_ACC_RDWR: Open with read/write access. If the file is - * currently open for read-only access then it - * will be reopened. Absence of this flag - * implies read-only access. + * Function: H5F_open * - * H5F_ACC_CREAT: Create a new file if it doesn't exist yet. - * The permissions are 0666 bit-wise AND with - * the current umask. H5F_ACC_WRITE must also - * be specified. + * Purpose: Opens (or creates) a file. This function understands the + * following flags which are similar in nature to the Posix + * open(2) flags. * - * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the - * file already exists. + * H5F_ACC_RDWR: Open with read/write access. If the file is + * currently open for read-only access then it + * will be reopened. Absence of this flag + * implies read-only access. * - * H5F_ACC_TRUNC: The file is truncated and a new HDF5 superblock - * is written. This operation will fail if the - * file is already open. + * H5F_ACC_CREAT: Create a new file if it doesn't exist yet. + * The permissions are 0666 bit-wise AND with + * the current umask. H5F_ACC_WRITE must also + * be specified. * - * Unlinking the file name from the group directed graph while - * the file is opened causes the file to continue to exist but - * one will not be able to upgrade the file from read-only - * access to read-write access by reopening it. Disk resources - * for the file are released when all handles to the file are - * closed. NOTE: This paragraph probably only applies to Unix; - * deleting the file name in other OS's has undefined results. + * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the + * file already exists. * - * The CREATE_PARMS argument is optional. A null pointer will - * cause the default file creation parameters to be used. + * H5F_ACC_TRUNC: The file is truncated and a new HDF5 superblock + * is written. This operation will fail if the + * file is already open. * - * The ACCESS_PARMS argument is optional. A null pointer will - * cause the default file access parameters to be used. + * Unlinking the file name from the group directed graph while + * the file is opened causes the file to continue to exist but + * one will not be able to upgrade the file from read-only + * access to read-write access by reopening it. Disk resources + * for the file are released when all handles to the file are + * closed. NOTE: This paragraph probably only applies to Unix; + * deleting the file name in other OS's has undefined results. * - * Return: Success: A new file pointer. - * Failure: NULL + * The CREATE_PARMS argument is optional. A null pointer will + * cause the default file creation parameters to be used. * - * Programmer: Robb Matzke - * Tuesday, September 23, 1997 + * The ACCESS_PARMS argument is optional. A null pointer will + * cause the default file access parameters to be used. * + * Return: Success: A new file pointer. + * Failure: NULL *------------------------------------------------------------------------- */ H5F_t * @@ -1134,15 +1092,11 @@ done: } /* end H5F_open() */ /*------------------------------------------------------------------------- - * Function: H5F_flush + * Function: H5F_flush * - * Purpose: Flushes cached data. + * Purpose: Flushes cached data. * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Aug 29 1997 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1206,26 +1160,11 @@ done: } /* end H5F_flush() */ /*------------------------------------------------------------------------- - * Function: H5F_close - * - * Purpose: Closes a file or causes the close operation to be pended. - * This function is called two ways: from the API it gets called - * by H5Fclose->H5I_dec_ref->H5F_close when H5I_dec_ref() - * decrements the file ID reference count to zero. The file ID - * is removed from the H5I_FILE group by H5I_dec_ref() just - * before H5F_close() is called. If there are open object - * headers then the close is pended by moving the file to the - * H5I_FILE_CLOSING ID group (the f->closing contains the ID - * assigned to file). + * Function: H5F_close * - * This function is also called directly from H5O_close() when - * the last object header is closed for the file and the file - * has a pending close. + * Purpose: Internal routine to close a file. * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Tuesday, September 23, 1997 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1242,7 +1181,8 @@ H5F_close(H5F_t *f) 0); /* This routine should only be called when a file ID's ref count drops to zero */ /* Perform checks for "semi" file close degree here, since closing the - * file is not allowed if there are objects still open */ + * file is not allowed if there are objects still open. + */ if (f->shared->fc_degree == H5F_CLOSE_SEMI) { unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ @@ -1254,10 +1194,11 @@ H5F_close(H5F_t *f) /* If there are no other file IDs open on this file/mount hier., but * there are still open objects, issue an error and bail out now, * without decrementing the file ID's reference count and triggering - * a "real" attempt at closing the file */ + * a "real" attempt at closing the file. + */ if (nopen_files == 1 && nopen_objs > 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") - } /* end if */ + } /* Reset the file ID for this file */ f->file_id = -1; @@ -1271,17 +1212,14 @@ done: } /* end H5F_close() */ /*------------------------------------------------------------------------- - * Function: H5F_try_close + * Function: H5F_try_close * - * Purpose: Attempts to close a file due to one of several actions: - * - The reference count on the file ID dropped to zero - * - The last open object was closed in the file - * - The file was unmounted + * Purpose: Attempts to close a file due to one of several actions: + * - The reference count on the file ID dropped to zero + * - The last open object was closed in the file + * - The file was unmounted * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Tuesday, July 19, 2005 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1309,12 +1247,12 @@ H5F_try_close(H5F_t *f) /* * Close file according to close degree: * - * H5F_CLOSE_WEAK: if there are still objects open, wait until - * they are all closed. - * H5F_CLOSE_SEMI: if there are still objects open, return fail; - * otherwise, close file. - * H5F_CLOSE_STRONG: if there are still objects open, close them - * first, then close file. + * H5F_CLOSE_WEAK: if there are still objects open, wait until + * they are all closed. + * H5F_CLOSE_SEMI: if there are still objects open, return fail; + * otherwise, close file. + * H5F_CLOSE_STRONG: if there are still objects open, close them + * first, then close file. */ switch (f->shared->fc_degree) { case H5F_CLOSE_WEAK: @@ -1334,7 +1272,8 @@ H5F_try_close(H5F_t *f) HGOTO_DONE(SUCCEED) /* Sanity check: If close degree if "semi" and we have gotten this - * far and there are objects left open, bail out now */ + * far and there are objects left open, bail out now. + */ HDassert(nopen_files == 0 && nopen_objs == 0); /* If we've gotten this far (ie. there are no open objects in the file), fall through to flush & @@ -1379,7 +1318,7 @@ H5F_try_close(H5F_t *f) for (u = 0; u < obj_count; u++) if (H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") - } /* end while */ + } if (result < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(1)") @@ -1397,7 +1336,7 @@ H5F_try_close(H5F_t *f) for (u = 0; u < obj_count; u++) if (H5I_dec_ref(objs[u]) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't close object") - } /* end while */ + } if (result < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed(2)") } /* end if */ @@ -1416,14 +1355,16 @@ H5F_try_close(H5F_t *f) /* If there is more than one reference to the shared file struct and the * file has an external file cache, we should see if it can be closed. This - * can happen if a cycle is formed with external file caches */ + * can happen if a cycle is formed with external file caches. + */ if (f->shared->efc && (f->shared->nrefs > 1)) if (H5F_efc_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't attempt to close EFC") /* Delay flush until the shared file struct is closed, in H5F_dest. If the * application called H5Fclose, it would have been flushed in that function - * (unless it will have been flushed in H5F_dest anyways). */ + * (unless it will have been flushed in H5F_dest anyways). + */ /* * Destroy the H5F_t struct and decrement the reference count for the @@ -1438,36 +1379,35 @@ done: } /* end H5F_try_close() */ /*------------------------------------------------------------------------- - * Function: H5F_get_id + * Function: H5F_get_id * - * Purpose: Get the file ID, incrementing it, or "resurrecting" it as + * Purpose: Get the file ID, incrementing it, or "resurrecting" it as * appropriate. * - * Return: Non-negative on success/Negative on failure + * Return: Success: An ID for a file * - * Programmer: Raymond Lu - * Oct 29, 2003 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5F_get_id(H5F_t *file, hbool_t app_ref) { - hid_t ret_value; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT HDassert(file); - if (file->file_id == -1) { + if (file->file_id == H5I_INVALID_HID) { /* Get an atom for the file */ if ((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file") } else { - /* Increment reference count on atom. */ + /* Increment reference count on existing ID */ if (H5I_inc_ref(file->file_id, app_ref) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") } /* end else */ ret_value = file->file_id; @@ -1477,18 +1417,12 @@ done: } /* end H5F_get_id() */ /*------------------------------------------------------------------------- - * Function: H5F_incr_nopen_objs - * - * Purpose: Increment the number of open objects for a file. - * - * Return: Success: The number of open objects, after the increment + * Function: H5F_incr_nopen_objs * - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 6 2007 + * Purpose: Increment the number of open objects for a file. * + * Return: Success: The number of open objects, after the increment + * Failure: (can't happen) *------------------------------------------------------------------------- */ unsigned @@ -1503,18 +1437,12 @@ H5F_incr_nopen_objs(H5F_t *f) } /* end H5F_incr_nopen_objs() */ /*------------------------------------------------------------------------- - * Function: H5F_decr_nopen_objs - * - * Purpose: Decrement the number of open objects for a file. - * - * Return: Success: The number of open objects, after the decrement + * Function: H5F_decr_nopen_objs * - * Failure: (can't happen) - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 6 2007 + * Purpose: Decrement the number of open objects for a file. * + * Return: Success: The number of open objects, after the decrement + * Failure: (can't happen) *------------------------------------------------------------------------- */ unsigned @@ -1529,26 +1457,21 @@ H5F_decr_nopen_objs(H5F_t *f) } /* end H5F_decr_nopen_objs() */ /*------------------------------------------------------------------------- - * Function: H5F_build_actual_name - * - * Purpose: Retrieve the name of a file, after following symlinks, etc. + * Function: H5F_build_actual_name * - * Note: Currently only working for "POSIX I/O compatible" VFDs + * Purpose: Retrieve the name of a file, after following symlinks, etc. * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Quincey Koziol - * November 25, 2009 + * Note: Currently only working for "POSIX I/O compatible" VFDs * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char **actual_name /*out*/) { - hid_t new_fapl_id = -1; /* ID for duplicated FAPL */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t new_fapl_id = H5I_INVALID_HID; /* ID for duplicated FAPL */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1644,17 +1567,13 @@ done: } /* H5F_build_actual_name() */ /*------------------------------------------------------------------------- - * Function: H5F_addr_encode_len - * - * Purpose: Encodes an address into the buffer pointed to by *PP and - * then increments the pointer to the first byte after the - * address. An undefined value is stored as all 1's. + * Function: H5F_addr_encode_len * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * Purpose: Encodes an address into the buffer pointed to by *PP and + * then increments the pointer to the first byte after the + * address. An undefined value is stored as all 1's. * + * Return: void *------------------------------------------------------------------------- */ void @@ -1684,17 +1603,13 @@ H5F_addr_encode_len(size_t addr_len, uint8_t **pp /*in,out*/, haddr_t addr) } /* end H5F_addr_encode_len() */ /*------------------------------------------------------------------------- - * Function: H5F_addr_encode - * - * Purpose: Encodes an address into the buffer pointed to by *PP and - * then increments the pointer to the first byte after the - * address. An undefined value is stored as all 1's. + * Function: H5F_addr_encode * - * Return: void - * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * Purpose: Encodes an address into the buffer pointed to by *PP and + * then increments the pointer to the first byte after the + * address. An undefined value is stored as all 1's. * + * Return: void *------------------------------------------------------------------------- */ void @@ -1711,20 +1626,16 @@ H5F_addr_encode(const H5F_t *f, uint8_t **pp /*in,out*/, haddr_t addr) } /* end H5F_addr_encode() */ /*------------------------------------------------------------------------- - * Function: H5F_addr_decode_len - * - * Purpose: Decodes an address from the buffer pointed to by *PP and - * updates the pointer to point to the next byte after the - * address. - * - * If the value read is all 1's then the address is returned - * with an undefined value. + * Function: H5F_addr_decode_len * - * Return: void + * Purpose: Decodes an address from the buffer pointed to by *PP and + * updates the pointer to point to the next byte after the + * address. * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * If the value read is all 1's then the address is returned + * with an undefined value. * + * Return: void *------------------------------------------------------------------------- */ void @@ -1777,20 +1688,16 @@ H5F_addr_decode_len(size_t addr_len, const uint8_t **pp /*in,out*/, haddr_t *add } /* end H5F_addr_decode_len() */ /*------------------------------------------------------------------------- - * Function: H5F_addr_decode - * - * Purpose: Decodes an address from the buffer pointed to by *PP and - * updates the pointer to point to the next byte after the - * address. - * - * If the value read is all 1's then the address is returned - * with an undefined value. + * Function: H5F_addr_decode * - * Return: void + * Purpose: Decodes an address from the buffer pointed to by *PP and + * updates the pointer to point to the next byte after the + * address. * - * Programmer: Robb Matzke - * Friday, November 7, 1997 + * If the value read is all 1's then the address is returned + * with an undefined value. * + * Return: void *------------------------------------------------------------------------- */ void @@ -1811,12 +1718,7 @@ H5F_addr_decode(const H5F_t *f, const uint8_t **pp /*in,out*/, haddr_t *addr_p / * * Purpose: Set the grp_btree_shared field with a valid ref-count pointer. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/19/11 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1840,12 +1742,7 @@ H5F_set_grp_btree_shared(H5F_t *f, H5RC_t *rc) * * Purpose: Set the sohm_addr field with a new value. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1868,12 +1765,7 @@ H5F_set_sohm_addr(H5F_t *f, haddr_t addr) * * Purpose: Set the sohm_vers field with a new value. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1896,12 +1788,7 @@ H5F_set_sohm_vers(H5F_t *f, unsigned vers) * * Purpose: Set the sohm_nindexes field with a new value. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1924,12 +1811,7 @@ H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes) * * Purpose: Set the store_msg_crt_idx field with a new value. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * 7/20/11 - * + * Return: SUCCEED/FAIL *------------------------------------------------------------------------- */ herr_t @@ -1953,28 +1835,24 @@ H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag) * Purpose: Private version of H5Fget_file_image * * Return: Success: Bytes copied / number of bytes needed. - * Failure: negative value - * - * Programmer: John Mainzer - * 11/15/11 - * + * Failure: -1 *------------------------------------------------------------------------- */ ssize_t H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) { - H5FD_t *fd_ptr; /* file driver */ - haddr_t eoa; /* End of file address */ - ssize_t ret_value; /* Return value */ + H5FD_t *fd_ptr; /* file driver */ + haddr_t eoa; /* End of file address */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Check args */ if (!file || !file->shared || !file->shared->lf) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "file_id yields invalid file pointer") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "file_id yields invalid file pointer") fd_ptr = file->shared->lf; if (!fd_ptr->cls) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "fd_ptr yields invalid class pointer") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "fd_ptr yields invalid class pointer") /* the address space used by the split and multi file drivers is not * a good fit for this call. Since the plan is to depreciate these @@ -1995,7 +1873,7 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * JRM -- 11/11/22 */ if (HDstrcmp(fd_ptr->cls->name, "multi") == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not supported for multi file driver.") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "Not supported for multi file driver.") /* While the family file driver is conceptually fully compatible * with the get file image operation, it sets a file driver message @@ -2017,11 +1895,11 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) * JRM -- 12/21/11 */ if (HDstrcmp(fd_ptr->cls->name, "family") == 0) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "Not supported for family file driver.") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "Not supported for family file driver.") /* Go get the actual file size */ if (HADDR_UNDEF == (eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file size") /* set ret_value = to eoa -- will overwrite this if appropriate */ ret_value = (ssize_t)eoa; @@ -2032,14 +1910,14 @@ H5F_get_file_image(H5F_t *file, void *buf_ptr, size_t buf_len) /* Check for buffer too small */ if ((haddr_t)buf_len < eoa) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "supplied buffer too small") + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, (-1), "supplied buffer too small") space_needed = (size_t)eoa; /* read in the file image */ /* (Note compensation for base address addition in internal routine) */ if (H5FD_read(fd_ptr, H5AC_ind_dxpl_g, H5FD_MEM_DEFAULT, 0, space_needed, buf_ptr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_READERROR, FAIL, "file image read request failed") + HGOTO_ERROR(H5E_FILE, H5E_READERROR, (-1), "file image read request failed") } /* end if */ done: diff --git a/src/H5Fmount.c b/src/H5Fmount.c index f3c75a9..0a598a0 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -17,14 +17,14 @@ #define H5_INTERFACE_INIT_FUNC H5F_init_mount_interface /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* PRIVATE PROTOTYPES */ static herr_t H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id, hid_t dxpl_id); @@ -132,7 +132,7 @@ H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED p H5G_name_t mp_path; /* Mount point group hier. path */ H5O_loc_t mp_oloc; /* Mount point object location */ H5G_loc_t root_loc; /* Group location of root of file to mount */ - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -433,7 +433,7 @@ done: hbool_t H5F_is_mount(const H5F_t *file) { - hbool_t ret_value; /* Return value */ + hbool_t ret_value = FALSE; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -512,13 +512,13 @@ H5Funmount(hid_t loc_id, const char *name) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); - /* Check args */ + /* Check arguments */ if (H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Unmount */ + /* Perform the unmount operation */ if (H5F_unmount(&loc, name, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 9a8258a..8cc2971 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -115,7 +115,7 @@ done: MPI_Comm H5F_mpi_get_comm(const H5F_t *f) { - MPI_Comm ret_value; + MPI_Comm ret_value = MPI_COMM_NULL; FUNC_ENTER_NOAPI(MPI_COMM_NULL) @@ -146,15 +146,15 @@ done: int H5F_mpi_get_size(const H5F_t *f) { - int ret_value; + int ret_value = -1; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) HDassert(f && f->shared); /* Dispatch to driver */ if ((ret_value = H5FD_mpi_get_size(f->shared->lf)) < 0) - HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "driver get_size request failed") + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, (-1), "driver get_size request failed") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 222e4b3..f74a342 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -33,14 +33,14 @@ #include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ /* Other private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object header messages */ -#include "H5RCprivate.h" /* Reference counted object functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object header messages */ +#include "H5RCprivate.h" /* Reference counted object functions */ /* * Feature: Define this constant on the compiler command-line if you want to diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index fe510bb..ec31f8c 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -22,7 +22,7 @@ #include "H5Fpublic.h" /* Public headers needed by this file */ -#include "H5FDpublic.h" /* File drivers */ +#include "H5FDpublic.h" /* File drivers */ /* Private headers needed by this file */ diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 01cb946..3270872 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -77,8 +77,8 @@ /* The difference between a single file and a set of mounted files */ typedef enum H5F_scope_t { - H5F_SCOPE_LOCAL = 0, /*specified file handle only */ - H5F_SCOPE_GLOBAL = 1 /*entire virtual file */ + H5F_SCOPE_LOCAL = 0, /*specified file handle only */ + H5F_SCOPE_GLOBAL = 1 /*entire virtual file */ } H5F_scope_t; /* Unlimited file size for H5Pset_external() */ diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 3f1a3b7..b9b1ead 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -29,7 +29,7 @@ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ #include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ @@ -492,7 +492,7 @@ H5F_super_init(H5F_t *f, hid_t dxpl_id) /* Initialize the shared message code & write the SOHM message to the extension */ if (H5SM_init(f, plist, &ext_loc, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to create SOHM table") - } /* end if */ + } /* Check for non-default v1 B-tree 'K' values to store */ if (sblock->btree_k[H5B_SNODE_ID] != HDF5_BTREE_SNODE_IK_DEF || diff --git a/src/H5Ftest.c b/src/H5Ftest.c index a582bfa..9c5b0810 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -36,12 +36,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5SMpkg.h" /* Shared object header messages */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5SMpkg.h" /* Shared object header messages */ /****************/ /* Local Macros */ diff --git a/src/H5G.c b/src/H5G.c index 7a77170..a74e74f 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -83,12 +83,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ /****************/ /* Local Macros */ @@ -246,7 +246,7 @@ H5G_term_interface(void) * writing. Call H5Gclose() when finished with * the group. * - * Failure: FAIL + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -257,43 +257,43 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t g H5G_t * grp = NULL; /* New group created */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, lcpl_id, gcpl_id, gapl_id); /* Check arguments */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Get correct property list */ if (H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not link creation property list") /* Check group creation property list */ if (H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group create property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list") /* Check the group access property list */ if (H5P_DEFAULT == gapl_id) gapl_id = H5P_GROUP_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group access property list") /* Create the new group & get its ID */ if (NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") if ((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: if (ret_value < 0) if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate2() */ @@ -326,7 +326,7 @@ done: * writing. Call H5Gclose() when finished with * the group. * - * Failure: FAIL + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -338,24 +338,24 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) H5G_obj_create_t gcrt_info; /* Information for group creation */ hid_t ret_value; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id); /* Check arguments */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") /* Check group creation property list */ if (H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; else if (TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group create property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list") /* Check the group access property list */ if (H5P_DEFAULT == gapl_id) gapl_id = H5P_GROUP_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group access property list") /* Set up group creation info */ gcrt_info.gcpl_id = gcpl_id; @@ -364,9 +364,9 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) /* Create the new group & get its ID */ if (NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") if ((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: /* Release the group's object header, if it was created */ @@ -375,23 +375,24 @@ done: /* Get the new group's object location */ if (NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object location of group") + HDONE_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to get object location of group") /* Decrement refcount on group's object header in memory */ if (H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, + "unable to decrement refcount on newly created object") } /* end if */ /* Cleanup on failure */ if (ret_value < 0) if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gcreate_anon() */ /*------------------------------------------------------------------------- - * Function: H5Gopen2 + * Function: H5Gopen2 * * Purpose: Opens an existing group for modification. When finished, * call H5Gclose() to close it and release resources. @@ -401,7 +402,7 @@ done: * * Return: Success: Object ID of the group * - * Failure: FAIL + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -412,34 +413,33 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) H5G_loc_t loc; /* Location of parent for group */ hid_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, gapl_id); /* Check args */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") /* Check the group access property list */ if (H5P_DEFAULT == gapl_id) gapl_id = H5P_GROUP_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group access property list") /* Open the group */ if ((grp = H5G__open_name(&loc, name, gapl_id, H5AC_ind_dxpl_id)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Register an ID for the group */ if ((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: - if (ret_value < 0) { + if (ret_value < 0) if (grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - } /* end if */ + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) } /* end H5Gopen2() */ @@ -453,7 +453,7 @@ done: * property list. The property list ID should be * released by calling H5Pclose(). * - * Failure: FAIL + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -461,17 +461,18 @@ hid_t H5Gget_create_plist(hid_t group_id) { H5G_t *group = NULL; - hid_t ret_value = FAIL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", group_id); /* Check args */ if (NULL == (group = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group") + /* Retrieve the GCPL */ if ((ret_value = H5G_get_create_plist(group)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group") done: FUNC_LEAVE_API(ret_value) @@ -486,7 +487,7 @@ done: * property list. The property list ID should be * released by calling H5Pclose(). * - * Failure: FAIL + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -499,60 +500,60 @@ H5G_get_create_plist(H5G_t *grp) htri_t pline_exists; H5P_genplist_t *gcpl_plist; H5P_genplist_t *new_plist; - hid_t new_gcpl_id = FAIL; - hid_t ret_value = FAIL; + hid_t new_gcpl_id = H5I_INVALID_HID; + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Copy the default group creation property list */ if (NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default group creation property list") if ((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get property list") /* Retrieve any object creation properties */ if (H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") /* Check for the group having a group info message */ if ((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") if (ginfo_exists) { H5O_ginfo_t ginfo; /* Group info message */ /* Read the group info */ if (NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, H5I_INVALID_HID, "can't get group info") /* Set the group info for the property list */ if (H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set group info") } /* end if */ /* Check for the group having a link info message */ if ((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to read object header") if (linfo_exists) { /* Set the link info for the property list */ if (H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set link info") } /* end if */ /* Check for the group having a pipeline message */ if ((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to read object header") if (pline_exists) { H5O_pline_t pline; /* Pipeline message */ /* Read the pipeline */ if (NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline") + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, H5I_INVALID_HID, "can't get link pipeline") /* Set the pipeline for the property list */ if (H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set link pipeline") } /* end if */ /* Set the return value */ @@ -562,7 +563,7 @@ done: if (ret_value < 0) { if (new_gcpl_id > 0) if (H5I_dec_app_ref(new_gcpl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "can't free") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Gcache.c b/src/H5Gcache.c index 90c3ac3..0366bfe 100644 --- a/src/H5Gcache.c +++ b/src/H5Gcache.c @@ -101,7 +101,6 @@ H5FL_SEQ_EXTERN(H5G_entry_t); * Failure: NULL * * Programmer: Robb Matzke - * matzke@llnl.gov * Jun 23 1997 * *------------------------------------------------------------------------- @@ -192,7 +191,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Jun 23 1997 * *------------------------------------------------------------------------- @@ -282,7 +280,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Jan 15 2003 * *------------------------------------------------------------------------- @@ -294,9 +291,7 @@ H5G_node_dest(H5F_t *f, H5G_node_t *sym) FUNC_ENTER_NOAPI_NOINIT - /* - * Check arguments. - */ + /* Sanity checks */ HDassert(f); HDassert(sym); @@ -330,7 +325,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 20 2003 * *------------------------------------------------------------------------- @@ -342,9 +336,7 @@ H5G_node_clear(H5F_t *f, H5G_node_t *sym, hbool_t destroy) FUNC_ENTER_NOAPI_NOINIT - /* - * Check arguments. - */ + /* Sanity checks */ HDassert(sym); /* Reset the node's dirty flag */ diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index 39009ba..a5d2d5b 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -212,8 +212,8 @@ ssize_t H5G__compact_get_name_by_idx(const H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t idx, char *name, size_t size) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - ssize_t ret_value; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -393,8 +393,8 @@ H5G__compact_iterate(const H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *li H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - herr_t ret_value; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -479,9 +479,9 @@ done: htri_t H5G__compact_lookup(const H5O_loc_t *oloc, const char *name, H5O_link_t *lnk, hid_t dxpl_id) { - H5G_iter_lkp_t udata; /* User data for iteration callback */ - H5O_mesg_operator_t op; /* Message operator */ - htri_t ret_value; /* Return value */ + H5G_iter_lkp_t udata; /* User data for iteration callback */ + H5O_mesg_operator_t op; /* Message operator */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -572,8 +572,8 @@ done: H5G_obj_t H5G__compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, hsize_t idx) { - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - H5G_obj_t ret_value; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Link table */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Gdense.c b/src/H5Gdense.c index b145aac..31f86a1 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -497,10 +497,10 @@ done: htri_t H5G__dense_lookup(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, const char *name, H5O_link_t *lnk) { - H5G_bt2_ud_common_t udata; /* User data for v2 B-tree link lookup */ - H5HF_t * fheap = NULL; /* Fractal heap handle */ - H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value; /* Return value */ + H5G_bt2_ud_common_t udata; /* User data for v2 B-tree link lookup */ + H5HF_t * fheap = NULL; /* Fractal heap handle */ + H5B2_t * bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -938,7 +938,7 @@ H5G__dense_iterate(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, H5_index_t H5G_link_table_t ltable = {0, NULL}; /* Table of links */ H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - herr_t ret_value; /* Return value */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -1138,7 +1138,7 @@ H5G__dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, H5_index H5G_link_table_t ltable = {0, NULL}; /* Table of links */ H5B2_t * bt2 = NULL; /* v2 B-tree handle for index */ haddr_t bt2_addr; /* Address of v2 B-tree to use for lookup */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE @@ -1765,8 +1765,8 @@ done: H5G_obj_t H5G__dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hsize_t idx) { - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5G_obj_t ret_value; /* Return value */ + H5G_link_table_t ltable = {0, NULL}; /* Table of links */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 2677c99..807851c 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -151,7 +151,7 @@ H5G__term_deprec_interface(void) H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type) { - H5G_obj_t ret_value; /* Return value */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -734,10 +734,10 @@ done: herr_t H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_obj; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value; + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_obj; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*Isx*x", loc_id, name, idx_p, op, op_data); @@ -839,7 +839,7 @@ done: herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, H5G_stat_t *statbuf /*out*/) { - H5G_loc_t loc; + H5G_loc_t loc; /* Group's location */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -962,6 +962,7 @@ H5G_get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5G FUNC_ENTER_NOAPI_NOINIT + /* Sanity checks */ HDassert(loc); HDassert(name && *name); diff --git a/src/H5Gint.c b/src/H5Gint.c index 20d12e6..ce79f36 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -152,9 +152,9 @@ H5G_t * H5G__create_named(const H5G_loc_t *loc, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id) { - H5O_obj_create_t ocrt_info; /* Information for object creation */ - H5G_obj_create_t gcrt_info; /* Information for group creation */ - H5G_t * ret_value; /* Return value */ + H5O_obj_create_t ocrt_info; /* Information for object creation */ + H5G_obj_create_t gcrt_info; /* Information for group creation */ + H5G_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -210,7 +210,7 @@ H5G__create(H5F_t *file, H5G_obj_create_t *gcrt_info, hid_t dxpl_id) { H5G_t * grp = NULL; /*new group */ unsigned oloc_init = 0; /* Flag to indicate that the group object location was created successfully */ - H5G_t * ret_value; /* Return value */ + H5G_t * ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -763,7 +763,7 @@ done: } /* end H5G_iterate_cb() */ /*------------------------------------------------------------------------- - * Function: H5G_iterate + * Function: H5G_iterate * * Purpose: Private function for iterating over links in a group * diff --git a/src/H5Glink.c b/src/H5Glink.c index d7cd56c..70bdea1 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -394,11 +394,20 @@ done: herr_t H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_order_t order) { + herr_t ret_value = SUCCEED; + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(ltable); + /* Can't sort when empty since the links table will be NULL */ + if (0 == ltable->nlinks) + HGOTO_DONE(ret_value); + + /* This should never be NULL if the number of links is non-zero */ + HDassert(ltable->lnks); + /* Pick appropriate sorting routine */ if (idx_type == H5_INDEX_NAME) { if (order == H5_ITER_INC) @@ -418,6 +427,7 @@ H5G__link_sort_table(H5G_link_table_t *ltable, H5_index_t idx_type, H5_iter_orde HDassert(order == H5_ITER_NATIVE); } /* end else */ +done: FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5G__link_sort_table() */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 105191a..8ffc01a 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -155,8 +155,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) /* Construct a group location for root group of the file */ if (H5G_root_loc(f, loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") - } /* end case */ - break; + break; + } case H5I_GENPROP_CLS: case H5I_GENPROP_LST: @@ -177,8 +177,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") if (NULL == (loc->path = H5G_nameof(group))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") - } /* end case */ - break; + break; + } case H5I_DATATYPE: { H5T_t *dt; @@ -189,8 +189,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") if (NULL == (loc->path = H5T_nameof(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") - } /* end case */ - break; + break; + } case H5I_DATASPACE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of dataspace") @@ -204,8 +204,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") if (NULL == (loc->path = H5D_nameof(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset") - } /* end case */ - break; + break; + } case H5I_ATTR: { H5A_t *attr; @@ -216,8 +216,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") if (NULL == (loc->path = H5A_nameof(attr))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute") - } /* end case */ - break; + break; + } case H5I_REFERENCE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of reference") @@ -614,8 +614,8 @@ H5G_loc_exists_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_ATTR_U htri_t H5G_loc_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { - H5G_loc_exists_t udata; /* User data for traversal callback */ - htri_t ret_value; /* Return value */ + H5G_loc_exists_t udata; /* User data for traversal callback */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -845,11 +845,12 @@ H5G_loc_get_comment_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc /*in*/, const char H5_A HDstrncpy(udata->comment, comment.s, udata->bufsize); udata->comment_size = (ssize_t)HDstrlen(comment.s); H5O_msg_reset(H5O_NAME_ID, &comment); - } /* end else */ + } done: /* Indicate that this callback didn't take ownership of the group * - * location for the object */ + * location for the object. + */ *own_loc = H5G_OWN_NONE; FUNC_LEAVE_NOAPI(ret_value) @@ -876,8 +877,8 @@ ssize_t H5G_loc_get_comment(H5G_loc_t *loc, const char *name, char *comment /*out*/, size_t bufsize, hid_t lapl_id, hid_t dxpl_id) { - H5G_loc_gc_t udata; /* User data for traversal callback */ - ssize_t ret_value; /* Return value */ + H5G_loc_gc_t udata; /* User data for traversal callback */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) diff --git a/src/H5Gname.c b/src/H5Gname.c index b22bddf..bc04488 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1264,16 +1264,16 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * /* Portably clear udata struct (before FUNC_ENTER) */ HDmemset(&udata, 0, sizeof(udata)); - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) - /* Construct the link info for the file's root group */ + /* Construct a group location for root group of the file */ if (H5G_loc(file, &root_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get root group's location") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get root group's location") /* Check for root group being the object looked for */ if (root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) { if (NULL == (udata.path = H5MM_strdup(""))) - HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, FAIL, "can't duplicate path string") + HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, (-1), "can't duplicate path string") found_obj = TRUE; } /* end if */ else { @@ -1286,7 +1286,7 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * /* Visit all the links in the file */ if ((status = H5G_visit(file, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata, lapl_id, dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group traversal failed while looking for object name") + HGOTO_ERROR(H5E_SYM, H5E_BADITER, (-1), "group traversal failed while looking for object name") else if (status > 0) found_obj = TRUE; } /* end else */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index b092361..2323608 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -294,8 +294,8 @@ done: htri_t H5G__obj_get_linfo(const H5O_loc_t *grp_oloc, H5O_linfo_t *linfo, hid_t dxpl_id) { - H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ - htri_t ret_value; /* Return value */ + H5B2_t *bt2_name = NULL; /* v2 B-tree handle for name index */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -629,9 +629,9 @@ herr_t H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, H5G_lib_iterate_t op, void *op_data, hid_t dxpl_id) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - herr_t ret_value; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + herr_t ret_value = FAIL; /* Return value */ FUNC_ENTER_PACKAGE @@ -775,9 +775,9 @@ ssize_t H5G_obj_get_name_by_idx(const H5O_loc_t *oloc, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name, size_t size, hid_t dxpl_id) { - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - ssize_t ret_value; /* Return value */ + H5O_linfo_t linfo; /* Link info message */ + htri_t linfo_exists; /* Whether the link info message exists */ + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1068,10 +1068,9 @@ H5G_obj_remove_by_idx(const H5O_loc_t *grp_oloc, H5RS_str_t *grp_full_path_r, H5 } /* end else */ /* Update link info for a new-style group */ - if (!use_old_format) { + if (!use_old_format) if (H5G_obj_remove_update_linfo(grp_oloc, &linfo, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTUPDATE, FAIL, "unable to update link info") - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1118,11 +1117,10 @@ H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, hi HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") } /* end else */ } /* end if */ - else { + else /* Get the object's info from the symbol table */ if ((ret_value = H5G__stab_lookup(grp_oloc, name, lnk, dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") - } /* end else */ + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't locate object") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Goh.c b/src/H5Goh.c index 0d51219..3d5b780 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -94,7 +94,7 @@ H5FL_DEFINE(H5G_copy_file_ud_t); static void * H5O_group_get_copy_file_udata(void) { - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -160,9 +160,9 @@ H5O_group_free_copy_file_udata(void *_udata) static htri_t H5O_group_isa(struct H5O_t *oh) { - htri_t stab_exists; /* Whether the 'stab' message is in the object header */ - htri_t linfo_exists; /* Whether the 'linfo' message is in the object header */ - htri_t ret_value; /* Return value */ + htri_t stab_exists; /* Whether the 'stab' message is in the object header */ + htri_t linfo_exists; /* Whether the 'linfo' message is in the object header */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -196,8 +196,8 @@ done: static hid_t H5O_group_open(const H5G_loc_t *obj_loc, hid_t H5_ATTR_UNUSED lapl_id, hid_t dxpl_id, hbool_t app_ref) { - H5G_t *grp = NULL; /* Group opened */ - hid_t ret_value; /* Return value */ + H5G_t *grp = NULL; /* Group opened */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -235,9 +235,9 @@ done: static void * H5O_group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) { - H5G_obj_create_t *crt_info = (H5G_obj_create_t *)_crt_info; /* Group creation parameters */ - H5G_t * grp = NULL; /* New group created */ - void * ret_value; /* Return value */ + H5G_obj_create_t *crt_info = (H5G_obj_create_t *)_crt_info; /* Group creation parameters */ + H5G_t * grp = NULL; /* New group created */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -283,8 +283,8 @@ done: static H5O_loc_t * H5O_group_get_oloc(hid_t obj_id) { - H5G_t * grp; /* Group opened */ - H5O_loc_t *ret_value; /* Return value */ + H5G_t * grp; /* Group opened */ + H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 8d72d86..2fe6374 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -1153,9 +1153,9 @@ done: H5G_obj_t H5G__stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id) { - H5O_stab_t stab; /* Info about local heap & B-tree */ - H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */ - H5G_obj_t ret_value; /* Return value */ + H5O_stab_t stab; /* Info about local heap & B-tree */ + H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */ + H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ FUNC_ENTER_PACKAGE diff --git a/src/H5Gtest.c b/src/H5Gtest.c index b815a4a..0bfa441 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -27,12 +27,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Iprivate.h" /* IDs */ /****************/ /* Local Macros */ @@ -653,9 +653,7 @@ H5G_verify_cached_stabs_test_cb(H5F_t *f, hid_t dxpl_id, const void H5_ATTR_UNUS FUNC_ENTER_NOAPI_NOINIT - /* - * Check arguments. - */ + /* Check arguments */ HDassert(f); HDassert(H5F_addr_defined(addr)); diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index c5329e3..6c5cbd9 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -31,17 +31,17 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5Gpkg.h" /* Groups */ -#include "H5HLprivate.h" /* Local Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Ppublic.h" /* Property Lists */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HLprivate.h" /* Local Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Ppublic.h" /* Property Lists */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ @@ -391,8 +391,7 @@ H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk, unsigned HDassert(obj_loc); HDassert(nlinks); - /* - * If we found a symbolic link then we should follow it. But if this + /* If we found a symbolic link then we should follow it. But if this * is the last component of the name and the H5G_TARGET_SLINK bit of * TARGET is set then we don't follow it. */ diff --git a/src/H5HF.c b/src/H5HF.c index 8c71641..2ec651a 100644 --- a/src/H5HF.c +++ b/src/H5HF.c @@ -135,10 +135,10 @@ H5HF_op_write(const void *obj, size_t obj_len, void *op_data) H5HF_t * H5HF_create(H5F_t *f, hid_t dxpl_id, const H5HF_create_t *cparam) { - H5HF_t * fh = NULL; /* Pointer to new fractal heap */ - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - haddr_t fh_addr; /* Heap header address */ - H5HF_t * ret_value; /* Return value */ + H5HF_t * fh = NULL; /* Pointer to new fractal heap */ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + haddr_t fh_addr; /* Heap header address */ + H5HF_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -201,9 +201,9 @@ done: H5HF_t * H5HF_open(H5F_t *f, hid_t dxpl_id, haddr_t fh_addr) { - H5HF_t * fh = NULL; /* Pointer to new fractal heap */ - H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ - H5HF_t * ret_value; /* Return value */ + H5HF_t * fh = NULL; /* Pointer to new fractal heap */ + H5HF_hdr_t *hdr = NULL; /* The fractal heap header information */ + H5HF_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) diff --git a/src/H5HFbtree2.c b/src/H5HFbtree2.c index 2e0e9af..7157c93 100644 --- a/src/H5HFbtree2.c +++ b/src/H5HFbtree2.c @@ -192,9 +192,9 @@ H5FL_DEFINE_STATIC(H5HF_huge_bt2_ctx_t); static void * H5HF_huge_bt2_crt_context(void *_f) { - H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ - H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ - void * ret_value; /* Return value */ + H5F_t * f = (H5F_t *)_f; /* User data for building callback context */ + H5HF_huge_bt2_ctx_t *ctx; /* Callback context structure */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -305,12 +305,6 @@ H5HF_huge_bt2_indir_found(const void *nrecord, void *op_data) { FUNC_ENTER_NOAPI_NOINIT_NOERR -#ifdef QAK - HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %Hu}\n", "H5HF_huge_bt2_indir_found", - ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->addr, - ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->len, - ((const H5HF_huge_bt2_indir_rec_t *)nrecord)->id); -#endif /* QAK */ *(H5HF_huge_bt2_indir_rec_t *)op_data = *(const H5HF_huge_bt2_indir_rec_t *)nrecord; FUNC_LEAVE_NOAPI(SUCCEED) @@ -509,14 +503,6 @@ H5HF_huge_bt2_filt_indir_found(const void *nrecord, void *op_data) { FUNC_ENTER_NOAPI_NOINIT_NOERR -#ifdef QAK - HDfprintf(stderr, "%s: nrecord = {%a, %Hu, %x, %Hu, %Hu}\n", "H5HF_huge_bt2_filt_indir_found", - ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->addr, - ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->len, - ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->filter_mask, - ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->obj_size, - ((const H5HF_huge_bt2_filt_indir_rec_t *)nrecord)->id); -#endif /* QAK */ *(H5HF_huge_bt2_filt_indir_rec_t *)op_data = *(const H5HF_huge_bt2_filt_indir_rec_t *)nrecord; FUNC_LEAVE_NOAPI(SUCCEED) @@ -987,12 +973,6 @@ H5HF_huge_bt2_filt_dir_compare(const void *_rec1, const void *_rec2, int *result FUNC_ENTER_NOAPI_NOINIT_NOERR -#ifdef QAK - HDfprintf(stderr, "%s: rec1 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec1->addr, - rec1->len, rec1->filter_mask, rec1->obj_size); - HDfprintf(stderr, "%s: rec2 = {%a, %Hu, %x, %Hu}\n", "H5HF_huge_bt2_filt_dir_compare", rec2->addr, - rec2->len, rec2->filter_mask, rec2->obj_size); -#endif /* QAK */ if (rec1->addr < rec2->addr) *result = -1; else if (rec1->addr > rec2->addr) diff --git a/src/H5HFdblock.c b/src/H5HFdblock.c index 2e83868..25fd768 100644 --- a/src/H5HFdblock.c +++ b/src/H5HFdblock.c @@ -427,9 +427,9 @@ H5HF_direct_t * H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr, size_t dblock_size, H5HF_indirect_t *par_iblock, unsigned par_entry, H5AC_protect_t rw) { - H5HF_direct_t * dblock; /* Direct block from cache */ - H5HF_dblock_cache_ud_t udata; /* parent and other infor for deserializing direct block */ - H5HF_direct_t * ret_value; /* Return value */ + H5HF_direct_t * dblock; /* Direct block from cache */ + H5HF_dblock_cache_ud_t udata; /* parent and other infor for deserializing direct block */ + H5HF_direct_t * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFhdr.c b/src/H5HFhdr.c index 09d10b3..7a0bc79 100644 --- a/src/H5HFhdr.c +++ b/src/H5HFhdr.c @@ -1445,11 +1445,10 @@ H5HF_hdr_delete(H5HF_hdr_t *hdr, hid_t dxpl_id) /* (must occur before attempting to delete the heap, so indirect blocks * will get unpinned) */ - if (H5F_addr_defined(hdr->fs_addr)) { + if (H5F_addr_defined(hdr->fs_addr)) /* Delete free space manager for heap */ if (H5HF_space_delete(hdr, dxpl_id) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to release fractal heap free space manager") - } /* end if */ /* Check for root direct/indirect block */ if (H5F_addr_defined(hdr->man_dtable.table_addr)) { diff --git a/src/H5HFhuge.c b/src/H5HFhuge.c index 5457612..a2b23e3 100644 --- a/src/H5HFhuge.c +++ b/src/H5HFhuge.c @@ -241,8 +241,8 @@ H5HF_huge_init(H5HF_hdr_t *hdr) static hsize_t H5HF_huge_new_id(H5HF_hdr_t *hdr) { - hsize_t new_id; /* New object's ID */ - hsize_t ret_value; /* Return value */ + hsize_t new_id; /* New object's ID */ + hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFiblock.c b/src/H5HFiblock.c index e613cab..394c44e 100644 --- a/src/H5HFiblock.c +++ b/src/H5HFiblock.c @@ -558,20 +558,10 @@ H5HF_man_iblock_root_double(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_si /* Check if the indirect block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) { - /* Currently, the old block data is "thrown away" after the space is reallocated, - * to avoid data copy in H5MF_realloc() call by just free'ing the space and - * allocating new space. - * - * This also keeps the file smaller, by freeing the space and then - * allocating new space, instead of vice versa (in H5MF_realloc). - * - * QAK - 3/14/2006 - */ + if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) /* Free previous indirect block disk space */ if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, dxpl_id, iblock->addr, (hsize_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") - } /* end if */ /* Compute size of buffer needed for new indirect block */ iblock->nrows = new_nrows; @@ -608,11 +598,10 @@ H5HF_man_iblock_root_double(H5HF_hdr_t *hdr, hid_t dxpl_id, size_t min_dblock_si HGOTO_ERROR(H5E_HEAP, H5E_NOSPACE, FAIL, "memory allocation failed for direct entries") /* Check for skipping over rows and add free section for skipped rows */ - if (skip_direct_rows) { + if (skip_direct_rows) /* Add skipped blocks to heap's free space */ if (H5HF_hdr_skip_blocks(hdr, dxpl_id, iblock, next_entry, (new_next_entry - next_entry)) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDEC, FAIL, "can't add skipped blocks to heap's free space") - } /* end if */ /* Initialize new direct block entries in rows added */ acc_dblock_free = 0; @@ -728,20 +717,10 @@ H5HF_man_iblock_root_halve(H5HF_indirect_t *iblock, hid_t dxpl_id) /* Check if the indirect block is NOT currently allocated in temp. file space */ /* (temp. file space does not need to be freed) */ - if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) { - /* Currently, the old block data is "thrown away" after the space is reallocated, - * to avoid data copy in H5MF_realloc() call by just free'ing the space and - * allocating new space. - * - * This also keeps the file smaller, by freeing the space and then - * allocating new space, instead of vice versa (in H5MF_realloc). - * - * QAK - 6/12/2006 - */ + if (!H5F_IS_TMP_ADDR(hdr->f, iblock->addr)) /* Free previous indirect block disk space */ if (H5MF_xfree(hdr->f, H5FD_MEM_FHEAP_IBLOCK, dxpl_id, iblock->addr, (hsize_t)iblock->size) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTFREE, FAIL, "unable to free fractal heap indirect block file space") - } /* end if */ /* Compute free space in rows to delete */ acc_dblock_free = 0; @@ -1139,7 +1118,7 @@ H5HF_man_iblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t iblock_addr, uns H5HF_parent_t par_info; /* Parent info for loading block */ H5HF_indirect_t *iblock = NULL; /* Indirect block from cache */ hbool_t should_protect = FALSE; /* Whether we should protect the indirect block or not */ - H5HF_indirect_t *ret_value; /* Return value */ + H5HF_indirect_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFsection.c b/src/H5HFsection.c index bd37bff..d363a70 100644 --- a/src/H5HFsection.c +++ b/src/H5HFsection.c @@ -2221,8 +2221,8 @@ done: static H5HF_free_section_t * H5HF_sect_indirect_for_row(H5HF_hdr_t *hdr, H5HF_indirect_t *iblock, H5HF_free_section_t *row_sect) { - H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ - H5HF_free_section_t *ret_value; /* Return value */ + H5HF_free_section_t *sect = NULL; /* 'Indirect' free space section to add */ + H5HF_free_section_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -3836,16 +3836,16 @@ static H5FS_section_info_t * H5HF_sect_indirect_deserialize(H5HF_hdr_t *hdr, hid_t dxpl_id, const uint8_t *buf, haddr_t sect_addr, hsize_t sect_size, unsigned *des_flags) { - H5HF_free_section_t *new_sect; /* New indirect section */ - hsize_t iblock_off; /* Indirect block's offset */ - unsigned start_row; /* Indirect section's start row */ - unsigned start_col; /* Indirect section's start column */ - unsigned nentries; /* Indirect section's number of entries */ - unsigned start_entry; /* Start entry in indirect block */ - unsigned end_entry; /* End entry in indirect block */ - unsigned end_row; /* End row in indirect block */ - unsigned end_col; /* End column in indirect block */ - H5FS_section_info_t *ret_value; /* Return value */ + H5HF_free_section_t *new_sect; /* New indirect section */ + hsize_t iblock_off; /* Indirect block's offset */ + unsigned start_row; /* Indirect section's start row */ + unsigned start_col; /* Indirect section's start column */ + unsigned nentries; /* Indirect section's number of entries */ + unsigned start_entry; /* Start entry in indirect block */ + unsigned end_entry; /* End entry in indirect block */ + unsigned end_row; /* End row in indirect block */ + unsigned end_col; /* End column in indirect block */ + H5FS_section_info_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5HFspace.c b/src/H5HFspace.c index 2744103..4544975 100644 --- a/src/H5HFspace.c +++ b/src/H5HFspace.c @@ -193,7 +193,7 @@ htri_t H5HF_space_find(H5HF_hdr_t *hdr, hid_t dxpl_id, hsize_t request, H5HF_free_section_t **node) { htri_t node_found = FALSE; /* Whether an existing free list node was found */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -294,11 +294,10 @@ H5HF_space_revert_root(const H5HF_hdr_t *hdr, hid_t dxpl_id) HDassert(hdr); /* Only need to scan the sections if the free space has been initialized */ - if (hdr->fspace) { - /* Iterate over all sections, reseting the parent pointers in 'single' sections */ + if (hdr->fspace) + /* Iterate over all sections, resetting the parent pointers in 'single' sections */ if (H5FS_sect_iterate(hdr->f, dxpl_id, hdr->fspace, H5HF_space_revert_root_cb, NULL) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to reset parent pointers") - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -385,12 +384,11 @@ H5HF_space_create_root(const H5HF_hdr_t *hdr, hid_t dxpl_id, H5HF_indirect_t *ro HDassert(root_iblock); /* Only need to scan the sections if the free space has been initialized */ - if (hdr->fspace) { + if (hdr->fspace) /* Iterate over all sections, seting the parent pointers in 'single' sections to the new indirect * block */ if (H5FS_sect_iterate(hdr->f, dxpl_id, hdr->fspace, H5HF_space_create_root_cb, root_iblock) < 0) HGOTO_ERROR(H5E_FSPACE, H5E_BADITER, FAIL, "can't iterate over sections to set parent pointers") - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index d32f733..b130199 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -31,9 +31,9 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HFpkg.h" /* Fractal heaps */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HFpkg.h" /* Fractal heaps */ /****************/ /* Local Macros */ @@ -41,10 +41,10 @@ /* Tiny object length information */ #define H5HF_TINY_LEN_SHORT 16 /* Max. length able to be encoded in first heap ID byte */ -#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */ -#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */ -#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */ -#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */ +#define H5HF_TINY_MASK_SHORT 0x0F /* Mask for length in first heap ID byte */ +#define H5HF_TINY_MASK_EXT 0x0FFF /* Mask for length in two heap ID bytes */ +#define H5HF_TINY_MASK_EXT_1 0x0F00 /* Mask for length in first byte of two heap ID bytes */ +#define H5HF_TINY_MASK_EXT_2 0x00FF /* Mask for length in second byte of two heap ID bytes */ /******************/ /* Local Typedefs */ @@ -263,7 +263,7 @@ H5HF_tiny_op_real(H5HF_hdr_t *hdr, const uint8_t *id, H5HF_operator_t op, void * */ id++; id++; - } /* end else */ + } /* Call the user's 'op' callback */ if (op(id, (enc_obj_size + 1), op_data) < 0) diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 7e352e6..f10a68f 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -210,16 +210,15 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata) heap->obj[idx].begin = begin; /* - * The total storage size includes the size of the object header - * and is zero padded so the next object header is properly - * aligned. The entire obj array was calloc'ed, so no need to zero - * the space here. The last bit of space is the free space object - * whose size is never padded and already includes the object - * header. + * The total storage size includes the size of the object + * header and is zero padded so the next object header is + * properly aligned. The entire obj array was calloc'ed, + * so no need to zero the space here. The last bit of space + * is the free space object whose size is never padded and + * already includes the object header. */ if (idx > 0) { need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(heap->obj[idx].size); - if (idx > max_idx) max_idx = idx; } /* end if */ @@ -237,6 +236,7 @@ H5HG_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata) else heap->nused = 1; + /* Sanity check */ HDassert(max_idx < heap->nused); /* Add the new heap to the CWFS list for the file */ @@ -259,7 +259,8 @@ done: * Purpose: Flushes a global heap collection from memory to disk if it's * dirty. Optionally deletes teh heap from memory. * - * Return: Non-negative on success/Negative on failure + * Return: Success: SUCCEED + * Failure: FAIL * * Programmer: Robb Matzke * Friday, March 27, 1998 @@ -299,7 +300,8 @@ done: * * Purpose: Destroys a global heap collection in memory * - * Return: Non-negative on success/Negative on failure + * Return: Success: SUCCEED + * Failure: FAIL * * Programmer: Quincey Koziol * Wednesday, January 15, 2003 @@ -343,7 +345,8 @@ done: * * Purpose: Mark a global heap in memory as non-dirty. * - * Return: Non-negative on success/Negative on failure + * Return: Success: SUCCEED + * Failure: FAIL * * Programmer: Quincey Koziol * Thursday, March 20, 2003 @@ -378,7 +381,8 @@ done: * H5HG_heap_t on disk, and return it in *len_ptr. On failure, * the value of *len_ptr is undefined. * - * Return: Non-negative on success/Negative on failure + * Return: Success: SUCCEED + * Failure: FAIL * * Programmer: John Mainzer * 5/13/04 diff --git a/src/H5HGpkg.h b/src/H5HGpkg.h index 757ee64..78f6611 100644 --- a/src/H5HGpkg.h +++ b/src/H5HGpkg.h @@ -110,9 +110,9 @@ H5FL_BLK_EXTERN(gheap_chunk); /****************************/ typedef struct H5HG_obj_t { - int nrefs; /*reference count */ - size_t size; /*total size of object */ - uint8_t *begin; /*ptr to object into heap->chunk*/ + int nrefs; /* reference count */ + size_t size; /* total size of object */ + uint8_t *begin; /* ptr to object into heap->chunk */ } H5HG_obj_t; /* Forward declarations for fields */ diff --git a/src/H5HLcache.c b/src/H5HLcache.c index 4fe9faa..8461392 100644 --- a/src/H5HLcache.c +++ b/src/H5HLcache.c @@ -31,11 +31,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local Heaps */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLpkg.h" /* Local Heaps */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5WBprivate.h" /* Wrapped Buffers */ /****************/ /* Local Macros */ @@ -225,7 +225,6 @@ H5HL_fl_serialize(const H5HL_t *heap) * Failure: NULL * * Programmer: Robb Matzke - * matzke@llnl.gov * Jul 17 1997 * *------------------------------------------------------------------------- @@ -368,7 +367,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Robb Matzke - * matzke@llnl.gov * Jul 17 1997 * *------------------------------------------------------------------------- @@ -471,7 +469,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Jan 15 2003 * *------------------------------------------------------------------------- @@ -526,7 +523,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 20 2003 * *------------------------------------------------------------------------- @@ -539,7 +535,7 @@ H5HL_prefix_clear(H5F_t H5_ATTR_UNUSED *f, void *thing, hbool_t destroy) FUNC_ENTER_NOAPI_NOINIT - /* check arguments */ + /* Check arguments */ HDassert(prfx); /* Mark heap prefix as clean */ @@ -598,7 +594,6 @@ H5HL_prefix_size(const H5F_t H5_ATTR_UNUSED *f, const void *thing, size_t *size_ * Failure: NULL * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Jan 5 2010 * *------------------------------------------------------------------------- @@ -661,10 +656,10 @@ done: * Purpose: Flushes a heap's data block from memory to disk if it's dirty. * Optionally deletes the heap data block from memory. * - * Return: Non-negative on success/Negative on failure + * Return: Success: SUCCEED + * Failure: FAIL * * Programmer: Robb Matzke - * matzke@llnl.gov * Jul 17 1997 * *------------------------------------------------------------------------- @@ -716,10 +711,10 @@ done: * * Purpose: Destroys a local heap data block in memory. * - * Return: Non-negative on success/Negative on failure + * Return: Success: SUCCEED + * Failure: FAIL * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Jan 15 2003 * *------------------------------------------------------------------------- @@ -766,10 +761,10 @@ done: * * Purpose: Mark a local heap data block in memory as non-dirty. * - * Return: Non-negative on success/Negative on failure + * Return: Success: SUCCEED + * Failure: FAIL * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Mar 20 2003 * *------------------------------------------------------------------------- diff --git a/src/H5HLdbg.c b/src/H5HLdbg.c index f8d9d92..3410235 100644 --- a/src/H5HLdbg.c +++ b/src/H5HLdbg.c @@ -18,11 +18,11 @@ */ #define H5HL_PACKAGE /* Suppress error about including H5HLpkg */ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local heaps */ -#include "H5Iprivate.h" /* ID Functions */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLpkg.h" /* Local heaps */ +#include "H5Iprivate.h" /* ID Functions */ +#include "H5MMprivate.h" /* Memory management */ /*------------------------------------------------------------------------- * Function: H5HL_debug @@ -64,10 +64,10 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int HDfprintf(stream, "%*s%-*s %a\n", indent, "", fwidth, "Address of heap data:", h->dblk_addr); HDfprintf(stream, "%*s%-*s %Zu\n", indent, "", fwidth, "Data bytes allocated for heap:", h->dblk_size); - /* - * Traverse the free list and check that all free blocks fall within + /* Traverse the free list and check that all free blocks fall within * the heap and that no two free blocks point to the same region of - * the heap. */ + * the heap. + */ if (NULL == (marker = (uint8_t *)H5MM_calloc(h->dblk_size))) HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, FAIL, "memory allocation failed") @@ -93,16 +93,14 @@ H5HL_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE *stream, int indent, int HDfprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n"); else amount_free += freelist->size; - } /* end for */ + } /* end else */ } /* end for */ if (h->dblk_size) HDfprintf(stream, "%*s%-*s %.2f%%\n", indent, "", fwidth, "Percent of heap used:", ((double)100.0f * (double)(h->dblk_size - amount_free) / (double)h->dblk_size)); - /* - * Print the data in a VMS-style octal dump. - */ + /* Print the data in a VMS-style octal dump */ H5_buffer_dump(stream, indent, h->dblk_image, marker, (size_t)0, h->dblk_size); done: diff --git a/src/H5HLint.c b/src/H5HLint.c index a74aaf2..41239a8 100644 --- a/src/H5HLint.c +++ b/src/H5HLint.c @@ -31,9 +31,9 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HLpkg.h" /* Local Heaps */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HLpkg.h" /* Local Heaps */ /****************/ /* Local Macros */ diff --git a/src/H5I.c b/src/H5I.c index 8e7be3d..e3f287b 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -30,25 +30,25 @@ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5I_init_interface -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5Ipkg.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Oprivate.h" /* Object headers */ -#include "H5SLprivate.h" /* Skip Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5Ipkg.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5SLprivate.h" /* Skip Lists */ /* Define this to compile in support for dumping ID information */ /* #define H5I_DEBUG_OUTPUT */ #ifndef H5I_DEBUG_OUTPUT -#include "H5Gprivate.h" /* Groups */ -#else /* H5I_DEBUG_OUTPUT */ +#include "H5Gprivate.h" /* Groups */ +#else /* H5I_DEBUG_OUTPUT */ #define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Tprivate.h" /* Datatypes */ -#endif /* H5I_DEBUG_OUTPUT */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Tprivate.h" /* Datatypes */ +#endif /* H5I_DEBUG_OUTPUT */ /* Local Macros */ @@ -164,18 +164,16 @@ H5I_init_interface(void) } /* end H5I_init_interface() */ /*------------------------------------------------------------------------- - * Function: H5I_term_interface + * Function: H5I_term_interface * - * Purpose: Terminate the H5I interface: release all memory, reset all - * global variables to initial values. This only happens if all - * types have been destroyed from other interfaces. + * Purpose: Terminate the H5I interface: release all memory, reset all + * global variables to initial values. This only happens if all + * types have been destroyed from other interfaces. * - * Return: Success: Positive if any action was taken that might - * affect some other interface; zero otherwise. + * Return: Success: Positive if any action was taken that might + * affect some other interface; zero otherwise. * - * Failure: Negative. - * - * Programmer: Unknown + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -376,9 +374,9 @@ H5Itype_exists(H5I_type_t type) FUNC_ENTER_API(FAIL) H5TRACE1("t", "It", type); + /* Validate parameter */ if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") - if (type <= H5I_BADID || type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") @@ -456,8 +454,8 @@ done: int H5I_nmembers(H5I_type_t type) { - H5I_id_type_t *type_ptr = NULL; - int ret_value; + H5I_id_type_t *type_ptr = NULL; + int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -554,6 +552,7 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref) FUNC_ENTER_NOAPI(FAIL) + /* Validate parameters */ if (type <= H5I_BADID || type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") @@ -612,8 +611,8 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) */ if (udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { /* Check for a 'free' function and call it, if it exists */ - /* (Casting away const OK -QAK) */ - if (udata->type_ptr->cls->free_func && (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { + if (udata->type_ptr->cls->free_func && + (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ if (udata->force) { #ifdef H5I_DEBUG if (H5DEBUG(I)) { @@ -702,6 +701,7 @@ H5I__destroy_type(H5I_type_t type) FUNC_ENTER_STATIC + /* Validate parameter */ if (type <= H5I_BADID || type >= H5I_next_type) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") @@ -818,24 +818,24 @@ H5I__wrapped_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) { - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *id_ptr; /*ptr to the new ID information */ - hid_t ret_value = SUCCEED; /*return value */ + H5I_id_type_t *type_ptr = NULL; /* ptr to the type */ + H5I_id_info_t *id_ptr = NULL; /* ptr to the new ID information */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Check arguments */ if (type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid type number") type_ptr = H5I_id_type_list_g[type]; if (NULL == type_ptr || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, H5I_INVALID_HID, "invalid type") /* If there is an available ID structure, use it. */ if (type_ptr->avail_count > 0) { /* Use existing available ID struct */ if (NULL == (id_ptr = (H5I_id_info_t *)H5SL_remove_first(type_ptr->avail_ids))) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREMOVE, FAIL, "can't remove ID from available ID list") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREMOVE, H5I_INVALID_HID, "can't remove ID from available ID list") /* Decrease count of available ID structures */ type_ptr->avail_count--; @@ -864,11 +864,11 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) /* Iterate over all the ID nodes, looking for a gap in the ID sequence */ if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__wrapped_cb, &udata)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "ID iteration failed") + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, H5I_INVALID_HID, "ID iteration failed") /* If we didn't break out of the iteration and we're at the max. ID, we've used all the IDs */ if (0 == iter_status && udata.nextid >= ID_MASK) - HGOTO_ERROR(H5E_ATOM, H5E_NOIDS, FAIL, "no IDs available in type") + HGOTO_ERROR(H5E_ATOM, H5E_NOIDS, H5I_INVALID_HID, "no IDs available in type") /* Sanity check */ HDassert(udata.nextid < ID_MASK); @@ -879,7 +879,7 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) /* Allocate new ID struct */ if (NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) - HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") /* Make a new ID */ id_ptr->id = H5I_MAKE(type, type_ptr->nextid); @@ -932,8 +932,7 @@ H5I_subst(hid_t id, const void *new_object) HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") /* Get the old object pointer to return */ - /* (Casting away const OK -QAK) */ - ret_value = (void *)id_ptr->obj_ptr; + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ /* Set the new object pointer for the ID */ id_ptr->obj_ptr = new_object; @@ -965,9 +964,8 @@ H5I_object(hid_t id) /* General lookup of the ID */ if (NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - /* (Casting away const OK -QAK) */ - ret_value = (void *)id_ptr->obj_ptr; - } /* end if */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1034,9 +1032,8 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) /* Verify that the type of the ID is correct & lookup the ID */ if (id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I__find_id(id))) { /* Get the object pointer to return */ - /* (Casting away const OK -QAK) */ - ret_value = (void *)id_ptr->obj_ptr; - } /* end if */ + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1728,7 +1725,7 @@ done: * be set to H5I_UNINIT). * * Return: Success: Number of references to type - * Failure: -1 + * Failure: FAIL * *------------------------------------------------------------------------- */ @@ -2128,13 +2125,13 @@ done: hid_t H5Iget_file_id(hid_t obj_id) { - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", obj_id); if ((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") done: FUNC_LEAVE_API(ret_value) @@ -2154,8 +2151,8 @@ done: hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref) { - H5I_type_t type; /* ID type */ - hid_t ret_value; /* Return value */ + H5I_type_t type; /* ID type */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2164,7 +2161,7 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) if (type == H5I_FILE) { /* Increment reference count on file ID */ if (H5I_inc_ref(obj_id, app_ref) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") /* Set return value */ ret_value = obj_id; @@ -2174,14 +2171,14 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) /* Get the object location information */ if (H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get object location") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* Get the file ID for the object */ if ((ret_value = H5F_get_id(loc.oloc->file, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") } /* end if */ else - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid object ID") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2212,9 +2209,9 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) FUNC_ENTER_STATIC_NOERR - HDfprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); - HDfprintf(stderr, " count = %u\n", item->count); - HDfprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr)); + HDfprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); + HDfprintf(stderr, " count = %u\n", item->count); + HDfprintf(stderr, " obj = 0x%08lx\n", (unsigned long)(item->obj_ptr)); /* Get the group location, so we get get the name */ switch (type) { @@ -2268,14 +2265,14 @@ H5I__debug(H5I_type_t type) type_ptr = H5I_id_type_list_g[type]; /* Header */ - HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); - HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); - HDfprintf(stderr, " wrapped = %u\n", type_ptr->wrapped); - HDfprintf(stderr, " id_count = %u\n", type_ptr->id_count); - HDfprintf(stderr, " nextid = %u\n", type_ptr->nextid); + HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); + HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); + HDfprintf(stderr, " wrapped = %u\n", type_ptr->wrapped); + HDfprintf(stderr, " id_count = %u\n", type_ptr->id_count); + HDfprintf(stderr, " nextid = %u\n", type_ptr->nextid); /* List */ - HDfprintf(stderr, " List:\n"); + HDfprintf(stderr, " List:\n"); H5SL_iterate(type_ptr->ids, H5I__debug_cb, &type); FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5Itest.c b/src/H5Itest.c index 74d649e..7256881 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -27,11 +27,11 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Ipkg.h" /* IDs */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Ipkg.h" /* IDs */ /****************/ /* Local Macros */ @@ -69,18 +69,18 @@ ssize_t H5I_get_name_test(hid_t id, char *name /*out*/, size_t size, hbool_t *cached) { - H5G_loc_t loc; /* Object location */ - ssize_t ret_value; /* Return value */ + H5G_loc_t loc; /* Object location */ + ssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Get object location */ if (H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") /* Call internal group routine to retrieve object's name */ if ((ret_value = H5G_get_name(&loc, name, size, cached, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5L.c b/src/H5L.c index d1ddfc3..7071cb0 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -282,8 +282,8 @@ H5L_term_interface(void) * group. The original name SRC is unlinked from the group graph * and then inserted with the new name DST (which can specify a * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. + * are interpreted relative to SRC_LOC_ID and DST_LOC_ID, + * which are either file IDs or group ID. * * Return: Non-negative on success/Negative on failure * @@ -548,7 +548,7 @@ done: * * Purpose: Removes the specified NAME from the group graph and * decrements the link count for the object to which NAME - * points. If the link count reaches zero then all file-space + * points. If the link count reaches zero then all file-space * associated with the object will be reclaimed (but if the * object is open, then the reclamation of the file space is * delayed until all handles to the object are closed). @@ -753,8 +753,7 @@ done: * * Purpose: Checks if a link of a given name exists in a group * - * Return: Success: TRUE/FALSE - * Failure: Negative + * Return: Success: TRUE/FALSE/FAIL * * Programmer: Quincey Koziol * Friday, March 16, 2007 @@ -765,7 +764,7 @@ htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { H5G_loc_t loc; - htri_t ret_value; + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); @@ -773,8 +772,11 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) /* Check arguments */ if (H5G_loc(loc_id, &loc)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") + if (H5P_DEFAULT == lapl_id) lapl_id = H5P_LINK_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) @@ -794,7 +796,6 @@ done: * Purpose: Gets metadata for a link. * * Return: Success: Non-negative with information in LINFO - * * Failure: Negative * * Programmer: James Laird @@ -806,7 +807,7 @@ herr_t H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, hid_t lapl_id) { H5G_loc_t loc; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); @@ -816,6 +817,7 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, hid_t lap HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (H5P_DEFAULT == lapl_id) lapl_id = H5P_LINK_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) @@ -975,9 +977,9 @@ done: * Purpose: Tests whether a user-defined link class has been registered * or not. * - * Return: Positive if the link class has been registered - * Zero if it is unregistered - * Negative on error (if the class is not a valid UD class ID) + * Return: TRUE if the link class has been registered + * FALSE if it is unregistered + * FAIL on error (if the class is not a valid UD class ID) * * Programmer: James Laird * Monday, July 10, 2006 @@ -1017,8 +1019,9 @@ done: * Same pattern of behavior as H5Iget_name. * * Return: Success: Non-negative length of name, with information - * in NAME buffer - * Failure: Negative + * in NAME buffer + * + * Failure: -1 * * Programmer: Quincey Koziol * Saturday, November 11, 2006 @@ -1033,22 +1036,23 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5 H5L_trav_gnbi_t udata; /* User data for callback */ ssize_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE8("Zs", "i*sIiIohxzi", loc_id, group_name, idx_type, order, n, name, size, lapl_id); /* Check arguments */ if (H5G_loc(loc_id, &loc)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name specified") if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid index type specified") if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid iteration order specified") + if (H5P_DEFAULT == lapl_id) lapl_id = H5P_LINK_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not link access property list ID") /* Set up user data for callback */ udata.idx_type = idx_type; @@ -1062,7 +1066,7 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5 /* Traverse the group hierarchy to locate the link to get name of */ if (H5G_traverse(&loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L_get_name_by_idx_cb, &udata, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + HGOTO_ERROR(H5E_SYM, H5E_EXISTS, (-1), "name doesn't exist") /* Set the return value */ ret_value = udata.name_len; @@ -1080,16 +1084,12 @@ done: * Same pattern of behavior as H5Giterate. * * Return: Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. - * - * - * Programmer: Quincey Koziol - * Thursday, November 16, 2006 + * library, or the negative value returned by one + * of the operators. * *------------------------------------------------------------------------- */ @@ -1147,12 +1147,12 @@ done: * Same pattern of behavior as H5Giterate. * * Return: Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * library, or the negative value returned by one + * of the operators. * * * Programmer: Quincey Koziol @@ -1173,8 +1173,10 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5 H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, group_name, idx_type, order, idx_p, op, op_data, lapl_id); /* Check arguments */ - if (!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (!group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") + if (!*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) @@ -1223,12 +1225,12 @@ done: * _object_. * * Return: Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * library, or the negative value returned by one + * of the operators. * * Programmer: Quincey Koziol * November 24 2007 @@ -1279,12 +1281,12 @@ done: * _object_. * * Return: Success: The return value of the first operator that - * returns non-zero, or zero if all members were - * processed with no operator returning non-zero. + * returns non-zero, or zero if all members were + * processed with no operator returning non-zero. * * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. + * library, or the negative value returned by one + * of the operators. * * Programmer: Quincey Koziol * November 3 2007 @@ -1301,14 +1303,17 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_i H5TRACE7("e", "i*sIiIox*xi", loc_id, group_name, idx_type, order, op, op_data, lapl_id); /* Check args */ - if (!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (!group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") + if (!*group_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be an empty string") if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + if (H5P_DEFAULT == lapl_id) lapl_id = H5P_LINK_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) @@ -1902,7 +1907,7 @@ done: * * Purpose: Creates a soft link from LINK_NAME to TARGET_PATH. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Monday, April 6, 1998 @@ -2351,11 +2356,10 @@ H5L_move_dest_cb(H5G_loc_t *grp_loc /*in*/, const char *name, const H5O_link_t H HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "an object with that name already exists") /* Check for crossing file boundaries with a new hard link */ - if (udata->lnk->type == H5L_TYPE_HARD) { + if (udata->lnk->type == H5L_TYPE_HARD) /* Check that both objects are in same file */ if (!H5F_SAME_SHARED(grp_loc->oloc->file, udata->file)) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "moving a link across files is not allowed") - } /* end if */ /* Give the object its new name */ /* Casting away const okay -JML */ @@ -2737,7 +2741,7 @@ done: * * Purpose: Returns metadata about a link. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: James Laird * Monday, April 17 2006 @@ -2891,7 +2895,6 @@ done: * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol - * koziol@hdfgroup.org * Sep 29 2006 * *------------------------------------------------------------------------- diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index aae3684..ed3d39a 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -157,25 +157,10 @@ done: * link access property list, appends that prefix to the * filename being opened. * - * Return: ID of the opened object on success/Negative on failure + * Return: ID of the opened object on success/H5I_INVALID_HID on failure * * Programmer: James Laird * Monday, July 10, 2006 - * Modifications: - * Vailin Choi, April 2, 2008 - * Add handling to search for the target file - * See description in RM: H5Lcreate_external - * - * Vailin Choi; Sept. 12th, 2008; bug #1247 - * Retrieve the file access property list identifer that is set - * for link access property via H5Pget_elink_fapl(). - * If the return value is H5P_DEFAULT, the parent's file access - * property is used to H5F_open() the target file; - * Otherwise, the file access property retrieved from H5Pget_elink_fapl() - * is used to H5F_open() the target file. - * - * Vailin Choi; Nov 2010 - * Free memory pointed to by tmp_env_prefix for HDF5_EXT_PREFIX case. * *------------------------------------------------------------------------- */ @@ -204,18 +189,18 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const char * actual_file_name = NULL; /* Parent file's actual name */ H5P_genplist_t * fa_plist; /* File access property list pointer */ H5F_close_degree_t fc_degree = H5F_CLOSE_WEAK; /* File close degree for target file */ - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Sanity checks */ HDassert(p); /* Check external link version & flags */ if (((*p >> 4) & 0x0F) > H5L_EXT_VERSION) - HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link") + HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, H5I_INVALID_HID, "bad version number for external link") if ((*p & 0x0F) & ~H5L_EXT_FLAGS_ALL) - HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link") + HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, H5I_INVALID_HID, "bad flags for external link") p++; /* Gather some information from the external link's user data */ @@ -225,19 +210,19 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Get the plist structure */ if (NULL == (plist = H5P_object_verify(lapl_id, H5P_LINK_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* Get the fapl_id set for lapl_id if any */ if (H5P_get(plist, H5L_ACS_ELINK_FAPL_NAME, &fapl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get fapl for links") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get fapl for links") /* Get the location for the group holding the external link */ if (H5G_loc(cur_group, &loc) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get object location") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* get the access flags set for lapl_id if any */ if (H5P_get(plist, H5L_ACS_ELINK_FLAGS_NAME, &intent) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get elink file access flags") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get elink file access flags") /* get the file access mode flags for the parent file, if they were not set * on lapl_id */ @@ -245,15 +230,15 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const intent = H5F_INTENT(loc.oloc->file); if ((fapl_id == H5P_DEFAULT) && ((fapl_id = H5F_get_access_plist(loc.oloc->file, FALSE)) < 0)) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't get parent's file access property list") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't get parent's file access property list") /* Get callback_info */ if (H5P_get(plist, H5L_ACS_ELINK_CB_NAME, &cb_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get elink callback info") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get elink callback info") /* Get file access property list */ if (NULL == (fa_plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") /* Make callback if it exists */ if (cb_info.func) { @@ -265,7 +250,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Query length of parent group name */ if ((group_name_len = H5G_get_name(&loc, NULL, (size_t)0, NULL, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve length of group name") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve length of group name") /* Account for null terminator */ group_name_len++; @@ -273,8 +258,8 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Check if we need to allocate larger buffer */ if ((size_t)group_name_len > sizeof(local_group_name)) { if (NULL == (parent_group_name = (char *)H5MM_malloc((size_t)group_name_len))) - HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, FAIL, - "can't allocate buffer to hold group name, group_name_len = %Zu", group_name_len) + HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, H5I_INVALID_HID, + "can't allocate buffer to hold group name, group_name_len = %zd", group_name_len) } /* end if */ else parent_group_name = local_group_name; @@ -282,21 +267,21 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Get parent group name */ if (H5G_get_name(&loc, parent_group_name, (size_t)group_name_len, NULL, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to retrieve group name") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve group name") /* Make callback */ if ((cb_info.func)(parent_file_name, parent_group_name, file_name, obj_name, &intent, fapl_id, cb_info.user_data) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, FAIL, "traversal operator failed") + HGOTO_ERROR(H5E_LINK, H5E_CALLBACK, H5I_INVALID_HID, "traversal operator failed") /* Check access flags */ if ((intent & H5F_ACC_TRUNC) || (intent & H5F_ACC_EXCL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file open flags") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags") } /* end if */ /* Set file close degree for new file to "weak" */ if (H5P_set(fa_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") /* * Start searching for the target file @@ -307,7 +292,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Copy the file name to use */ if (NULL == (temp_file_name = H5MM_strdup(file_name))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") temp_file_name_len = HDstrlen(temp_file_name); /* target file_name is an absolute pathname: see RM for detailed description */ @@ -352,7 +337,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const char *tmp_env_prefix, *saved_env; if (NULL == (saved_env = tmp_env_prefix = H5MM_strdup(env_prefix))) - HGOTO_ERROR(H5E_LINK, H5E_NOSPACE, FAIL, "memory allocation failed") + HGOTO_ERROR(H5E_LINK, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed") while ((tmp_env_prefix) && (*tmp_env_prefix)) { char *out_prefix_name; @@ -361,7 +346,8 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const if (out_prefix_name && (*out_prefix_name)) { if (H5L_build_name(out_prefix_name, temp_file_name, &full_name /*out*/) < 0) { saved_env = (char *)H5MM_xfree(saved_env); - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, + "can't prepend prefix to filename") } /* end if */ ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, @@ -379,10 +365,10 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* try searching from property list */ if (ext_file == NULL) { if (H5P_get(plist, H5L_ACS_ELINK_PREFIX_NAME, &my_prefix) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get external link prefix") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get external link prefix") if (my_prefix) { if (H5L_build_name(my_prefix, temp_file_name, &full_name /*out*/) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't prepend prefix to filename") if (NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) H5E_clear_stack(NULL); @@ -396,7 +382,7 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const if (NULL != (extpath = H5F_EXTPATH(loc.oloc->file))) { if (H5L_build_name(extpath, temp_file_name, &full_name /*out*/) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't prepend prefix to filename") if (NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) H5E_clear_stack(NULL); @@ -419,12 +405,12 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Copy resolved file name */ if (NULL == (actual_file_name = H5MM_strdup(H5F_ACTUAL_NAME(loc.oloc->file)))) - HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, FAIL, "can't duplicate resolved file name string") + HGOTO_ERROR(H5E_LINK, H5E_CANTALLOC, H5I_INVALID_HID, "can't duplicate resolved file name string") /* get last component of file_name */ H5_GET_LAST_DELIMITER(actual_file_name, ptr) if (!ptr) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open external file, external link file name = '%s', temp_file_name = '%s'", file_name, temp_file_name) @@ -433,12 +419,12 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Build new file name for the external file */ if (H5L_build_name(actual_file_name, temp_file_name, &full_name /*out*/) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't prepend prefix to filename") + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, H5I_INVALID_HID, "can't prepend prefix to filename") /* Try opening with the resolved name */ if (NULL == (ext_file = H5F_efc_open(loc.oloc->file, full_name, intent, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, FAIL, + HGOTO_ERROR(H5E_LINK, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open external file, external link file name = '%s', temp_file_name = '%s'", file_name, temp_file_name) full_name = (char *)H5MM_xfree(full_name); @@ -446,11 +432,11 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const /* Retrieve the "group location" for the file's root group */ if (H5G_root_loc(ext_file, &root_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, H5I_INVALID_HID, "unable to create location for file") /* Open the object referenced in the external file */ if ((ext_obj = H5O_open_name(&root_loc, obj_name, lapl_id, FALSE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Set return value */ ret_value = ext_obj; @@ -458,9 +444,10 @@ H5L_extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, const done: /* Release resources */ if (fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) - HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for file access property list") + HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to close atom for file access property list") if (ext_file && H5F_efc_close(loc.oloc->file, ext_file) < 0) - HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, FAIL, "problem closing external file") + HDONE_ERROR(H5E_LINK, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problem closing external file") if (parent_group_name && parent_group_name != local_group_name) parent_group_name = (char *)H5MM_xfree(parent_group_name); full_name = (char *)H5MM_xfree(full_name); @@ -470,7 +457,8 @@ done: if (ret_value < 0) { /* Close object if it's open and something failed */ if (ext_obj >= 0 && H5I_dec_ref(ext_obj) < 0) - HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, FAIL, "unable to close atom for external object") + HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, + "unable to close atom for external object") } /* end if */ FUNC_LEAVE_NOAPI(ret_value) @@ -479,16 +467,16 @@ done: /*------------------------------------------------------------------------- * Function: H5L_extern_query * - * Purpose: Default query function for external links. This can + * Purpose: Default query function for external links. This can * be overridden using H5Lregister(). * * Returns the size of the link's user data. If a buffer of * is provided, copies at most buf_size bytes of the udata * into it. * - * Return: Size of buffer on success/Negative on failure + * Return: Size of buffer on success/Negative on failure * - * Programmer: James Laird + * Programmer: James Laird * Monday, July 10, 2006 * *------------------------------------------------------------------------- @@ -526,21 +514,21 @@ done: } /* end H5L_extern_query() */ /*------------------------------------------------------------------------- - * Function: H5Lcreate_external + * Function: H5Lcreate_external * - * Purpose: Creates an external link from LINK_NAME to OBJ_NAME. + * Purpose: Creates an external link from LINK_NAME to OBJ_NAME. * * External links are links to objects in other HDF5 files. They * are allowed to "dangle" like soft links internal to a file. * FILE_NAME is the name of the file that OBJ_NAME is is contained * within. If OBJ_NAME is given as a relative path name, the * path will be relative to the root group of FILE_NAME. - * LINK_NAME is interpreted relative to LINK_LOC_ID, which is + * LINK_NAME is interpreted relative to LINK_LOC_ID, which is * either a file ID or a group ID. * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Wednesday, May 18, 2005 * *------------------------------------------------------------------------- diff --git a/src/H5MFaggr.c b/src/H5MFaggr.c index 48031ee..98f59c3 100644 --- a/src/H5MFaggr.c +++ b/src/H5MFaggr.c @@ -84,7 +84,7 @@ static herr_t H5MF_aggr_free(H5F_t *f, hid_t dxpl_id, H5FD_mem_t type, H5F_blk_a haddr_t H5MF_aggr_vfd_alloc(H5F_t *f, H5FD_mem_t alloc_type, hid_t dxpl_id, hsize_t size) { - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_ALLOC_DEBUG @@ -146,7 +146,7 @@ H5MF_aggr_alloc(H5F_t *f, hid_t dxpl_id, H5F_blk_aggr_t *aggr, H5F_blk_aggr_t *o haddr_t eoa_frag_addr = HADDR_UNDEF; /* Address of fragment at EOA */ hsize_t eoa_frag_size = 0; /* Size of fragment at EOA */ haddr_t eoa = HADDR_UNDEF; /* Initial EOA for the file */ - haddr_t ret_value; /* Return value */ + haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_NOAPI(HADDR_UNDEF) #ifdef H5MF_AGGR_DEBUG @@ -436,7 +436,7 @@ H5MF_aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, haddr_t bl if (f->shared->feature_flags & aggr->feature_flag) { /* * If the block being tested adjoins the beginning of the aggregator - * block, check if the aggregator can accomodate the extension. + * block, check if the aggregator can accommodate the extension. */ if (H5F_addr_eq(blk_end, aggr->addr)) { haddr_t eoa; /* EOA for the file */ @@ -480,10 +480,11 @@ H5MF_aggr_try_extend(H5F_t *f, H5F_blk_aggr_t *aggr, H5FD_mem_t type, haddr_t bl */ aggr->size += extra; aggr->size -= extra_requested; - } /* end if */ - } /* end if */ + } /* end else-if */ + } /* end else */ } /* end if */ - else { /* The aggreator is not at end of file */ + else { + /* The aggreator is not at end of file */ /* Check if aggregator has enough internal space to satisfy the extension. */ if (aggr->size >= extra_requested) { /* Extend block into aggregator */ diff --git a/src/H5MFpkg.h b/src/H5MFpkg.h index 4654227..e6dfde2 100644 --- a/src/H5MFpkg.h +++ b/src/H5MFpkg.h @@ -48,10 +48,10 @@ /* Define this to dump free space tracker contents after they've been modified */ /* #define H5MF_ALLOC_DEBUG_DUMP */ -/* Free space section types for file */ +/* Free-space section types for file */ /* (values stored in free space data structures in file) */ -#define H5MF_FSPACE_SECT_SIMPLE 0 /* Section is a range of actual bytes in file */ - +/* Section is a range of actual bytes in file */ +#define H5MF_FSPACE_SECT_SIMPLE 0 /****************************/ /* Package Private Typedefs */ /****************************/ diff --git a/src/H5O.c b/src/H5O.c index 1efc878..f0836fd 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -32,16 +32,16 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fprivate.h" /* File access */ -#include "H5FLprivate.h" /* Free lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5Opkg.h" /* Object headers */ -#include "H5SMprivate.h" /* Shared object header messages */ +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5SMprivate.h" /* Shared object header messages */ /****************/ /* Local Macros */ @@ -214,21 +214,23 @@ H5O_init_interface(void) hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; - hid_t ret_value = FAIL; + H5G_loc_t loc; /* Location of group */ + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, lapl_id); /* Check args */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if (!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") + if (!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") /* Open the object */ if ((ret_value = H5O_open_name(&loc, name, lapl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") done: FUNC_LEAVE_API(ret_value) @@ -261,29 +263,29 @@ hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5G_loc_t loc; + H5G_loc_t loc; /* Location of group */ H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t ret_value = FAIL; + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check args */ if (H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if (!group_name || !*group_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name specified") if (idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid index type specified") if (order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid iteration order specified") if (H5P_DEFAULT == lapl_id) lapl_id = H5P_LINK_ACCESS_DEFAULT; else if (TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not link access property list ID") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -293,18 +295,18 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_ite /* Find the object's location, according to the order in the index */ if (H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc /*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5I_INVALID_HID, "group not found") loc_found = TRUE; /* Open the object */ if ((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") done: /* Release the object location if we failed after copying it */ if (ret_value < 0 && loc_found) if (H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ @@ -347,21 +349,21 @@ done: hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { - H5G_loc_t loc; + H5G_loc_t loc; /* Location within file */ H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT; /* lapl to use to open this object */ - hid_t ret_value = FAIL; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "ia", loc_id, addr); /* Check args */ if (H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no address supplied") /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; @@ -373,7 +375,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) /* Open the object */ if ((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") done: FUNC_LEAVE_API(ret_value) @@ -465,9 +467,9 @@ H5Oincr_refcount(hid_t object_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - /* Get the object's oloc so we can adjust its link count */ + /* Get the location object */ if ((oloc = H5O_get_loc(object_id)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADVALUE, FAIL, "unable to get object location from ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") if (H5O_link(oloc, 1, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") @@ -505,9 +507,9 @@ H5Odecr_refcount(hid_t object_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - /* Get the object's oloc so we can adjust its link count */ + /* Get the location object */ if ((oloc = H5O_get_loc(object_id)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADVALUE, FAIL, "unable to get object location from ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") if (H5O_link(oloc, -1, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") @@ -533,7 +535,7 @@ htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { H5G_loc_t loc; /* Location info */ - hid_t ret_value = FAIL; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); @@ -727,9 +729,9 @@ H5Oset_comment(hid_t obj_id, const char *comment) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", obj_id, comment); - /* Check args */ + /* Get the location object */ if (H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* (Re)set the object's comment */ if (H5G_loc_set_comment(&loc, ".", comment, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0) @@ -2470,7 +2472,6 @@ H5O_loc_reset(H5O_loc_t *loc) * Failure: Negative * * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu * Monday, September 19, 2005 * * Notes: 'depth' parameter determines how much of the group entry diff --git a/src/H5Oainfo.c b/src/H5Oainfo.c index 785bb22..28bc305 100644 --- a/src/H5Oainfo.c +++ b/src/H5Oainfo.c @@ -102,9 +102,9 @@ H5O_ainfo_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *o unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, size_t H5_ATTR_UNUSED p_size, const uint8_t *p) { - H5O_ainfo_t * ainfo = NULL; /* Attribute info */ - unsigned char flags; /* Flags for encoding attribute info */ - void * ret_value; /* Return value */ + H5O_ainfo_t * ainfo = NULL; /* Attribute info */ + unsigned char flags; /* Flags for encoding attribute info */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -227,9 +227,9 @@ H5O_ainfo_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, co static void * H5O_ainfo_copy(const void *_mesg, void *_dest) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - H5O_ainfo_t * dest = (H5O_ainfo_t *)_dest; - void * ret_value; /* Return value */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + H5O_ainfo_t * dest = (H5O_ainfo_t *)_dest; + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -266,8 +266,8 @@ done: static size_t H5O_ainfo_size(const H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, const void *_mesg) { - const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; - size_t ret_value; /* Return value */ + const H5O_ainfo_t *ainfo = (const H5O_ainfo_t *)_mesg; + size_t ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -395,7 +395,7 @@ H5O_ainfo_copy_file(H5F_t *file_src, void *mesg_src, H5F_t *file_dst, hbool_t H5 { H5O_ainfo_t *ainfo_src = (H5O_ainfo_t *)mesg_src; H5O_ainfo_t *ainfo_dst = NULL; - void * ret_value; /* Return value */ + void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -458,11 +458,10 @@ H5O_ainfo_post_copy_file(const H5O_loc_t *src_oloc, const void *mesg_src, H5O_lo HDassert(ainfo_src); - if (H5F_addr_defined(ainfo_src->fheap_addr)) { + if (H5F_addr_defined(ainfo_src->fheap_addr)) if (H5A_dense_post_copy_file_all(src_oloc, ainfo_src, dst_oloc, (H5O_ainfo_t *)mesg_dst, dxpl_id, cpy_info) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "can't copy attribute") - } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 9e30c91..032bded 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -644,8 +644,8 @@ H5O_alloc_extend_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned chunkno, siz oh->mesg[u].raw = oh->chunk[chunkno].image + extra_prfx_size + (oh->mesg[u].raw - old_image); /* Find continuation message which points to this chunk and adjust chunk's size */ - /* (Chunk 0 doesn't have a continuation message that points to it and - * it's size is directly encoded in the object header) */ + /* (Chunk 0 doesn't have a continuation message that points to it, + * its size is directly encoded in the object header) */ if (chunkno > 0 && (H5O_CONT_ID == oh->mesg[u].type->id) && (((H5O_cont_t *)(oh->mesg[u].native))->chunkno == chunkno)) { H5O_chunk_proxy_t *chk_proxy2 = NULL; /* Chunk that continuation message is in */ @@ -873,7 +873,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, size_t *new /* * The total chunk size must include the requested space plus enough * for the message header. This must be at least some minimum and - * aligned propertly. + * aligned properly. */ size = MAX(H5O_MIN_SIZE, size + (size_t)H5O_SIZEOF_MSGHDR_OH(oh)); HDassert(size == H5O_ALIGN_OH(oh, size)); @@ -890,9 +890,7 @@ H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, size_t size, size_t *new if (HADDR_UNDEF == new_chunk_addr) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate space for new chunk") - /* - * Create the new chunk giving it a file address. - */ + /* Create the new chunk giving it a file address. */ if (oh->nchunks >= oh->alloc_nchunks) { size_t na = MAX(H5O_NCHUNKS, oh->alloc_nchunks * 2); /* Double # of chunks allocated */ H5O_chunk_t *x; @@ -1755,7 +1753,7 @@ H5O_merge_null(H5F_t *f, hid_t dxpl_id, H5O_t *oh) { hbool_t merged_msg; /* Flag to indicate that messages were merged */ hbool_t did_merging = FALSE; /* Whether any messages were merged */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1895,7 +1893,7 @@ H5O_remove_empty_chunks(H5F_t *f, hid_t dxpl_id, H5O_t *oh) { hbool_t deleted_chunk; /* Whether to a chunk was deleted */ hbool_t did_deleting = FALSE; /* Whether any chunks were deleted */ - htri_t ret_value; /* Return value */ + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT diff --git a/src/H5Oattr.c b/src/H5Oattr.c index c01277d..4bacee4 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -470,13 +470,6 @@ H5O_attr_size(const H5F_t H5_ATTR_UNUSED *f, const void *_mesg) * Programmer: Robb Matzke * Tuesday, December 9, 1997 * - * Modification:Raymond Lu - * 25 June 2008 - * Made this function empty. The freeing action is actually - * done in H5O_attr_free (see H5O_msg_free_real). But this - * empty reset function needs to be here. Otherwise, the - * caller function H5O_msg_reset_real will zero-set the whole - * message. *------------------------------------------------------------------------- */ herr_t @@ -490,17 +483,13 @@ H5O_attr_reset(void H5_ATTR_UNUSED *_mesg) /*------------------------------------------------------------------------- * Function: H5O_attr_free * - * Purpose: Free's the message + * Purpose: Frees the message * * Return: Non-negative on success/Negative on failure * * Programmer: Quincey Koziol * Thursday, November 18, 2004 * - * Modification:Raymond Lu - * 4 June 2008 - * Let this function call H5A_close in turn. - * *------------------------------------------------------------------------- */ static herr_t diff --git a/src/H5TS.c b/src/H5TS.c index 98e7d1b..ab25f47 100644 --- a/src/H5TS.c +++ b/src/H5TS.c @@ -34,8 +34,34 @@ H5TS_once_t H5TS_first_init_g = PTHREAD_ONCE_INIT; #endif /* H5_HAVE_WIN_THREADS */ H5TS_key_t H5TS_errstk_key_g; H5TS_key_t H5TS_funcstk_key_g; +H5TS_key_t H5TS_apictx_key_g; H5TS_key_t H5TS_cancel_key_g; +#ifndef H5_HAVE_WIN_THREADS + +/* An H5TS_tid_t is a record of a thread identifier that is + * available for reuse. + */ +struct _tid; +typedef struct _tid H5TS_tid_t; + +struct _tid { + H5TS_tid_t *next; + uint64_t id; +}; + +/* Pointer to first free thread ID record or NULL. */ +static H5TS_tid_t *H5TS_tid_next_free = NULL; +static uint64_t H5TS_tid_next_id = 0; + +/* Mutual exclusion for access to H5TS_tid_next_free and H5TS_tid_next_id. */ +static pthread_mutex_t H5TS_tid_mtx; + +/* Key for thread-local storage of the thread ID. */ +static H5TS_key_t H5TS_tid_key; + +#endif /* H5_HAVE_WIN_THREADS */ + /*-------------------------------------------------------------------------- * NAME * H5TS_key_destructor @@ -67,6 +93,127 @@ H5TS_key_destructor(void *key_val) /*-------------------------------------------------------------------------- * NAME + * H5TS_tid_destructor + * + * USAGE + * H5TS_tid_destructor() + * + * RETURNS + * + * DESCRIPTION + * When a thread shuts down, put its ID record on the free list. + * + *-------------------------------------------------------------------------- + */ +static void +H5TS_tid_destructor(void *_v) +{ + H5TS_tid_t *tid = _v; + + if (tid == NULL) + return; + + /* TBD use an atomic CAS */ + pthread_mutex_lock(&H5TS_tid_mtx); + tid->next = H5TS_tid_next_free; + H5TS_tid_next_free = tid; + pthread_mutex_unlock(&H5TS_tid_mtx); +} + +/*-------------------------------------------------------------------------- + * NAME + * H5TS_tid_init + * + * USAGE + * H5TS_tid_init() + * + * RETURNS + * + * DESCRIPTION + * Initialize for integer thread identifiers. + * + *-------------------------------------------------------------------------- + */ +static void +H5TS_tid_init(void) +{ + pthread_mutex_init(&H5TS_tid_mtx, NULL); + pthread_key_create(&H5TS_tid_key, H5TS_tid_destructor); +} + +/*-------------------------------------------------------------------------- + * NAME + * H5TS_thread_id + * + * USAGE + * uint64_t id = H5TS_thread_id() + * + * RETURNS + * Return an integer identifier, ID, for the current thread. + * + * DESCRIPTION + * The ID satisfies the following properties: + * + * 1 1 <= ID <= UINT64_MAX + * 2 ID is constant over the thread's lifetime. + * 3 No two threads share an ID during their lifetimes. + * 4 A thread's ID is available for reuse as soon as it is joined. + * + * ID 0 is reserved. H5TS_thread_id() returns 0 if the library was not + * built with thread safety or if an error prevents it from assigning an + * ID. + * + *-------------------------------------------------------------------------- + */ +uint64_t +H5TS_thread_id(void) +{ + H5TS_tid_t *tid = pthread_getspecific(H5TS_tid_key); + H5TS_tid_t proto_tid; + + /* An ID is already assigned. */ + if (tid != NULL) + return tid->id; + + /* An ID is *not* already assigned: reuse an ID that's on the + * free list, or else generate a new ID. + * + * Allocating memory while holding a mutex is bad form, so + * point `tid` at `proto_tid` if we need to allocate some + * memory. + */ + pthread_mutex_lock(&H5TS_tid_mtx); + if ((tid = H5TS_tid_next_free) != NULL) + H5TS_tid_next_free = tid->next; + else if (H5TS_tid_next_id != UINT64_MAX) { + tid = &proto_tid; + tid->id = ++H5TS_tid_next_id; + } + pthread_mutex_unlock(&H5TS_tid_mtx); + + /* If a prototype ID record was established, copy it to the heap. */ + if (tid == &proto_tid) { + if ((tid = HDmalloc(sizeof(*tid))) != NULL) + *tid = proto_tid; + } + + if (tid == NULL) + return 0; + + /* Finish initializing the ID record and set a thread-local pointer + * to it. + */ + tid->next = NULL; + if (pthread_setspecific(H5TS_tid_key, tid) != 0) { + H5TS_tid_destructor(tid); + return 0; + } + + return tid->id; +} + +/*-------------------------------------------------------------------------- + * NAME * H5TS_pthread_first_thread_init * * USAGE @@ -87,7 +234,7 @@ H5TS_key_destructor(void *key_val) void H5TS_pthread_first_thread_init(void) { - H5_g.H5_libinit_g = FALSE; + H5_g.H5_libinit_g = FALSE; /* Library hasn't been initialized */ #ifdef H5_HAVE_WIN32_API #ifdef PTW32_STATIC_LIB @@ -100,12 +247,18 @@ H5TS_pthread_first_thread_init(void) pthread_cond_init(&H5_g.init_lock.cond_var, NULL); H5_g.init_lock.lock_count = 0; + /* Initialize integer thread identifiers. */ + H5TS_tid_init(); + /* initialize key for thread-specific error stacks */ pthread_key_create(&H5TS_errstk_key_g, H5TS_key_destructor); /* initialize key for thread-specific function stacks */ pthread_key_create(&H5TS_funcstk_key_g, H5TS_key_destructor); + /* initialize key for thread-specific API contexts */ + pthread_key_create(&H5TS_apictx_key_g, H5TS_key_destructor); + /* initialize key for thread cancellability mechanism */ pthread_key_create(&H5TS_cancel_key_g, H5TS_key_destructor); } @@ -143,7 +296,7 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) if (ret_value) return ret_value; - if (mutex->lock_count && pthread_equal(HDpthread_self(), mutex->owner_thread)) { + if (mutex->lock_count && pthread_equal(pthread_self(), mutex->owner_thread)) { /* already owned by self - increment count */ mutex->lock_count++; } @@ -153,7 +306,7 @@ H5TS_mutex_lock(H5TS_mutex_t *mutex) pthread_cond_wait(&mutex->cond_var, &mutex->atomic_lock); /* After we've received the signal, take ownership of the mutex */ - mutex->owner_thread = HDpthread_self(); + mutex->owner_thread = pthread_self(); mutex->lock_count = 1; } @@ -254,11 +407,10 @@ H5TS_cancel_count_inc(void) * Don't use H5MM calls here since the destructor has to use HDfree in * order to avoid codestack calls. */ - cancel_counter = (H5TS_cancel_t *)H5MM_calloc(sizeof(H5TS_cancel_t)); + cancel_counter = (H5TS_cancel_t *)HDcalloc(1, sizeof(H5TS_cancel_t)); if (!cancel_counter) { - H5E_push_stack(NULL, "H5TS_cancel_count_inc", __FILE__, __LINE__, H5E_ERR_CLS_g, H5E_RESOURCE, - H5E_NOSPACE, "memory allocation failed"); + HERROR(H5E_RESOURCE, H5E_NOSPACE, "memory allocation failed"); return FAIL; } @@ -348,6 +500,9 @@ H5TS_win32_process_enter(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContex) ret_value = FALSE; #endif /* H5_HAVE_CODESTACK */ + if (TLS_OUT_OF_INDEXES == (H5TS_apictx_key_g = TlsAlloc())) + ret_value = FALSE; + return ret_value; } /* H5TS_win32_process_enter() */ #endif /* H5_HAVE_WIN_THREADS */ @@ -414,6 +569,7 @@ H5TS_win32_process_exit(void) #ifdef H5_HAVE_CODESTACK TlsFree(H5TS_funcstk_key_g); #endif /* H5_HAVE_CODESTACK */ + TlsFree(H5TS_apictx_key_g); return; } /* H5TS_win32_process_exit() */ @@ -457,6 +613,10 @@ H5TS_win32_thread_exit(void) LocalFree((HLOCAL)lpvData); #endif /* H5_HAVE_CODESTACK */ + lpvData = TlsGetValue(H5TS_apictx_key_g); + if (lpvData) + LocalFree((HLOCAL)lpvData); + return ret_value; } /* H5TS_win32_thread_exit() */ #endif /* H5_HAVE_WIN_THREADS */ diff --git a/src/H5TSprivate.h b/src/H5TSprivate.h index a153425..700d879 100644 --- a/src/H5TSprivate.h +++ b/src/H5TSprivate.h @@ -24,6 +24,7 @@ #ifndef H5TSprivate_H_ #define H5TSprivate_H_ +#ifdef H5_HAVE_THREADSAFE /* Public headers needed by this file */ #ifdef LATER #include "H5TSpublic.h" /*Public API prototypes */ @@ -66,6 +67,8 @@ H5_DLL void H5TS_win32_process_exit(void); H5_DLL herr_t H5TS_win32_thread_enter(void); H5_DLL herr_t H5TS_win32_thread_exit(void); +#define H5TS_thread_id() ((uint64_t)GetCurrentThreadId()) + #else /* H5_HAVE_WIN_THREADS */ /* Library level data structures */ @@ -98,6 +101,7 @@ typedef pthread_once_t H5TS_once_t; #define H5TS_mutex_init(mutex) pthread_mutex_init(mutex, NULL) #define H5TS_mutex_lock_simple(mutex) pthread_mutex_lock(mutex) #define H5TS_mutex_unlock_simple(mutex) pthread_mutex_unlock(mutex) +H5_DLL uint64_t H5TS_thread_id(void); #endif /* H5_HAVE_WIN_THREADS */ @@ -105,6 +109,7 @@ typedef pthread_once_t H5TS_once_t; extern H5TS_once_t H5TS_first_init_g; extern H5TS_key_t H5TS_errstk_key_g; extern H5TS_key_t H5TS_funcstk_key_g; +extern H5TS_key_t H5TS_apictx_key_g; #if defined c_plusplus || defined __cplusplus extern "C" { @@ -121,4 +126,10 @@ H5_DLL H5TS_thread_t H5TS_create_thread(void *(*func)(void *), H5TS_attr_t *attr } #endif /* c_plusplus || __cplusplus */ +#else /* H5_HAVE_THREADSAFE */ + +#define H5TS_thread_id() ((uint64_t)0) + +#endif /* H5_HAVE_THREADSAFE */ + #endif /* H5TSprivate_H_ */ diff --git a/src/H5dbg.c b/src/H5dbg.c index e0b2b74..a78dbe8 100644 --- a/src/H5dbg.c +++ b/src/H5dbg.c @@ -13,11 +13,11 @@ /*------------------------------------------------------------------------- * - * Created: H5dbg.c - * Mar 4 2006 - * Quincey Koziol + * Created: H5dbg.c + * Mar 4 2006 + * Quincey Koziol * - * Purpose: Generic debugging routines + * Purpose: Generic debugging routines * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ /****************/ /* Local Macros */ @@ -56,15 +56,14 @@ /*******************/ /*------------------------------------------------------------------------- - * Function: H5_buffer_dump + * Function: H5_buffer_dump * - * Purpose: Dumps a buffer of memory in an octal dump form + * Purpose: Dumps a buffer of memory in an octal dump form * - * Return: Non-negative on success/Negative on failure + * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol - * koziol@ncsa.uiuc.edu - * Mar 4 2006 + * Programmer: Quincey Koziol + * Mar 4 2006 * *------------------------------------------------------------------------- */ @@ -106,6 +105,7 @@ H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, const uint8_t *mark } /* end if */ else HDfprintf(stream, " "); + if (7 == v) HDfputc(' ', stream); } /* end for */ @@ -118,12 +118,14 @@ H5_buffer_dump(FILE *stream, int indent, const uint8_t *buf, const uint8_t *mark HDfputc(' ', stream); else { c = buf[buf_offset + u + v]; + if (HDisprint(c)) HDfputc(c, stream); else HDfputc('.', stream); } /* end else */ } /* end if */ + if (7 == v) HDfputc(' ', stream); } /* end for */ diff --git a/src/H5detect.c b/src/H5detect.c index 5227811..99aa58a 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -220,25 +220,6 @@ precision(detected_t *d) * * Return: void * - * Modifications: - * - * Robb Matzke, 4 Nov 1996 - * The INFO.perm now contains `-1' for bytes that aren't used and - * are always zero. This happens on the Cray for `short' where - * sizeof(short) is 8, but only the low-order 4 bytes are ever used. - * - * Robb Matzke, 4 Nov 1996 - * Added a `padding' field to indicate how many zero bytes appear to - * the left (N) or right (-N) of the value. - * - * Robb Matzke, 5 Nov 1996 - * Removed HFILE and CFILE arguments. - * - * Neil Fortner, 6 Sep 2013 - * Split macro into DETECT_I and DETECT_BYTE macros, extracted - * common code into DETECT_I_BYTE_CORE. This was done to remove - * "will never be executed" warnings. - * *------------------------------------------------------------------------- */ #define DETECT_I_BYTE_CORE(TYPE, VAR, INFO, DETECT_TYPE) \ @@ -1653,12 +1634,6 @@ verify_signal_handlers(int signum, void (*handler)(int)) * * Return: Success: EXIT_SUCCESS * - * Modifications: - * Some compilers, e.g., Intel C v7.0, took a long time to compile - * with optimization when a module routine contains many code lines. - * Divide up all those types detections macros into subroutines, both - * to avoid the compiler optimization error and cleaner codes. - * *------------------------------------------------------------------------- */ int HDF_NO_UBSAN diff --git a/src/H5err.txt b/src/H5err.txt index f0a60a1..624c801 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -46,7 +46,7 @@ MAJOR, H5E_ARGS, Invalid arguments to routine MAJOR, H5E_RESOURCE, Resource unavailable MAJOR, H5E_INTERNAL, Internal error (too specific to document in detail) -MAJOR, H5E_FILE, File accessibilty +MAJOR, H5E_FILE, File accessibility MAJOR, H5E_IO, Low-level I/O MAJOR, H5E_FUNC, Function entry/exit MAJOR, H5E_ATOM, Object atom @@ -78,7 +78,7 @@ MAJOR, H5E_NONE_MAJOR, No error # Sections (for grouping minor errors) SECTION, ARGS, Argument errors SECTION, RESOURCE, Resource errors -SECTION, FILEACC, File accessibilty errors +SECTION, FILEACC, File accessibility errors SECTION, FILE, Generic low-level file I/O errors SECTION, FUNC, Function entry/exit interface errors SECTION, ATOM, Object atom related errors @@ -119,7 +119,7 @@ MINOR, RESOURCE, H5E_CANTGC, Unable to garbage collect MINOR, RESOURCE, H5E_CANTGETSIZE, Unable to compute size MINOR, RESOURCE, H5E_OBJOPEN, Object is already open -# File accessibilty errors +# File accessibility errors MINOR, FILEACC, H5E_FILEEXISTS, File already exists MINOR, FILEACC, H5E_FILEOPEN, File already open MINOR, FILEACC, H5E_CANTCREATE, Unable to create file -- cgit v0.12