diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-19 20:15:21 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-04-19 20:15:21 (GMT) |
commit | 099b37d073e633b0cb4d8c3f41ddf5788e63e6ee (patch) | |
tree | 3316f03ab81dbbab9160aac62fefe3f78b50c1d4 /tools/h5dump | |
parent | 94cf912176257c753eaddde0acabc9a11be2e48d (diff) | |
download | hdf5-099b37d073e633b0cb4d8c3f41ddf5788e63e6ee.zip hdf5-099b37d073e633b0cb4d8c3f41ddf5788e63e6ee.tar.gz hdf5-099b37d073e633b0cb4d8c3f41ddf5788e63e6ee.tar.bz2 |
[svn-r20559] Description:
Bring r20407:20557 from trunk to revise_chunks branch
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-ia64 2.6 (ember) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Diffstat (limited to 'tools/h5dump')
-rw-r--r-- | tools/h5dump/CMakeLists.txt | 22 | ||||
-rw-r--r-- | tools/h5dump/Makefile.in | 63 | ||||
-rw-r--r-- | tools/h5dump/h5dump.c | 293 | ||||
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 112 | ||||
-rw-r--r-- | tools/h5dump/testh5dump.sh.in | 3 |
5 files changed, 303 insertions, 190 deletions
diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 92c7149..b732bfe 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -47,7 +47,6 @@ IF (BUILD_TESTING) tall-3.ddl tall-4s.ddl tall-5s.ddl - tall-6.ddl tallfilters.ddl tarray1.ddl tarray1_big.ddl @@ -221,6 +220,11 @@ IF (BUILD_TESTING) tbin2.ddl tbin3.ddl tbin4.ddl + tall-6.ddl + texceedsubstart.ddl + texceedsubcount.ddl + texceedsubstride.ddl + texceedsubblock.ddl out3.h5import filter_fail.h5 packedbits.h5 @@ -677,6 +681,14 @@ IF (BUILD_TESTING) tindicessub3.out.err tindicessub4.out tindicessub4.out.err + texceedsubstart.out + texceedsubstart.out.err + texceedsubcount.out + texceedsubcount.out.err + texceedsubstride.out + texceedsubstride.out.err + texceedsubblock.out + texceedsubblock.out.err tindicesyes.out tindicesyes.out.err tlarge_objname.out @@ -938,6 +950,12 @@ IF (BUILD_TESTING) # 4D case ADD_H5_TEST (tindicessub4 0 -d 4d -s 0,0,1,2 -c 2,2,3,2 -S 1,1,3,3 -k 1,1,2,2 taindices.h5) + # Exceed the dimensions for subsetting + ADD_H5_TEST (texceedsubstart 1 -d 1d -s 1,3 taindices.h5) + ADD_H5_TEST (texceedsubcount 1 -d 1d -c 1,3 taindices.h5) + ADD_H5_TEST (texceedsubstride 1 -d 1d -S 1,3 taindices.h5) + ADD_H5_TEST (texceedsubblock 1 -d 1d -k 1,3 taindices.h5) + # tests for filters # SZIP SET (TESTTYPE "TEST") @@ -1092,7 +1110,7 @@ IF (BUILD_TESTING) ADD_H5_TEST (textlink 0 textlink.h5) # test for error stack display (BZ2048) - ADD_H5_MASK_TEST (filter_fail 1 -E filter_fail.h5) + ADD_H5_MASK_TEST (filter_fail 1 --enable-error-stack filter_fail.h5) # test for -o -y for dataset with attributes ADD_H5_TEST (tall-6 0 -y -o data -d /g1/g1.1/dset1.1.1 tall.h5) diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in index 40af398..57e66a2 100644 --- a/tools/h5dump/Makefile.in +++ b/tools/h5dump/Makefile.in @@ -74,13 +74,16 @@ binread_SOURCES = binread.c binread_OBJECTS = binread.$(OBJEXT) binread_LDADD = $(LDADD) binread_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) +AM_V_lt = $(am__v_lt_$(V)) +am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) +am__v_lt_0 = --silent h5dump_SOURCES = h5dump.c h5dump_OBJECTS = h5dump.$(OBJEXT) h5dump_LDADD = $(LDADD) h5dump_DEPENDENCIES = $(LIBH5TOOLS) $(LIBHDF5) -h5dump_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(h5dump_LDFLAGS) \ - $(LDFLAGS) -o $@ +h5dump_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(h5dump_LDFLAGS) $(LDFLAGS) -o $@ h5dumpgentest_SOURCES = h5dumpgentest.c h5dumpgentest_OBJECTS = h5dumpgentest.$(OBJEXT) h5dumpgentest_LDADD = $(LDADD) @@ -91,13 +94,26 @@ am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ - $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_$(V)) +am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_$(V)) +am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) +am__v_at_0 = @ CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ - --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ - $(LDFLAGS) -o $@ +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_$(V)) +am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_$(V)) +am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) +am__v_GEN_0 = @echo " GEN " $@; SOURCES = binread.c h5dump.c h5dumpgentest.c DIST_SOURCES = binread.c h5dump.c h5dumpgentest.c ETAGS = etags @@ -113,13 +129,16 @@ AMTAR = @AMTAR@ # but which should not be exported to h5cc for building other programs. # AM_CFLAGS is an automake construct which should be used by Makefiles # 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_CPPFLAGS = @AM_CPPFLAGS@ @H5_CPPFLAGS@ AM_CXXFLAGS = @AM_CXXFLAGS@ @H5_CXXFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AM_FCFLAGS = @AM_FCFLAGS@ @H5_FCFLAGS@ -AM_LDFLAGS = @AM_LDFLAGS@ +AM_LDFLAGS = @AM_LDFLAGS@ @H5_LDFLAGS@ AM_MAKEFLAGS = @AM_MAKEFLAGS@ AR = @AR@ +AS = @AS@ # Set the paths for AFS installs of autotools for Linux machines # Ideally, these tools should never be needed during the build. @@ -179,7 +198,10 @@ GREP = @GREP@ H5_CFLAGS = @H5_CFLAGS@ H5_CPPFLAGS = @H5_CPPFLAGS@ H5_CXXFLAGS = @H5_CXXFLAGS@ +H5_CXX_SHARED = @H5_CXX_SHARED@ H5_FCFLAGS = @H5_FCFLAGS@ +H5_FORTRAN_SHARED = @H5_FORTRAN_SHARED@ +H5_LDFLAGS = @H5_LDFLAGS@ H5_LONE_COLON = @H5_LONE_COLON@ H5_VERSION = @H5_VERSION@ HADDR_T = @HADDR_T@ @@ -504,13 +526,13 @@ clean-checkPROGRAMS: rm -f $$list binread$(EXEEXT): $(binread_OBJECTS) $(binread_DEPENDENCIES) @rm -f binread$(EXEEXT) - $(LINK) $(binread_OBJECTS) $(binread_LDADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(binread_OBJECTS) $(binread_LDADD) $(LIBS) h5dump$(EXEEXT): $(h5dump_OBJECTS) $(h5dump_DEPENDENCIES) @rm -f h5dump$(EXEEXT) - $(h5dump_LINK) $(h5dump_OBJECTS) $(h5dump_LDADD) $(LIBS) + $(AM_V_CCLD)$(h5dump_LINK) $(h5dump_OBJECTS) $(h5dump_LDADD) $(LIBS) h5dumpgentest$(EXEEXT): $(h5dumpgentest_OBJECTS) $(h5dumpgentest_DEPENDENCIES) @rm -f h5dumpgentest$(EXEEXT) - $(LINK) $(h5dumpgentest_OBJECTS) $(h5dumpgentest_LDADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(h5dumpgentest_OBJECTS) $(h5dumpgentest_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -523,22 +545,25 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/h5dumpgentest.Po@am__quote@ .c.o: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: -@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: -@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< -@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< diff --git a/tools/h5dump/h5dump.c b/tools/h5dump/h5dump.c index 68cbac0..a6f5510 100644 --- a/tools/h5dump/h5dump.c +++ b/tools/h5dump/h5dump.c @@ -1454,13 +1454,16 @@ dump_attr_cb(hid_t oid, const char *attr_name, const H5A_info_t UNUSED *info, vo static herr_t dump_selected_attr(hid_t loc_id, const char *name) { - hid_t oid, attr_id; + hid_t oid = -1; + hid_t attr_id = -1; char *obj_name; const char *attr_name; int j; j = (int)HDstrlen(name) - 1; obj_name = (char *)HDmalloc((size_t)j + 2); + if(obj_name == NULL) + goto error; /* find the last / */ while(j >= 0) { @@ -1486,8 +1489,7 @@ dump_selected_attr(hid_t loc_id, const char *name) indentation(COL); error_msg("unable to open object \"%s\"\n", obj_name); end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - h5tools_setstatus(EXIT_FAILURE); - return FAIL; + goto error; } /* end if */ if((attr_id = H5Aopen(oid, attr_name, H5P_DEFAULT)) >= 0) { @@ -1513,17 +1515,27 @@ dump_selected_attr(hid_t loc_id, const char *name) indentation(COL); error_msg("unable to open attribute \"%s\"\n", obj_name); end_obj(dump_header_format->attributeend, dump_header_format->attributeblockend); - h5tools_setstatus(EXIT_FAILURE); + goto error; } /* Close object */ if(H5Oclose(oid) < 0) { - h5tools_setstatus(EXIT_FAILURE); - return FAIL; + goto error; } /* end if */ HDfree(obj_name); return SUCCEED; + +error: + h5tools_setstatus(EXIT_FAILURE); + if(obj_name) + HDfree(obj_name); + + H5E_BEGIN_TRY { + H5Oclose(oid); + H5Aclose(attr_id); + } H5E_END_TRY; + return FAIL; } /*------------------------------------------------------------------------- @@ -1556,7 +1568,11 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED /* Build the object's path name */ obj_path = (char *)HDmalloc(HDstrlen(prefix) + HDstrlen(name) + 2); - HDassert(obj_path); + if(!obj_path) { + ret = FAIL; + goto done; + } + HDstrcpy(obj_path, prefix); HDstrcat(obj_path, "/"); HDstrcat(obj_path, name); @@ -1572,17 +1588,14 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED goto done; } /* end if */ - switch(oinfo.type) - { + switch(oinfo.type) { case H5O_TYPE_GROUP: - if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) - { + if((obj = H5Gopen2(group, name, H5P_DEFAULT)) < 0) { error_msg("unable to dump group \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; } - else - { + else { char *old_prefix; /* Pointer to previous prefix */ /* Keep copy of prefix before iterating into group */ @@ -1625,7 +1638,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED ret = FAIL; H5Dclose(obj); goto done; - } else if(found_obj->displayed) { + } + else if(found_obj->displayed) { indentation(indent); if(!doxml) { @@ -1636,7 +1650,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED indentation(indent); end_obj(dump_header_format->datasetend, dump_header_format->datasetblockend); - } else { + } + else { /* the XML version */ char *t_obj_path = xml_escape_the_name(obj_path); char *t_prefix = xml_escape_the_name(HDstrcmp(prefix,"") ? prefix : "/"); @@ -1676,14 +1691,16 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED H5Dclose(obj); goto done; - } else { + } + else { found_obj->displayed = TRUE; } } /* end if */ dump_function_table->dump_dataset_function(obj, name, NULL); H5Dclose(obj); - } else { + } + else { error_msg("unable to dump dataset \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; @@ -1695,7 +1712,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED error_msg("unable to dump datatype \"%s\"\n", name); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } else { + } + else { dump_function_table->dump_named_datatype_function(obj, name); H5Tclose(obj); } @@ -1726,12 +1744,14 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED error_msg("unable to get link value\n"); h5tools_setstatus(EXIT_FAILURE); ret = FAIL; - } else { + } + else { /* print the value of a soft link */ if (!doxml) { /* Standard DDL: no modification */ printf("LINKTARGET \"%s\"\n", targbuf); - } else { + } + else { /* XML */ char linkxid[100]; char parentxid[100]; @@ -1772,7 +1792,8 @@ dump_all_cb(hid_t group, const char *name, const H5L_info_t *linfo, void UNUSED targetxid, /* TargetObj */ parentxid, /* Parents */ t_prefix); /* H5ParentPaths */ - } else { + } + else { /* dangling link -- omit from xml attributes */ printf("<%sSoftLink LinkName=\"%s\" " "OBJ-XID=\"%s\" " @@ -3606,35 +3627,40 @@ handle_datasets(hid_t fid, const char *dset, void *data, int pe, const char *dis if(sset) { unsigned int i; hid_t sid = H5Dget_space(dsetid); - unsigned int ndims = H5Sget_simple_extent_ndims(sid); + int ndims = H5Sget_simple_extent_ndims(sid); H5Sclose(sid); + if(ndims < 0) { + error_msg("H5Sget_simple_extent_ndims failed\n"); + h5tools_setstatus(EXIT_FAILURE); + return; + } if(!sset->start.data || !sset->stride.data || !sset->count.data || !sset->block.data) { /* they didn't specify a ``stride'' or ``block''. default to 1 in all * dimensions */ if(!sset->start.data) { /* default to (0, 0, ...) for the start coord */ - sset->start.data = (hsize_t *)calloc(ndims, sizeof(hsize_t)); + sset->start.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t)); sset->start.len = ndims; } if(!sset->stride.data) { - sset->stride.data = (hsize_t *)calloc(ndims, sizeof(hsize_t)); + sset->stride.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t)); sset->stride.len = ndims; for (i = 0; i < ndims; i++) sset->stride.data[i] = 1; } if(!sset->count.data) { - sset->count.data = (hsize_t *)calloc(ndims, sizeof(hsize_t)); + sset->count.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t)); sset->count.len = ndims; for (i = 0; i < ndims; i++) sset->count.data[i] = 1; } if(!sset->block.data) { - sset->block.data = (hsize_t *)calloc(ndims, sizeof(hsize_t)); + sset->block.data = (hsize_t *)calloc((size_t)ndims, sizeof(hsize_t)); sset->block.len = ndims; for (i = 0; i < ndims; i++) sset->block.data[i] = 1; @@ -4223,10 +4249,10 @@ parse_start: */ do { switch ((char)opt) { - case 's': free(s->start.data); parse_hsize_list(opt_arg, &s->start); break; - case 'S': free(s->stride.data); parse_hsize_list(opt_arg, &s->stride); break; - case 'c': free(s->count.data); parse_hsize_list(opt_arg, &s->count); break; - case 'k': free(s->block.data); parse_hsize_list(opt_arg, &s->block); break; + case 's': if(s->start.data) free(s->start.data); parse_hsize_list(opt_arg, &s->start); break; + case 'S': if(s->stride.data) free(s->stride.data); parse_hsize_list(opt_arg, &s->stride); break; + case 'c': if(s->count.data) free(s->count.data); parse_hsize_list(opt_arg, &s->count); break; + case 'k': if(s->block.data) free(s->block.data); parse_hsize_list(opt_arg, &s->block); break; default: goto end_collect; } } while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF); @@ -5147,7 +5173,9 @@ xml_print_datatype(hid_t type, unsigned in_group) printf("<%sAtomicType>\n",xmlnsprefix); indent += COL; indentation(indent); - printf("<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, H5Tget_tag(type)); + mname = H5Tget_tag(type); + printf("<%sOpaqueType Tag=\"%s\" ",xmlnsprefix, mname); + free(mname); size = H5Tget_size(type); printf("Size=\"%lu\"/>\n", (unsigned long)size); indent -= COL; @@ -6096,67 +6124,68 @@ xml_dump_group(hid_t gid, const char *name) static int xml_print_refs(hid_t did, int source) { - herr_t e; - hid_t type, space; - char *buf; - hobj_ref_t *refbuf; - hsize_t ssiz; - hsize_t i; + herr_t e; + hid_t type, space; + char *buf = NULL; + hobj_ref_t *refbuf = NULL; + hssize_t ssiz; + hsize_t i; + size_t tsiz; if (source == DATASET_DATA) { type = H5Dget_type(did); - } else if (source == ATTRIBUTE_DATA) { + } + else if (source == ATTRIBUTE_DATA) { type = H5Aget_type(did); - } else { + } + else { /* return an error */ return FAIL; } if (H5Tget_class(type) != H5T_REFERENCE) { /* return an error */ - return FAIL; + goto error; } if (!H5Tequal(type, H5T_STD_REF_OBJ)) { /* region ref not supported yet... */ /* return an error */ - return FAIL; + goto error; } if (source == DATASET_DATA) { space = H5Dget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); - - buf = (char *)calloc((size_t)ssiz, sizeof(char)); - if(buf == NULL) - return FAIL; + if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) + goto error; + if ((tsiz = H5Tget_size(type)) == 0) + goto error; + + buf = (char *) calloc((size_t)(ssiz * tsiz), sizeof(char)); + if (buf == NULL) + goto error; e = H5Dread(did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); /* need to check result here */ - if(e < 0) { - free(buf); - return FAIL; + if (e < 0) { + goto error; } - } else if (source == ATTRIBUTE_DATA) { + } + else if (source == ATTRIBUTE_DATA) { space = H5Aget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); + if ((ssiz = H5Sget_simple_extent_npoints(space)) < 0) + goto error; + if ((tsiz = H5Tget_size(type)) == 0) + goto error; - buf = (char *)calloc((size_t)ssiz, sizeof(char)); + buf = (char *) calloc((size_t)(ssiz * tsiz), sizeof(char)); if (buf == NULL) { - free(buf); - return FAIL; + goto error; } e = H5Aread(did, H5T_STD_REF_OBJ, buf); /* need to check the result here */ - if(e < 0) { - free(buf); - return FAIL; + if (e < 0) { + goto error; } - } else { - /* error */ - return FAIL; } refbuf = (hobj_ref_t *) buf; - ssiz = H5Sget_simple_extent_npoints(space); for (i = 0; i < ssiz; i++) { const char *path; @@ -6166,7 +6195,8 @@ xml_print_refs(hid_t did, int source) if (!path) { printf("\"%s\"\n", "NULL"); - } else { + } + else { char *t_path = xml_escape_the_string(path, -1); printf("\"%s\"\n", t_path); @@ -6177,8 +6207,19 @@ xml_print_refs(hid_t did, int source) } free(buf); - + H5Tclose(type); + H5Sclose(space); return SUCCEED; + +error: + if(buf) + free(buf); + + H5E_BEGIN_TRY { + H5Tclose(type); + H5Sclose(space); + } H5E_END_TRY; + return FAIL; } /*------------------------------------------------------------------------- @@ -6197,77 +6238,78 @@ xml_print_refs(hid_t did, int source) static int xml_print_strs(hid_t did, int source) { - herr_t e; - hid_t type, space; - void *buf; - char *bp; - char *onestring=NULL; - hsize_t ssiz; - size_t tsiz, str_size=0; - size_t i; - htri_t is_vlstr; + herr_t e; + hid_t type, space; + void *buf = NULL; + char *bp; + char *onestring = NULL; + hssize_t ssiz; + size_t tsiz; + size_t str_size = 0; + size_t i; + htri_t is_vlstr; if (source == DATASET_DATA) { type = H5Dget_type(did); - } else if (source == ATTRIBUTE_DATA) { + } + else if (source == ATTRIBUTE_DATA) { type = H5Aget_type(did); - } else { + } + else { /* return an error */ return FAIL; } if (H5Tget_class(type) != H5T_STRING) { /* return an error */ - return FAIL; + goto error; } - is_vlstr = H5Tis_variable_str(type); + /* Check if we have VL data in the dataset's datatype */ + is_vlstr = (TRUE == H5Tis_variable_str(type)); if (source == DATASET_DATA) { space = H5Dget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); + if((ssiz = H5Sget_simple_extent_npoints(space)) < 0) + goto error; + if((tsiz = H5Tget_size(type)) == 0) + goto error; - buf = malloc((size_t)ssiz); - if(buf == NULL) - return FAIL; + buf = malloc((size_t)(ssiz * tsiz)); + if (buf == NULL) + goto error; e = H5Dread(did, type, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); if (e < 0) { - free(buf); - return FAIL; + goto error; } - } else if (source == ATTRIBUTE_DATA) { + } + else if (source == ATTRIBUTE_DATA) { space = H5Aget_space(did); - ssiz = H5Sget_simple_extent_npoints(space); - ssiz *= H5Tget_size(type); + if((ssiz = H5Sget_simple_extent_npoints(space)) < 0) + goto error; + if((tsiz = H5Tget_size(type)) == 0) + goto error; - buf = malloc((size_t)ssiz); - if(buf == NULL) - return FAIL; + buf = malloc((size_t)(ssiz * tsiz)); + if (buf == NULL) + goto error; e = H5Aread(did, type, buf); if (e < 0) { - free(buf); - return FAIL; + goto error; } - } else { - /* error */ - return FAIL; } - /* pull out each string... */ - ssiz = H5Sget_simple_extent_npoints(space); - - tsiz = H5Tget_size(type); - bp = (char*)buf; - if(!is_vlstr) - onestring = (char *)calloc(tsiz, sizeof(char)); + bp = (char*) buf; + if (!is_vlstr) + onestring = (char *) calloc(tsiz, sizeof(char)); for (i = 0; i < ssiz; i++) { - if(is_vlstr) { - onestring = *(char **)bp; - if(onestring) - str_size = (size_t)HDstrlen(onestring); - } else { + if (is_vlstr) { + onestring = *(char **) bp; + if (onestring) + str_size = (size_t) HDstrlen(onestring); + } + else { HDstrncpy(onestring, bp, tsiz); str_size = tsiz; } @@ -6275,17 +6317,40 @@ xml_print_strs(hid_t did, int source) if (!onestring) { printf("NULL\n"); - } else { - char *t_onestring = xml_escape_the_string(onestring, (int)str_size); - - printf("\"%s\"\n", t_onestring); - free(t_onestring); + } + else { + char *t_onestring = xml_escape_the_string(onestring, (int) str_size); + if (t_onestring) { + printf("\"%s\"\n", t_onestring); + free(t_onestring); + } } - bp += tsiz; + bp += tsiz; } + /* Reclaim any VL memory, if necessary */ + if (!is_vlstr) + if (onestring) + free(onestring); + if (buf) { + if (is_vlstr) + H5Dvlen_reclaim(type, space, H5P_DEFAULT, buf); + free(buf); + } + H5Tclose(type); + H5Sclose(space); return SUCCEED; + +error: + if(buf) + free(buf); + + H5E_BEGIN_TRY { + H5Tclose(type); + H5Sclose(space); + } H5E_END_TRY; + return FAIL; } /*------------------------------------------------------------------------- diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index 8771cc6..c4df6fd 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -93,10 +93,9 @@ #define FILE61 "textlinksrc.h5" #define FILE62 "textlinktar.h5" #define FILE63 "textlinkfar.h5" -/*#define FILE64 "tarray8.h5"*/ -#define FILE65 "tattrreg.h5" -#define FILE66 "file_space.h5" -#define FILE67 "packedbits.h5" +#define FILE64 "tattrreg.h5" +#define FILE65 "file_space.h5" +#define FILE66 "packedbits.h5" #define FILE68 "tdset_idx.h5" @@ -256,21 +255,21 @@ typedef struct s1_t { #define STRATEGY H5F_FILE_SPACE_AGGR_VFD /* File space handling strategy */ #define THRESHOLD10 10 /* Free space section threshold */ -/* "FILE67" macros */ -#define F67_XDIM 8 -#define F67_DATASETU08 "DU08BITS" -#define F67_DATASETS08 "DS08BITS" -#define F67_YDIM8 8 -#define F67_DATASETU16 "DU16BITS" -#define F67_DATASETS16 "DS16BITS" -#define F67_YDIM16 16 -#define F67_DATASETU32 "DU32BITS" -#define F67_DATASETS32 "DS32BITS" -#define F67_YDIM32 32 -#define F67_DATASETU64 "DU64BITS" -#define F67_DATASETS64 "DS64BITS" -#define F67_YDIM64 64 -#define F67_DUMMYDBL "DummyDBL" +/* "FILE66" macros */ +#define F66_XDIM 8 +#define F66_DATASETU08 "DU08BITS" +#define F66_DATASETS08 "DS08BITS" +#define F66_YDIM8 8 +#define F66_DATASETU16 "DU16BITS" +#define F66_DATASETS16 "DS16BITS" +#define F66_YDIM16 16 +#define F66_DATASETU32 "DU32BITS" +#define F66_DATASETS32 "DS32BITS" +#define F66_YDIM32 32 +#define F66_DATASETU64 "DU64BITS" +#define F66_DATASETS64 "DS64BITS" +#define F66_YDIM64 64 +#define F66_DUMMYDBL "DummyDBL" /* Declarations for gent_dataset_idx() for "FILE68" */ #define DSET_FIXED "dset_fixed" @@ -2181,7 +2180,7 @@ static void gent_attrreg(void) drbuf = (uint8_t*) calloc(sizeof(uint8_t),SPACE2_DIM1*SPACE2_DIM2); /* Create file */ - fid1 = H5Fcreate(FILE65, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid1 = H5Fcreate(FILE64, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Create dataspace for datasets */ sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); @@ -2836,7 +2835,7 @@ static void gent_vldatatypes5(void) static void gent_array1_big(void) { - int wdata[SPACE_ARRAY1BIG_DIM][ARRAY1BIG_DIM]; /* Information to write */ + int *wdata; /* Information to write */ hid_t fid1; /* HDF5 File IDs */ hid_t dataset; /* Dataset ID */ hid_t sid1; /* Dataspace ID */ @@ -2856,24 +2855,27 @@ static void gent_array1_big(void) hsize_t count[SPACE1_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE1_RANK]; /* Block size of hyperslab */ hdset_reg_ref_t *wbuf; /* buffer to write to disk */ + start[0] = 0; stride[0] = 1; count[0] = 999; block[0] = 1; + /* Allocate write & read buffers */ wbuf = (hdset_reg_ref_t*) calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); + wdata = (int *)malloc(sizeof(int) * (size_t)(SPACE_ARRAY1BIG_DIM * ARRAY1BIG_DIM)); /* Allocate and initialize array data to write */ - for(i=0; i<SPACE_ARRAY1BIG_DIM; i++) - for(j=0; j<ARRAY1BIG_DIM; j++) - wdata[i][j]=i*1; + for(i = 0; i < SPACE_ARRAY1BIG_DIM; i++) + for(j = 0; j < ARRAY1BIG_DIM; j++) + *(wdata + (i * ARRAY1BIG_DIM) + j) = i * 1; /* Create file */ fid1 = H5Fcreate(FILE25_BIG, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /*------------------------- * Array type dataset - * + */ /* Create dataspace for datasets */ sid1 = H5Screate_simple(SPACE1_RANK, sdims1, NULL); @@ -2916,6 +2918,10 @@ static void gent_array1_big(void) assert(ret >= 0); ret = H5Fclose(fid1); assert(ret >= 0); + + /* Release memory */ + free(wbuf); + free(wdata); } static void gent_array1(void) @@ -6894,7 +6900,7 @@ gent_fs_strategy_threshold(void) H5Pset_file_space(fcpl, STRATEGY, (hsize_t)THRESHOLD10); /* Create the file with the specified strategy and threshold */ - fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); + fid = H5Fcreate(FILE65, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); /* close */ H5Fclose(fid); @@ -7002,23 +7008,23 @@ gent_packedbits(void) { hid_t fid, dataset, space; hsize_t dims[2]; - uint8_t dsetu8[F67_XDIM][F67_YDIM8], valu8bits; - uint16_t dsetu16[F67_XDIM][F67_YDIM16], valu16bits; - uint32_t dsetu32[F67_XDIM][F67_YDIM32], valu32bits; - uint64_t dsetu64[F67_XDIM][F67_YDIM64], valu64bits; - int8_t dset8[F67_XDIM][F67_YDIM8], val8bits; - int16_t dset16[F67_XDIM][F67_YDIM16], val16bits; - int32_t dset32[F67_XDIM][F67_YDIM32], val32bits; - int64_t dset64[F67_XDIM][F67_YDIM64], val64bits; - double dsetdbl[F67_XDIM][F67_YDIM8]; + uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; + uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; + uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; + uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; + int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; + int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; + int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; + int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; + double dsetdbl[F66_XDIM][F66_YDIM8]; unsigned int i, j; fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM8; + dims[0] = F66_XDIM; dims[1] = F66_YDIM8; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETU08, H5T_STD_U8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); valu8bits = (uint8_t) ~0u; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7034,9 +7040,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 16 bits unsigned int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM16; + dims[0] = F66_XDIM; dims[1] = F66_YDIM16; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETU16, H5T_STD_U16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); valu16bits = (uint16_t) ~0u; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7052,9 +7058,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 32 bits unsigned int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM32; + dims[0] = F66_XDIM; dims[1] = F66_YDIM32; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETU32, H5T_STD_U32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); valu32bits = (uint32_t) ~0u; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7070,9 +7076,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 64 bits unsigned int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM64; + dims[0] = F66_XDIM; dims[1] = F66_YDIM64; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETU64, H5T_STD_U64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); valu64bits = (uint64_t) ~0Lu; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7088,9 +7094,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 8 bits signed int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM8; + dims[0] = F66_XDIM; dims[1] = F66_YDIM8; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETS08, H5T_STD_I8LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); val8bits = (int8_t) ~0; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7106,9 +7112,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 16 bits signed int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM16; + dims[0] = F66_XDIM; dims[1] = F66_YDIM16; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETS16, H5T_STD_I16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); val16bits = (int16_t) ~0; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7124,9 +7130,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 32 bits signed int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM32; + dims[0] = F66_XDIM; dims[1] = F66_YDIM32; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETS32, H5T_STD_I32LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); val32bits = (int32_t) ~0; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7142,9 +7148,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Dataset of 64 bits signed int */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM64; + dims[0] = F66_XDIM; dims[1] = F66_YDIM64; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DATASETS64, H5T_STD_I64LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); val64bits = (int64_t) ~0L; /* all 1s */ for(i = 0; i < dims[0]; i++){ @@ -7160,9 +7166,9 @@ gent_packedbits(void) H5Dclose(dataset); /* Double Dummy set for failure tests */ - dims[0] = F67_XDIM; dims[1] = F67_YDIM8; + dims[0] = F66_XDIM; dims[1] = F66_YDIM8; space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(fid, F67_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, F66_DUMMYDBL, H5T_IEEE_F64BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); for(i = 0; i < dims[0]; i++) for(j = 0; j < dims[1]; j++) diff --git a/tools/h5dump/testh5dump.sh.in b/tools/h5dump/testh5dump.sh.in index 70cce41..f2f0fa5 100644 --- a/tools/h5dump/testh5dump.sh.in +++ b/tools/h5dump/testh5dump.sh.in @@ -68,7 +68,6 @@ TESTING() { # non-zero value. # TOOLTEST() { - expect="$srcdir/../testfiles/$1" actual="../testfiles/`basename $1 .ddl`.out" actual_err="../testfiles/`basename $1 .ddl`.err" @@ -634,7 +633,7 @@ TOOLTEST textlink.ddl textlink.h5 TOOLTEST3 filter_fail.ddl --enable-error-stack filter_fail.h5 # test for -o -y for dataset with attributes -TOOLTEST tall-6.ddl -y -o data -d /g1/g1.1/dset1.1.1 tall.h5 +TOOLTEST1 tall-6.ddl -y -o $TESTDIR/data -d /g1/g1.1/dset1.1.1 tall.h5 # tests for Fixed Array chunk indices TOOLTEST tdset_idx.ddl -p -H tdset_idx.h5 |