From cdbb523b940f70c160402a32f236f7e8121aabf9 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 16 Oct 2001 13:19:06 -0500 Subject: [svn-r4548] Purpose: Code cleanup. Description: Fix a few compiler warnings from the file creation property list -> generic property list conversion. Also change a hard-wired value (8) for the number of B-tree key values to a value that uses the enum's generated by the compiler. Platforms tested: FreeBSD 4.4 (hawkwind) --- src/H5B.c | 31 +++++++++++++++++++++++++++---- src/H5Bprivate.h | 5 ----- src/H5Bpublic.h | 8 ++++++++ src/H5F.c | 30 +++++++++++++++++------------- src/H5Fprivate.h | 14 +++++++------- src/H5Gnode.c | 32 ++++++++++++++++++++++++++++---- src/H5Gpkg.h | 2 +- src/H5P.c | 12 ++++++------ src/H5Ppublic.h | 4 ++-- 9 files changed, 96 insertions(+), 42 deletions(-) diff --git a/src/H5B.c b/src/H5B.c index 9d82d42..dd8e388 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -284,21 +284,44 @@ H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, FUNC_LEAVE(ret_value); } -int H5B_Kvalue(H5F_t *f, const H5B_class_t *type) + +/*------------------------------------------------------------------------- + * Function: H5B_Kvalue + * + * Purpose: Replaced a macro to retrieve a B-tree key value for a certain + * type, now that the generic properties are being used to store + * the B-tree values. + * + * Return: Success: Non-negative, and the B-tree key value is + * returned. + * + * Failure: Negative (should not happen) + * + * Programmer: Raymond Lu + * slu@ncsa.uiuc.edu + * Oct 14 2001 + * + * Modifications: + * Quincey Koziol, 2001-10-15 + * Added this header and removed unused ret_value variable. + *------------------------------------------------------------------------- + */ +int +H5B_Kvalue(H5F_t *f, const H5B_class_t *type) { - int ret_value = FAIL; - int btree_k[8]={0}; + int btree_k[H5B_NUM_BTREE_ID]; FUNC_ENTER(H5B_Kvalue, FAIL); assert(f); assert(type); + if(H5P_get(f->shared->fcpl_id, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get rank for btree internal nodes"); FUNC_LEAVE(btree_k[type->id]); -} +} /* end H5B_Kvalue() */ /*------------------------------------------------------------------------- diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index f24f725..8cab893 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -50,11 +50,6 @@ typedef enum H5B_ins_t { H5B_INS_REMOVE = 5 /*remove current node */ } H5B_ins_t; -typedef enum H5B_subid_t { - H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ - H5B_ISTORE_ID = 1 /*B-tree is for indexed object storage */ -} H5B_subid_t; - /* * Each class of object that can be pointed to by a B-link tree has a * variable of this type that contains class variables and methods. Each diff --git a/src/H5Bpublic.h b/src/H5Bpublic.h index fec9a51..4841923 100644 --- a/src/H5Bpublic.h +++ b/src/H5Bpublic.h @@ -20,6 +20,14 @@ /* Public headers needed by this file */ #include "H5public.h" +/* B-tree IDs for various internal things. */ +/* Not really a "public" symbol, but that should be OK -QAK */ +typedef enum H5B_subid_t { + H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */ + H5B_ISTORE_ID = 1, /*B-tree is for indexed object storage */ + H5B_NUM_BTREE_ID /* Number of B-tree key IDs (must be last) */ +} H5B_subid_t; + #ifdef __cplusplus extern "C" { #endif diff --git a/src/H5F.c b/src/H5F.c index 73d180e..4ac87dc 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -163,8 +163,8 @@ H5F_init_interface(void) */ H5P_genclass_t *crt_pclass; hsize_t userblock_size = H5F_CRT_USER_BLOCK_DEF; - int sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; - int btree_k[8] = H5F_CRT_BTREE_RANK_DEF; + unsigned sym_leaf_k = H5F_CRT_SYM_LEAF_DEF; + int btree_k[H5B_NUM_BTREE_ID] = H5F_CRT_BTREE_RANK_DEF; size_t sizeof_addr = H5F_CRT_ADDR_BYTE_NUM_DEF; size_t sizeof_size = H5F_CRT_OBJ_BYTE_NUM_DEF; int bootblock_ver = H5F_CRT_BOOT_VERS_DEF; @@ -1059,8 +1059,8 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) int share_head_vers; size_t sizeof_addr = 0; size_t sizeof_size = 0; - int sym_leaf_k = 0; - int btree_k[8] = {0}; + unsigned sym_leaf_k = 0; + int btree_k[H5B_NUM_BTREE_ID]; FUNC_ENTER(H5F_open, NULL); @@ -1297,7 +1297,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) "unable to set rank for symbol table leaf nodes"); /* Need 'get' call to set other array values */ - if(H5P_get(shared->fcpl_id, H5F_CRT_BTREE_RANK_NAME, &btree_k)<0) + if(H5P_get(shared->fcpl_id, H5F_CRT_BTREE_RANK_NAME, btree_k)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "unable to get rank for btree internal nodes"); UINT16DECODE(p, btree_k[H5B_SNODE_ID]); @@ -1305,7 +1305,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, NULL, "bad 1/2 rank for btree internal nodes"); } - if(H5P_set(shared->fcpl_id, H5F_CRT_BTREE_RANK_NAME, &btree_k)<0) + if(H5P_set(shared->fcpl_id, H5F_CRT_BTREE_RANK_NAME, btree_k)<0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, NULL, "unable to set rank for btree internal nodes"); @@ -1769,7 +1769,8 @@ H5F_flush(H5F_t *f, H5F_scope_t scope, hbool_t invalidate, char driver_name[9]; int boot_vers, freespace_vers, obj_dir_vers, share_head_vers, - sym_leaf_k, btree_k[8]={0}; + btree_k[H5B_NUM_BTREE_ID]; + unsigned sym_leaf_k; FUNC_ENTER(H5F_flush, FAIL); @@ -2606,7 +2607,7 @@ H5Freopen(hid_t file_id) *------------------------------------------------------------------------- */ unsigned -H5F_get_intent(H5F_t *f) +H5F_get_intent(const H5F_t *f) { FUNC_ENTER(H5F_get_intent, 0); @@ -2636,7 +2637,7 @@ H5F_get_intent(H5F_t *f) *------------------------------------------------------------------------- */ size_t -H5F_sizeof_addr(H5F_t *f) +H5F_sizeof_addr(const H5F_t *f) { size_t sizeof_addr = 0; @@ -2669,12 +2670,14 @@ H5F_sizeof_addr(H5F_t *f) *------------------------------------------------------------------------- */ size_t -H5F_sizeof_size(H5F_t *f) +H5F_sizeof_size(const H5F_t *f) { size_t sizeof_size = 0; FUNC_ENTER(H5F_sizeof_size, 0); + assert(f); + if(H5P_get(f->shared->fcpl_id, H5F_CRT_OBJ_BYTE_NUM_NAME, &sizeof_size)<0) HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get byte number for object size"); @@ -2699,7 +2702,7 @@ H5F_sizeof_size(H5F_t *f) *------------------------------------------------------------------------- */ hid_t -H5F_get_driver_id(H5F_t *f) +H5F_get_driver_id(const H5F_t *f) { FUNC_ENTER(H5F_get_driver_id, 0); @@ -2969,7 +2972,8 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent, int fwidth) { hsize_t userblock_size; - int sym_leaf_k, btree_k[8]={0}; + int btree_k[H5B_NUM_BTREE_ID]; + unsigned sym_leaf_k; size_t sizeof_addr, sizeof_size; int boot_vers, freespace_vers, obj_dir_vers, share_head_vers; @@ -3045,7 +3049,7 @@ H5F_debug(H5F_t *f, haddr_t UNUSED addr, FILE * stream, int indent, HDfprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth, "Size of file haddr_t type:", (unsigned) sizeof_addr); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, - "Symbol table leaf node 1/2 rank:", (unsigned) sym_leaf_k); + "Symbol table leaf node 1/2 rank:", sym_leaf_k); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Symbol table internal node 1/2 rank:", (unsigned) (btree_k[H5B_SNODE_ID])); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 10f8de2..77af814 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -215,8 +215,8 @@ typedef struct H5F_t H5F_t; #define H5F_SIZEOF_ADDR(F) (H5F_sizeof_addr(F)) #define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F)) -__DLL__ size_t H5F_sizeof_addr(H5F_t *f); -__DLL__ size_t H5F_sizeof_size(H5F_t *f); +__DLL__ size_t H5F_sizeof_addr(const H5F_t *f); +__DLL__ size_t H5F_sizeof_size(const H5F_t *f); /* Macros to encode/decode offset/length's for storing in the file */ #ifdef NOT_YET @@ -257,12 +257,12 @@ __DLL__ size_t H5F_sizeof_size(H5F_t *f); #define H5F_CRT_USER_BLOCK_DEF 0 /* Definitions for the 1/2 rank for symbol table leaf nodes */ #define H5F_CRT_SYM_LEAF_NAME "symbol_leaf" -#define H5F_CRT_SYM_LEAF_SIZE sizeof(int) +#define H5F_CRT_SYM_LEAF_SIZE sizeof(unsigned) #define H5F_CRT_SYM_LEAF_DEF 4 /* Definitions for the 1/2 rank for btree internal nodes */ #define H5F_CRT_BTREE_RANK_NAME "btree_rank" -#define H5F_CRT_BTREE_RANK_SIZE sizeof(int[8]) -#define H5F_CRT_BTREE_RANK_DEF {16,32,0} +#define H5F_CRT_BTREE_RANK_SIZE sizeof(int[H5B_NUM_BTREE_ID]) +#define H5F_CRT_BTREE_RANK_DEF {16,32} /* Definitions for byte number in an address */ #define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" #define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(size_t) @@ -325,8 +325,8 @@ struct H5S_t; /* Private functions, not part of the publicly documented API */ __DLL__ herr_t H5F_init(void); -__DLL__ unsigned H5F_get_intent(H5F_t *f); -__DLL__ hid_t H5F_get_driver_id(H5F_t *f); +__DLL__ unsigned H5F_get_intent(const H5F_t *f); +__DLL__ hid_t H5F_get_driver_id(const H5F_t *f); /* Functions that operate on array storage */ __DLL__ herr_t H5F_arr_create(H5F_t *f, diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 9a25c37..d698504 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1213,14 +1213,38 @@ H5G_node_debug(H5F_t *f, haddr_t addr, FILE * stream, int indent, FUNC_LEAVE(SUCCEED); } -unsigned H5G_node_k(H5F_t *f) + +/*------------------------------------------------------------------------- + * Function: H5G_node_k + * + * Purpose: Replaced a macro to retrieve the symbol table leaf size, + * now that the generic properties are being used to store + * the values. + * + * Return: Success: Non-negative, and the symbol table leaf size is + * returned. + * + * Failure: Negative (should not happen) + * + * Programmer: Raymond Lu + * slu@ncsa.uiuc.edu + * Oct 14 2001 + * + * Modifications: + * Quincey Koziol, 2001-10-15 + * Added this header and removed unused ret_value variable. + *------------------------------------------------------------------------- + */ +unsigned H5G_node_k(const H5F_t *f) { - int sym_leaf_k; + unsigned sym_leaf_k; + + FUNC_ENTER(H5G_node_k, UFAIL); - FUNC_ENTER(H5G_node_k, FAIL); + assert(f); if(H5P_get(f->shared->fcpl_id, H5F_CRT_SYM_LEAF_NAME, &sym_leaf_k) < 0) - HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, + HRETURN_ERROR(H5E_PLIST, H5E_CANTGET, UFAIL, "can't get rank for symbol table leaf node"); FUNC_LEAVE(sym_leaf_k); diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 1c70e7b..43409ba 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -138,6 +138,6 @@ __DLL__ herr_t H5G_ent_decode_vec(H5F_t *f, const uint8_t **pp, __DLL__ herr_t H5G_ent_encode_vec(H5F_t *f, uint8_t **pp, const H5G_entry_t *ent, int n); -__DLL__ unsigned H5G_node_k(H5F_t *f); +__DLL__ unsigned H5G_node_k(const H5F_t *f); #endif diff --git a/src/H5P.c b/src/H5P.c index 57414ff..3eeb1a8 100644 --- a/src/H5P.c +++ b/src/H5P.c @@ -1356,9 +1356,9 @@ H5Pget_sizes(hid_t plist_id, *------------------------------------------------------------------------- */ herr_t -H5Pset_sym_k(hid_t plist_id, int ik, int lk) +H5Pset_sym_k(hid_t plist_id, int ik, unsigned lk) { - int btree_k[8]={0}; + int btree_k[H5B_NUM_BTREE_ID]; FUNC_ENTER(H5Pset_sym_k, FAIL); H5TRACE3("e","iIsIs",plist_id,ik,lk); @@ -1408,9 +1408,9 @@ H5Pset_sym_k(hid_t plist_id, int ik, int lk) *------------------------------------------------------------------------- */ herr_t -H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , int *lk /*out */ ) +H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , unsigned *lk /*out */ ) { - int btree_k[8]; + int btree_k[H5B_NUM_BTREE_ID]; FUNC_ENTER(H5Pget_sym_k, FAIL); H5TRACE3("e","ixx",plist_id,ik,lk); @@ -1457,7 +1457,7 @@ H5Pget_sym_k(hid_t plist_id, int *ik /*out */ , int *lk /*out */ ) herr_t H5Pset_istore_k(hid_t plist_id, int ik) { - int btree_k[8]={0}; + int btree_k[H5B_NUM_BTREE_ID]; FUNC_ENTER(H5Pset_istore_k, FAIL); H5TRACE2("e","iIs",plist_id,ik); @@ -1507,7 +1507,7 @@ H5Pset_istore_k(hid_t plist_id, int ik) herr_t H5Pget_istore_k(hid_t plist_id, int *ik /*out */ ) { - int btree_k[8]={0}; + int btree_k[H5B_NUM_BTREE_ID]; FUNC_ENTER(H5Pget_istore_k, FAIL); H5TRACE2("e","ix",plist_id,ik); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index d8e8383..9156065 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -175,8 +175,8 @@ __DLL__ herr_t H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size); __DLL__ herr_t H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr/*out*/, size_t *sizeof_size/*out*/); -__DLL__ herr_t H5Pset_sym_k(hid_t plist_id, int ik, int lk); -__DLL__ herr_t H5Pget_sym_k(hid_t plist_id, int *ik/*out*/, int *lk/*out*/); +__DLL__ herr_t H5Pset_sym_k(hid_t plist_id, int ik, unsigned lk); +__DLL__ herr_t H5Pget_sym_k(hid_t plist_id, int *ik/*out*/, unsigned *lk/*out*/); __DLL__ herr_t H5Pset_istore_k(hid_t plist_id, int ik); __DLL__ herr_t H5Pget_istore_k(hid_t plist_id, int *ik/*out*/); __DLL__ herr_t H5Pset_layout(hid_t plist_id, H5D_layout_t layout); -- cgit v0.12