From 34eff2aae501e0276f58d2113c02d15b51fca7d8 Mon Sep 17 00:00:00 2001 From: David Young Date: Tue, 5 Nov 2019 12:14:26 -0600 Subject: Change some GCC warnings to errors. Fix code to quiet some warnings. --- config/commence.am | 2 +- config/gnu-flags | 86 +++++++++++++++++++++++++++++++++----- configure.ac | 4 ++ src/H5Cpkg.h | 2 +- src/H5Dchunk.c | 13 ++++-- src/H5FSsection.c | 10 ++--- src/H5Fsuper_cache.c | 14 +++---- src/H5Pmapl.c | 3 +- src/H5private.h | 14 +++---- test/Makefile.am | 2 +- test/cache.c | 2 +- test/cache_tagging.c | 2 +- test/null_vol_connector.c | 6 +++ test/tfile.c | 1 + test/tid.c | 25 +++++++---- test/tvlstr.c | 4 +- tools/src/h5import/h5import.c | 2 +- tools/src/h5repack/h5repack_main.c | 14 ++++--- 18 files changed, 149 insertions(+), 57 deletions(-) diff --git a/config/commence.am b/config/commence.am index a16eee5..830c494 100644 --- a/config/commence.am +++ b/config/commence.am @@ -70,7 +70,7 @@ H5CPP=${DESTDIR}$(bindir)/h5c++ # instead of CFLAGS, as CFLAGS is reserved solely for the user to define. # This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well. -AM_CFLAGS=@AM_CFLAGS@ @H5_CFLAGS@ +AM_CFLAGS=@AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@ AM_FCFLAGS=@AM_FCFLAGS@ @H5_FCFLAGS@ AM_CXXFLAGS=@AM_CXXFLAGS@ @H5_CXXFLAGS@ AM_CPPFLAGS=@AM_CPPFLAGS@ @H5_CPPFLAGS@ diff --git a/config/gnu-flags b/config/gnu-flags index 6355ccf..eddd169 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -168,12 +168,41 @@ if test "X-gcc" = "X-$cc_vendor"; then # NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add # it to the developer flags. # - H5_CFLAGS="$H5_CFLAGS -pedantic -Wall -Wextra -Wbad-function-cast -Wc++-compat -Wcast-align" - H5_CFLAGS="$H5_CFLAGS -Wcast-qual -Wconversion -Wdeclaration-after-statement -Wdisabled-optimization -Wfloat-equal" - H5_CFLAGS="$H5_CFLAGS -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-declarations -Wmissing-include-dirs" - H5_CFLAGS="$H5_CFLAGS -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked" - H5_CFLAGS="$H5_CFLAGS -Wredundant-decls -Wshadow -Wstrict-prototypes -Wswitch-enum -Wswitch-default" - H5_CFLAGS="$H5_CFLAGS -Wundef -Wunused-macros -Wunsafe-loop-optimizations -Wwrite-strings" + H5_CFLAGS="$H5_CFLAGS -pedantic -Wall -Wextra -Wcast-align" + H5_CFLAGS="$H5_CFLAGS -Wcast-qual -Wconversion -Wfloat-equal" + H5_CFLAGS="$H5_CFLAGS -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-include-dirs" + H5_CFLAGS="$H5_CFLAGS" + H5_CFLAGS="$H5_CFLAGS -Wshadow" + H5_CFLAGS="$H5_CFLAGS -Wundef -Wwrite-strings" + + # + # Lots of noise, questionable benefit: + # + #H5_CFLAGS="$H5_CFLAGS -Wunused-macros -Wunsafe-loop-optimizations" + + # + # HDF5 code should not trigger the following warnings under any + # circumstances, so ask the compiler to treat them as errors: + # + H5_ECFLAGS="$H5_ECFLAGS -Werror=bad-function-cast" + H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-declarations" + H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-prototypes -Werror=nested-externs" + H5_ECFLAGS="$H5_ECFLAGS -Werror=old-style-definition -Werror=packed" + H5_ECFLAGS="$H5_ECFLAGS -Werror=redundant-decls -Werror=strict-prototypes" + H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" + H5_ECFLAGS="$H5_ECFLAGS -Werror=switch" + H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" + H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" + +# +# Should be enabled only with discussion: +# +# H5_CFLAGS="$H5_CFLAGS -Wdeclaration-after-statement -Wdisabled-optimization" +# +# -Wswitch is helpful, but these seem a step too far: +# +# H5_CFLAGS="$H5_CFLAGS -Wswitch-enum -Wswitch-default" +# ###################### # Developer warnings # @@ -222,17 +251,34 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc 4.3 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then - H5_CFLAGS="$H5_CFLAGS -Wlogical-op -Wlarger-than=2560" + H5_CFLAGS="$H5_CFLAGS -Wlogical-op" + # + # Lots of noise, questionable benefit: + # + #H5_CFLAGS="$H5_CFLAGS -Wlarger-than=2560" + # fi # gcc 4.4 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then - H5_CFLAGS="$H5_CFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" + H5_CFLAGS="$H5_CFLAGS -Wsync-nand -Wpacked-bitfield-compat" + # + # Lots of noise, questionable benefit: + # + #H5_CFLAGS="$H5_CFLAGS -Wframe-larger-than=16384" + # fi # gcc 4.5 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5; then - H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wjump-misses-init -Wunsuffixed-float-constants" + H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wunsuffixed-float-constants" + # + # -Wjump-misses-init makes lots of noise for a questionable benefit. + # Can jumping over an initialization in C cause any harm, if + # the variable is never *used* before it has been initialized? + # + #H5_CFLAGS="$H5_CFLAGS -Wjump-misses-init" + # fi # gcc 4.6 @@ -244,7 +290,16 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc 4.7 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then - H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance" + # + # It's not clear that -Wvector-operation-performance warnigns are + # actionable. + # + # -Wstack-usage=8192 warnings need better justification; + # if justifiable, should be enabled on a branch and swept up there + # before burdening the whole development team. + # + #H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance" + # DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn" fi @@ -267,7 +322,16 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc 6 if test $cc_vers_major -ge 6; then - H5_CFLAGS="$H5_CFLAGS -Wnull-dereference -Wunused-const-variable -Wduplicated-cond -Whsa -Wnormalized" + H5_CFLAGS="$H5_CFLAGS -Wunused-const-variable -Whsa -Wnormalized" + # + # Unacceptably noisy on HDF5 right now. + # + #H5_CFLAGS="$H5_CFLAGS -Wnull-dereference" + # + # Careful! -Wduplicated-cond, combined with HDF5's heavy use of + # macros, can make a lot of noise. + # + H5_CFLAGS="$H5_CFLAGS -Wduplicated-cond" fi # gcc 7 diff --git a/configure.ac b/configure.ac index 2ffbf0f..0bda754 100644 --- a/configure.ac +++ b/configure.ac @@ -103,7 +103,11 @@ AC_SUBST([AR_FLAGS]) ## H5_CFLAGS (and company) are for CFLAGS that should be used on HDF5, but ## not exported to h5cc (or h5fc, etc.) +## +## H5_ECFLAGS is for warnings that should be treated as errors. +## AC_SUBST([H5_CFLAGS]) +AC_SUBST([H5_ECFLAGS]) AC_SUBST([H5_CPPFLAGS]) AC_SUBST([H5_FCFLAGS]) AC_SUBST([H5_CXXFLAGS]) diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 9156c0d..b8648f0 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -4694,7 +4694,7 @@ struct H5C_t { uint32_t num_last_entries; #if H5C_DO_SANITY_CHECKS int32_t slist_len_increase; - ssize_t slist_size_increase; + int64_t slist_size_increase; #endif /* H5C_DO_SANITY_CHECKS */ /* Fields for maintaining list of tagged entries */ diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 53ca7d1..a6b22f8 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -284,7 +284,8 @@ static int H5D__chunk_format_convert_cb(const H5D_chunk_rec_t *chunk_rec, void * static herr_t H5D__chunk_set_info_real(H5O_layout_chunk_t *layout, unsigned ndims, const hsize_t *curr_dims, const hsize_t *max_dims); static void *H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline); -static void *H5D__chunk_mem_xfree(void *chk, const void *pline); +static void *H5D__chunk_mem_xfree(void *chk, void *pline); +static void H5D__chunk_mem_xfree_wrapper(void *chk, void *pline); static void *H5D__chunk_mem_realloc(void *chk, size_t size, const H5O_pline_t *pline); static herr_t H5D__chunk_cinfo_cache_reset(H5D_chunk_cached_t *last); @@ -1431,7 +1432,7 @@ H5D__chunk_mem_alloc(size_t size, const H5O_pline_t *pline) *------------------------------------------------------------------------- */ static void * -H5D__chunk_mem_xfree(void *chk, const void *_pline) +H5D__chunk_mem_xfree(void *chk, void *_pline) { const H5O_pline_t *pline = (const H5O_pline_t *)_pline; @@ -1447,6 +1448,12 @@ H5D__chunk_mem_xfree(void *chk, const void *_pline) FUNC_LEAVE_NOAPI(NULL) } /* H5D__chunk_mem_xfree() */ +static void +H5D__chunk_mem_xfree_wrapper(void *chk, void *_pline) +{ + (void)H5D__chunk_mem_xfree(chk, _pline); +} + /*------------------------------------------------------------------------- * Function: H5D__chunk_mem_realloc @@ -4451,7 +4458,7 @@ H5D__chunk_allocate(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_ /* (delay allocating fill buffer for VL datatypes until refilling) */ /* (casting away const OK - QAK) */ if(H5D__fill_init(&fb_info, NULL, (H5MM_allocate_t)H5D__chunk_mem_alloc, - (void *)pline, (H5MM_free_t)H5D__chunk_mem_xfree, (void *)pline, + (void *)pline, H5D__chunk_mem_xfree_wrapper, (void *)pline, &dset->shared->dcpl_cache.fill, dset->shared->type, dset->shared->type_id, (size_t)0, orig_chunk_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize fill buffer info") diff --git a/src/H5FSsection.c b/src/H5FSsection.c index df67bd9..cf4a587 100644 --- a/src/H5FSsection.c +++ b/src/H5FSsection.c @@ -371,10 +371,10 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" /* Check if section info lock count dropped to zero */ if(fspace->sinfo_lock_count == 0) { hbool_t release_sinfo_space = FALSE; /* Flag to indicate section info space in file should be released */ - hbool_t flush_in_progress = FALSE; /* Is flushing in progress */ + hbool_t closing_or_flushing = f->shared->closing; /* Is closing or flushing in progress */ - /* Check whether cache is flush_in_progress */ - if(H5AC_get_cache_flush_in_progress(f->shared->cache, &flush_in_progress) < 0) + /* Check whether cache-flush is in progress if closing is not. */ + if(!closing_or_flushing && H5AC_get_cache_flush_in_progress(f->shared->cache, &closing_or_flushing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Can't get flush_in_progress") /* Check if we actually protected the section info */ @@ -390,7 +390,7 @@ HDfprintf(stderr, "%s: fspace->alloc_sect_size = %Hu, fspace->sect_size = %Hu\n" cache_flags |= H5AC__DIRTIED_FLAG; /* On file close or flushing, does not allow section info to shrink in size */ - if(f->shared->closing || flush_in_progress) { + if(closing_or_flushing) { if(fspace->sect_size > fspace->alloc_sect_size) cache_flags |= H5AC__DELETED_FLAG | H5AC__TAKE_OWNERSHIP_FLAG; else @@ -441,7 +441,7 @@ HDfprintf(stderr, "%s: Relinquishing section info ownership\n", FUNC); /* Set flag to release section info space in file */ /* On file close or flushing, only need to release section info with size bigger than previous section */ - if(f->shared->closing || flush_in_progress) { + if(closing_or_flushing) { if(fspace->sect_size > fspace->alloc_sect_size) release_sinfo_space = TRUE; else diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index 125d6cf..ebf4a39 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -347,7 +347,7 @@ static herr_t H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len, void *_udata, size_t *actual_len) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ H5F_super_t sblock; /* Temporary file superblock */ htri_t ret_value = SUCCEED; /* Return value */ @@ -393,7 +393,7 @@ done: static htri_t H5F__cache_superblock_verify_chksum(const void *_image, size_t len, void *_udata) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ uint32_t stored_chksum; /* Stored metadata checksum value */ uint32_t computed_chksum; /* Computed metadata checksum value */ @@ -439,7 +439,7 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata, { H5F_super_t *sblock = NULL; /* File's superblock */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_super_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -664,7 +664,7 @@ H5F__cache_superblock_serialize(const H5F_t *f, void *_image, size_t H5_ATTR_UNU void *_thing) { H5F_super_t *sblock = (H5F_super_t *)_thing; /* Pointer to the object */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = _image; /* Pointer into raw data buffer */ haddr_t rel_eof; /* Relative EOF for file */ herr_t ret_value = SUCCEED; /* Return value */ @@ -870,7 +870,7 @@ static herr_t H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t image_len, void *_udata, size_t *actual_len) { - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ H5O_drvinfo_t drvrinfo; /* Driver info */ herr_t ret_value = SUCCEED; /* Return value */ @@ -916,7 +916,7 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t len, void *_udata, { H5O_drvinfo_t *drvinfo = NULL; /* Driver info */ H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ - const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */ + const uint8_t *image = _image; /* Pointer into raw data buffer */ char drv_name[9]; /* Name of driver */ H5O_drvinfo_t *ret_value = NULL; /* Return value */ @@ -1010,7 +1010,7 @@ H5F__cache_drvrinfo_serialize(const H5F_t *f, void *_image, size_t len, void *_thing) { H5O_drvinfo_t *drvinfo = (H5O_drvinfo_t *)_thing; /* Pointer to the object */ - uint8_t *image = (uint8_t *)_image; /* Pointer into raw data buffer */ + uint8_t *image = _image; /* Pointer into raw data buffer */ uint8_t *dbuf; /* Pointer to beginning of driver info */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Pmapl.c b/src/H5Pmapl.c index fe5be0f..59da91a 100644 --- a/src/H5Pmapl.c +++ b/src/H5Pmapl.c @@ -138,6 +138,7 @@ done: } /* end H5P__macc_reg_prop() */ +#ifdef H5_HAVE_MAP_API /*------------------------------------------------------------------------- * Function: H5Pset_map_iterate_hints * @@ -214,4 +215,4 @@ H5Pget_map_iterate_hints(hid_t mapl_id, size_t *key_prefetch_size, size_t *key_a done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_map_iterate_hints() */ - +#endif /* H5_HAVE_MAP_API */ diff --git a/src/H5private.h b/src/H5private.h index 0bfc91b..bdc6268 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1365,25 +1365,25 @@ typedef off_t h5_stat_size_t; #define HDstrcpy(X,Y) strcpy(X,Y) #endif /* HDstrcpy */ #ifndef HDstrcspn - #define HDstrcspn(X,Y) strcspn(X,Y) + #define HDstrcspn strcspn #endif /* HDstrcspn */ #ifndef HDstrerror - #define HDstrerror(N) strerror(N) + #define HDstrerror strerror #endif /* HDstrerror */ #ifndef HDstrftime - #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) + #define HDstrftime strftime #endif /* HDstrftime */ #ifndef HDstrlen - #define HDstrlen(S) strlen(S) + #define HDstrlen strlen #endif /* HDstrlen */ #ifndef HDstrncat - #define HDstrncat(X,Y,Z) strncat(X,Y,Z) + #define HDstrncat strncat #endif /* HDstrncat */ #ifndef HDstrncmp - #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) + #define HDstrncmp strncmp #endif /* HDstrncmp */ #ifndef HDstrncpy - #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) + #define HDstrncpy strncpy #endif /* HDstrncpy */ #ifndef HDstrpbrk #define HDstrpbrk(X,Y) strpbrk(X,Y) diff --git a/test/Makefile.am b/test/Makefile.am index 57080aa..3a8a8a8 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -61,7 +61,7 @@ TEST_PROG= testhdf5 \ dtypes dsets chunk_info cmpd_dset filter_fail extend direct_chunk \ external efc objcopy objcopy_ref links unlink twriteorder big mtime fillval mount \ flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ - enc_dec_plist_cross_platform getname vfd ros3 s3comms hdfs ntypes \ + getname vfd ros3 s3comms hdfs ntypes \ dangle dtransform reserved cross_read freespace mf vds file_image \ unregister cache_logging cork swmr vol diff --git a/test/cache.c b/test/cache.c index 1a726fa..e59dc3e 100644 --- a/test/cache.c +++ b/test/cache.c @@ -16926,7 +16926,7 @@ check_move_entry_errs(unsigned paged) { herr_t result; H5F_t * file_ptr = NULL; - H5C_t * cache_ptr = NULL; + H5C_t * cache_ptr; test_entry_t * entry_ptr = NULL; test_entry_t * entry_0_0_ptr; test_entry_t * entry_0_1_ptr; diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 7ce4e88..c3921ea 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -528,7 +528,7 @@ check_file_open_tags(hid_t fcpl, int type) hid_t fid = -1; /* File Identifier */ int verbose = FALSE; /* verbose file outout */ hid_t fapl = -1; /* File access prop list */ - haddr_t root_tag; /* Root Group Tag */ + haddr_t root_tag = HADDR_UNDEF; /* Root Group Tag */ haddr_t sbe_tag; /* Sblock Extension Tag */ /* Testing Macro */ diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c index 5ed8545..64f62c4 100644 --- a/test/null_vol_connector.c +++ b/test/null_vol_connector.c @@ -116,6 +116,12 @@ static const H5VL_class_t null_vol_g = { NULL, /* optional */ NULL /* free */ }, + { /* blob_cls */ + NULL, /* put */ + NULL, /* get */ + NULL, /* specific */ + NULL /* optional */ + }, NULL /* optional */ }; diff --git a/test/tfile.c b/test/tfile.c index 4fb2bc9..3525ec0 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1057,6 +1057,7 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1, oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR); CHECK(oid_count, FAIL, "H5Fget_obj_count"); VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count"); + fprintf(stderr, "fid1: %zd datasets, %zd groups, %zd datatypes, %zd attributes\n", H5Fget_obj_count(fid1, H5F_OBJ_DATASET), H5Fget_obj_count(fid1, H5F_OBJ_GROUP), H5Fget_obj_count(fid1, H5F_OBJ_DATATYPE), H5Fget_obj_count(fid1, H5F_OBJ_ATTR)); oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL); CHECK(oid_count, FAIL, "H5Fget_obj_count"); diff --git a/test/tid.c b/test/tid.c index d0ae3e4..2e8be0f 100644 --- a/test/tid.c +++ b/test/tid.c @@ -19,6 +19,13 @@ #define H5I_FRIEND /*suppress error about including H5Ipkg */ #include "H5Ipkg.h" +static herr_t +free_wrapper(void *p) +{ + free(p); + return SUCCEED; +} + /* Test basic functionality of registering and deleting types and IDs */ static int basic_id_test(void) { @@ -69,7 +76,7 @@ static int basic_id_test(void) goto out; /* Register a type */ - myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); + myType = H5Iregister_type((size_t)64, 0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); if(myType == H5I_BADID) @@ -163,7 +170,7 @@ static int basic_id_test(void) H5E_END_TRY /* Register another type and another object in that type */ - myType = H5Iregister_type((size_t)64, 0, (H5I_free_t) free ); + myType = H5Iregister_type((size_t)64, 0, free_wrapper); CHECK(myType, H5I_BADID, "H5Iregister_type"); if(myType == H5I_BADID) @@ -238,7 +245,7 @@ out: /* A dummy search function for the next test */ -static int test_search_func(void H5_ATTR_UNUSED * ptr1, void H5_ATTR_UNUSED * ptr2) { return 0; } +static int test_search_func(void H5_ATTR_UNUSED * ptr1, hid_t H5_ATTR_UNUSED id, void H5_ATTR_UNUSED * ptr2) { return 0; } /* Ensure that public functions cannot access "predefined" ID types */ static int id_predefined_test(void ) @@ -264,7 +271,7 @@ static int id_predefined_test(void ) goto out; H5E_BEGIN_TRY - testPtr = H5Isearch(H5I_GENPROP_LST, (H5I_search_func_t) test_search_func, testObj); + testPtr = H5Isearch(H5I_GENPROP_LST, test_search_func, testObj); H5E_END_TRY CHECK_PTR_NULL(testPtr, "H5Isearch"); @@ -492,7 +499,7 @@ static int test_id_type_list(void) H5I_type_t testType; int i; /* Just a counter variable */ - startType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + startType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(startType, H5I_BADID, "H5Iregister_type"); if(startType == H5I_BADID) goto out; @@ -507,7 +514,7 @@ static int test_id_type_list(void) /* Create types up to H5I_MAX_NUM_TYPES */ for(i = startType + 1; i < H5I_MAX_NUM_TYPES; i++) { - currentType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + currentType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); if(currentType == H5I_BADID) goto out; @@ -516,7 +523,7 @@ static int test_id_type_list(void) /* Wrap around to low type ID numbers */ for(i = H5I_NTYPES; i < startType; i++) { - currentType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + currentType = H5Iregister_type((size_t)8, 0, free_wrapper); CHECK(currentType, H5I_BADID, "H5Iregister_type"); if(currentType == H5I_BADID) goto out; @@ -524,7 +531,7 @@ static int test_id_type_list(void) /* There should be no room at the inn for a new ID type*/ H5E_BEGIN_TRY - testType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + testType = H5Iregister_type((size_t)8, 0, free_wrapper); H5E_END_TRY VERIFY(testType, H5I_BADID, "H5Iregister_type"); @@ -533,7 +540,7 @@ static int test_id_type_list(void) /* Now delete a type and try to insert again */ H5Idestroy_type(H5I_NTYPES); - testType = H5Iregister_type((size_t)8, 0, (H5I_free_t) free ); + testType = H5Iregister_type((size_t)8, 0, free_wrapper); VERIFY(testType, H5I_NTYPES, "H5Iregister_type"); if(testType != H5I_NTYPES) diff --git a/test/tvlstr.c b/test/tvlstr.c index 731270c..cc01084 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -861,12 +861,12 @@ static void test_write_same_element(void) hid_t file1, dataset1; hid_t mspace, fspace, dtype; hsize_t fdim[] = {SPACE1_DIM1}; - char *val[SPACE1_DIM1] = {"But", "reuniting", "is a", "great joy"}; + const char *val[SPACE1_DIM1] = {"But", "reuniting", "is a", "great joy"}; hsize_t marray[] = {NUMP}; hsize_t coord[SPACE1_RANK][NUMP]; herr_t ret; - char *wdata[SPACE1_DIM1] = {"Parting", "is such a", "sweet", "sorrow."}; + const char *wdata[SPACE1_DIM1] = {"Parting", "is such a", "sweet", "sorrow."}; file1 = H5Fcreate(DATAFILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(file1, FAIL, "H5Fcreate"); diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 1eef5ab..65c2359 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -1428,7 +1428,7 @@ static int processConfigurationFile(char *infile, struct Input *in) /* Initialize machine endian */ volatile uint32_t ibyte=0x01234567; /* 0 for big endian, 1 for little endian. */ - if ((*((uint8_t*)(&ibyte))) == 0x67) { + if ((*((volatile uint8_t*)(&ibyte))) == 0x67) { if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { (void) HDfprintf(stderr, "%s", err11e); return (-1); diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index c628beb..16899a3 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -281,7 +281,7 @@ int read_info(const char *filename, pack_opt_t *options) char comp_info[1024]; FILE *fp = NULL; char c; - int i, rc = 1; + int i; int ret_value = EXIT_SUCCESS; if (NULL == (fp = HDfopen(filename, "r"))) { @@ -412,7 +412,7 @@ set_sort_order(const char *form) static int parse_command_line(int argc, const char **argv, pack_opt_t* options) { - int opt; + int bound, opt; int ret_value = 0; /* parse command line options */ @@ -492,19 +492,21 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) break; case 'j': - options->low_bound = (H5F_libver_t)HDatoi(opt_arg); - if (options->low_bound < H5F_LIBVER_EARLIEST || options->low_bound > H5F_LIBVER_LATEST) { + bound = HDatoi(opt_arg); + if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) { error_msg("in parsing low bound\n"); goto done; } + options->low_bound = bound; break; case 'k': - options->high_bound = (H5F_libver_t)HDatoi(opt_arg); - if (options->high_bound < H5F_LIBVER_EARLIEST || options->high_bound > H5F_LIBVER_LATEST) { + bound = HDatoi(opt_arg); + if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) { error_msg("in parsing high bound\n"); goto done; } + options->high_bound = bound; break; case 'c': -- cgit v0.12 From c538919509780b7729354124eeb21ceaa321dbda Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:22:09 -0600 Subject: Format a pointer with %p to avoid a gripe about casting a pointer to an integer. --- src/H5Cdbg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 1f55e86..cb1d0e2 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -319,9 +319,8 @@ H5C_dump_cache_skip_list(H5C_t * cache_ptr, char * calling_fcn) (int)(entry_ptr->is_dirty), entry_ptr->type->name); - HDfprintf(stdout, " node_ptr = 0x%llx, item = %p\n", - (unsigned long long)node_ptr, - H5SL_item(node_ptr)); + HDfprintf(stdout, " node_ptr = %p, item = %p\n", + node_ptr, H5SL_item(node_ptr)); /* increment node_ptr before we delete its target */ node_ptr = H5SL_next(node_ptr); -- cgit v0.12 From 587758e8c6272d7acde6bb765ac5003ddc754e4d Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:23:12 -0600 Subject: Initialize a variable before its first use. --- hl/src/H5DS.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index b24f887..44e0ecf9 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1433,7 +1433,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) union { /* union is needed to eliminate compiler warnings about */ char ** buf; /* discarding the 'const' qualifier in the free */ char const ** const_buf; /* buf calls */ - } u; + } u = {.buf = NULL, .const_buf = NULL}; /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- -- cgit v0.12 From 769a6e9d328e59c503da345e55a8427094c76b25 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:24:40 -0600 Subject: Delete variables that are unused or set and unused. --- src/H5Dchunk.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index fe1f31a..c93fa38 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1101,14 +1101,10 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf H5D_chunk_map_t *fm) { const H5D_t *dataset = io_info->dset; /* Local pointer to dataset info */ - H5S_t *tmp_mspace = NULL; /* Temporary memory dataspace */ hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset */ htri_t file_space_normalized = FALSE; /* File dataspace was normalized */ - H5T_t *file_type = NULL; /* Temporary copy of file datatype for iteration */ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ unsigned f_ndims; /* The number of dimensions of the file's dataspace */ int sm_ndims; /* The number of dimensions of the memory buffer's dataspace (signed) */ - char bogus; /* "bogus" buffer to pass to selection iterator */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2147,12 +2143,6 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ H5SL_node_t *curr_node; /* Current node in skip list */ - hsize_t file_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t file_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ - hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ - hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ - hssize_t adjust[H5S_MAX_RANK]; /* Adjustment to make to all file chunks */ - unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -7160,7 +7150,6 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ hsize_t num_chunks = 0; /* Number of written chunks */ H5D_rdcc_ent_t *ent; /* Cache entry */ const H5D_rdcc_t *rdcc = NULL; /* Raw data chunk cache */ - const H5O_layout_t *layout; /* Dataset layout */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE_TAG(dset->oloc.addr) @@ -7170,7 +7159,6 @@ H5D__get_num_chunks(const H5D_t *dset, const H5S_t H5_ATTR_UNUSED *space, hsize_ HDassert(space); HDassert(nchunks); - layout = &(dset->shared->layout); /* Dataset layout */ rdcc = &(dset->shared->cache.chunk); /* raw data chunk cache */ HDassert(rdcc); -- cgit v0.12 From 0cb24f8ad4748c4ea49d85c24f1031083a04a011 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:25:27 -0600 Subject: Mark an unused parameter H5_ATTR_UNUSED. --- tools/lib/h5tools_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 47ce690..6fc9de4 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -1279,7 +1279,7 @@ done: int h5tools_set_configured_fapl(hid_t fapl_id, const char vfd_name[], - void *fapl_t_ptr) + void *fapl_t_ptr H5_ATTR_UNUSED) { int ret_value = 1; -- cgit v0.12 From aa0f3cb1a84729b3344abfcd9fc6d16ccf812954 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:25:51 -0600 Subject: Delete an unused variable. --- tools/test/h5repack/h5repackgentest.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/test/h5repack/h5repackgentest.c b/tools/test/h5repack/h5repackgentest.c index aaac285..87ca31c 100644 --- a/tools/test/h5repack/h5repackgentest.c +++ b/tools/test/h5repack/h5repackgentest.c @@ -314,7 +314,6 @@ generate_f32le(hbool_t external) { int main(void) { int i = 0; - int ret_value = 0; for (i = 0; i < 2; i++) { hbool_t external = (i & 1) ? TRUE : FALSE; -- cgit v0.12 From 77a9806ab5692b3abaf3bb5d6f5bc68ef62fd8a1 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:26:49 -0600 Subject: Demote errors to warnings for a couple of unused-but-set variables that I cannot untangle right now. --- tools/lib/h5diff.c | 3 +++ tools/lib/h5diff_array.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index c2153e5..1b4bc56 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -258,6 +258,8 @@ free_exclude_path_list(diff_opt_t *opts) * Parameter: * table_out [OUT] : return the list *------------------------------------------------------------------------*/ +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wunused-but-set-variable" static void build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, trav_table_t ** table_out, diff_opt_t *opts) @@ -374,6 +376,7 @@ done: *table_out = table; h5difftrace("build_match_list finish\n"); } +#pragma GCC diagnostic pop /*------------------------------------------------------------------------- diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 2a45913..55ad65c 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -2245,6 +2245,9 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, *------------------------------------------------------------------------- */ +#pragma GCC diagnostic push +#pragma GCC diagnostic warning "-Wunused-but-set-variable" + static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, hsize_t i, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { @@ -2305,6 +2308,7 @@ static hsize_t character_compare_opt(unsigned char *mem1, unsigned char *mem2, return nfound; } +#pragma GCC diagnostic pop /*------------------------------------------------------------------------- * Function: diff_float -- cgit v0.12 From 37eb3dd7d22af773ba09da1577c3f07fe2243571 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:31:20 -0600 Subject: Avoid unused-variable warnings: change static const strings in a couple of header-file templates to #defines. --- hl/test/H5srcdir_str.h.in | 2 +- test/H5srcdir_str.h.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hl/test/H5srcdir_str.h.in b/hl/test/H5srcdir_str.h.in index bab1df3..ba30a88 100644 --- a/hl/test/H5srcdir_str.h.in +++ b/hl/test/H5srcdir_str.h.in @@ -16,5 +16,5 @@ */ /* Set the 'srcdir' path from configure time */ -static const char *config_srcdir = "@srcdir@"; +#define config_srcdir "@srcdir@" diff --git a/test/H5srcdir_str.h.in b/test/H5srcdir_str.h.in index bab1df3..ba30a88 100644 --- a/test/H5srcdir_str.h.in +++ b/test/H5srcdir_str.h.in @@ -16,5 +16,5 @@ */ /* Set the 'srcdir' path from configure time */ -static const char *config_srcdir = "@srcdir@"; +#define config_srcdir "@srcdir@" -- cgit v0.12 From 3f11ed26f77d3adabe61dc0c97c00994b801db81 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:32:38 -0600 Subject: Change a signed variable to unsigned to avoid a warning about the sign being lost by a cast. --- src/H5Dchunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index c93fa38..3575aab 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -2177,7 +2177,7 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) /* Iterate over each chunk in the chunk list */ curr_node = H5SL_first(fm->sel_chunks); while(curr_node) { - hssize_t schunk_points; /* Number of elements in chunk selection */ + hsize_t schunk_points; /* Number of elements in chunk selection */ hsize_t tmp_count = 1; /* Get pointer to chunk's information */ -- cgit v0.12 From 98c4ed49e843e9006e027553597a7e244d21c5cb Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:33:35 -0600 Subject: Delete unused variable. --- src/H5FDhdfs.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 819d200..0b954cf 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -581,7 +581,6 @@ hid_t H5FD_hdfs_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - unsigned int bin_i; FUNC_ENTER_NOAPI(FAIL) -- cgit v0.12 From 833c0a2fc62927b1c1920c895f760260c3515b9b Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:35:00 -0600 Subject: Move some static functions and variables to .c files to avoid unused function/variable warnings. --- test/H5srcdir.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ test/H5srcdir.h | 39 ++++---------------------------- test/vds_swmr.h | 24 +++++--------------- test/vds_swmr_common.c | 36 +++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 54 deletions(-) create mode 100644 test/H5srcdir.c create mode 100644 test/vds_swmr_common.c diff --git a/test/H5srcdir.c b/test/H5srcdir.c new file mode 100644 index 0000000..8268d2c --- /dev/null +++ b/test/H5srcdir.c @@ -0,0 +1,61 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "H5private.h" +#include "H5srcdir.h" + +/* Buffer to construct path in and return pointer to */ +char srcdir_path[1024] = ""; + +/* Buffer to construct file in and return pointer to */ +char srcdir_testpath[1024] = ""; + +/* Just return the srcdir path */ +const char * +H5_get_srcdir(void) +{ + const char *srcdir = HDgetenv("srcdir"); + + /* Check for using the srcdir from configure time */ + if(NULL == srcdir) + srcdir = config_srcdir; + + /* Build path to all test files */ + if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) { + HDsnprintf(srcdir_path, sizeof(srcdir_path), "%s/", srcdir); + return(srcdir_path); + } /* end if */ + else + return(NULL); +} /* end H5_get_srcdir() */ + +/* Append the test file name to the srcdir path and return the whole string */ +const char * +H5_get_srcdir_filename(const char *filename) +{ + const char *srcdir = H5_get_srcdir(); + + /* Check for error */ + if(NULL == srcdir) + return(NULL); + else { + /* Build path to test file */ + if((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) { + HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename); + return(srcdir_testpath); + } /* end if */ + else + return(NULL); + } /* end else */ +} /* end H5_get_srcdir_filename() */ + diff --git a/test/H5srcdir.h b/test/H5srcdir.h index 32fe8c9..d0a4bf7 100644 --- a/test/H5srcdir.h +++ b/test/H5srcdir.h @@ -24,47 +24,16 @@ #include "H5srcdir_str.h" /* Buffer to construct path in and return pointer to */ -static char srcdir_path[1024] = ""; +extern char srcdir_path[1024]; /* Buffer to construct file in and return pointer to */ -static char srcdir_testpath[1024] = ""; +extern char srcdir_testpath[1024]; /* Just return the srcdir path */ -static const char * -H5_get_srcdir(void) -{ - const char *srcdir = HDgetenv("srcdir"); - - /* Check for using the srcdir from configure time */ - if(NULL == srcdir) - srcdir = config_srcdir; - - /* Build path to all test files */ - if((HDstrlen(srcdir) + 2) < sizeof(srcdir_path)) { - HDsnprintf(srcdir_path, sizeof(srcdir_path), "%s/", srcdir); - return(srcdir_path); - } /* end if */ - else - return(NULL); -} /* end H5_get_srcdir() */ +const char *H5_get_srcdir(void); /* Append the test file name to the srcdir path and return the whole string */ -static const char *H5_get_srcdir_filename(const char *filename) -{ - const char *srcdir = H5_get_srcdir(); +const char *H5_get_srcdir_filename(const char *); - /* Check for error */ - if(NULL == srcdir) - return(NULL); - else { - /* Build path to test file */ - if((HDstrlen(srcdir) + HDstrlen(filename) + 1) < sizeof(srcdir_testpath)) { - HDsnprintf(srcdir_testpath, sizeof(srcdir_testpath), "%s%s", srcdir, filename); - return(srcdir_testpath); - } /* end if */ - else - return(NULL); - } /* end else */ -} /* end H5_get_srcdir_filename() */ #endif /* _H5SRCDIR_H */ diff --git a/test/vds_swmr.h b/test/vds_swmr.h index eb2dcf4..18d6b35 100644 --- a/test/vds_swmr.h +++ b/test/vds_swmr.h @@ -84,31 +84,17 @@ #define N_PLANES_TO_WRITE 25 /* Planes */ -static hsize_t PLANES[N_SOURCES][RANK] = { - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH}, - {1, SM_HEIGHT, WIDTH}, - {1, LG_HEIGHT, WIDTH} -}; +extern hsize_t PLANES[N_SOURCES][RANK]; /* File names for source datasets */ -static char FILE_NAMES[N_SOURCES][NAME_LEN] = { - {"vds_swmr_src_a.h5"}, - {"vds_swmr_src_b.h5"}, - {"vds_swmr_src_c.h5"}, - {"vds_swmr_src_d.h5"}, - {"vds_swmr_src_e.h5"}, - {"vds_swmr_src_f.h5"} -}; +extern char FILE_NAMES[N_SOURCES][NAME_LEN]; /* VDS file name */ -static char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; +extern char VDS_FILE_NAME[NAME_LEN]; /* Dataset names */ -static char SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; -static char VDS_DSET_NAME[NAME_LEN] = "vds_dset"; +extern char SOURCE_DSET_PATH[NAME_LEN]; +extern char VDS_DSET_NAME[NAME_LEN]; /* Fill values */ #endif /* VDS_SWMR_H */ diff --git a/test/vds_swmr_common.c b/test/vds_swmr_common.c new file mode 100644 index 0000000..d2b4bd6 --- /dev/null +++ b/test/vds_swmr_common.c @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include "vds_swmr.h" + +hsize_t PLANES[N_SOURCES][RANK] = { + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH}, + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH}, + {1, SM_HEIGHT, WIDTH}, + {1, LG_HEIGHT, WIDTH} +}; + +char FILE_NAMES[N_SOURCES][NAME_LEN] = { + {"vds_swmr_src_a.h5"}, + {"vds_swmr_src_b.h5"}, + {"vds_swmr_src_c.h5"}, + {"vds_swmr_src_d.h5"}, + {"vds_swmr_src_e.h5"}, + {"vds_swmr_src_f.h5"} +}; + +char VDS_FILE_NAME[NAME_LEN] = "vds_swmr.h5"; +char SOURCE_DSET_PATH[NAME_LEN] = "/source_dset"; +char VDS_DSET_NAME[NAME_LEN] = "vds_dset"; -- cgit v0.12 From e2d9cc558448224360d0641d225b9f71344c3e5a Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:35:36 -0600 Subject: To quiet a warning, initialize some `struct timeval`s that the compiler does not realize are always set before use by `gettimeofday`. --- src/H5FDlog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5FDlog.c b/src/H5FDlog.c index ac5667f..1c7d549 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -489,8 +489,8 @@ H5FD_log_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr) #endif #ifdef H5_HAVE_GETTIMEOFDAY struct timeval timeval_start; - struct timeval open_timeval_diff; - struct timeval stat_timeval_diff; + struct timeval open_timeval_diff = {0, 0}; + struct timeval stat_timeval_diff = {0, 0}; #endif /* H5_HAVE_GETTIMEOFDAY */ h5_stat_t sb; H5FD_t *ret_value = NULL; /* Return value */ -- cgit v0.12 From 193702935442785cf752ed705b977b004ce29d30 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:37:14 -0600 Subject: Initialize a couple of variables that the compiler does not realize are initialized when they're passed by reference to functions. --- src/H5Fsuper_cache.c | 2 +- src/H5HFtiny.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index ebf4a39..ecb98ed 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -872,7 +872,7 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t image_len, { const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ - H5O_drvinfo_t drvrinfo; /* Driver info */ + H5O_drvinfo_t drvrinfo = {.len = 0}; /* Driver info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5HFtiny.c b/src/H5HFtiny.c index 0c27180..79d790b 100644 --- a/src/H5HFtiny.c +++ b/src/H5HFtiny.c @@ -377,7 +377,7 @@ done: herr_t H5HF_tiny_remove(H5HF_hdr_t *hdr, const uint8_t *id) { - size_t enc_obj_size; /* Encoded object size */ + size_t enc_obj_size = 0; /* Encoded object size */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT -- cgit v0.12 From 918e1a879d95114929a3f7abf1952bc6dd90c9d1 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:39:24 -0600 Subject: Initialize a couple of return values to avoid used-before-set warnings. --- src/H5SL.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5SL.c b/src/H5SL.c index 5f00fb8..ec06395 100644 --- a/src/H5SL.c +++ b/src/H5SL.c @@ -1394,7 +1394,7 @@ H5SL_search(H5SL_t *slist, const void *key) { H5SL_node_t *x; /* Current node to examine */ uint32_t hashval = 0; /* Hash value for key */ - void *ret_value; /* Return value */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -1695,7 +1695,7 @@ H5SL_find(H5SL_t *slist, const void *key) { H5SL_node_t *x; /* Current node to examine */ uint32_t hashval = 0; /* Hash value for key */ - H5SL_node_t *ret_value; /* Return value */ + H5SL_node_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT_NOERR -- cgit v0.12 From 408d2087108b95256a39ea4d2c547ee64b92c1ec Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:41:25 -0600 Subject: Explicitly initialize `type_flags`; the compiler does not realize that it is set before use by passing it as a reference to another function. --- src/H5SM.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5SM.c b/src/H5SM.c index 290e575..91ef98b 100644 --- a/src/H5SM.c +++ b/src/H5SM.c @@ -313,7 +313,7 @@ ssize_t H5SM_get_index(const H5SM_master_table_t *table, unsigned type_id) { size_t x; - unsigned type_flag; + unsigned type_flag = 0; ssize_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT @@ -353,7 +353,7 @@ htri_t H5SM_type_shared(H5F_t *f, unsigned type_id) { H5SM_master_table_t *table = NULL; /* Shared object master table */ - unsigned type_flag; /* Flag corresponding to message type */ + unsigned type_flag = 0; /* Flag corresponding to message type */ size_t u; /* Local index variable */ htri_t ret_value = FALSE; /* Return value */ -- cgit v0.12 From 19e3b93c81784da50893ef3d2913046491b8dd9f Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:42:50 -0600 Subject: Use FUNC_ENTER_STATIC_NOERR instead of FUNC_ENTER_STATIC for a function that does not generate its own error, so GCC does not warn that err_occurred (or whatever it is called) is unused or set and unused. --- src/H5Shyper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 9feb8de..cd702e0 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -6267,7 +6267,7 @@ H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(space); -- cgit v0.12 From c5b8f3db3b9be323b621cdd8204e247521df0192 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:45:29 -0600 Subject: Make many warnings about H5T_copy() calls that discard const qualifiers into a few warnings in H5T_copy() itself. --- src/H5T.c | 2 +- src/H5Tprivate.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/H5T.c b/src/H5T.c index 9263158..3fc59d0 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -3320,7 +3320,7 @@ done: *------------------------------------------------------------------------- */ H5T_t * -H5T_copy(H5T_t *old_dt, H5T_copy_t method) +H5T_copy(const H5T_t *old_dt, H5T_copy_t method) { H5T_t *new_dt = NULL, *tmp = NULL; H5T_shared_t *reopened_fo = NULL; diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index d8e98af..86bc174 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -109,7 +109,7 @@ H5_DLLVAR H5T_order_t H5T_native_order_g; /* Private functions */ H5_DLL herr_t H5T_init(void); -H5_DLL H5T_t *H5T_copy(H5T_t *old_dt, H5T_copy_t method); +H5_DLL H5T_t *H5T_copy(const H5T_t *old_dt, H5T_copy_t method); H5_DLL herr_t H5T_lock(H5T_t *dt, hbool_t immutable); H5_DLL herr_t H5T_close(H5T_t *dt); H5_DLL herr_t H5T_close_real(H5T_t *dt); -- cgit v0.12 From 943e601b1044256c26924b6bcca1b6d3de7b9914 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:49:15 -0600 Subject: Straggler from previous commit: build and link the new .c files where I moved some previously-static variables and functions that were causing unused-variable/function warnings. --- test/Makefile.am | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 3a8a8a8..6a83585 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -135,7 +135,7 @@ else noinst_LTLIBRARIES=libh5test.la endif -libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c external_common.c +libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c external_common.c H5srcdir.c # Use libhd5test.la to compile all of the tests LDADD=libh5test.la $(LIBHDF5) @@ -145,6 +145,12 @@ ttsafe_SOURCES=ttsafe.c ttsafe_dcreate.c ttsafe_error.c ttsafe_cancel.c \ ttsafe_acreate.c cache_image_SOURCES=cache_image.c genall5.c +#filter_plugin_SOURCES=filter_plugin.c H5srcdir.c + +vds_swmr_gen_SOURCES=vds_swmr_gen.c vds_swmr_common.c +vds_swmr_writer_SOURCES=vds_swmr_writer.c vds_swmr_common.c +vds_swmr_reader_SOURCES=vds_swmr_reader.c vds_swmr_common.c + VFD_LIST = sec2 stdio core core_paged split multi family if DIRECT_VFD_CONDITIONAL VFD_LIST += direct -- cgit v0.12 From dc0d3a3881567c4813bd9a1ca63471f670d83995 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:50:11 -0600 Subject: Quiet a warning about an unused variable. This code looks like it should be heavily restructured to avoid the use of globals like `pass`, but that's a project for another day and another person. --- test/cache_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/cache_common.c b/test/cache_common.c index 24962bc..740523e 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -5522,7 +5522,7 @@ col_major_scan_backward(H5F_t * file_ptr, int mile_stone = 1; int32_t type; int32_t idx; - int32_t local_max_index[NUMBER_OF_ENTRY_TYPES]; + int32_t local_max_index[NUMBER_OF_ENTRY_TYPES] = {0}; if ( verbose ) HDfprintf(stdout, "%s: entering.\n", FUNC); -- cgit v0.12 From 7bdf30738da4366d1521951c3dd52ae0c666c436 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 11:56:46 -0600 Subject: I'm not sure what the previous code was trying to do, casting an array of `hsize_t`, `start`, to `long long`, but I think the way that I have rewritten it, it probably produces a more useful result? As a bonus, GCC has stopped warning about it. --- test/swmr_sparse_reader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/swmr_sparse_reader.c b/test/swmr_sparse_reader.c index 6adc6c5..a969b16 100644 --- a/test/swmr_sparse_reader.c +++ b/test/swmr_sparse_reader.c @@ -115,7 +115,7 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t /* Emit informational message */ if(verbose) - HDfprintf(stderr, "Symbol = '%s', location = %lld\n", symbol->name, (long long)start); + HDfprintf(stderr, "Symbol = '%s', location = %ju,%ju\n", symbol->name, (uintmax_t)start[0], (uintmax_t)start[1]); /* Read record from dataset */ record->rec_id = (uint64_t)ULLONG_MAX; @@ -126,7 +126,7 @@ check_dataset(hid_t fid, unsigned verbose, const symbol_info_t *symbol, symbol_t if(record->rec_id != start[1]) { HDfprintf(stderr, "*** ERROR ***\n"); HDfprintf(stderr, "Incorrect record value!\n"); - HDfprintf(stderr, "Symbol = '%s', location = %lld, record->rec_id = %llu\n", symbol->name, (long long)start, (unsigned long long)record->rec_id); + HDfprintf(stderr, "Symbol = '%s', location = %ju,%ju, record->rec_id = %" PRIu64 "\n", symbol->name, (uintmax_t)start[0], (uintmax_t)start[1], record->rec_id); return -1; } /* end if */ -- cgit v0.12 From 42cd35b717701b474141d5827215642b22384cc9 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 12:03:18 -0600 Subject: GCC isn't smart enough to realize that `fill_c` is always initialized and exclusively used in `datatype == H5T_COMPOUND` branches, so just initialize it at its declaration so that GCC doesn't warn. --- test/fillval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/fillval.c b/test/fillval.c index 47cd53a..5c20e14 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -758,7 +758,8 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, int fillval=(-1), val_rd, should_be; int i, j, *buf=NULL, odd; unsigned u; - comp_datatype rd_c, fill_c, should_be_c; + comp_datatype rd_c, fill_c = {.a = 0, .x = 0, .y = 0, .z = 0}, + should_be_c; comp_datatype *buf_c=NULL; H5D_space_status_t allocation; -- cgit v0.12 From 81a256b02ee714eb6a62bcce86eac0c31a0c127b Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 12:04:42 -0600 Subject: Don't assign a constant string to a pointer to non-constant character. --- test/del_many_dense_attrs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/del_many_dense_attrs.c b/test/del_many_dense_attrs.c index ada7a6f..ce85d1b 100644 --- a/test/del_many_dense_attrs.c +++ b/test/del_many_dense_attrs.c @@ -70,7 +70,7 @@ main(void) hid_t fapl = -1; /* File access property lists */ hid_t gcpl = -1; /* Group creation property list */ char aname[50]; /* Name of attribute */ - char *basename="attr"; /* Name prefix for attribute */ + const char *basename="attr";/* Name prefix for attribute */ char filename[100]; /* File name */ int i; /* Local index variable */ -- cgit v0.12 From 1e3d63dcdf4cc88155f12f5a3960baef4c01ba5f Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 12:05:16 -0600 Subject: `same_file` is assigned but never used. Delete it. --- test/objcopy_ref.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/objcopy_ref.c b/test/objcopy_ref.c index 721a7c6..fdb3179 100644 --- a/test/objcopy_ref.c +++ b/test/objcopy_ref.c @@ -1587,7 +1587,6 @@ main(void) unsigned max_compact, min_dense; int configuration; /* Configuration of tests. */ int ExpressMode; - hbool_t same_file; /* Whether to run tests that only use one file */ /* Setup */ h5_reset(); @@ -1620,11 +1619,6 @@ main(void) hid_t fcpl_src; hid_t fcpl_dst; - /* Start with same_file == TRUE. Use source file settings for these - * tests. Don't run with a non-default destination file setting, as - * destination settings have no effect. */ - same_file = TRUE; - /* No need to test dense attributes with old format */ if(!(configuration & CONFIG_SRC_NEW_FORMAT) && (configuration & CONFIG_DENSE)) continue; @@ -1646,7 +1640,6 @@ main(void) if(configuration & CONFIG_SHARE_DST) { HDputs("Testing with shared dst messages:"); fcpl_dst = fcpl_shared; - same_file = FALSE; } else { HDputs("Testing without shared dst messages:"); @@ -1678,7 +1671,6 @@ main(void) if(configuration & CONFIG_DST_NEW_FORMAT) { HDputs("Testing with latest format for destination file:"); dst_fapl = fapl2; - same_file = FALSE; } /* end if */ else { HDputs("Testing with oldest file format for destination file:"); -- cgit v0.12 From 695c62bafe07cf6213135f439b122ea7c4755a39 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 12:06:01 -0600 Subject: In every instance, `x` is initialized by `memcpy`, but GCC isn't smart enough to figure that out. Quiet some warnings by always initializing `x` to 0. --- test/dt_arith.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/dt_arith.c b/test/dt_arith.c index 7e1adf5..8d04770 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -770,7 +770,7 @@ static int test_particular_fp_integer(void) /* Print errors */ if(dst_c != SCHAR_MAX) { - double x; + double x = 0.; signed char y; if(0 == fails_this_test++) @@ -814,7 +814,7 @@ static int test_particular_fp_integer(void) /* Print errors */ if(dst_i != fill_value) { - float x; + float x = 0.; int y; if(0 == fails_this_test++) @@ -2723,16 +2723,16 @@ my_isnan(dtype_t type, void *val) char s[256]; if (FLT_FLOAT==type) { - float x; + float x = 0.; HDmemcpy(&x, val, sizeof(float)); retval = (x!=x); } else if (FLT_DOUBLE==type) { - double x; + double x = 0.; HDmemcpy(&x, val, sizeof(double)); retval = (x!=x); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 } else if (FLT_LDOUBLE==type) { - long double x; + long double x = 0.; HDmemcpy(&x, val, sizeof(long double)); retval = (x!=x); #endif @@ -2746,18 +2746,18 @@ my_isnan(dtype_t type, void *val) */ if (!retval) { if (FLT_FLOAT==type) { - float x; + float x = 0.; HDmemcpy(&x, val, sizeof(float)); HDsnprintf(s, sizeof(s), "%g", (double)x); } else if (FLT_DOUBLE==type) { - double x; + double x = 0.; HDmemcpy(&x, val, sizeof(double)); HDsnprintf(s, sizeof(s), "%g", x); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE && H5_SIZEOF_LONG_DOUBLE!=0 } else if (FLT_LDOUBLE==type) { - long double x; + long double x = 0.; HDmemcpy(&x, val, sizeof(long double)); HDsnprintf(s, sizeof(s), "%Lg", x); @@ -3197,7 +3197,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) int check_expo[2]; if (FLT_FLOAT==dst_type) { - float x; + float x = 0.; HDmemcpy(&x, &buf[j*dst_size], sizeof(float)); if (underflow && HDfabsf(x) <= FLT_MIN && HDfabsf(hw_f) <= FLT_MIN) @@ -3208,7 +3208,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) check_mant[0] = HDfrexpf(x, check_expo+0); check_mant[1] = HDfrexpf(hw_f, check_expo+1); } else if (FLT_DOUBLE==dst_type) { - double x; + double x = 0.; HDmemcpy(&x, &buf[j*dst_size], sizeof(double)); if (underflow && HDfabs(x) <= DBL_MIN && HDfabs(hw_d) <= DBL_MIN) @@ -3220,7 +3220,7 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) check_mant[1] = HDfrexp(hw_d, check_expo+1); #if H5_SIZEOF_LONG_DOUBLE !=0 && (H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE) } else { - long double x; + long double x = 0.; HDmemcpy(&x, &buf[j*dst_size], sizeof(long double)); /* dst is largest float, no need to check underflow. */ check_mant[0] = (double)HDfrexpl(x, check_expo+0); @@ -3265,16 +3265,16 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) HDprintf(" %02x", saved[j*src_size+ENDIAN(src_size,k,sendian)]); HDprintf("%*s", (int)(3*MAX(0, (ssize_t)dst_size-(ssize_t)src_size)), ""); if (FLT_FLOAT==src_type) { - float x; + float x = 0.; HDmemcpy(&x, &saved[j*src_size], sizeof(float)); HDprintf(" %29.20e\n", (double)x); } else if (FLT_DOUBLE==src_type) { - double x; + double x = 0.; HDmemcpy(&x, &saved[j*src_size], sizeof(double)); HDprintf(" %29.20e\n", x); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE } else { - long double x; + long double x = 0.; HDmemcpy(&x, &saved[j*src_size], sizeof(long double)); HDfprintf(stdout," %29.20Le\n", x); #endif @@ -3285,16 +3285,16 @@ test_conv_flt_1 (const char *name, int run_test, hid_t src, hid_t dst) HDprintf(" %02x", buf[j*dst_size+ENDIAN(dst_size,k,dendian)]); HDprintf("%*s", (int)(3*MAX(0, (ssize_t)src_size-(ssize_t)dst_size)), ""); if (FLT_FLOAT==dst_type) { - float x; + float x = 0.; HDmemcpy(&x, &buf[j*dst_size], sizeof(float)); HDprintf(" %29.20e\n", (double)x); } else if (FLT_DOUBLE==dst_type) { - double x; + double x = 0.; HDmemcpy(&x, &buf[j*dst_size], sizeof(double)); HDprintf(" %29.20e\n", x); #if H5_SIZEOF_LONG_DOUBLE!=H5_SIZEOF_DOUBLE } else { - long double x; + long double x = 0.; HDmemcpy(&x, &buf[j*dst_size], sizeof(long double)); HDfprintf(stdout," %29.20Le\n", x); #endif -- cgit v0.12 From b505226ad581f50804ee0a8cb5cb63b85d698dc7 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 13:29:59 -0600 Subject: Change hdset_reg_ref_t and H5R_ref_t from arrays of unsigned char to structs containing those arrays. Encapsulating the arrays in this way makes it easier to write and think about pointers to these types, casts to/from these types, etc. An interesting side-effect that we probably should *not* rely on is that the struct-encapsulation changes the alignment so that some GCC warnings about casts that increase the alignment requirement of the operand go away. Warnings like that have to be taken seriously: I will add -Werror=cast-align to the default compiler flags so that they stop the build quickly. GCC warnings led me to some surprising casts in test/trefer.c. I found that it was possible to make many simplifications after introducing the struct-encapsulation that I described, above. --- src/H5Rpublic.h | 8 +- test/trefer.c | 271 ++++++++++++++++++++++++++------------------------- test/trefer_deprec.c | 2 +- 3 files changed, 145 insertions(+), 136 deletions(-) diff --git a/src/H5Rpublic.h b/src/H5Rpublic.h index ce54ac4..045e04a 100644 --- a/src/H5Rpublic.h +++ b/src/H5Rpublic.h @@ -70,14 +70,18 @@ typedef haddr_t hobj_ref_t; * machine (8 bytes currently) plus an int. * Note! This type can only be used with the "native" HDF5 VOL connector. */ -typedef unsigned char hdset_reg_ref_t[H5R_DSET_REG_REF_BUF_SIZE]; +typedef struct { + unsigned char content[H5R_DSET_REG_REF_BUF_SIZE]; +} hdset_reg_ref_t; /** * Opaque reference type. The same reference type is used for object, * dataset region and attribute references. This is the type that * should always be used with the current reference API. */ -typedef unsigned char H5R_ref_t[H5R_REF_BUF_SIZE]; +typedef struct { + unsigned char content[H5R_REF_BUF_SIZE]; +} H5R_ref_t; /********************/ /* Public Variables */ diff --git a/test/trefer.c b/test/trefer.c index 7d87ea9..4ffc2dc 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -89,9 +89,9 @@ test_reference_params(void) H5R_ref_t *wbuf, /* buffer to write to disk */ *rbuf, /* buffer read from disk */ *tbuf; /* temp. buffer read from disk */ + unsigned *obuf; H5R_type_t type; /* Reference type */ - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i; /* Counters */ + unsigned int i; /* Counters */ const char *write_comment = "Foo!"; /* Comments for group */ hid_t ret_id; /* Generic hid_t return value */ ssize_t name_size; /* Size of reference name */ @@ -101,12 +101,13 @@ test_reference_params(void) MESSAGE(5, ("Testing Reference Parameters\n")); /* Allocate write & read buffers */ - wbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - rbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - tbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); + wbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + tbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + obuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)i * 3; + for(i = 0; i < SPACE1_DIM1; i++) + obuf[i] = i * 3; /* Create file */ fid1 = H5Fcreate(FILE_REF_PARAM, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -137,7 +138,7 @@ test_reference_params(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* Write selection to disk */ - ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obuf); CHECK(ret, FAIL, "H5Dwrite"); /* Close Dataset */ @@ -153,7 +154,7 @@ test_reference_params(void) CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); /* Write attribute to disk */ - ret = H5Awrite(attr, H5T_NATIVE_UINT, wbuf); + ret = H5Awrite(attr, H5T_NATIVE_UINT, obuf); CHECK(ret, FAIL, "H5Awrite"); /* Close attribute */ @@ -233,19 +234,19 @@ test_reference_params(void) VERIFY(type, H5R_BADTYPE, "H5Rget_type ref"); /* Test parameters to H5Requal */ - ret = H5Requal(NULL, (const H5R_ref_t *)&rbuf[0]); + ret = H5Requal(NULL, &rbuf[0]); VERIFY(ret, FAIL, "H5Requal ref1"); - ret = H5Requal((const H5R_ref_t *)&rbuf[0], NULL); + ret = H5Requal(&rbuf[0], NULL); VERIFY(ret, FAIL, "H5Requal ref2"); /* Test parameters to H5Rcopy */ ret = H5Rcopy(NULL, &wbuf[0]); VERIFY(ret, FAIL, "H5Rcopy src_ref"); - ret = H5Rcopy((const H5R_ref_t *)&rbuf[0], NULL); + ret = H5Rcopy(&rbuf[0], NULL); VERIFY(ret, FAIL, "H5Rcopy dest_ref"); /* Test parameters to H5Ropen_object */ - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf[0], H5I_INVALID_HID, H5I_INVALID_HID); + dset2 = H5Ropen_object(&rbuf[0], H5I_INVALID_HID, H5I_INVALID_HID); VERIFY(dset2, FAIL, "H5Ropen_object oapl_id"); dset2 = H5Ropen_object(NULL, H5P_DEFAULT, dapl_id); VERIFY(dset2, FAIL, "H5Ropen_object ref"); @@ -298,6 +299,7 @@ test_reference_params(void) HDfree(wbuf); HDfree(rbuf); HDfree(tbuf); + HDfree(obuf); } /* test_reference_params() */ /**************************************************************** @@ -318,10 +320,9 @@ test_reference_obj(void) hsize_t dims1[] = {SPACE1_DIM1}; hid_t dapl_id; /* Dataset access property list */ H5R_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i, j; /* Counters */ + *rbuf; /* buffer read from disk */ + unsigned *ibuf, *obuf; + unsigned i, j; /* Counters */ H5O_type_t obj_type; /* Object type */ herr_t ret; /* Generic return value */ @@ -329,12 +330,13 @@ test_reference_obj(void) MESSAGE(5, ("Testing Object Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - rbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - tbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); + wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + ibuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); + obuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)i * 3; + for (i = 0; i < SPACE1_DIM1; i++) + obuf[i] = i * 3; /* Create file */ fid1 = H5Fcreate(FILE_REF_OBJ, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -357,7 +359,7 @@ test_reference_obj(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* Write selection to disk */ - ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obuf); CHECK(ret, FAIL, "H5Dwrite"); /* Close Dataset */ @@ -405,28 +407,28 @@ test_reference_obj(void) /* Create reference to dataset */ ret = H5Rcreate_object(fid1, "/Group1/Dataset1", &wbuf[0]); CHECK(ret, FAIL, "H5Rcreate_object"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Create reference to dataset */ ret = H5Rcreate_object(fid1, "/Group1/Dataset2", &wbuf[1]); CHECK(ret, FAIL, "H5Rcreate_object"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[1], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[1], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Create reference to group */ ret = H5Rcreate_object(fid1, "/Group1", &wbuf[2]); CHECK(ret, FAIL, "H5Rcreate_object"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[2], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[2], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_GROUP, "H5Rget_obj_type3"); /* Create reference to named datatype */ ret = H5Rcreate_object(fid1, "/Group1/Datatype1", &wbuf[3]); CHECK(ret, FAIL, "H5Rcreate_object"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[3], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[3], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3"); @@ -459,7 +461,7 @@ test_reference_obj(void) CHECK(ret, FAIL, "H5Dread"); /* Open dataset object */ - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, dapl_id); + dset2 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); /* Check information in referenced dataset */ @@ -470,18 +472,18 @@ test_reference_obj(void) VERIFY(ret, SPACE1_DIM1, "H5Sget_simple_extent_npoints"); /* Read from disk */ - ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tbuf); + ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); CHECK(ret, FAIL, "H5Dread"); - for(tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)(i*3), "Data"); + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(ibuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ ret = H5Dclose(dset2); CHECK(ret, FAIL, "H5Dclose"); /* Open group object. GAPL isn't supported yet. But it's harmless to pass in */ - group = H5Ropen_object((const H5R_ref_t *)&rbuf[2], H5P_DEFAULT, H5P_DEFAULT); + group = H5Ropen_object(&rbuf[2], H5P_DEFAULT, H5P_DEFAULT); CHECK(group, H5I_INVALID_HID, "H5Ropen_object"); /* Close group */ @@ -489,7 +491,7 @@ test_reference_obj(void) CHECK(ret, FAIL, "H5Gclose"); /* Open datatype object. TAPL isn't supported yet. But it's harmless to pass in */ - tid1 = H5Ropen_object((const H5R_ref_t *)&rbuf[3], H5P_DEFAULT, H5P_DEFAULT); + tid1 = H5Ropen_object(&rbuf[3], H5P_DEFAULT, H5P_DEFAULT); CHECK(tid1, H5I_INVALID_HID, "H5Ropen_object"); /* Verify correct datatype */ @@ -530,7 +532,8 @@ test_reference_obj(void) /* Free memory buffers */ HDfree(wbuf); HDfree(rbuf); - HDfree(tbuf); + HDfree(ibuf); + HDfree(obuf); } /* test_reference_obj() */ /**************************************************************** @@ -565,7 +568,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t high[SPACE2_RANK]; /* Selection bounds */ H5R_ref_t *wbuf, /* buffer to write to disk */ *rbuf; /* buffer read from disk */ - H5R_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ + H5R_ref_t nvrbuf[3]={{{0}},{{101}},{{255}}}; /* buffer with non-valid refs */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ *drbuf; /* Buffer for reading numeric data from disk */ uint8_t *tu8; /* Temporary pointer to uint8 data */ @@ -583,8 +586,8 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) MESSAGE(5, ("Testing Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); - rbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); dwbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)(SPACE2_DIM1 * SPACE2_DIM2)); @@ -647,7 +650,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* Store first dataset region */ ret = H5Rcreate_region(fid1, "/Dataset2", sid2, &wbuf[0]); CHECK(ret, FAIL, "H5Rcreate_region"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); @@ -691,7 +694,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) ret = H5Rcreate_region(fid1, "/Dataset2", sid2, &wbuf[2]); CHECK(ret, FAIL, "H5Rcreate_region"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[2], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[2], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); @@ -764,7 +767,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) * Dereference an undefined reference (should fail) */ H5E_BEGIN_TRY { - dset2 = H5Ropen_object((const H5R_ref_t *)&rdata_NA[0], H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Ropen_object(&rdata_NA[0], H5P_DEFAULT, H5P_DEFAULT); } H5E_END_TRY; VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); @@ -798,11 +801,11 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Dread"); /* Try to open objects */ - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, dapl_id); + dset2 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); /* Check what H5Rget_obj_type3 function returns */ - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); @@ -821,7 +824,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(*tu8, (uint8_t)(i * 3), "Data"); /* Get the hyperslab selection */ - sid2 = H5Ropen_region((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); + sid2 = H5Ropen_region(&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); CHECK(sid2, H5I_INVALID_HID, "H5Ropen_region"); /* Verify correct hyperslab selected */ @@ -849,7 +852,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Sclose"); /* Get the element selection */ - sid2 = H5Ropen_region((const H5R_ref_t *)&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); + sid2 = H5Ropen_region(&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); CHECK(sid2, H5I_INVALID_HID, "H5Ropen_region"); /* Verify correct elements selected */ @@ -893,7 +896,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Sclose"); /* Get the unlimited selection */ - sid2 = H5Ropen_region((const H5R_ref_t *)&rbuf[2], H5P_DEFAULT, H5P_DEFAULT); + sid2 = H5Ropen_region(&rbuf[2], H5P_DEFAULT, H5P_DEFAULT); CHECK(sid2, H5I_INVALID_HID, "H5Ropen_region"); /* Verify correct hyperslab selected */ @@ -928,7 +931,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) /* Attempting to retrieve type of object using non-valid refs */ for(j = 0; j < 3; j++) { H5E_BEGIN_TRY { - ret = H5Rget_obj_type3((const H5R_ref_t *)&nvrbuf[j], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&nvrbuf[j], H5P_DEFAULT, &obj_type); } H5E_END_TRY; VERIFY(ret, FAIL, "H5Rget_obj_type3"); } /* end for */ @@ -1006,8 +1009,8 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) MESSAGE(5, ("Testing 1-D Dataset Region Reference Functions\n")); /* Allocate write & read buffers */ - wbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); - rbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); + wbuf = HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); + rbuf = HDcalloc(sizeof(H5R_ref_t), (size_t)SPACE1_DIM1); dwbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1); @@ -1070,7 +1073,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) /* Store first dataset region */ ret = H5Rcreate_region(fid1, "/Dataset2", sid3, &wbuf[0]); CHECK(ret, FAIL, "H5Rcreate_region"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); @@ -1128,11 +1131,11 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Dread"); /* Try to open objects */ - dset3 = H5Ropen_object((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, dapl_id); + dset3 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); CHECK(dset3, H5I_INVALID_HID, "H5Ropen_object"); /* Check what H5Rget_obj_type3 function returns */ - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); @@ -1151,7 +1154,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(*tu8, (uint8_t)(i * 3), "Data"); /* Get the hyperslab selection */ - sid3 = H5Ropen_region((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); + sid3 = H5Ropen_region(&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); /* Verify correct hyperslab selected */ @@ -1203,7 +1206,7 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(ret, FAIL, "H5Sclose"); /* Get the element selection */ - sid3 = H5Ropen_region((const H5R_ref_t *)&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); + sid3 = H5Ropen_region(&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); /* Verify correct elements selected */ @@ -1313,7 +1316,7 @@ test_reference_obj_deleted(void) /* Create reference to dataset */ ret = H5Rcreate_object(fid1, "/Dataset1", &oref); CHECK(ret, FAIL, "H5Rcreate_object"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&oref, H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&oref, H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); @@ -1354,7 +1357,7 @@ test_reference_obj_deleted(void) CHECK(ret, FAIL, "H5Dread"); /* Open deleted dataset object */ - dset2 = H5Ropen_object((const H5R_ref_t *)&oref, H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Ropen_object(&oref, H5P_DEFAULT, H5P_DEFAULT); VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); /* Close Dataset */ @@ -1501,7 +1504,7 @@ test_reference_group(void) CHECK(ret, FAIL, "H5Dread"); /* Dereference to get the group */ - gid = H5Ropen_object((const H5R_ref_t *)&rref, H5P_DEFAULT, H5P_DEFAULT); + gid = H5Ropen_object(&rref, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid, H5I_INVALID_HID, "H5Ropen_object"); /* Iterate through objects in dereferenced group */ @@ -1562,8 +1565,7 @@ test_reference_attr(void) H5R_ref_t ref_wbuf[SPACE1_DIM1], /* Buffer to write to disk */ ref_rbuf[SPACE1_DIM1]; /* Buffer read from disk */ unsigned wbuf[SPACE1_DIM1], rbuf[SPACE1_DIM1]; - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i; /* Local index variables */ + unsigned i; /* Local index variables */ H5O_type_t obj_type; /* Object type */ herr_t ret; /* Generic return value */ @@ -1590,8 +1592,8 @@ test_reference_attr(void) attr = H5Acreate2(group, "Attr2", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)((i * 3) + 1); + for(i = 0; i < SPACE1_DIM1; i++) + wbuf[i] = (i * 3) + 1; /* Write attribute to disk */ ret = H5Awrite(attr, H5T_NATIVE_UINT, wbuf); @@ -1609,8 +1611,8 @@ test_reference_attr(void) attr = H5Acreate2(dataset, "Attr1", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)(i * 3); + for(i = 0; i < SPACE1_DIM1; i++) + wbuf[i] = i * 3; /* Write attribute to disk */ ret = H5Awrite(attr, H5T_NATIVE_UINT, wbuf); @@ -1654,8 +1656,8 @@ test_reference_attr(void) attr = H5Acreate2(tid, "Attr3", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)((i * 3) + 2); + for(i = 0; i < SPACE1_DIM1; i++) + wbuf[i] = (i * 3) + 2; /* Write attribute to disk */ ret = H5Awrite(attr, H5T_NATIVE_UINT, wbuf); @@ -1680,28 +1682,28 @@ test_reference_attr(void) /* Create reference to dataset1 attribute */ ret = H5Rcreate_attr(fid, "/Group1/Dataset1", "Attr1", &ref_wbuf[0]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Create reference to dataset2 attribute */ ret = H5Rcreate_attr(fid, "/Group1/Dataset2", "Attr1", &ref_wbuf[1]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[1], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[1], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Create reference to group attribute */ ret = H5Rcreate_attr(fid, "/Group1", "Attr2", &ref_wbuf[2]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[2], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[2], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_GROUP, "H5Rget_obj_type3"); /* Create reference to named datatype attribute */ ret = H5Rcreate_attr(fid, "/Group1/Datatype1", "Attr3", &ref_wbuf[3]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[3], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[3], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3"); @@ -1734,7 +1736,7 @@ test_reference_attr(void) CHECK(ret, FAIL, "H5Dread"); /* Open attribute on dataset object */ - attr = H5Ropen_attr((const H5R_ref_t *)&ref_rbuf[0], H5P_DEFAULT, H5P_DEFAULT); + attr = H5Ropen_attr(&ref_rbuf[0], H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Ropen_attr"); /* Check information in referenced dataset */ @@ -1748,38 +1750,38 @@ test_reference_attr(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(tu32 = (unsigned *)rbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)(i * 3), "Data"); + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(rbuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Open attribute on group object */ - attr = H5Ropen_attr((const H5R_ref_t *)&ref_rbuf[2], H5P_DEFAULT, H5P_DEFAULT); + attr = H5Ropen_attr(&ref_rbuf[2], H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Ropen_attr"); /* Read from disk */ ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(tu32 = (unsigned *)rbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)((i * 3) + 1), "Data"); + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(rbuf[i], (i * 3) + 1, "Data"); /* Close attribute */ ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Open attribute on named datatype object */ - attr = H5Ropen_attr((const H5R_ref_t *)&ref_rbuf[3], H5P_DEFAULT, H5P_DEFAULT); + attr = H5Ropen_attr(&ref_rbuf[3], H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Ropen_attr"); /* Read from disk */ ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(tu32 = (unsigned *)rbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)((i * 3) + 2), "Data"); + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(rbuf[i], (i * 3) + 2, "Data"); /* Close attribute */ ret = H5Aclose(attr); @@ -1826,8 +1828,7 @@ test_reference_external(void) H5R_ref_t ref_wbuf[SPACE1_DIM1], /* Buffer to write to disk */ ref_rbuf[SPACE1_DIM1]; /* Buffer read from disk */ unsigned wbuf[SPACE1_DIM1], rbuf[SPACE1_DIM1]; - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i; /* Local index variables */ + unsigned i; /* Local index variables */ H5O_type_t obj_type; /* Object type */ herr_t ret; /* Generic return value */ @@ -1854,8 +1855,8 @@ test_reference_external(void) attr = H5Acreate2(group, "Attr2", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)((i * 3) + 1); + for(i = 0; i < SPACE1_DIM1; i++) + wbuf[i] = (i * 3) + 1; /* Write attribute to disk */ ret = H5Awrite(attr, H5T_NATIVE_UINT, wbuf); @@ -1873,8 +1874,8 @@ test_reference_external(void) attr = H5Acreate2(dataset, "Attr1", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)(i * 3); + for(i = 0; i < SPACE1_DIM1; i++) + wbuf[i] = i * 3; /* Write attribute to disk */ ret = H5Awrite(attr, H5T_NATIVE_UINT, wbuf); @@ -1918,8 +1919,8 @@ test_reference_external(void) attr = H5Acreate2(tid, "Attr3", H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)((i * 3) + 2); + for(i = 0; i < SPACE1_DIM1; i++) + wbuf[i] = (i * 3) + 2; /* Write attribute to disk */ ret = H5Awrite(attr, H5T_NATIVE_UINT, wbuf); @@ -1940,28 +1941,28 @@ test_reference_external(void) /* Create reference to dataset1 attribute */ ret = H5Rcreate_attr(fid1, "/Group1/Dataset1", "Attr1", &ref_wbuf[0]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Create reference to dataset2 attribute */ ret = H5Rcreate_attr(fid1, "/Group1/Dataset2", "Attr1", &ref_wbuf[1]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[1], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[1], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Create reference to group attribute */ ret = H5Rcreate_attr(fid1, "/Group1", "Attr2", &ref_wbuf[2]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[2], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[2], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_GROUP, "H5Rget_obj_type3"); /* Create reference to named datatype attribute */ ret = H5Rcreate_attr(fid1, "/Group1/Datatype1", "Attr3", &ref_wbuf[3]); CHECK(ret, FAIL, "H5Rcreate_attr"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&ref_wbuf[3], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&ref_wbuf[3], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3"); @@ -2014,7 +2015,7 @@ test_reference_external(void) CHECK(ret, FAIL, "H5Dread"); /* Open attribute on dataset object */ - attr = H5Ropen_attr((const H5R_ref_t *)&ref_rbuf[0], H5P_DEFAULT, H5P_DEFAULT); + attr = H5Ropen_attr(&ref_rbuf[0], H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Ropen_attr"); /* Check information in referenced dataset */ @@ -2028,38 +2029,38 @@ test_reference_external(void) ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(tu32 = (unsigned *)rbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)(i * 3), "Data"); + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(rbuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Open attribute on group object */ - attr = H5Ropen_attr((const H5R_ref_t *)&ref_rbuf[2], H5P_DEFAULT, H5P_DEFAULT); + attr = H5Ropen_attr(&ref_rbuf[2], H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Ropen_attr"); /* Read from disk */ ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(tu32 = (unsigned *)rbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)((i * 3) + 1), "Data"); + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(rbuf[i], (i * 3) + 1, "Data"); /* Close attribute */ ret = H5Aclose(attr); CHECK(ret, FAIL, "H5Aclose"); /* Open attribute on named datatype object */ - attr = H5Ropen_attr((const H5R_ref_t *)&ref_rbuf[3], H5P_DEFAULT, H5P_DEFAULT); + attr = H5Ropen_attr(&ref_rbuf[3], H5P_DEFAULT, H5P_DEFAULT); CHECK(attr, H5I_INVALID_HID, "H5Ropen_attr"); /* Read from disk */ ret = H5Aread(attr, H5T_NATIVE_UINT, rbuf); CHECK(ret, FAIL, "H5Aread"); - for(tu32 = (unsigned *)rbuf, i = 0; i < SPACE1_DIM1; i++, tu32++) - VERIFY(*tu32, (uint32_t)((i * 3) + 2), "Data"); + for(i = 0; i < SPACE1_DIM1; i++) + VERIFY(rbuf[i], (i * 3) + 2, "Data"); /* Close attribute */ ret = H5Aclose(attr); @@ -2121,9 +2122,9 @@ test_reference_compat_conv(void) /* Allocate write & read buffers */ wbuf_obj = (hobj_ref_t *)HDcalloc(sizeof(hobj_ref_t), SPACE1_DIM1); - rbuf_obj = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf_obj = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); wbuf_reg = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), 2); - rbuf_reg = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), 2); + rbuf_reg = HDcalloc(sizeof(H5R_ref_t), 2); /* Create file */ fid1 = H5Fcreate(FILE_REF_COMPAT, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2286,43 +2287,43 @@ test_reference_compat_conv(void) CHECK(ret, FAIL, "H5Dread"); /* Verify type of objects pointed at */ - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf_obj[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf_obj[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf_obj[1], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf_obj[1], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf_obj[2], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf_obj[2], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_GROUP, "H5Rget_obj_type3"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf_obj[3], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf_obj[3], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_NAMED_DATATYPE, "H5Rget_obj_type3"); /* Make sure the referenced objects can be opened */ - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf_obj[0], H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Ropen_object(&rbuf_obj[0], H5P_DEFAULT, H5P_DEFAULT); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); ret = H5Dclose(dset2); CHECK(ret, FAIL, "H5Dclose"); - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf_obj[1], H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Ropen_object(&rbuf_obj[1], H5P_DEFAULT, H5P_DEFAULT); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); ret = H5Dclose(dset2); CHECK(ret, FAIL, "H5Dclose"); - group2 = H5Ropen_object((const H5R_ref_t *)&rbuf_obj[2], H5P_DEFAULT, H5P_DEFAULT); + group2 = H5Ropen_object(&rbuf_obj[2], H5P_DEFAULT, H5P_DEFAULT); CHECK(group2, H5I_INVALID_HID, "H5Ropen_object"); ret = H5Gclose(group2); CHECK(ret, FAIL, "H5Gclose"); - tid2 = H5Ropen_object((const H5R_ref_t *)&rbuf_obj[3], H5P_DEFAULT, H5P_DEFAULT); + tid2 = H5Ropen_object(&rbuf_obj[3], H5P_DEFAULT, H5P_DEFAULT); CHECK(tid2, H5I_INVALID_HID, "H5Ropen_object"); ret = H5Tclose(tid2); @@ -2342,22 +2343,22 @@ test_reference_compat_conv(void) CHECK(ret, FAIL, "H5Dread"); /* Verify type of objects pointed at */ - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf_reg[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf_reg[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&rbuf_reg[1], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&rbuf_reg[1], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); /* Make sure the referenced objects can be opened */ - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf_reg[0], H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Ropen_object(&rbuf_reg[0], H5P_DEFAULT, H5P_DEFAULT); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); ret = H5Dclose(dset2); CHECK(ret, FAIL, "H5Dclose"); - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf_reg[1], H5P_DEFAULT, H5P_DEFAULT); + dset2 = H5Ropen_object(&rbuf_reg[1], H5P_DEFAULT, H5P_DEFAULT); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); ret = H5Dclose(dset2); @@ -2414,8 +2415,8 @@ test_reference_perf(void) *rbuf_deprec;/* deprecated references */ hdset_reg_ref_t *wbuf_reg_deprec, /* deprecated references*/ *rbuf_reg_deprec; /* deprecated references*/ - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i, j; /* Counters */ + unsigned *ibuf, *obuf; + unsigned i, j; /* Counters */ H5O_type_t obj_type; /* Object type */ herr_t ret; /* Generic return value */ double t1, t2, t; /* Timers */ @@ -2424,18 +2425,20 @@ test_reference_perf(void) MESSAGE(5, ("Testing Object Reference Performance\n")); /* Allocate write & read buffers */ - wbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - wbuf_deprec = (hobj_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)), SPACE1_DIM1); - rbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - rbuf_deprec = (hobj_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)), SPACE1_DIM1); - tbuf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - wbuf_reg = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - rbuf_reg = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), SPACE1_DIM1); - wbuf_reg_deprec = (hdset_reg_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(hdset_reg_ref_t)), SPACE1_DIM1); - rbuf_reg_deprec = (hdset_reg_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(hdset_reg_ref_t)), SPACE1_DIM1); - - for(tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++) - *tu32++ = (unsigned)i * 3; + wbuf = HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + obuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); + ibuf = HDcalloc(sizeof(unsigned), SPACE1_DIM1); + wbuf_deprec = (hobj_ref_t *)HDcalloc(sizeof(hobj_ref_t), SPACE1_DIM1); + rbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf_deprec = (hobj_ref_t *)HDcalloc(sizeof(hobj_ref_t), SPACE1_DIM1); + tbuf = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + wbuf_reg = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + rbuf_reg = (H5R_ref_t *)HDcalloc(sizeof(H5R_ref_t), SPACE1_DIM1); + wbuf_reg_deprec = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + rbuf_reg_deprec = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + + for(i = 0; i < SPACE1_DIM1; i++) + obuf[i] = i * 3; /* Create file */ fid1 = H5Fcreate(FILE_REF_OBJ, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); @@ -2458,7 +2461,7 @@ test_reference_perf(void) CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); /* Write selection to disk */ - ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, obuf); CHECK(ret, FAIL, "H5Dwrite"); /* Close Dataset */ @@ -2518,7 +2521,7 @@ test_reference_perf(void) /* Create reference to dataset */ ret = H5Rcreate_object(fid1, "/Group1/Dataset1", &wbuf[0]); CHECK(ret, FAIL, "H5Rcreate_object"); - ret = H5Rget_obj_type3((const H5R_ref_t *)&wbuf[0], H5P_DEFAULT, &obj_type); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type3"); VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); @@ -2670,7 +2673,7 @@ test_reference_perf(void) CHECK(ret, FAIL, "H5Dread"); /* Open dataset object */ - dset2 = H5Ropen_object((const H5R_ref_t *)&rbuf[0], H5P_DEFAULT, dapl_id); + dset2 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); CHECK(dset2, H5I_INVALID_HID, "H5Ropen_object"); /* Check information in referenced dataset */ @@ -2681,11 +2684,11 @@ test_reference_perf(void) VERIFY(ret, dims1[0], "H5Sget_simple_extent_npoints"); /* Read from disk */ - ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, tbuf); + ret = H5Dread(dset2, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, ibuf); CHECK(ret, FAIL, "H5Dread"); - for(tu32 = (unsigned *)tbuf, i = 0; i < (int)dims1[0]; i++, tu32++) - VERIFY(*tu32, (uint32_t)(i*3), "Data"); + for(i = 0; i < dims1[0]; i++) + VERIFY(ibuf[i], i * 3, "Data"); /* Close dereferenced Dataset */ ret = H5Dclose(dset2); @@ -2767,7 +2770,7 @@ test_reference_perf(void) CHECK(ret, FAIL, "H5Fclose"); /* Destroy references */ - for(j = 0; j < (int)dims1[0]; j++) { + for(j = 0; j < dims1[0]; j++) { ret = H5Rdestroy(&wbuf[j]); CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&wbuf_reg[j]); @@ -2788,6 +2791,8 @@ test_reference_perf(void) HDfree(wbuf_reg_deprec); HDfree(rbuf_reg_deprec); HDfree(tbuf); + HDfree(ibuf); + HDfree(obuf); } /* test_reference_perf() */ /**************************************************************** diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c index 949f41b..1b77e9c 100644 --- a/test/trefer_deprec.c +++ b/test/trefer_deprec.c @@ -517,7 +517,7 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t high[SPACE2_RANK]; /* Selection bounds */ hdset_reg_ref_t *wbuf, /* buffer to write to disk */ *rbuf; /* buffer read from disk */ - hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ + hdset_reg_ref_t nvrbuf[3]={{{0}},{{101}},{{255}}}; /* buffer with non-valid refs */ uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ *drbuf; /* Buffer for reading numeric data from disk */ uint8_t *tu8; /* Temporary pointer to uint8 data */ -- cgit v0.12 From 15f5a6980d0a319080e84684c799989f3157a857 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 13:31:51 -0600 Subject: Cast to the parameter type, H5VL_token_t *, instead of to unsigned char *. (H5VL_token_t, too, probably should turn from a typedef for a constant-length array to an array encapsulated in a struct.) --- src/H5Tref.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Tref.c b/src/H5Tref.c index 2e52954..b1bc9e8 100644 --- a/src/H5Tref.c +++ b/src/H5Tref.c @@ -709,7 +709,7 @@ H5T__ref_obj_disk_read(H5VL_object_t *src_file, const void *src_buf, size_t src_ /* Get object address */ if(H5R__decode_token_obj_compat((const unsigned char *)src_buf, &src_size, - (unsigned char *)dst_buf, H5F_SIZEOF_ADDR(src_f)) < 0) + (H5VL_token_t *)dst_buf, H5F_SIZEOF_ADDR(src_f)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address") done: -- cgit v0.12 From 560db03d66244a5d9f74a9c2e6a1341e21d51e57 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 13:33:46 -0600 Subject: Make errors of some more warnings. Move disabled warnings to DEVELOPER_WARNING_CFLAGS. Put just one warning option on a line, and sort some of the options. --- config/gnu-flags | 74 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 31 deletions(-) diff --git a/config/gnu-flags b/config/gnu-flags index eddd169..101b27b 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -168,41 +168,38 @@ if test "X-gcc" = "X-$cc_vendor"; then # NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add # it to the developer flags. # - H5_CFLAGS="$H5_CFLAGS -pedantic -Wall -Wextra -Wcast-align" + H5_CFLAGS="$H5_CFLAGS -pedantic -Wall -Wextra" H5_CFLAGS="$H5_CFLAGS -Wcast-qual -Wconversion -Wfloat-equal" H5_CFLAGS="$H5_CFLAGS -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-include-dirs" - H5_CFLAGS="$H5_CFLAGS" H5_CFLAGS="$H5_CFLAGS -Wshadow" H5_CFLAGS="$H5_CFLAGS -Wundef -Wwrite-strings" # - # Lots of noise, questionable benefit: - # - #H5_CFLAGS="$H5_CFLAGS -Wunused-macros -Wunsafe-loop-optimizations" - - # # HDF5 code should not trigger the following warnings under any # circumstances, so ask the compiler to treat them as errors: # H5_ECFLAGS="$H5_ECFLAGS -Werror=bad-function-cast" - H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-declarations" - H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-prototypes -Werror=nested-externs" - H5_ECFLAGS="$H5_ECFLAGS -Werror=old-style-definition -Werror=packed" - H5_ECFLAGS="$H5_ECFLAGS -Werror=redundant-decls -Werror=strict-prototypes" + H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-align" + H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" +# H5_ECFLAGS="$H5_ECFLAGS -Werror=discarded-qualifiers" + H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" + H5_ECFLAGS="$H5_ECFLAGS -Werror=maybe-uninitialized" + H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-declarations" + H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-prototypes" + H5_ECFLAGS="$H5_ECFLAGS -Werror=nested-externs" + H5_ECFLAGS="$H5_ECFLAGS -Werror=old-style-definition" + H5_ECFLAGS="$H5_ECFLAGS -Werror=packed" + H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-sign" + H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-to-int-cast" + H5_ECFLAGS="$H5_ECFLAGS -Werror=redundant-decls" + H5_ECFLAGS="$H5_ECFLAGS -Werror=shadow" + H5_ECFLAGS="$H5_ECFLAGS -Werror=strict-prototypes" H5_ECFLAGS="$H5_ECFLAGS -Werror=switch" - H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" - H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" - -# -# Should be enabled only with discussion: -# -# H5_CFLAGS="$H5_CFLAGS -Wdeclaration-after-statement -Wdisabled-optimization" -# -# -Wswitch is helpful, but these seem a step too far: -# -# H5_CFLAGS="$H5_CFLAGS -Wswitch-enum -Wswitch-default" -# + H5_ECFLAGS="$H5_ECFLAGS -Werror=unused-but-set-variable" + H5_ECFLAGS="$H5_ECFLAGS -Werror=unused-function" + H5_ECFLAGS="$H5_ECFLAGS -Werror=unused-parameter" + H5_ECFLAGS="$H5_ECFLAGS -Werror=unused-variable" ###################### # Developer warnings # @@ -213,6 +210,20 @@ if test "X-gcc" = "X-$cc_vendor"; then DEVELOPER_WARNING_CFLAGS="-Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn -Wformat-nonliteral" NO_DEVELOPER_WARNING_CFLAGS="-Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn" + # + # Let's discuss: + # + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wdeclaration-after-statement" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wdisabled-optimization" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunused-macros" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunsafe-loop-optimizations" + + # + # -Wswitch is helpful, but these seem a step too far---let's discuss: + # + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wswitch-default" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wswitch-enum" + ####################### # gcc 4 special cases # ####################### @@ -255,7 +266,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # # Lots of noise, questionable benefit: # - #H5_CFLAGS="$H5_CFLAGS -Wlarger-than=2560" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wlarger-than=2560" # fi @@ -265,7 +276,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # # Lots of noise, questionable benefit: # - #H5_CFLAGS="$H5_CFLAGS -Wframe-larger-than=16384" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wframe-larger-than=16384" # fi @@ -277,7 +288,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # Can jumping over an initialization in C cause any harm, if # the variable is never *used* before it has been initialized? # - #H5_CFLAGS="$H5_CFLAGS -Wjump-misses-init" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wjump-misses-init" # fi @@ -291,15 +302,16 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc 4.7 if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then # - # It's not clear that -Wvector-operation-performance warnigns are + # It's not clear that -Wvector-operation-performance warnings are # actionable. # # -Wstack-usage=8192 warnings need better justification; # if justifiable, should be enabled on a branch and swept up there # before burdening the whole development team. # - #H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance" - # + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wstack-usage=8192" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wvector-operation-performance" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn" fi @@ -326,12 +338,12 @@ if test "X-gcc" = "X-$cc_vendor"; then # # Unacceptably noisy on HDF5 right now. # - #H5_CFLAGS="$H5_CFLAGS -Wnull-dereference" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wnull-dereference" # # Careful! -Wduplicated-cond, combined with HDF5's heavy use of # macros, can make a lot of noise. # - H5_CFLAGS="$H5_CFLAGS -Wduplicated-cond" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wduplicated-cond" fi # gcc 7 -- cgit v0.12 From b0dd6184bcaad08465b564ccd6de62bebad9292a Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 13:38:47 -0600 Subject: Undo my changes to the HD macros, hadn't really intended those to be on this branch.... --- src/H5private.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/H5private.h b/src/H5private.h index 8cc6b30..b5ee984 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1373,25 +1373,25 @@ typedef off_t h5_stat_size_t; #define HDstrcpy(X,Y) strcpy(X,Y) #endif /* HDstrcpy */ #ifndef HDstrcspn - #define HDstrcspn strcspn + #define HDstrcspn(X,Y) strcspn(X,Y) #endif /* HDstrcspn */ #ifndef HDstrerror - #define HDstrerror strerror + #define HDstrerror(N) strerror(N) #endif /* HDstrerror */ #ifndef HDstrftime - #define HDstrftime strftime + #define HDstrftime(S,Z,F,T) strftime(S,Z,F,T) #endif /* HDstrftime */ #ifndef HDstrlen - #define HDstrlen strlen + #define HDstrlen(S) strlen(S) #endif /* HDstrlen */ #ifndef HDstrncat - #define HDstrncat strncat + #define HDstrncat(X,Y,Z) strncat(X,Y,Z) #endif /* HDstrncat */ #ifndef HDstrncmp - #define HDstrncmp strncmp + #define HDstrncmp(X,Y,Z) strncmp(X,Y,Z) #endif /* HDstrncmp */ #ifndef HDstrncpy - #define HDstrncpy strncpy + #define HDstrncpy(X,Y,Z) strncpy(X,Y,Z) #endif /* HDstrncpy */ #ifndef HDstrpbrk #define HDstrpbrk(X,Y) strpbrk(X,Y) -- cgit v0.12 From 305177a51f5351ba13fb171858469ddec0848aeb Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 13:39:59 -0600 Subject: Oops, delete a debug printf that snuck in here. --- test/tfile.c | 1 - 1 file changed, 1 deletion(-) diff --git a/test/tfile.c b/test/tfile.c index 3525ec0..4fb2bc9 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1057,7 +1057,6 @@ create_objects(hid_t fid1, hid_t fid2, hid_t *ret_did, hid_t *ret_gid1, oid_count = H5Fget_obj_count(fid1, H5F_OBJ_DATASET|H5F_OBJ_GROUP|H5F_OBJ_DATATYPE|H5F_OBJ_ATTR); CHECK(oid_count, FAIL, "H5Fget_obj_count"); VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count"); - fprintf(stderr, "fid1: %zd datasets, %zd groups, %zd datatypes, %zd attributes\n", H5Fget_obj_count(fid1, H5F_OBJ_DATASET), H5Fget_obj_count(fid1, H5F_OBJ_GROUP), H5Fget_obj_count(fid1, H5F_OBJ_DATATYPE), H5Fget_obj_count(fid1, H5F_OBJ_ATTR)); oid_count = H5Fget_obj_count(fid2, H5F_OBJ_ALL); CHECK(oid_count, FAIL, "H5Fget_obj_count"); -- cgit v0.12 From bd77af437f5a64cf26bd0e7d2da04fd383b602d3 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 13:41:05 -0600 Subject: Undo accidental test deletion. --- test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 6a83585..d66200d 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -61,7 +61,7 @@ TEST_PROG= testhdf5 \ dtypes dsets chunk_info cmpd_dset filter_fail extend direct_chunk \ external efc objcopy objcopy_ref links unlink twriteorder big mtime fillval mount \ flush1 flush2 app_ref enum set_extent ttsafe enc_dec_plist \ - getname vfd ros3 s3comms hdfs ntypes \ + enc_dec_plist_cross_platform getname vfd ros3 s3comms hdfs ntypes \ dangle dtransform reserved cross_read freespace mf vds file_image \ unregister cache_logging cork swmr vol -- cgit v0.12 From 3dd539473b7440f84f1297cc53d90d6d63b39ad4 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 13:48:07 -0600 Subject: Document H5D__chunk_mem_xfree_wrapper(). --- src/H5Dchunk.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 3575aab..53a2c5f 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1444,6 +1444,11 @@ H5D__chunk_mem_xfree(void *chk, void *_pline) FUNC_LEAVE_NOAPI(NULL) } /* H5D__chunk_mem_xfree() */ +/* H5D__chunk_mem_xfree_wrapper() safely adapts the type of + * H5D__chunk_mem_xfree() to an H5MM_free_t callback, without making + * compilers warn. It is used with H5D__chunk_mem_xfree_wrapper(), for + * example. + */ static void H5D__chunk_mem_xfree_wrapper(void *chk, void *_pline) { -- cgit v0.12 From 7dcd36a37da595367e3a5d95ac87062df76ef717 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 14:21:15 -0600 Subject: Move a statement under some declarations since some vintages of Visual Studio don't like declarations after statements. --- src/H5Dchunk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 53a2c5f..947f611 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -2172,10 +2172,11 @@ H5D__create_chunk_mem_map_1d(const H5D_chunk_map_t *fm) chunk_info->mspace_shared = TRUE; } /* end if */ else { - HDassert(fm->m_ndims == 1); hsize_t mem_sel_start[H5S_MAX_RANK]; /* Offset of low bound of file selection */ hsize_t mem_sel_end[H5S_MAX_RANK]; /* Offset of high bound of file selection */ + HDassert(fm->m_ndims == 1); + if(H5S_SELECT_BOUNDS(fm->mem_space, mem_sel_start, mem_sel_end) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get file selection bound info") -- cgit v0.12 From bf6b89c8414844b53497ff222f47e425345ad797 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 14:38:22 -0600 Subject: Quiet decleration-after-statement warnings. --- src/H5Rint.c | 2 +- test/dsets.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/H5Rint.c b/src/H5Rint.c index 504ae06..9fbc7ef 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -1169,8 +1169,8 @@ H5R__encode_region(H5S_t *space, unsigned char *buf, size_t *nalloc) /* Don't encode if buffer size isn't big enough or buffer is empty */ if(buf && *nalloc >= ((size_t)buf_size + 2 * H5_SIZEOF_UINT32_T)) { - p = (uint8_t *)buf; int rank; + p = (uint8_t *)buf; /* Encode the size for safety check */ UINT32ENCODE(p, (uint32_t)buf_size); diff --git a/test/dsets.c b/test/dsets.c index eaa469f..aa84833 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -7065,16 +7065,15 @@ static void make_random_offset_and_increment(long nelts, long *offsetp, long *incp) { long inc; - - HDassert(0 < nelts); - - *offsetp = HDrandom() % nelts; - /* `maxinc` is chosen so that for any `x` in [0, nelts - 1], * `x + maxinc` does not overflow a long. */ const long maxinc = MIN(nelts - 1, LONG_MAX - nelts); + HDassert(0 < nelts); + + *offsetp = HDrandom() % nelts; + /* Choose a random number in [1, nelts - 1]. If its greatest divisor * in common with `nelts` is 1, then it will "generate" the additive ring * [0, nelts - 1], so let it be our increment. Otherwise, choose a new -- cgit v0.12 From 29561bac95ad5af985afe55ba7653d1b15399650 Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 13 Nov 2019 14:39:12 -0600 Subject: Promote decleration-after-statement warnings to errors. --- config/gnu-flags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/gnu-flags b/config/gnu-flags index 101b27b..968bbfe 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -181,6 +181,7 @@ if test "X-gcc" = "X-$cc_vendor"; then H5_ECFLAGS="$H5_ECFLAGS -Werror=bad-function-cast" H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-align" H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" + H5_ECFLAGS="$H5_ECFLAGS -Werror=declaration-after-statement" # H5_ECFLAGS="$H5_ECFLAGS -Werror=discarded-qualifiers" H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" @@ -213,7 +214,6 @@ if test "X-gcc" = "X-$cc_vendor"; then # # Let's discuss: # - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wdeclaration-after-statement" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wdisabled-optimization" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunused-macros" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunsafe-loop-optimizations" -- cgit v0.12 From 559bcaf57089ca48b09d9f12ce0d6d842c56c56b Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 20 Nov 2019 15:53:46 -0600 Subject: free -> HDfree --- test/tid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tid.c b/test/tid.c index 2e8be0f..7a839d2 100644 --- a/test/tid.c +++ b/test/tid.c @@ -22,7 +22,7 @@ static herr_t free_wrapper(void *p) { - free(p); + HDfree(p); return SUCCEED; } -- cgit v0.12 From adb0c7bde53f5632d61ab48024144972a5bcb33f Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 20 Nov 2019 15:54:15 -0600 Subject: Mention the -Werror= flags in libhdf5.settings.in. --- src/libhdf5.settings.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 1591bed..0c2be75 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -39,7 +39,7 @@ Languages: H5_CPPFLAGS: @H5_CPPFLAGS@ AM_CPPFLAGS: @AM_CPPFLAGS@ C Flags: @CFLAGS@ - H5 C Flags: @H5_CFLAGS@ + H5 C Flags: @H5_CFLAGS@ @H5_ECFLAGS@ AM C Flags: @AM_CFLAGS@ Shared C Library: @enable_shared@ Static C Library: @enable_static@ -- cgit v0.12 From 456171651ae2abc58c8b5fb9a26bbf7476ed45bd Mon Sep 17 00:00:00 2001 From: David Young Date: Wed, 20 Nov 2019 16:56:00 -0600 Subject: Add new source files to CMakeLists.txt. --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c7a945e..d3f8ed8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,9 +16,11 @@ set (TEST_LIB_SOURCES ${HDF5_TEST_SOURCE_DIR}/cache_common.c ${HDF5_TEST_SOURCE_DIR}/external_common.c ${HDF5_TEST_SOURCE_DIR}/swmr_common.c + ${HDF5_TEST_SOURCE_DIR}/vds_swmr_common.c ) set (TEST_LIB_HEADERS + ${HDF5_TEST_SOURCE_DIR}/H5srcdir.h ${HDF5_TEST_SOURCE_DIR}/h5test.h ${HDF5_TEST_SOURCE_DIR}/cache_common.h ${HDF5_TEST_SOURCE_DIR}/external_common.h -- cgit v0.12 From edb6f344401209ebf90b3c085537d6934d346d66 Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 22 Nov 2019 13:41:45 -0600 Subject: Put all of the -W options back into the order I found them in so that it's easier to compare old and new config/gnu-flags. --- config/gnu-flags | 52 +++++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/config/gnu-flags b/config/gnu-flags index 968bbfe..2547b67 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -169,33 +169,40 @@ if test "X-gcc" = "X-$cc_vendor"; then # it to the developer flags. # H5_CFLAGS="$H5_CFLAGS -pedantic -Wall -Wextra" - H5_CFLAGS="$H5_CFLAGS -Wcast-qual -Wconversion -Wfloat-equal" - H5_CFLAGS="$H5_CFLAGS -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch -Wmissing-include-dirs" - H5_CFLAGS="$H5_CFLAGS -Wshadow" - H5_CFLAGS="$H5_CFLAGS -Wundef -Wwrite-strings" + H5_ECFLAGS="$H5_ECFLAGS -Werror=bad-function-cast" + H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-align" + H5_CFLAGS="$H5_CFLAGS -Wcast-qual -Wconversion" + H5_ECFLAGS="$H5_ECFLAGS -Werror=declaration-after-statement" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wdisabled-optimization" + H5_CFLAGS="$H5_CFLAGS -Wfloat-equal" + H5_CFLAGS="$H5_CFLAGS -Wformat=2 -Wno-format-nonliteral -Winit-self -Winvalid-pch" + H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-declarations" + H5_CFLAGS="$H5_CFLAGS -Wmissing-include-dirs" + H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-prototypes" + H5_ECFLAGS="$H5_ECFLAGS -Werror=nested-externs" + H5_ECFLAGS="$H5_ECFLAGS -Werror=old-style-definition" + H5_ECFLAGS="$H5_ECFLAGS -Werror=packed" + H5_ECFLAGS="$H5_ECFLAGS -Werror=redundant-decls" + H5_ECFLAGS="$H5_ECFLAGS -Werror=shadow" + H5_ECFLAGS="$H5_ECFLAGS -Werror=strict-prototypes" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wswitch-default" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wswitch-enum" + H5_CFLAGS="$H5_CFLAGS -Wundef" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunused-macros" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunsafe-loop-optimizations" + H5_CFLAGS="$H5_CFLAGS -Wwrite-strings" # # HDF5 code should not trigger the following warnings under any # circumstances, so ask the compiler to treat them as errors: # - H5_ECFLAGS="$H5_ECFLAGS -Werror=bad-function-cast" - H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-align" H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" - H5_ECFLAGS="$H5_ECFLAGS -Werror=declaration-after-statement" # H5_ECFLAGS="$H5_ECFLAGS -Werror=discarded-qualifiers" H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" H5_ECFLAGS="$H5_ECFLAGS -Werror=maybe-uninitialized" - H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-declarations" - H5_ECFLAGS="$H5_ECFLAGS -Werror=missing-prototypes" - H5_ECFLAGS="$H5_ECFLAGS -Werror=nested-externs" - H5_ECFLAGS="$H5_ECFLAGS -Werror=old-style-definition" - H5_ECFLAGS="$H5_ECFLAGS -Werror=packed" H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-sign" H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-to-int-cast" - H5_ECFLAGS="$H5_ECFLAGS -Werror=redundant-decls" - H5_ECFLAGS="$H5_ECFLAGS -Werror=shadow" - H5_ECFLAGS="$H5_ECFLAGS -Werror=strict-prototypes" H5_ECFLAGS="$H5_ECFLAGS -Werror=switch" H5_ECFLAGS="$H5_ECFLAGS -Werror=unused-but-set-variable" H5_ECFLAGS="$H5_ECFLAGS -Werror=unused-function" @@ -211,19 +218,6 @@ if test "X-gcc" = "X-$cc_vendor"; then DEVELOPER_WARNING_CFLAGS="-Winline -Waggregate-return -Wmissing-format-attribute -Wmissing-noreturn -Wformat-nonliteral" NO_DEVELOPER_WARNING_CFLAGS="-Wno-inline -Wno-aggregate-return -Wno-missing-format-attribute -Wno-missing-noreturn" - # - # Let's discuss: - # - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wdisabled-optimization" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunused-macros" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunsafe-loop-optimizations" - - # - # -Wswitch is helpful, but these seem a step too far---let's discuss: - # - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wswitch-default" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wswitch-enum" - ####################### # gcc 4 special cases # ####################### @@ -310,7 +304,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # before burdening the whole development team. # DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wstack-usage=8192" - DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wvector-operation-performance" + DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wvector-operation-performance" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn" -- cgit v0.12 From dde718ad51fdedd5318335ba6f7917f046d5ea77 Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 22 Nov 2019 13:49:59 -0600 Subject: Only use -Werror=cast-function-type with GCC 8 and later. --- config/gnu-flags | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/gnu-flags b/config/gnu-flags index 2547b67..c71974b 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -196,7 +196,6 @@ if test "X-gcc" = "X-$cc_vendor"; then # HDF5 code should not trigger the following warnings under any # circumstances, so ask the compiler to treat them as errors: # - H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" # H5_ECFLAGS="$H5_ECFLAGS -Werror=discarded-qualifiers" H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" @@ -348,6 +347,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc 8 if test $cc_vers_major -ge 8; then + H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wstringop-overflow=4 -Wsuggest-attribute=cold -Wsuggest-attribute=malloc" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc" H5_CFLAGS="$H5_CFLAGS -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2" -- cgit v0.12 From fa1dfbbd8dc1cc226e440d6a9462a4b02009f11b Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 22 Nov 2019 14:23:07 -0600 Subject: Only promote maybe-uninitialized warnings to errors on GCC 8. Even on GCC 8, there may be false positives at low optimization levels? I need to check. --- config/gnu-flags | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/config/gnu-flags b/config/gnu-flags index c71974b..d228c8b 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -199,7 +199,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # H5_ECFLAGS="$H5_ECFLAGS -Werror=discarded-qualifiers" H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" - H5_ECFLAGS="$H5_ECFLAGS -Werror=maybe-uninitialized" + H5_ECFLAGS="$H5_ECFLAGS -Wmaybe-uninitialized" H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-sign" H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-to-int-cast" H5_ECFLAGS="$H5_ECFLAGS -Werror=switch" @@ -347,6 +347,12 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc 8 if test $cc_vers_major -ge 8; then + # For GCC 8, promote maybe-initialized warnings to an error. GCC 8 + # reports 0 maybe-uninitialized warnings where earlier versions + # make many false reports. GCC 8 seems to analyze calls to static + # in order to detect initializations that occur there. It's possible + # that GCC 8 only performs that analysis at -O3, though. + H5_ECFLAGS="$H5_ECFLAGS -Werror=maybe-uninitialized" H5_ECFLAGS="$H5_ECFLAGS -Werror=cast-function-type" DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wstringop-overflow=4 -Wsuggest-attribute=cold -Wsuggest-attribute=malloc" NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc" -- cgit v0.12 From 6d5ec83fc3537ec7fc6e9f1802ae36ef9b54acb4 Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 22 Nov 2019 14:34:42 -0600 Subject: Always warn on maybe-uninitialized. -Wincompatible-pointer-types was not available until GCC 5, so enable it only if that's the GCC version we're using. --- config/gnu-flags | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/gnu-flags b/config/gnu-flags index d228c8b..bc120a8 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -198,8 +198,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # # H5_ECFLAGS="$H5_ECFLAGS -Werror=discarded-qualifiers" H5_ECFLAGS="$H5_ECFLAGS -Werror=implicit-function-declaration" - H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" - H5_ECFLAGS="$H5_ECFLAGS -Wmaybe-uninitialized" + H5_CFLAGS="$H5_CFLAGS -Wmaybe-uninitialized" H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-sign" H5_ECFLAGS="$H5_ECFLAGS -Werror=pointer-to-int-cast" H5_ECFLAGS="$H5_ECFLAGS -Werror=switch" @@ -323,6 +322,7 @@ if test "X-gcc" = "X-$cc_vendor"; then # gcc 5 if test $cc_vers_major -ge 5; then H5_CFLAGS="$H5_CFLAGS -Warray-bounds=2 -Wc99-c11-compat" + H5_ECFLAGS="$H5_ECFLAGS -Werror=incompatible-pointer-types" fi # gcc 6 -- cgit v0.12 From edd529714302f9ed218d1e61d5f496fa788d10b4 Mon Sep 17 00:00:00 2001 From: David Young Date: Fri, 22 Nov 2019 15:31:00 -0600 Subject: Quiet some more maybe-uninitialized warnings---each is a false positive, *sigh*. This is more code that may not compile with VS2010, *sigh sigh*. --- src/H5Fsuper_cache.c | 6 +++++- src/H5HFcache.c | 7 ++++++- src/H5HGcache.c | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index ecb98ed..b5e4255 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -349,7 +349,11 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len, { const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ - H5F_super_t sblock; /* Temporary file superblock */ + /* Temporary file superblock, initialized because GCC 5.5 does not + * realize that H5F__superblock_prefix_decode() initializes it. + * TBD condition on compiler version. + */ + H5F_super_t sblock = {.super_vers = 0, .sizeof_addr = 0, .sizeof_size = 0}; htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 2d1c1f2..39dc554 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -406,7 +406,12 @@ static herr_t H5HF__cache_hdr_get_final_load_size(const void *_image, size_t image_len, void *_udata, size_t *actual_len) { - H5HF_hdr_t hdr; /* Temporary fractal heap header */ + /* Temporary fractal heap header, initialized because GCC 5.5 does + * not realize that the H5HF__hdr_prefix_decode() call is sufficient + * to initialize. GCC 8 is clever enough to see that the variable + * is initialized. TBD condition on compiler version. + */ + H5HF_hdr_t hdr = {.filter_len = 0}; const uint8_t *image = (const uint8_t *)_image; /* Pointer into into supplied image */ H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5HGcache.c b/src/H5HGcache.c index 29e88df..a6c9996 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -205,7 +205,11 @@ static herr_t H5HG__cache_heap_get_final_load_size(const void *image, size_t image_len, void *udata, size_t *actual_len) { - H5HG_heap_t heap; /* Global heap */ + /* Global heap, initialized because GCC 5.5 cannot see that + * H5HG__hdr_deserialize() initializes. TBD condition on compiler + * version. + */ + H5HG_heap_t heap = {.size = 0}; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC -- cgit v0.12 From f2f8a554e65ee3e3ca501adf80fbdfd0225dac3f Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 25 Nov 2019 15:43:56 -0600 Subject: Don't use C99 designated initializers, they're not compatible with Visual Studio 2010. --- src/H5Fsuper_cache.c | 15 ++++++++++----- src/H5HFcache.c | 13 +++++++------ src/H5HGcache.c | 12 +++++++----- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index b5e4255..b7c1dad 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -349,11 +349,7 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len, { const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */ - /* Temporary file superblock, initialized because GCC 5.5 does not - * realize that H5F__superblock_prefix_decode() initializes it. - * TBD condition on compiler version. - */ - H5F_super_t sblock = {.super_vers = 0, .sizeof_addr = 0, .sizeof_size = 0}; + H5F_super_t sblock; /* Temporary file superblock */ htri_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -365,6 +361,15 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len, HDassert(*actual_len == image_len); HDassert(image_len >= H5F_SUPERBLOCK_FIXED_SIZE + 6); + /* Initialize because GCC 5.5 does not realize that + * H5F__superblock_prefix_decode() initializes it. + * + * TBD condition on compiler version. + */ + sblock.super_vers = 0; + sblock.sizeof_addr = 0; + sblock.sizeof_size = 0; + /* Deserialize the file superblock's prefix */ if(H5F__superblock_prefix_decode(&sblock, &image, udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file superblock prefix") diff --git a/src/H5HFcache.c b/src/H5HFcache.c index 39dc554..ab448ef 100644 --- a/src/H5HFcache.c +++ b/src/H5HFcache.c @@ -406,12 +406,7 @@ static herr_t H5HF__cache_hdr_get_final_load_size(const void *_image, size_t image_len, void *_udata, size_t *actual_len) { - /* Temporary fractal heap header, initialized because GCC 5.5 does - * not realize that the H5HF__hdr_prefix_decode() call is sufficient - * to initialize. GCC 8 is clever enough to see that the variable - * is initialized. TBD condition on compiler version. - */ - H5HF_hdr_t hdr = {.filter_len = 0}; + H5HF_hdr_t hdr; /* Temporary fractal heap header */ const uint8_t *image = (const uint8_t *)_image; /* Pointer into into supplied image */ H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ @@ -424,6 +419,12 @@ H5HF__cache_hdr_get_final_load_size(const void *_image, size_t image_len, HDassert(actual_len); HDassert(*actual_len == image_len); + /* Initialize because GCC 5.5 does not realize that the + * H5HF__hdr_prefix_decode() call is sufficient to initialize. + * GCC 8 is clever enough to see that the variable is initialized. + * TBD condition on compiler version. + */ + hdr.filter_len = 0; /* Deserialize the fractal heap header's prefix */ if(H5HF__hdr_prefix_decode(&hdr, &image) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode fractal heap header prefix") diff --git a/src/H5HGcache.c b/src/H5HGcache.c index a6c9996..e3d0f4c 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -205,11 +205,7 @@ static herr_t H5HG__cache_heap_get_final_load_size(const void *image, size_t image_len, void *udata, size_t *actual_len) { - /* Global heap, initialized because GCC 5.5 cannot see that - * H5HG__hdr_deserialize() initializes. TBD condition on compiler - * version. - */ - H5HG_heap_t heap = {.size = 0}; + H5HG_heap_t heap = {.size = 0}; /* Global heap */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -221,6 +217,12 @@ H5HG__cache_heap_get_final_load_size(const void *image, size_t image_len, HDassert(*actual_len == image_len); HDassert(image_len == H5HG_MINSIZE); + /* Initialize because GCC 5.5 cannot see that + * H5HG__hdr_deserialize() initializes. + * + * TBD condition on compiler version. + */ + heap.size = 0; /* Deserialize the heap's header */ if(H5HG__hdr_deserialize(&heap, (const uint8_t *)image, (const H5F_t *)udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode global heap prefix") -- cgit v0.12 From 62208b056a09c01855fbac7f75146be58ad6bfe5 Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 25 Nov 2019 16:56:03 -0600 Subject: Add an #include to get a function declaration. --- src/H5Oint.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/H5Oint.c b/src/H5Oint.c index b97ff30..0029976 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -31,6 +31,7 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5FLprivate.h" /* Free lists */ -- cgit v0.12 From f907b511d06612dafc7814a7c30f2f3d2b76d52b Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 25 Nov 2019 17:30:08 -0600 Subject: Oops, remove more C99 designated initializers for VS 2010 compatibility. --- hl/src/H5DS.c | 6 +++++- src/H5Fsuper_cache.c | 3 ++- src/H5HGcache.c | 2 +- test/fillval.c | 8 ++++++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 44e0ecf9..ce61028 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -1433,7 +1433,11 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) union { /* union is needed to eliminate compiler warnings about */ char ** buf; /* discarding the 'const' qualifier in the free */ char const ** const_buf; /* buf calls */ - } u = {.buf = NULL, .const_buf = NULL}; + } u; + + u.buf = NULL; + u.const_buf = NULL; + /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- diff --git a/src/H5Fsuper_cache.c b/src/H5Fsuper_cache.c index b7c1dad..ce216a2 100644 --- a/src/H5Fsuper_cache.c +++ b/src/H5Fsuper_cache.c @@ -881,7 +881,7 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t image_len, { const uint8_t *image = _image; /* Pointer into raw data buffer */ H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */ - H5O_drvinfo_t drvrinfo = {.len = 0}; /* Driver info */ + H5O_drvinfo_t drvrinfo; /* Driver info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -893,6 +893,7 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t image_len, HDassert(*actual_len == image_len); HDassert(image_len == H5F_DRVINFOBLOCK_HDR_SIZE); + drvrinfo.len = 0; /* Deserialize the file driver info's prefix */ if(H5F__drvrinfo_prefix_decode(&drvrinfo, NULL, &image, udata, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file driver info prefix") diff --git a/src/H5HGcache.c b/src/H5HGcache.c index e3d0f4c..9f6e73f 100644 --- a/src/H5HGcache.c +++ b/src/H5HGcache.c @@ -205,7 +205,7 @@ static herr_t H5HG__cache_heap_get_final_load_size(const void *image, size_t image_len, void *udata, size_t *actual_len) { - H5HG_heap_t heap = {.size = 0}; /* Global heap */ + H5HG_heap_t heap; /* Global heap */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC diff --git a/test/fillval.c b/test/fillval.c index 5c20e14..dd0ca7f 100644 --- a/test/fillval.c +++ b/test/fillval.c @@ -758,11 +758,15 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval, int fillval=(-1), val_rd, should_be; int i, j, *buf=NULL, odd; unsigned u; - comp_datatype rd_c, fill_c = {.a = 0, .x = 0, .y = 0, .z = 0}, - should_be_c; + comp_datatype rd_c, fill_c, should_be_c; comp_datatype *buf_c=NULL; H5D_space_status_t allocation; + fill_c.a = 0; + fill_c.x = 0; + fill_c.y = 0; + fill_c.z = 0; + if(datatype == H5T_INTEGER) { fillval = *(int*)_fillval; } -- cgit v0.12