From bbb512bb55b430977713b4f8c662d6a918a456e9 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 30 Nov 2017 17:12:37 -0800 Subject: Normalization with VOL integration branch. --- src/H5.c | 1 + src/H5A.c | 4 +- src/H5Aint.c | 16 +- src/H5Dio.c | 2 +- src/H5Fprivate.h | 11 +- src/H5Gdeprec.c | 61 +++--- src/H5I.c | 657 ++++++++++++++++++++++++------------------------------- src/H5L.c | 114 +++------- src/H5Lprivate.h | 49 +++++ src/H5Opkg.h | 18 +- src/H5Oprivate.h | 5 +- src/H5Pfapl.c | 4 +- src/H5Tbit.c | 395 ++++++++++++++++----------------- src/H5Tconv.c | 90 +++++--- 14 files changed, 674 insertions(+), 753 deletions(-) diff --git a/src/H5.c b/src/H5.c index 965c2e1..f0a222d 100644 --- a/src/H5.c +++ b/src/H5.c @@ -24,6 +24,7 @@ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ +#include "H5FSprivate.h" /* File free space */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ diff --git a/src/H5A.c b/src/H5A.c index 1b80612..07aca92 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -1150,7 +1150,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) if(HDstrcmp(old_name, new_name)) { H5G_loc_t loc; /* Object location */ - if(H5G_loc(loc_id, & loc) < 0) + if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call private attribute rename routine */ @@ -1205,7 +1205,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists") - if(H5G_loc(loc_id, & loc) < 0) + if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call private attribute rename routine */ diff --git a/src/H5Aint.c b/src/H5Aint.c index a661a89..f1dd41e 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -33,14 +33,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 */ /****************/ diff --git a/src/H5Dio.c b/src/H5Dio.c index 4ab0b37..aee3c35 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -322,7 +322,7 @@ done: /*------------------------------------------------------------------------- * Function: H5D__pre_write * - * Purpose: Preparation for writing data. + * Purpose: Preparation for writing data. * * Return: SUCCEED/FAIL * diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index eba48de..18d0460 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -18,6 +18,9 @@ #ifndef _H5Fprivate_H #define _H5Fprivate_H +/* Early typedefs to avoid circular dependencies */ +typedef struct H5F_t H5F_t; + /* Include package's public header */ #include "H5Fpublic.h" @@ -475,8 +478,8 @@ #define H5F_ACS_SIEVE_BUF_SIZE_NAME "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */ #define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ -#define H5F_ACS_FILE_DRV_NAME "driver-id/info" /* File driver ID & info */ -#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ +#define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ +#define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ #define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ #define H5F_ACS_FAMILY_TO_SEC2_NAME "family_to_sec2" /* Whether to convert family to sec2 driver. (private property only used by h5repart) */ @@ -484,7 +487,7 @@ #define H5F_ACS_LATEST_FORMAT_NAME "latest_format" /* 'Use latest format version' flag */ #define H5F_ACS_WANT_POSIX_FD_NAME "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address */ #define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */ -#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ +#define H5F_ACS_OBJECT_FLUSH_CB_NAME "object_flush_cb" /* Object flush callback */ #define H5F_ACS_EFC_SIZE_NAME "efc_size" /* Size of external file cache */ #define H5F_ACS_FILE_IMAGE_INFO_NAME "file_image_info" /* struct containing initial file image and callback info */ #define H5F_ACS_CLEAR_STATUS_FLAGS_NAME "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) */ @@ -652,12 +655,12 @@ struct H5B_class_t; struct H5UC_t; struct H5O_loc_t; struct H5HG_heap_t; +struct H5VL_class_t; struct H5P_genplist_t; /* Forward declarations for anonymous H5F objects */ /* Main file structures */ -typedef struct H5F_t H5F_t; typedef struct H5F_file_t H5F_file_t; /* Block aggregation structure */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 228fb9c..1cc7e15 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -695,29 +695,26 @@ done: /*------------------------------------------------------------------------- - * Function: H5Giterate + * Function: H5Giterate * - * Purpose: Iterates over the entries of a group. The LOC_ID and NAME - * identify the group over which to iterate and IDX indicates - * where to start iterating (zero means at the beginning). The - * OPERATOR is called for each member and the iteration - * continues until the operator returns non-zero or all members - * are processed. The operator is passed a group ID for the - * group being iterated, a member name, and OP_DATA for each - * member. + * Purpose: Iterates over the entries of a group. The LOC_ID and NAME + * identify the group over which to iterate and IDX indicates + * where to start iterating (zero means at the beginning). The + * OPERATOR is called for each member and the iteration + * continues until the operator returns non-zero or all members + * are processed. The operator is passed a group ID for the + * group being iterated, a member name, and OP_DATA for each + * member. * - * Note: Deprecated in favor of H5Literate + * NOTE: Deprecated in favor of H5Literate * - * 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. + * 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. * - * Failure: Negative if something goes wrong within the - * library, or the negative value returned by one - * of the operators. - * - * Programmer: Robb Matzke - * Monday, March 23, 1998 + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. * *------------------------------------------------------------------------- */ @@ -725,21 +722,21 @@ 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); /* Check args */ - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - if(idx_p && *idx_p < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") - if(!op) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + if (!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + if (idx_p && *idx_p < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index specified") + if (!op) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") /* Set number of objects looked at to zero */ last_obj = 0; @@ -750,11 +747,11 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, lnk_op.op_func.op_old = op; /* Call private function. */ - if((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") + if ((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") /* Set the index we stopped at */ - if(idx_p) + if (idx_p) *idx_p = (int)last_obj; done: diff --git a/src/H5I.c b/src/H5I.c index 3bd9c4d..99f944d 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -28,24 +28,24 @@ #include "H5Imodule.h" /* This source code file is part of the H5I module */ -#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 */ +#include "H5Gprivate.h" /* Groups */ #else /* H5I_DEBUG_OUTPUT */ -#define H5G_FRIEND /*suppress error about including H5Gpkg */ -#include "H5Gpkg.h" /* Groups */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Tprivate.h" /* Datatypes */ +#define H5G_FRIEND /* Suppress error about including H5Gpkg */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Tprivate.h" /* Datatypes */ #endif /* H5I_DEBUG_OUTPUT */ /* Local Macros */ @@ -186,23 +186,19 @@ H5I_term_package(void) /*------------------------------------------------------------------------- - * Function: H5Iregister_type + * Function: H5Iregister_type * - * Purpose: Public interface to H5I_register_type. Creates a new type - * of ID's to give out. A specific number (RESERVED) of type - * entries may be reserved to enable "constant" values to be handed - * out which are valid IDs in the type, but which do not map to any - * data structures and are not allocated dynamically later. HASH_SIZE is - * the minimum hash table size to use for the type. FREE_FUNC is - * called with an object pointer when the object is removed from - * the type. + * Purpose: Public interface to H5I_register_type. Creates a new type + * of ID's to give out. A specific number (RESERVED) of type + * entries may be reserved to enable "constant" values to be handed + * out which are valid IDs in the type, but which do not map to any + * data structures and are not allocated dynamically later. HASH_SIZE is + * the minimum hash table size to use for the type. FREE_FUNC is + * called with an object pointer when the object is removed from + * the type. * - * Return: Success: Type ID of the new type - * Failure: H5I_BADID - * - * Programmers: Nathaniel Furrer - * James Laird - * Friday, April 30, 2004 + * Return: Success: Type ID of the new type + * Failure: H5I_BADID * *------------------------------------------------------------------------- */ @@ -270,18 +266,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_register_type + * Function: H5I_register_type * - * Purpose: Creates a new type of ID's to give out. - * The class is initialized or its reference count is incremented + * Purpose: Creates a new type of ID's to give out. + * The class is initialized or its reference count is incremented * (if it is already initialized). * - * Return: Success: Type ID of the new type - * Failure: H5I_BADID - * - * Programmers: Nathaniel Furrer - * James Laird - * Friday, April 30, 2004 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -335,17 +326,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Itype_exists + * Function: H5Itype_exists * * Purpose: Query function to inform the user if a given type is * currently registered with the library. * - * Return: Success: 1 if the type is registered, 0 if it is not - * Failure: Negative - * - * Programmer: James Laird - * Nathaniel Furrer - * Tuesday, June 29, 2004 + * Return: Success: 1 if the type is registered, 0 if it is not + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -357,10 +344,10 @@ H5Itype_exists(H5I_type_t type) FUNC_ENTER_API(FAIL) H5TRACE1("t", "It", type); - if(type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + if (type <= H5I_BADID || type >= H5I_next_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - if(NULL == H5I_id_type_list_g[type]) + if (NULL == H5I_id_type_list_g[type]) ret_value = FALSE; done: @@ -401,9 +388,9 @@ H5Inmembers(H5I_type_t type, hsize_t *num_members) * an error when the supplied type does not exist. */ if(type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") if(NULL == H5I_id_type_list_g[type]) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "supplied type does not exist") if(num_members) { int64_t members; @@ -685,15 +672,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iregister + * Function: H5Iregister * - * Purpose: Public interface to H5I_register. + * Purpose: Public interface to H5I_register. * - * Return: Success: New object id. - * Failure: Negative - * - * Programmer: Nathaniel Furrer - * James Laird + * Return: Success: New object id. + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -727,7 +711,7 @@ done: * the ID which is returned to the user. * * Return: Success: New object id - * Failure: Negative + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -737,18 +721,18 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) 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 new_id = -1; /* new ID */ - hid_t ret_value = SUCCEED; /* return value */ + hid_t ret_value = H5I_INVALID_HID; /* return value */ FUNC_ENTER_NOAPI(FAIL) /* 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 (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") /* Create the struct & its ID */ new_id = H5I_MAKE(type, type_ptr->nextid); @@ -759,7 +743,7 @@ H5I_register(H5I_type_t type, const void *object, hbool_t app_ref) /* Insert into the type */ if (H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't insert ID node into skip list") + HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, H5I_INVALID_HID, "can't insert ID node into skip list") type_ptr->id_count++; type_ptr->nextid++; @@ -777,27 +761,23 @@ done: /*------------------------------------------------------------------------- * Function: H5I_register_with_id * - * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it. - * This routine will check to ensure the supplied ID is not already - * in use, and ensure that it is a valid ID for the given type, - * but will NOT check to ensure the OBJECT is not already - * registered (thus, it is possible to register one object under - * multiple IDs). - * - * Return: Success: 0 - * Failure: -1 + * Purpose: Registers an OBJECT in a TYPE with the supplied ID for it. + * This routine will check to ensure the supplied ID is not already + * in use, and ensure that it is a valid ID for the given type, + * but will NOT check to ensure the OBJECT is not already + * registered (thus, it is possible to register one object under + * multiple IDs). * - * Programmer: Mike McGreevy - * Wednesday, July 21, 2010 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id) { - H5I_id_type_t *type_ptr; /*ptr to the type */ - H5I_id_info_t *id_ptr; /*ptr to the new ID information */ - herr_t ret_value = SUCCEED; /*return value */ + H5I_id_type_t *type_ptr; /* ptr to the type */ + H5I_id_info_t *id_ptr; /* ptr to the new ID information */ + herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1187,10 +1167,10 @@ H5I_remove(hid_t id) /* Check arguments */ type = H5I_TYPE(id); if(type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, NULL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; if(type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "invalid type") /* Remove the node from the type */ if(NULL == (ret_value = H5I__remove_common(type_ptr, id))) @@ -1226,7 +1206,7 @@ H5Idec_ref(hid_t id) /* Check arguments */ if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") /* Do actual decrement operation */ if((ret_value = H5I_dec_app_ref(id)) < 0) @@ -1359,16 +1339,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref_always_close + * Function: H5I_dec_app_ref_always_close * - * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, - * even when the free routine fails + * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, + * even when the free routine fails * - * Return: Success: New app. reference count. - * Failure: Negative - * - * Programmer: Quincey Koziol - * Sept 16, 2010 + * Return: Success: New app. reference count. + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1386,7 +1363,7 @@ H5I_dec_app_ref_always_close(hid_t id) ret_value = H5I_dec_app_ref(id); /* Check for failure */ - if(ret_value < 0) { + if (ret_value < 0) { /* * If an object is closing, we can remove the ID even though the free * method might fail. This can happen when a mandatory filter fails to @@ -1396,7 +1373,7 @@ H5I_dec_app_ref_always_close(hid_t id) H5I_remove(id); HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") - } /* end if */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1404,15 +1381,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iinc_ref - * - * Purpose: Increments the number of references outstanding for an ID. + * Function: H5Iinc_ref * - * Return: Success: New reference count - * Failure: Negative + * Purpose: Increments the number of references outstanding for an ID. * - * Programmer: Quincey Koziol - * Dec 7, 2003 + * Return: Success: New reference count + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1425,11 +1399,11 @@ H5Iinc_ref(hid_t id) H5TRACE1("Is", "i", id); /* Check arguments */ - if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + if (id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") /* Do actual increment operation */ - if((ret_value = H5I_inc_ref(id, TRUE)) < 0) + if ((ret_value = H5I_inc_ref(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") done: @@ -1438,15 +1412,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_inc_ref + * Function: H5I_inc_ref * - * Purpose: Increment the reference count for an object. + * Purpose: Increment the reference count for an object. * - * Return: Success: The new reference count. - * Failure: Negative - * - * Programmer: Robb Matzke - * Thursday, July 29, 1999 + * Return: Success: The new reference count. + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1462,8 +1433,8 @@ H5I_inc_ref(hid_t id, hbool_t app_ref) HDassert(id >= 0); /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + if (NULL == (id_ptr = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") /* Adjust reference counts */ ++(id_ptr->count); @@ -1479,15 +1450,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iget_ref + * Function: H5Iget_ref * - * Purpose: Retrieves the number of references outstanding for an ID. - * - * Return: Success: Reference count - * Failure: Negative + * Purpose: Retrieves the number of references outstanding for an ID. * - * Programmer: Quincey Koziol - * Dec 7, 2003 + * Return: Success: Reference count + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1500,11 +1468,11 @@ H5Iget_ref(hid_t id) H5TRACE1("Is", "i", id); /* Check arguments */ - if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + if (id < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") /* Do actual retrieve operation */ - if((ret_value = H5I_get_ref(id, TRUE)) < 0) + if ((ret_value = H5I_get_ref(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") done: @@ -1513,15 +1481,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_get_ref + * Function: H5I_get_ref * - * Purpose: Retrieve the reference count for an object. + * Purpose: Retrieve the reference count for an object. * - * Return: Success: The reference count. - * Failure: Negative - * - * Programmer: Quincey Koziol - * Saturday, Decemeber 6, 2003 + * Return: Success: The reference count. + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1537,8 +1502,8 @@ H5I_get_ref(hid_t id, hbool_t app_ref) HDassert(id >= 0); /* General lookup of the ID */ - if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + if (NULL == (id_ptr = H5I__find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") /* Set return value */ ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); @@ -1549,16 +1514,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iinc_type_ref + * Function: H5Iinc_type_ref * - * Purpose: Increments the number of references outstanding for an ID type. + * Purpose: Increments the number of references outstanding for an ID type. * - * Return: Success: New reference count - * Failure: Negative - * - * Programmer: Nat Furrer - * James Laird - * April 30, 2004 + * Return: Success: New reference count + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1571,14 +1532,14 @@ H5Iinc_type_ref(H5I_type_t type) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || type >= H5I_next_type) + if (type <= 0 || type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") /* Do actual increment operation */ - if((ret_value = H5I__inc_type_ref(type)) < 0) + if ((ret_value = H5I__inc_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID type ref count") done: @@ -1587,16 +1548,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__inc_type_ref + * Function: H5I__inc_type_ref * - * Purpose: Increment the reference count for an ID type. + * Purpose: Increment the reference count for an ID type. * - * Return: Success: The new reference count. - * Failure: Negative - * - * Programmer: James Laird - * Nat Furrer - * Friday, April 30, 2004 + * Return: Success: The new reference count + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1613,8 +1570,8 @@ H5I__inc_type_ref(H5I_type_t type) /* Check arguments */ type_ptr = H5I_id_type_list_g[type]; - if(!type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + if (!type_ptr) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Set return value */ ret_value = (int)(++(type_ptr->init_count)); @@ -1625,24 +1582,26 @@ done: /*------------------------------------------------------------------------- - * Function: H5Idec_type_ref - * - * Purpose: Decrements the reference count on an entire type of IDs. - * If the type reference count becomes zero then the type is - * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling - * the free-func for each ID's object and then adding the ID - * struct to the ID free list. Public interface to - * H5I_dec_type_ref. - * Returns the number of references to the type on success; a - * return value of 0 means that the type will have to be - * re-initialized before it can be used again (and should probably - * be set to H5I_UNINIT). - * - * Return: Number of references to type on success/Negative on failure - * - * Programmer: Nathaniel Furrer - * James Laird + * Function: H5Idec_type_ref + * + * Purpose: Decrements the reference count on an entire type of IDs. + * If the type reference count becomes zero then the type is + * destroyed along with all atoms in that type regardless of + * their reference counts. Destroying IDs involves calling + * the free-func for each ID's object and then adding the ID + * struct to the ID free list. Public interface to + * H5I_dec_type_ref. + * Returns the number of references to the type on success; a + * return value of 0 means that the type will have to be + * re-initialized before it can be used again (and should probably + * be set to H5I_UNINIT). + * + * NOTE: Using an error type to also represent a count is semantially + * incorrect. We should consider fixing this in a future major + * release (DER). + * + * Return: Success: Number of references to type + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1654,7 +1613,7 @@ H5Idec_type_ref(H5I_type_t type) FUNC_ENTER_API(FAIL) H5TRACE1("e", "It", type); - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") ret_value = H5I_dec_type_ref(type); @@ -1665,22 +1624,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_type_ref - * - * Purpose: Decrements the reference count on an entire type of IDs. - * If the type reference count becomes zero then the type is - * destroyed along with all atoms in that type regardless of - * their reference counts. Destroying IDs involves calling - * the free-func for each ID's object and then adding the ID - * struct to the ID free list. - * Returns the number of references to the type on success; a - * return value of 0 means that the type will have to be - * re-initialized before it can be used again (and should probably - * be set to H5I_UNINIT). - * - * Return: Number of references to type on success/Negative on failure - * - * Programmer: Unknown + * Function: H5I_dec_type_ref + * + * Purpose: Decrements the reference count on an entire type of IDs. + * If the type reference count becomes zero then the type is + * destroyed along with all atoms in that type regardless of + * their reference counts. Destroying IDs involves calling + * the free-func for each ID's object and then adding the ID + * struct to the ID free list. + * Returns the number of references to the type on success; a + * return value of 0 means that the type will have to be + * re-initialized before it can be used again (and should probably + * be set to H5I_UNINIT). + * + * Return: Success: Number of references to type + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1692,27 +1650,26 @@ H5I_dec_type_ref(H5I_type_t type) FUNC_ENTER_NOAPI(FAIL) - if(type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + if (type <= H5I_BADID || type >= H5I_next_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; - if(type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + if (type_ptr == NULL || type_ptr->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") - /* - * Decrement the number of users of the atomic type. If this is the + /* Decrement the number of users of the atomic type. If this is the * last user of the type then release all atoms from the type and * free all memory it used. The free function is invoked for each atom * being freed. */ - if(1 == type_ptr->init_count) { + if (1 == type_ptr->init_count) { H5I__destroy_type(type); ret_value = 0; - } /* end if */ + } else { --(type_ptr->init_count); ret_value = (herr_t)type_ptr->init_count; - } /* end else */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1720,16 +1677,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iget_type_ref + * Function: H5Iget_type_ref * - * Purpose: Retrieves the number of references outstanding for a type. - * - * Return: Success: Reference count - * Failure: Negative + * Purpose: Retrieves the number of references outstanding for a type. * - * Programmer: Nat Furrer - * James Laird - * April 30, 2004 + * Return: Success: Reference count + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1742,14 +1695,14 @@ H5Iget_type_ref(H5I_type_t type) H5TRACE1("Is", "It", type); /* Check arguments */ - if(type <= 0 || type >= H5I_next_type) + if (type <= 0 || type >= H5I_next_type) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") /* Do actual retrieve operation */ - if((ret_value = H5I__get_type_ref(type)) < 0) + if ((ret_value = H5I__get_type_ref(type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID type ref count") done: @@ -1758,25 +1711,21 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__get_type_ref + * Function: H5I__get_type_ref * - * Purpose: Retrieve the reference count for an ID type. + * Purpose: Retrieve the reference count for an ID type. * - * Return: Success: The reference count. + * Return: Success: The reference count. * - * Failure: Negative - * - * Programmer: Nat Furrer - * James Laird - * April 30, 2004 + * Failure: Negative * *------------------------------------------------------------------------- */ static int H5I__get_type_ref(H5I_type_t type) { - H5I_id_type_t *type_ptr; /*ptr to the type */ - int ret_value = -1; /* Return value */ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + int ret_value = -1; /* Return value */ FUNC_ENTER_STATIC @@ -1785,7 +1734,7 @@ H5I__get_type_ref(H5I_type_t type) /* Check arguments */ type_ptr = H5I_id_type_list_g[type]; - if(!type_ptr) + if (!type_ptr) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") /* Set return value */ @@ -1797,17 +1746,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iis_valid + * Function: H5Iis_valid * - * Purpose: Check if the given id is valid. An id is valid if it is in + * Purpose: Check if the given id is valid. An id is valid if it is in * use and has an application reference count of at least 1. * - * Return: Success: TRUE if the id is valid, FALSE otherwise. - * - * Failure: Negative (never fails currently) + * Return: Success: TRUE if the id is valid, FALSE otherwise. * - * Programmer: Neil Fortner - * Friday, October 31, 2008 (boo) + * Failure: Negative (never fails currently) * *------------------------------------------------------------------------- */ @@ -1823,9 +1769,7 @@ H5Iis_valid(hid_t id) /* Find the ID */ if (NULL == (id_ptr = H5I__find_id(id))) ret_value = FALSE; - - /* Check if the found id is an internal id */ - else if (!id_ptr->app_count) + else if (!id_ptr->app_count) /* Check if the found id is an internal id */ ret_value = FALSE; done: @@ -1834,19 +1778,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__search_cb + * Function: H5I__search_cb * - * Purpose: Callback routine for H5Isearch, when it calls H5I_iterate. - * Calls "user" callback search function, and then sets return - * value, based on the result of that callback. - * - * Return: Success: The first object in the type for which FUNC - * returns non-zero. NULL if FUNC returned zero - * for every object in the type. - * Failure: NULL + * Purpose: Callback routine for H5Isearch, when it calls H5I_iterate. + * Calls "user" callback search function, and then sets return + * value, based on the result of that callback. * - * Programmer: Quincey Koziol - * Friday, March 30, 2012 + * Return: Success: The first object in the type for which FUNC + * returns non-zero. NULL if FUNC returned zero + * for every object in the type. + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -1859,7 +1800,7 @@ H5I__search_cb(void *obj, hid_t id, void *_udata) FUNC_ENTER_STATIC_NOERR ret_value = (*udata->app_cb)(obj, id, udata->app_key); - if(ret_value > 0) + if (ret_value > 0) udata->ret_obj = obj; FUNC_LEAVE_NOAPI(ret_value) @@ -1867,26 +1808,22 @@ H5I__search_cb(void *obj, hid_t id, void *_udata) /*------------------------------------------------------------------------- - * Function: H5Isearch + * Function: H5Isearch * - * Purpose: Apply function FUNC to each member of type TYPE and return a - * pointer to the first object for which FUNC returns non-zero. - * The FUNC should take a pointer to the object and the KEY as - * arguments and return non-zero to terminate the search (zero - * to continue). Public interface to H5I_search. + * Purpose: Apply function FUNC to each member of type TYPE and return a + * pointer to the first object for which FUNC returns non-zero. + * The FUNC should take a pointer to the object and the KEY as + * arguments and return non-zero to terminate the search (zero + * to continue). Public interface to H5I_search. * - * Limitation: Currently there is no way to start searching from where a - * previous search left off. + * Limitation: Currently there is no way to start searching from where a + * previous search left off. * - * Return: Success: The first object in the type for which FUNC - * returns non-zero. NULL if FUNC returned zero - * for every object in the type. + * Return: Success: The first object in the type for which FUNC + * returns non-zero. NULL if FUNC returned zero + * for every object in the type. * - * Failure: NULL - * - * Programmer: James Laird - * Nathaniel Furrer - * Friday, April 23, 2004 + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -1900,7 +1837,7 @@ H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key) H5TRACE3("*x", "Itx*x", type, func, key); /* Check arguments */ - if(H5I_IS_LIB_TYPE(type)) + if (H5I_IS_LIB_TYPE(type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") /* Set up udata struct */ @@ -1922,17 +1859,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__iterate_cb + * Function: H5I__iterate_cb * - * Purpose: Callback routine for H5I_iterate, invokes "user" callback + * Purpose: Callback routine for H5I_iterate, invokes "user" callback * function, and then sets return value, based on the result of * that callback. * - * Return: Success: Non-negative on success - * Failure: Negative - * - * Programmer: Quincey Koziol - * Thursday, October 3, 2013 + * Return: Success: Non-negative on success + * Failure: Negative * *------------------------------------------------------------------------- */ @@ -1964,29 +1898,25 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /*------------------------------------------------------------------------- * Function: H5I_iterate * - * Purpose: Apply function FUNC to each member of type TYPE (with - * non-zero application reference count if app_ref is TRUE). - * Stop if FUNC returns a non zero value (i.e. anything - * other than H5_ITER_CONT). + * Purpose: Apply function FUNC to each member of type TYPE (with + * non-zero application reference count if app_ref is TRUE). + * Stop if FUNC returns a non zero value (i.e. anything + * other than H5_ITER_CONT). * - * If FUNC returns a positive value (i.e. H5_ITER_STOP), - * return SUCCEED. + * If FUNC returns a positive value (i.e. H5_ITER_STOP), + * return SUCCEED. * - * If FUNC returns a negative value (i.e. H5_ITER_ERROR), - * return FAIL. + * If FUNC returns a negative value (i.e. H5_ITER_ERROR), + * return FAIL. * - * The FUNC should take a pointer to the object and the - * udata as arguments and return non-zero to terminate - * siteration, and zero to continue. + * The FUNC should take a pointer to the object and the + * udata as arguments and return non-zero to terminate + * siteration, and zero to continue. * - * Limitation: Currently there is no way to start the iteration from - * where a previous iteration left off. + * Limitation: Currently there is no way to start the iteration from + * where a previous iteration left off. * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: John Mainzer - * Monday, December 6, 2011 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -1999,12 +1929,12 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ - if(type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + if (type <= H5I_BADID || type >= H5I_next_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") type_ptr = H5I_id_type_list_g[type]; /* Only iterate through ID list if it is initialized and there are IDs in type */ - if(type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { + if (type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ herr_t iter_status; /* Iteration status */ @@ -2014,9 +1944,9 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re iter_udata.app_ref = app_ref; /* Iterate over IDs */ - if((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) + if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") - } /* end if */ + } done: FUNC_LEAVE_NOAPI(ret_value) @@ -2024,16 +1954,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__find_id - * - * Purpose: Given an object ID find the info struct that describes the - * object. + * Function: H5I__find_id * - * Return: Success: Ptr to the object's info struct. + * Purpose: Given an object ID find the info struct that describes the + * object. * - * Failure: NULL + * Return: Success: A pointer to the object's info struct. * - * Programmer: Unknown + * Failure: NULL * *------------------------------------------------------------------------- */ @@ -2048,12 +1976,12 @@ H5I__find_id(hid_t id) /* Check arguments */ type = H5I_TYPE(id); - if(type <= H5I_BADID || type >= H5I_next_type) - HGOTO_DONE(NULL) + if (type <= H5I_BADID || type >= H5I_next_type) + HGOTO_DONE(NULL) type_ptr = H5I_id_type_list_g[type]; - if(!type_ptr || type_ptr->init_count <= 0) - HGOTO_DONE(NULL) + if (!type_ptr || type_ptr->init_count <= 0) + HGOTO_DONE(NULL) /* Locate the ID node for the ID */ ret_value = (H5I_id_info_t *)H5SL_search(type_ptr->ids, &id); @@ -2064,17 +1992,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iget_name - * - * Purpose: Gets a name of an object from its ID. + * Function: H5Iget_name * - * Return: Success: The length of name. + * Purpose: Gets a name of an object from its ID. * - * Failure: -1 + * Return: Success: The length of the name * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: July 26, 2002 + * Failure: -1 * * Comments: Public function * If `name' is non-NULL then write up to `size' bytes into that @@ -2098,12 +2022,12 @@ H5Iget_name(hid_t id, char *name/*out*/, size_t size) H5TRACE3("Zs", "ixz", id, name, size); /* Get object location */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location") + if (H5G_loc(id, &loc) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location") /* Call internal group routine to retrieve object's name */ - if((ret_value = H5G_get_name(&loc, name, size, NULL, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + if ((ret_value = H5G_get_name(&loc, name, size, NULL, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") done: FUNC_LEAVE_API(ret_value) @@ -2111,30 +2035,27 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iget_file_id + * Function: H5Iget_file_id * - * Purpose: The public version of H5I_get_file_id(), obtains the file + * Purpose: The public version of H5I_get_file_id(), obtains the file * ID given an object ID. User has to close this ID. * - * Return: Success: file ID - * - * Failure: a negative value + * Return: Success: The file ID associated with the object * - * Programmer: Raymond Lu - * Oct 27, 2003 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ 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) 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") + if ((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") done: FUNC_LEAVE_API(ret_value) @@ -2142,50 +2063,48 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_get_file_id + * Function: H5I_get_file_id * - * Purpose: The private version of H5Iget_file_id(), obtains the file + * Purpose: The private version of H5Iget_file_id(), obtains the file * ID given an object ID. * - * Return: Success: file ID - * Failure: a negative value + * Return: Success: The file ID associated with the object * - * Programmer: Raymond Lu - * Oct 27, 2003 + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref) { - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5I_type_t type; /* ID type */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get object type */ type = H5I_TYPE(obj_id); - if(type == H5I_FILE) { + 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; - } /* end if */ - else if(type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { + } + else if (type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { H5G_loc_t loc; /* Location of object */ /* 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") - } /* end if */ + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") + } 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) @@ -2194,34 +2113,29 @@ done: #ifdef H5I_DEBUG_OUTPUT /*------------------------------------------------------------------------- - * Function: H5I__debug_cb + * Function: H5I__debug_cb * - * Purpose: Dump the contents of an ID to stderr for debugging. + * Purpose: Dump the contents of an ID to stderr for debugging. * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Robb Matzke - * Friday, February 19, 1999 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ static herr_t H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t *path = NULL; - int ret_value = H5_ITER_CONT; /* Return value */ + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + H5G_name_t *path = NULL; FUNC_ENTER_STATIC_NOERR - fprintf(stderr, " id = %lu\n", (unsigned long)(item->id)); - fprintf(stderr, " count = %u\n", item->count); - fprintf(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) { + switch (type) { case H5I_GROUP: path = H5G_nameof((H5G_t*)item->obj_ptr); break; @@ -2234,31 +2148,40 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) path = H5T_nameof((H5T_t*)item->obj_ptr); break; + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_ATTR: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: default: break; /* Other types of IDs are not stored in files */ - } /* end switch*/ + } - if(path) { - if(path->user_path_r) - fprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); - if(path->full_path_r) - fprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); - } /* end if */ + if (path) { + if (path->user_path_r) + HDfprintf(stderr, " user_path = %s\n", H5RS_get_str(path->user_path_r)); + if (path->full_path_r) + HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); + } FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5I__debug_cb() */ /*------------------------------------------------------------------------- - * Function: H5I__debug - * - * Purpose: Dump the contents of a type to stderr for debugging. + * Function: H5I__debug * - * Return: Success: Non-negative - * Failure: Negative + * Purpose: Dump the contents of a type to stderr for debugging. * - * Programmer: Robb Matzke - * Friday, February 19, 1999 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -2269,17 +2192,17 @@ H5I__debug(H5I_type_t type) FUNC_ENTER_STATIC_NOERR - fprintf(stderr, "Dumping ID type %d\n", (int)type); + HDfprintf(stderr, "Dumping ID type %d\n", (int)type); type_ptr = H5I_id_type_list_g[type]; /* Header */ - fprintf(stderr, " init_count = %u\n", type_ptr->init_count); - fprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); - fprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); - fprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); + HDfprintf(stderr, " init_count = %u\n", type_ptr->init_count); + HDfprintf(stderr, " reserved = %u\n", type_ptr->cls->reserved); + HDfprintf(stderr, " id_count = %llu\n", (unsigned long long)type_ptr->id_count); + HDfprintf(stderr, " nextid = %llu\n", (unsigned long long)type_ptr->nextid); /* List */ - fprintf(stderr, " List:\n"); + HDfprintf(stderr, " List:\n"); H5SL_iterate(type_ptr->ids, H5I__debug_cb, &type); FUNC_LEAVE_NOAPI(SUCCEED) diff --git a/src/H5L.c b/src/H5L.c index 469a86c..afd033a 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -50,18 +50,6 @@ typedef struct { hid_t dxpl_id; /* DXPL to use in callback */ } H5L_trav_gi_t; -/* User data for path traversal routine for getting link info by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - hid_t dxpl_id; /* DXPL to use in callback */ - - /* Out */ - H5L_info_t *linfo; /* Buffer to return to user */ -} H5L_trav_gibi_t; - /* User data for path traversal callback to creating a link */ typedef struct { H5F_t *file; /* Pointer to the file */ @@ -108,47 +96,11 @@ typedef struct { void *buf; /* User buffer */ } H5L_trav_gv_t; -/* User data for path traversal routine for getting link value by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - hid_t dxpl_id; /* DXPL to use in callback */ - size_t size; /* Size of user buffer */ - - /* Out */ - void *buf; /* User buffer */ -} H5L_trav_gvbi_t; - /* User data for path traversal routine for removing link */ typedef struct { hid_t dxpl_id; /* DXPL to use in callback */ } H5L_trav_rm_t; -/* User data for path traversal routine for removing link by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - hid_t dxpl_id; /* DXPL to use in callback */ -} H5L_trav_rmbi_t; - -/* User data for path traversal routine for getting name by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of name buffer */ - hid_t dxpl_id; /* DXPL to use in callback */ - - /* Out */ - char *name; /* Buffer to return name to user */ - ssize_t name_len; /* Length of full name */ -} H5L_trav_gnbi_t; - /********************/ /* Local Prototypes */ /********************/ @@ -185,8 +137,6 @@ static herr_t H5L__exists_final_cb(H5G_loc_t *grp_loc/*in*/, const char *name, static herr_t H5L__exists_inter_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static htri_t H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, - hid_t dxpl_id); static herr_t H5L_get_info_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); @@ -866,17 +816,17 @@ 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") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Verify access property list and get correct dxpl */ if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists") /* Check for the existence of the link */ - if((ret_value = H5L__exists(&loc, name, lapl_id, dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + if((ret_value = H5L_exists(&loc, name, lapl_id, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) @@ -1181,24 +1131,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5Literate + * Function: H5Literate * - * Purpose: Iterates over links in a group, with user callback routine, + * Purpose: Iterates over links in a group, with user callback routine, * according to the order within an index. * * 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. + * 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. * - * 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 + * Failure: Negative if something goes wrong within the + * library, or the negative value returned by one + * of the operators. * *------------------------------------------------------------------------- */ @@ -1206,25 +1152,25 @@ herr_t H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data) { - H5I_type_t id_type; /* Type of ID */ - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ - herr_t ret_value; /* Return value */ + H5I_type_t id_type; /* Type of ID */ + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_lnk; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIo*hx*x", grp_id, idx_type, order, idx_p, op, op_data); /* Check arguments */ id_type = H5I_get_type(grp_id); - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - 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 operator specified") + 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 operator specified") /* Set up iteration beginning/end info */ idx = (idx_p == NULL ? 0 : *idx_p); @@ -1235,8 +1181,8 @@ H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, lnk_op.op_func.op_new = op; /* Iterate over the links */ - if((ret_value = H5G_iterate(grp_id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") + if ((ret_value = H5G_iterate(grp_id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_read_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") /* Set the index we stopped at */ if(idx_p) @@ -2930,7 +2876,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5L__exists + * Function: H5L_exists * * Purpose: Returns whether a link exists in a group * @@ -2944,8 +2890,8 @@ done: * *------------------------------------------------------------------------- */ -static htri_t -H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) +htri_t +H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { H5L_trav_le_t udata; /* User data for traversal */ htri_t ret_value = FAIL; /* Return value */ @@ -2966,7 +2912,7 @@ H5L__exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5L__exists() */ +} /* H5L_exists() */ /*------------------------------------------------------------------------- diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index dd243a6..8a2bd34 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -48,6 +48,54 @@ /* Library Private Typedefs */ /****************************/ +/* User data for path traversal routine for getting link value by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + hid_t dxpl_id; /* DXPL to use in callback */ + size_t size; /* Size of user buffer */ + + /* Out */ + void *buf; /* User buffer */ +} H5L_trav_gvbi_t; + +/* User data for path traversal routine for getting link info by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + hid_t dxpl_id; /* DXPL to use in callback */ + + /* Out */ + H5L_info_t *linfo; /* Buffer to return to user */ +} H5L_trav_gibi_t; + +/* User data for path traversal routine for getting name by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of name buffer */ + hid_t dxpl_id; /* DXPL to use in callback */ + + /* Out */ + char *name; /* Buffer to return name to user */ + ssize_t name_len; /* Length of full name */ +} H5L_trav_gnbi_t; + +/* User data for path traversal routine for removing link by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + hid_t dxpl_id; /* DXPL to use in callback */ +} H5L_trav_rmbi_t; + /* Structure for external link traversal callback property */ typedef struct H5L_elink_cb_t { H5L_elink_traverse_t func; @@ -81,6 +129,7 @@ H5_DLL herr_t H5L_move(H5G_loc_t *src_loc, const char *src_name, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id); H5_DLL htri_t H5L_exists_tolerant(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id); +H5_DLL htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id, diff --git a/src/H5Opkg.h b/src/H5Opkg.h index b0c67d1..109d273 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -247,20 +247,20 @@ struct H5O_msg_class_t { }; struct H5O_mesg_t { - const H5O_msg_class_t *type; /*type of message */ - hbool_t dirty; /*raw out of date wrt native */ - uint8_t flags; /*message flags */ - H5O_msg_crt_idx_t crt_idx; /*message creation index */ - unsigned chunkno; /*chunk number for this mesg */ - void *native; /*native format message */ - uint8_t *raw; /*ptr to raw data */ - size_t raw_size; /*size with alignment */ + const H5O_msg_class_t *type; /* type of message */ + hbool_t dirty; /* raw out of date wrt native */ + uint8_t flags; /* message flags */ + H5O_msg_crt_idx_t crt_idx; /* message creation index */ + unsigned chunkno; /* chunk number for this mesg */ + void *native; /* native format message */ + uint8_t *raw; /* pointer to raw data */ + size_t raw_size; /* size with alignment */ }; /* Struct for storing information about "best" message to move to new chunk */ typedef struct H5O_msg_alloc_info_t { int msgno; /* Index in message array */ - unsigned id; /* Message type ID on disk */ + unsigned id; /* Message type ID on disk */ unsigned chunkno; /* Index in chunk array */ size_t gap_size; /* Size of any "gap" in the chunk immediately after message */ size_t null_size; /* Size of any null message in the chunk immediately after message */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index e87c148..4b74d8f 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -26,6 +26,7 @@ /* Early typedefs to avoid circular dependencies */ typedef struct H5O_t H5O_t; +typedef struct H5O_fill_t H5O_fill_t; /* Include the public header file for this API */ #include "H5Opublic.h" /* Object header functions */ @@ -308,7 +309,7 @@ typedef struct H5O_linfo_t { * message if it's shared. */ -typedef struct H5O_fill_t { +struct H5O_fill_t { H5O_shared_t sh_loc; /* Shared message info (must be first) */ unsigned version; /* Encoding version number */ @@ -318,7 +319,7 @@ typedef struct H5O_fill_t { H5D_alloc_time_t alloc_time; /* time to allocate space */ H5D_fill_time_t fill_time; /* time to write fill value */ hbool_t fill_defined; /* whether fill value is defined */ -} H5O_fill_t; +}; /* * Link message. diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 6beee6f..915aa38 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -389,8 +389,8 @@ static const unsigned H5F_def_page_buf_min_raw_perc_g = H5F_ACS_PAGE_BUFFER_MIN_ static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass) { - const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ - herr_t ret_value = SUCCEED; /* Return value */ + const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5Tbit.c b/src/H5Tbit.c index 12d1fd1..df6d2c3 100644 --- a/src/H5Tbit.c +++ b/src/H5Tbit.c @@ -11,10 +11,9 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Module Info: Operations on bit vectors. A bit vector is an array of bytes - * with the least-significant bits in the first byte. That is, - * the bytes are in little-endian order. +/* Module Info: Operations on bit vectors. A bit vector is an array of bytes + * with the least-significant bits in the first byte. That is, + * the bytes are in little-endian order. */ #include "H5Tmodule.h" /* This source code file is part of the H5T module */ @@ -29,14 +28,11 @@ /*------------------------------------------------------------------------- - * Function: H5T__bit_copy + * Function: H5T__bit_copy * - * Purpose: Copies bits from one vector to another. + * Purpose: Copies bits from one vector to another. * - * Return: void - * - * Programmer: Robb Matzke - * Wednesday, June 10, 1998 + * Return: void * *------------------------------------------------------------------------- */ @@ -50,8 +46,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, FUNC_ENTER_PACKAGE_NOERR - /* - * Normalize the offset to be a byte number and a bit offset within that + /* Normalize the offset to be a byte number and a bit offset within that * byte. */ s_idx = src_offset / 8; @@ -59,8 +54,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, src_offset %= 8; dst_offset %= 8; - /* - * Get things rolling. This means copying bits until we're aligned on a + /* Get things rolling. This means copying bits until we're aligned on a * source byte. This the following example, five bits are copied to the * destination. * @@ -75,30 +69,29 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, * ...+---------------+---------------+ * dst[d_idx+1] dst[d_idx] */ - while(src_offset && size > 0) { - size_t nbits = MIN3(size, 8 - dst_offset, 8 - src_offset); - size_t mask = ((size_t)1 << nbits) - 1; - - dst[d_idx] &= (uint8_t)~(mask << dst_offset); - dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); - - src_offset += nbits; - if(src_offset >= 8) { - s_idx++; - src_offset %= 8; - } /* end if */ - - dst_offset += nbits; - if(dst_offset >= 8) { - d_idx++; - dst_offset %= 8; - } /* end if */ - - size -= nbits; - } /* end while */ - - /* - * The middle bits. We are aligned on a source byte which needs to be + while (src_offset && size > 0) { + size_t nbits = MIN3(size, 8 - dst_offset, 8 - src_offset); + size_t mask = ((size_t)1 << nbits) - 1; + + dst[d_idx] &= (uint8_t)~(mask << dst_offset); + dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); + + src_offset += nbits; + if (src_offset >= 8) { + s_idx++; + src_offset %= 8; + } + + dst_offset += nbits; + if (dst_offset >= 8) { + d_idx++; + dst_offset %= 8; + } + + size -= nbits; + } + + /* The middle bits. We are aligned on a source byte which needs to be * copied to two (or one in the degenerate case) destination bytes. * * src[s_idx] @@ -122,48 +115,48 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, mask_lo = ((size_t)1 << (8 - shift)) - 1; mask_hi = (~mask_lo) & 0xff; - for(/*void*/; size > 8; size -= 8, d_idx++, s_idx++) { - if(shift) { - dst[d_idx + 0] &= (uint8_t)(~(mask_lo << shift)); - dst[d_idx + 0] |= (uint8_t)((src[s_idx] & mask_lo) << shift); - dst[d_idx + 1] &= (uint8_t)(~(mask_hi >> (8 - shift))); - dst[d_idx + 1] |= (uint8_t)((src[s_idx] & mask_hi) >> (8 - shift)); - } /* end if */ + for (/*void*/; size > 8; size -= 8, d_idx++, s_idx++) { + if (shift) { + dst[d_idx + 0] &= (uint8_t)(~(mask_lo << shift)); + dst[d_idx + 0] |= (uint8_t)((src[s_idx] & mask_lo) << shift); + dst[d_idx + 1] &= (uint8_t)(~(mask_hi >> (8 - shift))); + dst[d_idx + 1] |= (uint8_t)((src[s_idx] & mask_hi) >> (8 - shift)); + } else - dst[d_idx] = src[s_idx]; - } /* end for */ + dst[d_idx] = src[s_idx]; + } /* Finish up */ - while(size > 0) { - size_t nbits = (size_t)MIN3 (size, 8 - dst_offset, 8 - src_offset); - size_t mask = ((size_t)1 << nbits) - 1; + while (size > 0) { + size_t nbits = (size_t)MIN3 (size, 8 - dst_offset, 8 - src_offset); + size_t mask = ((size_t)1 << nbits) - 1; - dst[d_idx] &= (uint8_t)(~(mask << dst_offset)); - dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); + dst[d_idx] &= (uint8_t)(~(mask << dst_offset)); + dst[d_idx] = (uint8_t)(dst[d_idx] | (((src[s_idx] >> src_offset) & (uint8_t)mask) << dst_offset)); - src_offset += nbits; - if(src_offset >= 8) { - s_idx++; - src_offset %= 8; - } /* end if */ + src_offset += nbits; + if (src_offset >= 8) { + s_idx++; + src_offset %= 8; + } - dst_offset += nbits; - if(dst_offset >= 8) { - d_idx++; - dst_offset %= 8; - } /* end if */ + dst_offset += nbits; + if (dst_offset >= 8) { + d_idx++; + dst_offset %= 8; + } - size -= nbits; - } /* end while */ + size -= nbits; + } FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_copy() */ /*------------------------------------------------------------------------- - * Function: H5T__bit_shift + * Function: H5T__bit_shift * - * Purpose: Simulation of hardware shifting. Shifts a bit vector + * Purpose: Simulation of hardware shifting. Shifts a bit vector * in a way similar to shifting a variable value, like * value <<= 3, or value >>= 16. SHIFT_DIST is positive for * left shift, negative for right shift. The bit vector starts @@ -173,10 +166,7 @@ H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, * For example, if we have a bit sequence 00011100, offset=2, * size=3, shift_dist=2, the result will be 00010000. * - * Return: void - * - * Programmer: Raymond Lu - * Monday, April 12, 2004 + * Return: void * *------------------------------------------------------------------------- */ @@ -193,25 +183,25 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) HDassert(buf); HDassert(size); - if(shift_dist) { + if (shift_dist) { size_t abs_shift_dist = (size_t)ABS(shift_dist); - if(abs_shift_dist >= size) + if (abs_shift_dist >= size) H5T__bit_set(buf, offset, size, 0); else { size_t buf_size = (size / 8) + 1; /* Size of shift buffer needed */ uint8_t *shift_buf; /* Pointer to shift buffer */ /* Wrap the local buffer for serialized header info */ - if(NULL == (wb = H5WB_wrap(tmp_buf, sizeof(tmp_buf)))) + if (NULL == (wb = H5WB_wrap(tmp_buf, sizeof(tmp_buf)))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't wrap buffer") /* Get a pointer to a buffer that's large enough */ - if(NULL == (shift_buf = (uint8_t *)H5WB_actual(wb, buf_size))) + if (NULL == (shift_buf = (uint8_t *)H5WB_actual(wb, buf_size))) HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "can't get actual buffer") /* Shift vector by making copies */ - if(shift_dist > 0) { /* left shift */ + if (shift_dist > 0) { /* left shift */ /* Copy part to be shifted to a temporary buffer */ H5T__bit_copy(shift_buf, (size_t)0, buf, offset, size - abs_shift_dist); @@ -220,18 +210,18 @@ H5T__bit_shift(uint8_t *buf, ssize_t shift_dist, size_t offset, size_t size) /* Zero-set the left part*/ H5T__bit_set(buf, offset, abs_shift_dist, 0); - } /* end if */ + } else { /* right shift */ H5T__bit_copy(shift_buf, (size_t)0, buf, offset + abs_shift_dist, size - abs_shift_dist); H5T__bit_copy(buf, offset, shift_buf, (size_t)0, size - abs_shift_dist); H5T__bit_set(buf, offset + size - abs_shift_dist, abs_shift_dist, 0); - } /* end else */ + } } /* end else */ } /* end if */ done: /* Release resources */ - if(wb && H5WB_unwrap(wb) < 0) + if (wb && H5WB_unwrap(wb) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "can't close wrapped buffer") FUNC_LEAVE_NOAPI(ret_value) @@ -239,27 +229,24 @@ done: /*------------------------------------------------------------------------- - * Function: H5T__bit_get_d + * Function: H5T__bit_get_d * - * Purpose: Return a small bit sequence as a number. Bit vector starts + * Purpose: Return a small bit sequence as a number. Bit vector starts * at OFFSET and is SIZE bits long. * - * Return: Success: The bit sequence interpretted as an unsigned - * integer. - * - * Failure: 0 + * Return: Success: The bit sequence interpretted as an unsigned + * integer. * - * Programmer: Robb Matzke - * Tuesday, June 23, 1998 + * Failure: 0 * *------------------------------------------------------------------------- */ uint64_t H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) { - uint64_t val = 0; - size_t i, hs; - uint64_t ret_value = 0; /* Return value */ + uint64_t val = 0; + size_t i, hs; + uint64_t ret_value = 0; /* Return value */ FUNC_ENTER_PACKAGE_NOERR @@ -271,11 +258,11 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) break; case H5T_ORDER_BE: - for(i = 0, hs = sizeof(val) / 2; i < hs; i++) { + for (i = 0, hs = sizeof(val) / 2; i < hs; i++) { uint8_t tmp = ((uint8_t*)&val)[i]; ((uint8_t*)&val)[i] = ((uint8_t*)&val)[sizeof(val) - (i + 1)]; ((uint8_t*)&val)[sizeof(val) - (i + 1)] = tmp; - } /* end for */ + } break; case H5T_ORDER_ERROR: @@ -285,7 +272,7 @@ H5T__bit_get_d(uint8_t *buf, size_t offset, size_t size) default: /* Unknown endianness. Bail out. */ HGOTO_DONE(UFAIL) - } /* end switch */ + } /* Set return value */ ret_value = val; @@ -296,14 +283,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5T__bit_set_d + * Function: H5T__bit_set_d * - * Purpose: Sets part of a bit vector to the specified unsigned value. + * Purpose: Sets part of a bit vector to the specified unsigned value. * - * Return: void - * - * Programmer: Robb Matzke - * Wednesday, June 24, 1998 + * Return: void * *------------------------------------------------------------------------- */ @@ -321,11 +305,11 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) break; case H5T_ORDER_BE: - for(i = 0, hs = sizeof(val) / 2; i < hs; i++) { + for (i = 0, hs = sizeof(val) / 2; i < hs; i++) { uint8_t tmp = ((uint8_t *)&val)[i]; ((uint8_t *)&val)[i] = ((uint8_t *)&val)[sizeof(val) - (i + 1)]; ((uint8_t *)&val)[sizeof(val) - (i + 1)] = tmp; - } /* end for */ + } break; case H5T_ORDER_ERROR: @@ -334,7 +318,7 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) case H5T_ORDER_MIXED: default: HDabort(); - } /* end switch */ + } H5T__bit_copy(buf, offset, (uint8_t*)&val, (size_t)0, size); @@ -343,24 +327,19 @@ H5T__bit_set_d(uint8_t *buf, size_t offset, size_t size, uint64_t val) /*------------------------------------------------------------------------- - * Function: H5T__bit_set + * Function: H5T__bit_set * - * Purpose: Sets or clears bits in a contiguous region of a vector - * beginning at bit OFFSET and continuing for SIZE bits. + * Purpose: Sets or clears bits in a contiguous region of a vector + * beginning at bit OFFSET and continuing for SIZE bits. * - * Return: void - * - * Programmer: Robb Matzke - * Wednesday, June 10, 1998 - * - * Modifications: + * Return: void * *------------------------------------------------------------------------- */ void H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) { - int idx; + int idx; FUNC_ENTER_PACKAGE_NOERR @@ -369,54 +348,51 @@ H5T__bit_set(uint8_t *buf, size_t offset, size_t size, hbool_t value) offset %= 8; /* The first partial byte */ - if(size && offset % 8) { - size_t nbits = MIN(size, 8 - offset); - unsigned mask = ((unsigned)1 << nbits) - 1; + if (size && offset % 8) { + size_t nbits = MIN(size, 8 - offset); + unsigned mask = ((unsigned)1 << nbits) - 1; - if(value) - buf[idx] = (uint8_t)(buf[idx] | (mask << offset)); - else - buf[idx] &= (uint8_t)(~(mask << offset)); + if (value) + buf[idx] = (uint8_t)(buf[idx] | (mask << offset)); + else + buf[idx] &= (uint8_t)(~(mask << offset)); - idx++; - size -= nbits; - } /* end if */ + idx++; + size -= nbits; + } /* The middle bytes */ - while(size >= 8) { - buf[idx++] = value ? 0xff : 0x00; - size -= 8; - } /* end while */ + while (size >= 8) { + buf[idx++] = value ? 0xff : 0x00; + size -= 8; + } /* The last partial byte */ - if(size) { - if(value) - buf[idx] |= (uint8_t)(((unsigned)1 << size) - 1); - else - buf[idx] &= (uint8_t)(~(((unsigned)1 << size) - 1)); - } /* end if */ + if (size) { + if (value) + buf[idx] |= (uint8_t)(((unsigned)1 << size) - 1); + else + buf[idx] &= (uint8_t)(~(((unsigned)1 << size) - 1)); + } FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_set() */ /*------------------------------------------------------------------------- - * Function: H5T__bit_find + * Function: H5T__bit_find * - * Purpose: Finds the first bit with the specified VALUE within a region - * of a bit vector. The region begins at OFFSET and continues - * for SIZE bits, but the region can be searched from the least - * significat end toward the most significant end(H5T_BIT_LSB - * as DIRECTION), or from the most significant end to the least - * significant end(H5T_BIT_MSB as DIRECTION). + * Purpose: Finds the first bit with the specified VALUE within a region + * of a bit vector. The region begins at OFFSET and continues + * for SIZE bits, but the region can be searched from the least + * significat end toward the most significant end(H5T_BIT_LSB + * as DIRECTION), or from the most significant end to the least + * significant end(H5T_BIT_MSB as DIRECTION). * - * Return: Success: The position of the bit found, relative to - * the offset. + * Return: Success: The position of the bit found, relative to + * the offset. * - * Failure: -1 - * - * Programmer: Robb Matzke - * Wednesday, June 10, 1998 + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -424,9 +400,9 @@ ssize_t H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, hbool_t value) { - ssize_t base = (ssize_t)offset; - ssize_t idx, i; - size_t iu; + ssize_t base = (ssize_t)offset; + ssize_t idx, i; + size_t iu; ssize_t ret_value = (-1); /* Return value */ /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ @@ -435,16 +411,16 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, /* Some functions call this with value=TRUE */ HDassert(TRUE == 1); - switch(direction) { + switch (direction) { case H5T_BIT_LSB: /* Calculate index */ idx = (ssize_t)(offset / 8); offset %= 8; /* Beginning */ - if(offset) { - for(iu = offset; iu < 8 && size > 0; iu++, size--) - if(value == (hbool_t)((buf[idx] >> iu) & 0x01)) + if (offset) { + for (iu = offset; iu < 8 && size > 0; iu++, size--) + if (value == (hbool_t)((buf[idx] >> iu) & 0x01)) HGOTO_DONE(8 * idx + (ssize_t)iu - base); offset = 0; @@ -452,10 +428,10 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, } /* end if */ /* Middle */ - while(size >= 8) { - if((value ? 0x00 : 0xff) != buf[idx]) - for(i = 0; i < 8; i++) - if(value == (hbool_t)((buf[idx] >> i) & 0x01)) + while (size >= 8) { + if ((value ? 0x00 : 0xff) != buf[idx]) + for (i = 0; i < 8; i++) + if (value == (hbool_t)((buf[idx] >> i) & 0x01)) HGOTO_DONE(8 * idx + i - base); size -= 8; @@ -463,8 +439,8 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, } /* end while */ /* End */ - for(i = 0; i < (ssize_t)size; i++) - if(value == (hbool_t)((buf[idx] >> i) & 0x01)) + for (i = 0; i < (ssize_t)size; i++) + if (value == (hbool_t)((buf[idx] >> i) & 0x01)) HGOTO_DONE(8 * idx + i - base); break; @@ -474,19 +450,19 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, offset %= 8; /* Beginning */ - if(size > 8 - offset && (offset + size) % 8) { - for(iu = (offset + size) % 8; iu > 0; --iu, --size) - if(value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01)) + if (size > 8 - offset && (offset + size) % 8) { + for (iu = (offset + size) % 8; iu > 0; --iu, --size) + if (value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01)) HGOTO_DONE(8 * idx + (ssize_t)(iu - 1) - base); --idx; } /* end if */ /* Middle */ - while(size >= 8) { - if((value ? 0x00 : 0xff) != buf[idx]) { - for(i = 7; i >= 0; --i) - if(value == (hbool_t)((buf[idx] >> i) & 0x01)) + while (size >= 8) { + if ((value ? 0x00 : 0xff) != buf[idx]) { + for (i = 7; i >= 0; --i) + if (value == (hbool_t)((buf[idx] >> i) & 0x01)) HGOTO_DONE(8 * idx + i - base); } /* end if */ @@ -495,11 +471,11 @@ H5T__bit_find(uint8_t *buf, size_t offset, size_t size, H5T_sdir_t direction, } /* end while */ /* End */ - if(size > 0) { - for(iu = offset + size; iu > offset; --iu) - if(value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01)) + if (size > 0) { + for (iu = offset + size; iu > offset; --iu) + if (value == (hbool_t)((buf[idx] >> (iu - 1)) & 0x01)) HGOTO_DONE(8 * idx + (ssize_t)(iu - 1) - base); - } /* end if */ + } break; default: @@ -519,17 +495,14 @@ done: * * Return: The carry-out value. TRUE if overflows, FALSE otherwise. * - * Programmer: Robb Matzke - * Friday, June 26, 1998 - * *------------------------------------------------------------------------- */ hbool_t H5T__bit_inc(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; - unsigned carry = 1; - unsigned acc, mask; + size_t idx = start / 8; + unsigned carry = 1; + unsigned acc, mask; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -539,7 +512,7 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) start %= 8; /* The first partial byte */ - if(start) { + if (start) { if(size + start < 8) mask = ((unsigned)1 << size) - 1; else @@ -552,34 +525,34 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) size -= MIN(size, 8 - start); start = 0; idx++; - } /* end if */ + } /* The middle */ - while(carry && size >= 8) { + while (carry && size >= 8) { acc = buf[idx]; acc++; carry = acc & 0x100; buf[idx] = acc & 0xff; idx++; size -= 8; - } /* end while */ + } /* The last bits */ - if(carry && size > 0) { + if (carry && size > 0) { mask = ((unsigned)1 << size) - 1; acc = buf[idx] & mask; acc++; carry = acc & ((unsigned)1 << size); buf[idx] &= (uint8_t)(~mask); buf[idx] |= (uint8_t)(acc & mask); - } /* end if */ + } FUNC_LEAVE_NOAPI(carry ? TRUE : FALSE) } /* end H5T__bit_inc() */ /*------------------------------------------------------------------------- - * Function: H5T__bit_dec + * Function: H5T__bit_dec * * Purpose: Decrement part of a bit field by substracting 1. The bit * field starts with bit position START and is SIZE bits long. @@ -587,18 +560,15 @@ H5T__bit_inc(uint8_t *buf, size_t start, size_t size) * Return: The "borrow-in" value. It's TRUE if underflows, FALSE * otherwise. * - * Programmer: Raymond Lu - * March 17, 2004 - * *------------------------------------------------------------------------- */ hbool_t H5T__bit_dec(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; + size_t idx = start / 8; size_t pos = start % 8; uint8_t tmp; - unsigned borrow = 0; + unsigned borrow = 0; /* Use FUNC_ENTER_PACKAGE_NOERR here to avoid performance issues */ FUNC_ENTER_PACKAGE_NOERR @@ -607,71 +577,72 @@ H5T__bit_dec(uint8_t *buf, size_t start, size_t size) HDassert(size); /* The first partial byte */ - if((size + start - 1) / 8 > idx) { /*bit sequence doesn't end in the same byte as starts*/ + if ((size + start - 1) / 8 > idx) { + /* The bit sequence doesn't end in the same byte as starts */ + /* Example: a sequence like 11000100 and start = 3. We substract 00001000 from * it and get 10111100. If a sequence is 00000111, we do right shift for START * bits and get 00000000. So we need to borrow from higher byte when we substract * 00001000. */ - if(!(buf[idx] >> pos)) + if (!(buf[idx] >> pos)) borrow = 1; buf[idx] = (uint8_t)(buf[idx] - (1 << pos)); idx++; size -= (8 - pos); /* The middle bytes */ - while(borrow && size >= 8) { - if(buf[idx]) + while (borrow && size >= 8) { + if (buf[idx]) borrow = 0; buf[idx]--; idx++; size -= 8; - } /* end while */ + } /* The last partial byte */ - if(borrow && size > 0) { + if (borrow && size > 0) { /* Similar to the first byte case, where sequence ends in the same byte as starts */ tmp = buf[idx]; buf[idx]--; - if((buf[idx] >> size) != tmp >> size) + if ((buf[idx] >> size) != tmp >> size) buf[idx] = (uint8_t)(buf[idx] + (1 << size)); - } /* end if */ - } /* end if */ - else { /* bit sequence ends in the same byte as starts */ + } + } + else { + /* The bit sequence ends in the same byte as starts */ + /* Example: a sequence like 11000100 and pos=3, size=3. We substract 00001000 * and get 10111100. A bit is borrowed from 6th bit(buf[idx]>>6=00000010, tmp>>6=00000011, * not equal). We need to put this bit back by increment 1000000. */ tmp = buf[idx]; buf[idx] = (uint8_t)(buf[idx] - (1 << pos)); - if((buf[idx] >> (pos + size)) != tmp >> (pos + size)) { + if ((buf[idx] >> (pos + size)) != tmp >> (pos + size)) { buf[idx] = (uint8_t)(buf[idx] + (1 << (pos + size))); borrow = 1; - } /* end if */ - } /* end else */ + } + } FUNC_LEAVE_NOAPI(borrow ? TRUE : FALSE) } /* end H5T__bit_dec() */ /*------------------------------------------------------------------------- - * Function: H5T__bit_neg - * - * Purpose: negate part of a bit sequence. The bit - * field starts with bit position START and is SIZE bits long. + * Function: H5T__bit_neg * - * Return: void + * Purpose: Negate part of a bit sequence. The bit field starts with + * bit position START and is SIZE bits long. * - * Programmer: Raymond Lu - * March 19, 2004 + * Return: void * *------------------------------------------------------------------------- */ void H5T__bit_neg(uint8_t *buf, size_t start, size_t size) { - size_t idx = start / 8; + size_t idx = start / 8; size_t pos = start % 8; uint8_t tmp[1]; @@ -695,17 +666,19 @@ H5T__bit_neg(uint8_t *buf, size_t start, size_t size) buf[idx] = (uint8_t)~(buf[idx]); idx++; size -= 8; - } /* end while */ + } /* The last partial byte */ if(size > 0) { /* Similar to the first byte case, where sequence ends in the same byte as starts */ tmp[0] = (uint8_t)~buf[idx]; H5T__bit_copy(&(buf[idx]), (size_t)0, tmp, (size_t)0, size); - } /* end if */ - } /* end if */ - else /* bit sequence ends in the same byte as starts */ + } + } + else { + /* bit sequence ends in the same byte as starts */ H5T__bit_copy(&(buf[idx]), pos, tmp, pos, size); + } FUNC_LEAVE_NOAPI_VOID } /* end H5T__bit_neg() */ diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 84a997e..3f4b489 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -4079,13 +4079,15 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, sp = dp = (uint8_t*)buf; direction = 1; olap = nelmts; - } else if (src_p->shared->size>=dst_p->shared->size) { + } + else if (src_p->shared->size>=dst_p->shared->size) { double olap_d = HDceil((double)(dst_p->shared->size)/ (double)(src_p->shared->size-dst_p->shared->size)); olap = (size_t)olap_d; sp = dp = (uint8_t*)buf; direction = 1; - } else { + } + else { double olap_d = HDceil((double)(src_p->shared->size)/ (double)(dst_p->shared->size-src_p->shared->size)); olap = (size_t)olap_d; @@ -4127,7 +4129,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (direction>0) { s = sp; d = elmtno= nelmts ? dbuf : dp; } @@ -4136,7 +4139,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (d==dbuf) { HDassert((dp>=sp && dpshared->size) || (sp>=dp && spshared->size)); - } else { + } + else { HDassert((dpshared->size<=sp) || (spshared->size<=dp)); } @@ -4154,7 +4158,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, s[src_p->shared->size-(i+1)] = s[i]; s[i] = tmp1; } - } else if (H5T_ORDER_VAX==src.order) { + } + else if (H5T_ORDER_VAX==src.order) { tsize = src_p->shared->size; HDassert(0 == tsize % 2); @@ -4187,7 +4192,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, FALSE); H5T__bit_set (d, dst.u.f.mpos, dst.u.f.msize, FALSE); goto padding; - } else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, + } + else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /* +Inf or -Inf */ if(cb_struct.func) { /*If user's exception handler is present, use it*/ @@ -4210,16 +4216,19 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *this case.*/ if (H5T_NORM_NONE==dst.u.f.norm) H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + } + else if(except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) + } + else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; } - } else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1, + } + else if (H5T_NORM_NONE==src.u.f.norm && H5T__bit_find (s, src.u.f.mpos, src.u.f.msize-1, H5T_BIT_LSB, TRUE)<0 && H5T__bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /*This is a special case for the source of no implied mantissa bit. @@ -4246,11 +4255,13 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, *this case.*/ if (H5T_NORM_NONE==dst.u.f.norm) H5T__bit_set (d, dst.u.f.mpos+dst.u.f.msize-1, (size_t)1, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + } + else if(except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) + } + else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; @@ -4259,7 +4270,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * still need to handle legacy VAX files so this code must * remain in place. */ - } else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, + } + else if (H5T__bit_find (s, src.u.f.epos, src.u.f.esize, H5T_BIT_LSB, FALSE)<0) { /* NaN */ if(cb_struct.func) { /*If user's exception handler is present, use it*/ @@ -4275,11 +4287,13 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T__bit_copy (d, dst.u.f.sign, s, src.u.f.sign, (size_t)1); H5T__bit_set (d, dst.u.f.epos, dst.u.f.esize, TRUE); H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, TRUE); - } else if(except_ret == H5T_CONV_HANDLED) { + } + else if(except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = FALSE; goto next; - } else if(except_ret == H5T_CONV_ABORT) + } + else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") goto padding; @@ -4292,7 +4306,7 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ expo = (int64_t)H5T__bit_get_d(s, src.u.f.epos, src.u.f.esize); - if(expo==0) + if (expo==0) denormalized=TRUE; /* @@ -4302,16 +4316,19 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, implied = 1; mpos = src.u.f.mpos; mrsh = 0; - if(0 == expo || H5T_NORM_NONE == src.u.f.norm) { - if((bitno = H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE)) > 0) { + if (0 == expo || H5T_NORM_NONE == src.u.f.norm) { + if ((bitno = H5T__bit_find(s, src.u.f.mpos, src.u.f.msize, H5T_BIT_MSB, TRUE)) > 0) { msize = (size_t)bitno; - } else if (0==bitno) { + } + else if (0==bitno) { msize = 1; H5T__bit_set(s, src.u.f.mpos, (size_t)1, FALSE); } - } else if (H5T_NORM_IMPLIED==src.u.f.norm) { + } + else if (H5T_NORM_IMPLIED==src.u.f.norm) { msize = src.u.f.msize; - } else { + } + else { HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") } @@ -4328,9 +4345,11 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if (0==expo || H5T_NORM_NONE==src.u.f.norm) { HDassert(bitno>=0); expo -= (int64_t)((src.u.f.ebias - 1) + (src.u.f.msize - (size_t)bitno)); - } else if (H5T_NORM_IMPLIED==src.u.f.norm) { + } + else if (H5T_NORM_IMPLIED==src.u.f.norm) { expo -= (int64_t)src.u.f.ebias; - } else { + } + else { HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "normalization method not implemented yet") } @@ -4353,7 +4372,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, expo = 0; H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; - } else if (expo<=0) { + } + else if (expo<=0) { /* * The exponent is too small to fit in the exponent field, * but by shifting the mantissa to the right we can @@ -4363,7 +4383,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, mrsh += (size_t)(1 - expo); expo = 0; denormalized=TRUE; - } else if (expo>=expo_max) { + } + else if (expo>=expo_max) { /* * The exponent is too large to fit in the available region * or it results in the maximum possible value. Use positive @@ -4383,7 +4404,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, expo = expo_max; H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); msize = 0; - } else if(except_ret == H5T_CONV_ABORT) + } + else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) { reverse = FALSE; @@ -4410,7 +4432,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if(carry) implied = 2; } - } else if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized) + } + else if(H5T__bit_get_d(s, (mpos + (size_t)bitno) - 1, (size_t)1) && denormalized) /* For either source or destination, denormalized value doesn't increment carry.*/ H5T__bit_inc(s, mpos + (size_t)bitno - 1, 1 + msize - (size_t)bitno); } @@ -4422,13 +4445,16 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, */ if (mrsh>dst.u.f.msize+1) { H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); - } else if (mrsh==dst.u.f.msize+1) { + } + else if (mrsh==dst.u.f.msize+1) { H5T__bit_set(d, dst.u.f.mpos+1, dst.u.f.msize-1, FALSE); H5T__bit_set(d, dst.u.f.mpos, (size_t)1, TRUE); - } else if (mrsh==dst.u.f.msize) { + } + else if (mrsh==dst.u.f.msize) { H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); H5T__bit_set_d(d, dst.u.f.mpos, MIN(2, dst.u.f.msize), (hsize_t)implied); - } else { + } + else { if (mrsh>0) { H5T__bit_set(d, dst.u.f.mpos+dst.u.f.msize-mrsh, mrsh, FALSE); @@ -4439,7 +4465,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, H5T__bit_copy(d, dst.u.f.mpos, s, (mpos+msize+mrsh-dst.u.f.msize), dst.u.f.msize-mrsh); - } else { + } + else { H5T__bit_copy(d, dst.u.f.mpos+dst.u.f.msize-(mrsh+msize), s, mpos, msize); H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize-(mrsh+msize), @@ -4469,7 +4496,8 @@ H5T__conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, if(except_ret == H5T_CONV_UNHANDLED) { expo = expo_max; H5T__bit_set(d, dst.u.f.mpos, dst.u.f.msize, FALSE); - } else if(except_ret == H5T_CONV_ABORT) + } + else if(except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception") else if(except_ret == H5T_CONV_HANDLED) { reverse = FALSE; -- cgit v0.12 From 2e80fbbfcc5a15c296c16e4a4295ce77a9af6587 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 30 Nov 2017 17:25:39 -0800 Subject: Fixed an incorrect FUNC_ENTER macro. --- src/H5L.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5L.c b/src/H5L.c index afd033a..07f3cdb 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -2896,7 +2896,7 @@ H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) H5L_trav_le_t udata; /* User data for traversal */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_NOAPI(FAIL) /* A path of "/" will always exist in a file */ if(0 == HDstrcmp(name, "/")) -- cgit v0.12