From bbe03d73613afbcdeca14c045c8b90fac37e0fe8 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 7 May 2005 14:37:48 -0500 Subject: [svn-r10736] Purpose: Code cleanup Description: Clean up some compiler warnings Platforms tested: FreeBSD 4.11 (sleipnir) h5committest --- config/freebsd | 4 +- fortran/src/H5match_types.c | 192 +++++++++++--------------------------------- hl/src/H5PT.c | 6 +- hl/test/test_packet.c | 11 +-- hl/tools/gif2h5/readhdf.c | 4 +- hl/tools/gif2h5/writehdf.c | 3 - src/H5.c | 2 +- src/H5A.c | 6 +- src/H5B.c | 12 +-- src/H5Bpkg.h | 2 +- src/H5C.c | 2 +- src/H5Dprivate.h | 2 +- src/H5E.c | 4 +- src/H5F.c | 28 +++---- src/H5Fpkg.h | 10 +-- src/H5G.c | 4 +- src/H5Gpkg.h | 2 +- src/H5Ipublic.h | 1 + src/H5Opkg.h | 2 +- src/H5P.c | 2 +- src/H5SHcache.c | 2 +- src/H5T.c | 4 + src/H5Znbit.c | 6 +- src/H5Zscaleoffset.c | 19 ++--- src/H5public.h | 2 + test/bittests.c | 32 ++++---- test/dsets.c | 26 +++--- test/dt_atomic.c | 40 ++++----- test/testmeta.c | 6 +- tools/gifconv/readhdf.c | 4 +- tools/gifconv/writehdf.c | 3 - tools/lib/h5diff.c | 2 + tools/lib/h5tools_str.c | 12 +-- 33 files changed, 167 insertions(+), 290 deletions(-) diff --git a/config/freebsd b/config/freebsd index c3b3904..e07054e 100644 --- a/config/freebsd +++ b/config/freebsd @@ -11,9 +11,9 @@ if test "X-" = "X-$CC"; then CC_BASENAME=gcc fi -# Add "_POSIX_C_SOURCE" define to cpp flags, to quiet warnings +# Add "_XOPEN_SOURCE" define to cpp flags, to quiet warnings # from /usr/include/sys/cdefs.h -CPPFLAGS="$CPPFLAGS -D_POSIX_C_SOURCE=1" +CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600" # Figure out C compiler flags . $srcdir/config/gnu-flags diff --git a/fortran/src/H5match_types.c b/fortran/src/H5match_types.c index 13c6d4c..97dcf33 100644 --- a/fortran/src/H5match_types.c +++ b/fortran/src/H5match_types.c @@ -17,7 +17,8 @@ FILE * fort_header; #define CFILE "H5f90i_gen.h" #define FFILE "H5fortran_types.f90" -void initCfile() +static void +initCfile(void) { fprintf(c_header, "/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\n\ @@ -42,7 +43,8 @@ void initCfile() #include \"H5public.h\"\n\n"); } -void initFfile() +static void +initFfile(void) { fprintf(fort_header, "! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \n\ @@ -67,11 +69,13 @@ void initFfile() } -void endCfile() +static void +endCfile(void) { fprintf(c_header, "\n#endif /* _H5f90i_gen_H */\n"); } -void endFfile() +static void +endFfile(void) { fprintf(fort_header, "\n INTEGER(SIZE_T), PARAMETER :: OBJECT_NAMELEN_DEFAULT_F = -1\n\n"); fprintf(fort_header, " END MODULE H5FORTRAN_TYPES\n"); @@ -98,11 +102,6 @@ void writeToFiles(const char* fortran_type, const char* c_type, unsigned int siz fprintf(c_header, "typedef c_int_%d %s;\n", size, c_type); } -/* hid_t and hssize_t don't have their sizes defined anywhere. - * Use sizeof() instead. */ -#define H5_SIZEOF_HID_T sizeof(hid_t) -#define H5_SIZEOF_HSSIZE_T sizeof(hssize_t) - int main() { /* Open target files */ @@ -165,184 +164,89 @@ int main() fprintf(c_header, "\n"); /* haddr_t */ - if( H5_SIZEOF_HADDR_T >= 8) { - #ifdef H5_FORTRAN_HAS_INTEGER_8 - writeToFiles("HADDR_T", "haddr_t_f", 8); - goto hsize_t_start; - #endif - } - if( H5_SIZEOF_HADDR_T >= 4) { - #ifdef H5_FORTRAN_HAS_INTEGER_4 - writeToFiles("HADDR_T", "haddr_t_f", 4); - goto hsize_t_start; - #endif - } - if( H5_SIZEOF_HADDR_T >= 2) { - #ifdef H5_FORTRAN_HAS_INTEGER_2 - writeToFiles("HADDR_T", "haddr_t_f", 2); - goto hsize_t_start; - #endif - } - if( H5_SIZEOF_HADDR_T >= 1) { - #ifdef H5_FORTRAN_HAS_INTEGER_1 - writeToFiles("HADDR_T", "haddr_t_f", 1); - goto hsize_t_start; - #endif - } +#if defined H5_FORTRAN_HAS_INTEGER_8 && H5_SIZEOF_HADDR_T >= 8 + writeToFiles("HADDR_T", "haddr_t_f", 8); +#elif defined H5_FORTRAN_HAS_INTEGER_4 && H5_SIZEOF_HADDR_T >= 4 + writeToFiles("HADDR_T", "haddr_t_f", 4); +#elif defined H5_FORTRAN_HAS_INTEGER_2 && H5_SIZEOF_HADDR_T >= 2 + writeToFiles("HADDR_T", "haddr_t_f", 2); +#elif defined H5_FORTRAN_HAS_INTEGER_1 && H5_SIZEOF_HADDR_T >= 1 + writeToFiles("HADDR_T", "haddr_t_f", 1); +#else /* Error: couldn't find a size for haddr_t */ return -1; - - hsize_t_start: +#endif /* hsize_t */ - if( H5_SIZEOF_HSIZE_T >= 8) { - #ifdef H5_FORTRAN_HAS_INTEGER_8 +#if defined H5_FORTRAN_HAS_INTEGER_8 && H5_SIZEOF_HSIZE_T >= 8 writeToFiles("HSIZE_T", "hsize_t_f", 8); - goto hssize_t_start; - #endif - } - if( H5_SIZEOF_HSIZE_T >= 4) { - #ifdef H5_FORTRAN_HAS_INTEGER_4 +#elif defined H5_FORTRAN_HAS_INTEGER_4 && H5_SIZEOF_HSIZE_T >= 4 writeToFiles("HSIZE_T", "hsize_t_f", 4); - goto hssize_t_start; - #endif - } - if( H5_SIZEOF_HSIZE_T >= 2) { - #ifdef H5_FORTRAN_HAS_INTEGER_2 +#elif defined H5_FORTRAN_HAS_INTEGER_2 && H5_SIZEOF_HSIZE_T >= 2 writeToFiles("HSIZE_T", "hsize_t_f", 2); - goto hssize_t_start; - #endif - } - if( H5_SIZEOF_HSIZE_T >= 1) { - #ifdef H5_FORTRAN_HAS_INTEGER_1 +#elif defined H5_FORTRAN_HAS_INTEGER_1 && H5_SIZEOF_HSIZE_T >= 1 writeToFiles("HSIZE_T", "hsize_t_f", 1); - goto hssize_t_start; - #endif - } +#else /* Error: couldn't find a size for hsize_t */ return -1; - - hssize_t_start: +#endif /* hssize_t */ - if( H5_SIZEOF_HSSIZE_T >= 8) { - #ifdef H5_FORTRAN_HAS_INTEGER_8 +#if defined H5_FORTRAN_HAS_INTEGER_8 && H5_SIZEOF_HSSIZE_T >= 8 writeToFiles("HSSIZE_T", "hssize_t_f", 8); - goto size_t_start; - #endif - } - if( H5_SIZEOF_HSSIZE_T >= 4) { - #ifdef H5_FORTRAN_HAS_INTEGER_4 +#elif defined H5_FORTRAN_HAS_INTEGER_4 && H5_SIZEOF_HSSIZE_T >= 4 writeToFiles("HSSIZE_T", "hssize_t_f", 4); - goto size_t_start; - #endif - } - if( H5_SIZEOF_HSSIZE_T >= 2) { - #ifdef H5_FORTRAN_HAS_INTEGER_2 +#elif defined H5_FORTRAN_HAS_INTEGER_2 && H5_SIZEOF_HSSIZE_T >= 2 writeToFiles("HSSIZE_T", "hssize_t_f", 2); - goto size_t_start; - #endif - } - if( H5_SIZEOF_HSSIZE_T >= 1) { - #ifdef H5_FORTRAN_HAS_INTEGER_1 +#elif defined H5_FORTRAN_HAS_INTEGER_1 && H5_SIZEOF_HSSIZE_T >= 1 writeToFiles("HSSIZE_T", "hssize_t_f", 1); - goto size_t_start; - #endif - } +#else /* Error: couldn't find a size for hssize_t */ return -1; +#endif - size_t_start: /* size_t */ - if( H5_SIZEOF_SIZE_T >= 8) { - #ifdef H5_FORTRAN_HAS_INTEGER_8 +#if defined H5_FORTRAN_HAS_INTEGER_8 && H5_SIZEOF_SIZE_T >= 8 writeToFiles("SIZE_T", "size_t_f", 8); - goto int_start; - #endif - } - if( H5_SIZEOF_SIZE_T >= 4) { - #ifdef H5_FORTRAN_HAS_INTEGER_4 +#elif defined H5_FORTRAN_HAS_INTEGER_4 && H5_SIZEOF_SIZE_T >= 4 writeToFiles("SIZE_T", "size_t_f", 4); - goto int_start; - #endif - } - if( H5_SIZEOF_SIZE_T >= 2) { - #ifdef H5_FORTRAN_HAS_INTEGER_2 +#elif defined H5_FORTRAN_HAS_INTEGER_2 && H5_SIZEOF_SIZE_T >= 2 writeToFiles("SIZE_T", "size_t_f", 2); - goto int_start; - #endif - } - if( H5_SIZEOF_SIZE_T >= 1) { - #ifdef H5_FORTRAN_HAS_INTEGER_1 +#elif defined H5_FORTRAN_HAS_INTEGER_1 && H5_SIZEOF_SIZE_T >= 1 writeToFiles("SIZE_T", "size_t_f", 1); - goto int_start; - #endif - } +#else /* Error: couldn't find a size for size_t */ return -1; +#endif - int_start: /* int */ - if( H5_SIZEOF_INT >= 8) { - #ifdef H5_FORTRAN_HAS_INTEGER_8 +#if defined H5_FORTRAN_HAS_INTEGER_8 && H5_SIZEOF_INT >= 8 writeToFiles("INT", "int_f", 8); - goto hid_t_start; - #endif - } - if( H5_SIZEOF_INT >= 4) { - #ifdef H5_FORTRAN_HAS_INTEGER_4 +#elif defined H5_FORTRAN_HAS_INTEGER_4 && H5_SIZEOF_INT >= 4 writeToFiles("INT", "int_f", 4); - goto hid_t_start; - #endif - } - if( H5_SIZEOF_INT >= 2) { - #ifdef H5_FORTRAN_HAS_INTEGER_2 +#elif defined H5_FORTRAN_HAS_INTEGER_2 && H5_SIZEOF_INT >= 2 writeToFiles("INT", "int_f", 2); - goto hid_t_start; - #endif - } - if( H5_SIZEOF_INT >= 1) { - #ifdef H5_FORTRAN_HAS_INTEGER_1 +#elif defined H5_FORTRAN_HAS_INTEGER_1 && H5_SIZEOF_INT >= 1 writeToFiles("INT", "int_f", 1); - goto hid_t_start; - #endif - } +#else /* Error: couldn't find a size for int */ return -1; +#endif - hid_t_start: /* hid_t */ - if( H5_SIZEOF_HID_T >= 8) { - #ifdef H5_FORTRAN_HAS_INTEGER_8 +#if defined H5_FORTRAN_HAS_INTEGER_8 && H5_SIZEOF_HID_T >= 8 writeToFiles("HID_T", "hid_t_f", 8); - goto real_start; - #endif - } - if( H5_SIZEOF_HID_T >= 4) { - #ifdef H5_FORTRAN_HAS_INTEGER_4 +#elif defined H5_FORTRAN_HAS_INTEGER_4 && H5_SIZEOF_HID_T >= 4 writeToFiles("HID_T", "hid_t_f", 4); - goto real_start; - #endif - } - if( H5_SIZEOF_HID_T >= 2) { - #ifdef H5_FORTRAN_HAS_INTEGER_2 +#elif defined H5_FORTRAN_HAS_INTEGER_2 && H5_SIZEOF_HID_T >= 2 writeToFiles("HID_T", "hid_t_f", 2); - goto real_start; - #endif - } - if( H5_SIZEOF_HID_T >= 1) { - #ifdef H5_FORTRAN_HAS_INTEGER_1 +#elif defined H5_FORTRAN_HAS_INTEGER_1 && H5_SIZEOF_HID_T >= 1 writeToFiles("HID_T", "hid_t_f", 1); - goto real_start; - #endif - } +#else /* Error: couldn't find a size for hid_t */ return -1; - - real_start: - goto done; - done: +#endif /* Close files */ endCfile(); diff --git a/hl/src/H5PT.c b/hl/src/H5PT.c index 10b148b..d59e9ed 100644 --- a/hl/src/H5PT.c +++ b/hl/src/H5PT.c @@ -291,8 +291,6 @@ out: */ herr_t H5PT_close( htbl_t* table) { - herr_t return_status = 0; - if(table == NULL) goto out; @@ -670,10 +668,8 @@ out: */ herr_t H5PTis_valid(hid_t table_id) { - htbl_t * table; - /* find the table struct from its ID */ - if((table = (htbl_t *) H5Iobject_verify(table_id, H5PT_ptable_id_type)) ==NULL) + if(H5Iobject_verify(table_id, H5PT_ptable_id_type) ==NULL) return -1; return 0; diff --git a/hl/test/test_packet.c b/hl/test/test_packet.c index 0500edd..0593579 100644 --- a/hl/test/test_packet.c +++ b/hl/test/test_packet.c @@ -82,7 +82,8 @@ static int cmp_par(hsize_t i, hsize_t j, particle_t *rbuf, particle_t *wbuf ) * function to create a datatype representing the particle struct *------------------------------------------------------------------------- */ -static hid_t make_particle_type() +static hid_t +make_particle_type(void) { hid_t type_id; hid_t string_type; @@ -113,8 +114,6 @@ static hid_t make_particle_type() /* Create a normal HL table just like the HL examples do */ static int create_hl_table(hid_t fid) { - particle_t testparticle; - /* Calculate the offsets of the particle struct members in memory */ size_t part_offset[NFIELDS] = { HOFFSET( particle_t, name ), HOFFSET( particle_t, lati ), @@ -122,12 +121,6 @@ static int create_hl_table(hid_t fid) HOFFSET( particle_t, pressure ), HOFFSET( particle_t, temperature )}; - size_t part_sizes[NFIELDS] = { sizeof( testparticle.name), - sizeof( testparticle.lati), - sizeof( testparticle.longi), - sizeof( testparticle.pressure), - sizeof( testparticle.temperature)}; - /* Define field information */ const char *field_names[NFIELDS] = { "Name","Latitude", "Longitude", "Pressure", "Temperature" }; diff --git a/hl/tools/gif2h5/readhdf.c b/hl/tools/gif2h5/readhdf.c index 4b05ad9..2720d4d 100644 --- a/hl/tools/gif2h5/readhdf.c +++ b/hl/tools/gif2h5/readhdf.c @@ -86,7 +86,7 @@ int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, return -1; } if (H5Tget_size(dtype) != 1) { - fprintf(stderr , "Data is %d bytes per pixel. Cannot convert to GIF\n",H5Tget_size(dtype)); + fprintf(stderr , "Data is %d bytes per pixel. Cannot convert to GIF\n",(int)H5Tget_size(dtype)); return -1; } @@ -141,7 +141,7 @@ int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, return -1; } if (H5Tget_size(pal_dtype) != 1) { - fprintf(stderr , "Palette data is %d bytes per pixel. Cannot convert to GIF\n",H5Tget_size(pal_dtype)); + fprintf(stderr , "Palette data is %d bytes per pixel. Cannot convert to GIF\n",(int)H5Tget_size(pal_dtype)); return -1; } diff --git a/hl/tools/gif2h5/writehdf.c b/hl/tools/gif2h5/writehdf.c index 7df7f29..d343aae 100644 --- a/hl/tools/gif2h5/writehdf.c +++ b/hl/tools/gif2h5/writehdf.c @@ -25,7 +25,6 @@ static int write_text_attribute(hid_t dataset_id , const char *attr_name, const char *attr_value, const size_t attr_len) { /* variables for the attributes */ - hsize_t attr_dims; /* dimensions for the attribute */ hsize_t attr_size; /* dimensions for the attribute */ hid_t attr_dataspace_id; /* dataspaces needed for the various attributes */ hid_t attr_attr_id; /* attribute id */ @@ -35,8 +34,6 @@ static int write_text_attribute(hid_t dataset_id , const char *attr_name, if (!attr_name || !attr_value) return -1; - attr_dims = 1; - /* figure out size of the data */ attr_size = (hsize_t)attr_len; diff --git a/src/H5.c b/src/H5.c index ab488ba..821ee3a 100644 --- a/src/H5.c +++ b/src/H5.c @@ -1564,7 +1564,7 @@ H5_trace (const double *returning, const char *func, const char *type, ...) if (argname) { unsigned n = (unsigned)MAX (0, (int)HDstrlen(argname)-3); /*lint !e666 Allow expression with side effects */ if (!HDstrcmp (argname+n, "_id")) { - HDstrncpy (buf, argname, MIN ((int)sizeof(buf)-1, n)); + HDstrncpy (buf, argname, (size_t)MIN ((int)sizeof(buf)-1, n)); buf[MIN((int)sizeof(buf)-1, n)] = '\0'; argname = buf; } diff --git a/src/H5A.c b/src/H5A.c index 863cf75..a8acc3a 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -77,7 +77,7 @@ H5A_init_interface(void) /* * Create attribute group. */ - if (H5I_register_type(H5I_ATTR, H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS, (H5I_free_t)H5A_close)data,(src_type_size*nelmts)); /* Perform datatype conversion. */ - if (H5T_convert(tpath, src_id, dst_id, nelmts, 0, 0, tconv_buf, bkg_buf, dxpl_id)<0) + if (H5T_convert(tpath, src_id, dst_id, nelmts, (size_t)0, (size_t)0, tconv_buf, bkg_buf, dxpl_id)<0) HGOTO_ERROR(H5E_ATTR, H5E_CANTENCODE, FAIL, "datatype conversion failed") /* Copy the converted data into the user's buffer */ diff --git a/src/H5B.c b/src/H5B.c index 525e12e..aa752cf 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -230,7 +230,7 @@ H5B_create(H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, void *udata, shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || - NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,shared->two_k))) + NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for B-tree root node") if (HADDR_UNDEF==(*addr_p=H5MF_alloc(f, H5FD_MEM_BTREE, dxpl_id, (hsize_t)shared->sizeof_rnode))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for B-tree root node") @@ -307,7 +307,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) shared=H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); if (NULL==(bt->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || - NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,shared->two_k))) + NULL==(bt->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if (H5F_block_read(f, H5FD_MEM_BTREE, addr, shared->sizeof_rnode, dxpl_id, shared->page)<0) @@ -316,7 +316,7 @@ H5B_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void *_type, void *udata) p = shared->page; /* magic number */ - if (HDmemcmp(p, H5B_MAGIC, H5B_SIZEOF_MAGIC)) + if (HDmemcmp(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC)) HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL, "wrong B-tree signature") p += 4; @@ -400,7 +400,7 @@ H5B_serialize(const H5F_t *f, const H5B_t *bt) p = shared->page; /* magic number */ - HDmemcpy(p, H5B_MAGIC, H5B_SIZEOF_MAGIC); + HDmemcpy(p, H5B_MAGIC, (size_t)H5B_SIZEOF_MAGIC); p += 4; /* node type and level */ @@ -1537,7 +1537,7 @@ H5B_iterate (H5F_t *f, hid_t dxpl_id, const H5B_class_t *type, H5B_operator_t op * We've reached the left-most leaf. Now follow the right-sibling * pointer from leaf to leaf until we've processed all leaves. */ - if (NULL==(child=H5FL_SEQ_MALLOC(haddr_t,shared->two_k)) || + if (NULL==(child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k)) || NULL==(key=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -2114,7 +2114,7 @@ H5B_copy(const H5B_t *old_bt) HDmemcpy(new_node,old_bt,sizeof(H5B_t)); if ( NULL==(new_node->native=H5FL_BLK_MALLOC(native_block,shared->sizeof_keys)) || - NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,shared->two_k))) + NULL==(new_node->child=H5FL_SEQ_MALLOC(haddr_t,(size_t)shared->two_k))) HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for B-tree root node") /* Copy the other structures */ diff --git a/src/H5Bpkg.h b/src/H5Bpkg.h index 37047e7..74fa393 100644 --- a/src/H5Bpkg.h +++ b/src/H5Bpkg.h @@ -49,9 +49,9 @@ struct H5B_t { /* first field in structure */ H5RC_t *rc_shared; /*ref-counted shared info */ unsigned level; /*node level */ + unsigned nchildren; /*number of child pointers */ haddr_t left; /*address of left sibling */ haddr_t right; /*address of right sibling */ - unsigned nchildren; /*number of child pointers */ uint8_t *native; /*array of keys in native format */ haddr_t *child; /*2k child pointers */ }; diff --git a/src/H5C.c b/src/H5C.c index 0e1064a..28cb17a 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -1919,7 +1919,7 @@ H5C_create(size_t max_cache_size, "memory allocation failed") } - if ( (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR,0.5,16)) + if ( (cache_ptr->slist_ptr = H5SL_create(H5SL_TYPE_HADDR,0.5,(size_t)16)) == NULL ) { HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, NULL, "can't create skip list.") diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index d6d2333..732af1f 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -192,12 +192,12 @@ typedef struct H5D_dxpl_cache_t { void *tconv_buf; /* Temporary conversion buffer (H5D_XFER_TCONV_BUF_NAME) */ void *bkgr_buf; /* Background conversion buffer (H5D_XFER_BKGR_BUF_NAME) */ H5T_bkg_t bkgr_buf_type; /* Background buffer type (H5D_XFER_BKGR_BUF_NAME) */ + H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ double btree_split_ratio[3];/* B-tree split ratios (H5D_XFER_BTREE_SPLIT_RATIO_NAME) */ size_t vec_size; /* Size of hyperslab vector (H5D_XFER_HYPER_VECTOR_SIZE_NAME) */ #ifdef H5_HAVE_PARALLEL H5FD_mpio_xfer_t xfer_mode; /* Parallel transfer for this request (H5D_XFER_IO_XFER_MODE_NAME) */ #endif /*H5_HAVE_PARALLEL*/ - H5Z_EDC_t err_detect; /* Error detection info (H5D_XFER_EDC_NAME) */ H5Z_cb_t filter_cb; /* Filter callback function (H5D_XFER_FILTER_CB_NAME) */ H5Z_data_xform_t *data_xform_prop; /* Data transform prop (H5D_XFER_XFORM_NAME) */ } H5D_dxpl_cache_t; diff --git a/src/H5E.c b/src/H5E.c index 74c67fa..2323288 100644 --- a/src/H5E.c +++ b/src/H5E.c @@ -105,7 +105,7 @@ static herr_t H5E_set_current_stack(H5E_t *estack); static herr_t H5E_close_stack(H5E_t *err_stack); static int H5E_get_num(const H5E_t *err_stack); static herr_t H5E_pop(H5E_t *err_stack, size_t count); -static herr_t H5E_clear_entries(H5E_t *estack, unsigned nentries); +static herr_t H5E_clear_entries(H5E_t *estack, size_t nentries); static herr_t H5E_print_stack(const H5E_t *estack, FILE *stream); static herr_t H5E_walk_stack(const H5E_t *estack, H5E_direction_t direction, H5E_walk_t func, void *client_data); @@ -1755,7 +1755,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5E_clear_entries(H5E_t *estack, unsigned nentries) +H5E_clear_entries(H5E_t *estack, size_t nentries) { H5E_error_t *error; /* Pointer to error stack entry to clear */ unsigned u; /* Local index variable */ diff --git a/src/H5F.c b/src/H5F.c index 8ad29cb..442baac 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -227,8 +227,8 @@ H5F_init_interface(void) * which are pending completion because there are object headers still * open within the file. */ - if (H5I_register_type(H5I_FILE, H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)nrefs>0); @@ -3232,7 +3232,7 @@ H5F_close(H5F_t *f) int i; /* Local index variable */ /* Get the list of IDs of open dataset objects */ - while((obj_count=H5F_get_obj_ids(f, H5F_OBJ_DATASET, (sizeof(objs)/sizeof(objs[0])), objs))!=0) { + while((obj_count=H5F_get_obj_ids(f, H5F_OBJ_DATASET, (int)(sizeof(objs)/sizeof(objs[0])), objs))!=0) { /* Try to close all the open objects */ for(i=0; iheap_type = *p++; + sh->heap_type = (H5SH_data_type_t)*p++; if(sh->heap_type == H5SH_RAW) sh->file_mem_type = H5FD_MEM_DRAW; else diff --git a/src/H5T.c b/src/H5T.c index bc20caf..0c41d7f 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -675,7 +675,9 @@ H5T_init_interface(void) H5T_t *native_ullong=NULL; /* Datatype structure for native unsigned llong */ H5T_t *native_float=NULL; /* Datatype structure for native float */ H5T_t *native_double=NULL; /* Datatype structure for native double */ +#if H5_SW_LDOUBLE_TO_INTEGER_WORKS H5T_t *native_ldouble=NULL; /* Datatype structure for native double */ +#endif /*H5_SW_LDOUBLE_TO_INTEGER_WORKS*/ H5T_t *std_u8le=NULL; /* Datatype structure for unsigned 8-bit little-endian integer */ H5T_t *std_u8be=NULL; /* Datatype structure for unsigned 8-bit big-endian integer */ H5T_t *std_u16le=NULL; /* Datatype structure for unsigned 16-bit little-endian integer */ @@ -747,8 +749,10 @@ H5T_init_interface(void) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL==(native_double=H5I_object(H5T_NATIVE_DOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); +#if H5_SW_LDOUBLE_TO_INTEGER_WORKS if (NULL==(native_ldouble=H5I_object(H5T_NATIVE_LDOUBLE_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); +#endif /*H5_SW_LDOUBLE_TO_INTEGER_WORKS*/ /*------------------------------------------------------------ * Native types diff --git a/src/H5Znbit.c b/src/H5Znbit.c index ab47461..938528c 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -130,18 +130,16 @@ static unsigned parms_index = 0; static herr_t H5Z_can_apply_nbit(hid_t UNUSED dcpl_id, hid_t type_id, hid_t UNUSED space_id) { - H5T_class_t dtype_class; /* Datatype's class */ - unsigned dtype_size; /* Datatype's size (in bytes) */ herr_t ret_value=TRUE; /* Return value */ FUNC_ENTER_NOAPI(H5Z_can_apply_nbit, FAIL) /* Get datatype's class, for checking the "datatype class" */ - if((dtype_class = H5Tget_class(type_id)) == H5T_NO_CLASS ) + if(H5Tget_class(type_id) == H5T_NO_CLASS ) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Get datatype's size, for checking the "datatype size" */ - if((dtype_size = H5Tget_size(type_id)) == 0) + if(H5Tget_size(type_id) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") done: diff --git a/src/H5Zscaleoffset.c b/src/H5Zscaleoffset.c index 417d60b..cfbe59c 100644 --- a/src/H5Zscaleoffset.c +++ b/src/H5Zscaleoffset.c @@ -31,7 +31,7 @@ typedef struct { unsigned mem_order; /* current memory endianness order */ } parms_atomic; -enum H5Z_scaleoffset_type {t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long, +enum H5Z_scaleoffset_type {t_bad=0, t_uchar=1, t_ushort, t_uint, t_ulong, t_ulong_long, t_schar, t_short, t_int, t_long, t_long_long, t_float, t_double}; @@ -584,7 +584,6 @@ static herr_t H5Z_can_apply_scaleoffset(hid_t UNUSED dcpl_id, hid_t type_id, hid_t UNUSED space_id) { H5T_class_t dtype_class; /* Datatype's class */ - unsigned dtype_size; /* Datatype's size (in bytes) */ H5T_order_t dtype_order; /* Datatype's endianness order */ herr_t ret_value=TRUE; /* Return value */ @@ -595,7 +594,7 @@ H5Z_can_apply_scaleoffset(hid_t UNUSED dcpl_id, hid_t type_id, hid_t UNUSED spac HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype class") /* Get datatype's size, for checking the "datatype size" */ - if((dtype_size = H5Tget_size(type_id)) == 0) + if(H5Tget_size(type_id) == 0) HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "bad datatype size") if(dtype_class == H5T_INTEGER || dtype_class == H5T_FLOAT) { @@ -634,9 +633,9 @@ static enum H5Z_scaleoffset_type H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dtype_sign) { enum H5Z_scaleoffset_type type; /* integer type */ - unsigned ret_value; /* return value */ + enum H5Z_scaleoffset_type ret_value; /* return value */ - FUNC_ENTER_NOAPI(H5Z_scaleoffset_get_type, 0) + FUNC_ENTER_NOAPI_NOINIT(H5Z_scaleoffset_get_type) if(dtype_class==H5Z_SCALEOFFSET_CLS_INTEGER) { if(dtype_sign==H5Z_SCALEOFFSET_SGN_NONE) { /* unsigned integer */ @@ -646,7 +645,7 @@ H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dty else if(dtype_size == sizeof(unsigned long)) type = t_ulong; else if(dtype_size == sizeof(unsigned long_long)) type = t_ulong_long; else - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot find matched memory dataype") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } if(dtype_sign==H5Z_SCALEOFFSET_SGN_2) { /* signed integer */ @@ -656,7 +655,7 @@ H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dty else if(dtype_size == sizeof(long)) type = t_long; else if(dtype_size == sizeof(long_long)) type = t_long_long; else - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot find matched memory dataype") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } } @@ -664,11 +663,13 @@ H5Z_scaleoffset_get_type(unsigned dtype_class, unsigned dtype_size, unsigned dty if(dtype_size == sizeof(float)) type = t_float; else if(dtype_size == sizeof(double)) type = t_double; else - HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, 0, "cannot find matched memory dataype") + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, t_bad, "cannot find matched memory dataype") } -done: + /* Set return value */ ret_value = type; + +done: FUNC_LEAVE_NOAPI(ret_value) } diff --git a/src/H5public.h b/src/H5public.h index d4ccce1..ce4aa22 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -152,11 +152,13 @@ typedef long_long ssize_t; typedef unsigned long_long hsize_t; typedef signed long_long hssize_t; # define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG +# define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG # endif #else /* H5_HAVE_LARGE_HSIZET */ typedef size_t hsize_t; typedef ssize_t hssize_t; # define H5_SIZEOF_HSIZE_T H5_SIZEOF_SIZE_T +# define H5_SIZEOF_HSSIZE_T H5_SIZEOF_SIZE_T #endif /* H5_HAVE_LARGE_HSIZET */ /* diff --git a/test/bittests.c b/test/bittests.c index cb038f7..872a01a 100644 --- a/test/bittests.c +++ b/test/bittests.c @@ -174,9 +174,9 @@ test_copy (void) TESTING("bit copy operations"); for (i=0; i HDpow(10, -3)) { H5_FAILED(); printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", 0, (unsigned long)j); + printf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); goto error; } } @@ -4470,7 +4467,7 @@ test_scaleoffset_double_2(hid_t file) double orig_data[2][5]; double new_data[2][5]; double fillval; - hssize_t start[2]; /* Start of hyperslab */ + hsize_t start[2]; /* Start of hyperslab */ hsize_t stride[2]; /* Stride of hyperslab */ hsize_t count[2]; /* Block count */ hsize_t block[2]; /* Block sizes */ @@ -4567,7 +4564,7 @@ test_scaleoffset_double_2(hid_t file) if (HDfabs(new_data[0][j]-orig_data[0][j]) > HDpow(10, -7)) { H5_FAILED(); printf(" Read different values than written.\n"); - printf(" At index %lu,%lu\n", 0, (unsigned long)j); + printf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j); goto error; } } @@ -5982,7 +5979,8 @@ error: * *------------------------------------------------------------------------- */ -int main(void) +int +main(void) { hid_t file, grp, fapl; int mdc_nelmts; @@ -5996,7 +5994,7 @@ int main(void) fapl = h5_fileaccess(); /* Set the random # seed */ - HDsrandom((unsigned long)HDtime(NULL)); + HDsrandom((unsigned long)HDtime(NULL)); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); diff --git a/test/dt_atomic.c b/test/dt_atomic.c index 7348a9f..31a7c76 100644 --- a/test/dt_atomic.c +++ b/test/dt_atomic.c @@ -275,7 +275,7 @@ static int without_hardware_g = 0; #define INIT_FP_SPECIAL(SRC_SIZE, SRC_PREC, SRC_ORDR, SRC_MANT_DIG, DST_SIZE, \ BUF, SAVED, NELMTS) \ { \ - unsigned char *buf_p, *saved_p; \ + unsigned char *buf_p; \ unsigned char *value; \ int n; \ \ @@ -291,7 +291,6 @@ static int without_hardware_g = 0; value = (unsigned char*)calloc(SRC_SIZE, sizeof(unsigned char)); \ \ buf_p = BUF; \ - saved_p = SAVED; \ \ /* +0 */ \ H5T_bit_set(value, 0, SRC_PREC, FALSE); \ @@ -562,8 +561,7 @@ test_derived_flt(void) hid_t file=-1, tid1=-1, tid2=-1; hid_t dxpl_id=-1; char filename[1024]; - size_t precision, spos, epos, esize, mpos, msize, size, ebias; - int offset; + size_t spos, epos, esize, mpos, msize, size; size_t src_size, dst_size; unsigned char *buf=NULL, *saved_buf=NULL; int *aligned=NULL; @@ -679,12 +677,12 @@ test_derived_flt(void) goto error; } - if((precision = H5Tget_precision(tid1))!=42) { + if(H5Tget_precision(tid1)!=42) { H5_FAILED(); printf("Can't get precision or wrong precision\n"); goto error; } - if((offset = H5Tget_offset(tid1))!=3) { + if(H5Tget_offset(tid1)!=3) { H5_FAILED(); printf("Can't get offset or wrong offset\n"); goto error; @@ -694,7 +692,7 @@ test_derived_flt(void) printf("Can't get size or wrong size\n"); goto error; } - if((ebias = H5Tget_ebias(tid1))!=511) { + if(H5Tget_ebias(tid1)!=511) { H5_FAILED(); printf("Can't get exponent bias or wrong bias\n"); goto error; @@ -841,12 +839,12 @@ test_derived_flt(void) goto error; } - if((precision = H5Tget_precision(tid2))!=24) { + if(H5Tget_precision(tid2)!=24) { H5_FAILED(); printf("Can't get precision or wrong precision\n"); goto error; } - if((offset = H5Tget_offset(tid2))!=0) { + if(H5Tget_offset(tid2)!=0) { H5_FAILED(); printf("Can't get offset or wrong offset\n"); goto error; @@ -856,7 +854,7 @@ test_derived_flt(void) printf("Can't get size or wrong size\n"); goto error; } - if((ebias = H5Tget_ebias(tid2))!=63) { + if(H5Tget_ebias(tid2)!=63) { H5_FAILED(); printf("Can't get exponent bias or wrong bias\n"); goto error; @@ -1003,10 +1001,6 @@ test_derived_integer(void) hid_t file=-1, tid1=-1, tid2=-1; hid_t dxpl_id=-1; char filename[1024]; - size_t precision, size; - int offset; - H5T_order_t order; - H5T_sign_t sign; size_t src_size, dst_size; unsigned char *buf=NULL, *saved_buf=NULL; int *aligned=NULL; @@ -1099,22 +1093,22 @@ test_derived_integer(void) goto error; } - if((precision = H5Tget_precision(tid1))!=24) { + if(H5Tget_precision(tid1)!=24) { H5_FAILED(); printf("Can't get precision or wrong precision\n"); goto error; } - if((offset = H5Tget_offset(tid1))!=0) { + if(H5Tget_offset(tid1)!=0) { H5_FAILED(); printf("Can't get offset or wrong offset\n"); goto error; } - if((size = H5Tget_size(tid1))!=3) { + if(H5Tget_size(tid1)!=3) { H5_FAILED(); printf("Can't get size or wrong size\n"); goto error; } - if((order = H5Tget_order(tid1))!=H5T_ORDER_BE) { + if(H5Tget_order(tid1)!=H5T_ORDER_BE) { H5_FAILED(); printf("Can't get order or wrong order\n"); goto error; @@ -1164,22 +1158,22 @@ test_derived_integer(void) goto error; } - if((precision = H5Tget_precision(tid2))!=48) { + if(H5Tget_precision(tid2)!=48) { H5_FAILED(); printf("Can't get precision or wrong precision\n"); goto error; } - if((offset = H5Tget_offset(tid2))!=10) { + if(H5Tget_offset(tid2)!=10) { H5_FAILED(); printf("Can't get offset or wrong offset\n"); goto error; } - if((size = H5Tget_size(tid2))!=8) { + if(H5Tget_size(tid2)!=8) { H5_FAILED(); printf("Can't get size or wrong size\n"); goto error; } - if((sign = H5Tget_sign(tid2))!=H5T_SGN_2) { + if(H5Tget_sign(tid2)!=H5T_SGN_2) { H5_FAILED(); printf("Can't get sign or wrong sign\n"); goto error; @@ -4476,13 +4470,11 @@ int main(void) { unsigned long nerrors = 0; - hid_t fapl=-1; /* Set the random # seed */ HDsrandom((unsigned long)HDtime(NULL)); reset_hdf5(); - fapl = h5_fileaccess(); if (ALIGNMENT) printf("Testing non-aligned conversions (ALIGNMENT=%d)....\n", ALIGNMENT); diff --git a/test/testmeta.c b/test/testmeta.c index c7edafc..03fd841 100644 --- a/test/testmeta.c +++ b/test/testmeta.c @@ -41,8 +41,8 @@ int main(void) { hid_t file_id, prop_id, memspace_id, type_id; - hid_t group_id, access_plist; - hid_t dataset_id, dataspace_id, s_dataspace_id; + hid_t group_id; + hid_t dataset_id, dataspace_id; herr_t status; hsize_t dims[1]; hsize_t maxdims[1]; @@ -51,7 +51,7 @@ int main(void) unsigned numdataobj = 0; unsigned i, j; char name[80]; - hssize_t start[1] = {0}; + hsize_t start[1] = {0}; hsize_t stride[1] = {1}; hsize_t count[1] = {1}; diff --git a/tools/gifconv/readhdf.c b/tools/gifconv/readhdf.c index 4b05ad9..2720d4d 100644 --- a/tools/gifconv/readhdf.c +++ b/tools/gifconv/readhdf.c @@ -86,7 +86,7 @@ int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, return -1; } if (H5Tget_size(dtype) != 1) { - fprintf(stderr , "Data is %d bytes per pixel. Cannot convert to GIF\n",H5Tget_size(dtype)); + fprintf(stderr , "Data is %d bytes per pixel. Cannot convert to GIF\n",(int)H5Tget_size(dtype)); return -1; } @@ -141,7 +141,7 @@ int ReadHDF(BYTE** data, BYTE palette[256][3], hsize_t *image_size, return -1; } if (H5Tget_size(pal_dtype) != 1) { - fprintf(stderr , "Palette data is %d bytes per pixel. Cannot convert to GIF\n",H5Tget_size(pal_dtype)); + fprintf(stderr , "Palette data is %d bytes per pixel. Cannot convert to GIF\n",(int)H5Tget_size(pal_dtype)); return -1; } diff --git a/tools/gifconv/writehdf.c b/tools/gifconv/writehdf.c index 7df7f29..d343aae 100644 --- a/tools/gifconv/writehdf.c +++ b/tools/gifconv/writehdf.c @@ -25,7 +25,6 @@ static int write_text_attribute(hid_t dataset_id , const char *attr_name, const char *attr_value, const size_t attr_len) { /* variables for the attributes */ - hsize_t attr_dims; /* dimensions for the attribute */ hsize_t attr_size; /* dimensions for the attribute */ hid_t attr_dataspace_id; /* dataspaces needed for the various attributes */ hid_t attr_attr_id; /* attribute id */ @@ -35,8 +34,6 @@ static int write_text_attribute(hid_t dataset_id , const char *attr_name, if (!attr_name || !attr_value) return -1; - attr_dims = 1; - /* figure out size of the data */ attr_size = (hsize_t)attr_len; diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index a13232d..d9380d0 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -487,7 +487,9 @@ diff_match (hid_t file1_id, { if (table->objs[i].flags[0] && table->objs[i].flags[1]) { +#ifdef H5_HAVE_PARALLEL int workerFound = 0; +#endif /* H5_HAVE_PARALLEL */ options->cmn_objs = 1; if(!g_Parallel) { diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 32fea3d..c611715 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -312,10 +312,9 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5dump_t *info, hsize_t elmtno, int ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx) { - hsize_t p_prod[H5S_MAX_RANK], p_idx[H5S_MAX_RANK]; - hsize_t n, i = 0; + hsize_t p_prod[H5S_MAX_RANK]; + hsize_t i = 0; hsize_t curr_pos=elmtno; - h5tools_str_reset(str); @@ -327,13 +326,6 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5dump_t *info, for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) p_prod[i - 1] = (max_idx[i] - min_idx[i]) * p_prod[i]; - /* Calculate the index values from the element number. */ - for (i = 0, n = elmtno; i < (hsize_t)ndims; i++) { - p_idx[i] = n / p_prod[i] + min_idx[i]; - n %= p_prod[i]; - } - - for ( i = 0; i < (hsize_t)ndims; i++) { ctx->pos[i] = curr_pos/ctx->acc[i]; -- cgit v0.12