summaryrefslogtreecommitdiffstats
path: root/tools/h5ls
diff options
context:
space:
mode:
authorJonathan Kim <jkm@hdfgroup.org>2012-01-06 16:17:22 (GMT)
committerJonathan Kim <jkm@hdfgroup.org>2012-01-06 16:17:22 (GMT)
commit26c62123ebc540395dce8c186eae7d4a36d74f4e (patch)
tree90d8edd5bd3cfa2c45f6ed10efe65ee251e28603 /tools/h5ls
parent677ad4d18f16c41551aabc869e66aaec8346e3be (diff)
downloadhdf5-26c62123ebc540395dce8c186eae7d4a36d74f4e.zip
hdf5-26c62123ebc540395dce8c186eae7d4a36d74f4e.tar.gz
hdf5-26c62123ebc540395dce8c186eae7d4a36d74f4e.tar.bz2
[svn-r21866] Purpose:
Fix for HDFFV-7838 h5ls: segfault for handling region reference in attribute with -v option Description: Segfault occurred when h5ls access region reference data in an attribute. This didn't occurred when -v option was used. The cause was "h5tool_format_t info;" struct variable members were accessed without proper values were assigned (was NULL), so printf failed later in the code. Merged from HDF5 trunk r21865. Tested: jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE), tejeda (mac32-LE), , cmake-Windows (32-LE)
Diffstat (limited to 'tools/h5ls')
-rw-r--r--tools/h5ls/CMakeLists.txt21
-rw-r--r--tools/h5ls/h5ls.c8
-rw-r--r--tools/h5ls/testh5ls.sh.in11
3 files changed, 36 insertions, 4 deletions
diff --git a/tools/h5ls/CMakeLists.txt b/tools/h5ls/CMakeLists.txt
index 2bbe088..ad37da0 100644
--- a/tools/h5ls/CMakeLists.txt
+++ b/tools/h5ls/CMakeLists.txt
@@ -38,6 +38,8 @@ IF (BUILD_TESTING)
tall-2.ls
tarray1.ls
tattr2.ls
+ tattrreg_le.ls
+ tattrreg_be.ls
tcomp-1.ls
tdataregbe.ls
tdataregle.ls
@@ -88,6 +90,7 @@ IF (BUILD_TESTING)
tall.h5
tarray1.h5
tattr2.h5
+ tattrreg.h5
tcompound.h5
tdatareg.h5
tdset.h5
@@ -395,16 +398,28 @@ IF (BUILD_TESTING)
# enable -S for avoiding printing NATIVE types
ADD_H5_TEST (tattr2 0 -w80 -v -S tattr2.h5)
+ # test for attribute with region references wo verbose mode
+ # ( HDFFV-7838, )
+ IF (H5_WORDS_BIGENDIAN)
+ ADD_H5_TEST (tattrreg_be 0 -w80 -v -d tattrreg.h5)
+ ELSE (H5_WORDS_BIGENDIAN)
+ ADD_H5_TEST (tattrreg_le 0 -w80 -v -d tattrreg.h5)
+ ENDIF (H5_WORDS_BIGENDIAN)
+
# test for non-existing file
ADD_H5_TEST (nosuchfile 1 nosuchfile.h5)
+ # test for variable length data types in verbose mode
IF (H5_WORDS_BIGENDIAN)
- # test for variable length data types in verbose mode
ADD_H5_TEST (tvldtypes2be 0 -v tvldtypes1.h5)
- # test for dataset region references data types in verbose mode
- ADD_H5_TEST (tdataregbe 0 -v tdatareg.h5)
ELSE (H5_WORDS_BIGENDIAN)
ADD_H5_TEST (tvldtypes2le 0 -v tvldtypes1.h5)
+ ENDIF (H5_WORDS_BIGENDIAN)
+
+ # test for dataset region references data types in verbose mode
+ IF (H5_WORDS_BIGENDIAN)
+ ADD_H5_TEST (tdataregbe 0 -v tdatareg.h5)
+ ELSE (H5_WORDS_BIGENDIAN)
ADD_H5_TEST (tdataregle 0 -v tdatareg.h5)
ENDIF (H5_WORDS_BIGENDIAN)
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c
index a00a9e1..66e588f 100644
--- a/tools/h5ls/h5ls.c
+++ b/tools/h5ls/h5ls.c
@@ -1447,9 +1447,15 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t UNUSED *ainfo,
info.line_suf = "\"";
} /* end if */
- /* values of type reference */
+ /* values of reference type formats */
+ info.dset_format = "DSET-%s ";
+ info.dset_hidefileno = 1;
+ info.dset_blockformat_pre = "%sBlk%lu: ";
+ info.dset_ptformat_pre = "%sPt%lu: ";
+
info.obj_format = "-%lu:"H5_PRINTF_HADDR_FMT;
info.obj_hidefileno = 0;
+
if(hexdump_g)
p_type = H5Tcopy(type);
else
diff --git a/tools/h5ls/testh5ls.sh.in b/tools/h5ls/testh5ls.sh.in
index bdf0af7..e2c204b 100644
--- a/tools/h5ls/testh5ls.sh.in
+++ b/tools/h5ls/testh5ls.sh.in
@@ -65,6 +65,7 @@ LIST_HDF5_TEST_FILES="
$SRC_H5LS_TESTFILES/tall.h5
$SRC_H5LS_TESTFILES/tarray1.h5
$SRC_H5LS_TESTFILES/tattr2.h5
+$SRC_H5LS_TESTFILES/tattrreg.h5
$SRC_H5LS_TESTFILES/tcompound.h5
$SRC_H5LS_TESTFILES/tdatareg.h5
$SRC_H5LS_TESTFILES/tdset.h5
@@ -94,6 +95,8 @@ $SRC_H5LS_TESTFILES/tall-1.ls
$SRC_H5LS_TESTFILES/tall-2.ls
$SRC_H5LS_TESTFILES/tarray1.ls
$SRC_H5LS_TESTFILES/tattr2.ls
+$SRC_H5LS_TESTFILES/tattrreg_le.ls
+$SRC_H5LS_TESTFILES/tattrreg_be.ls
$SRC_H5LS_TESTFILES/tcomp-1.ls
$SRC_H5LS_TESTFILES/tdataregbe.ls
$SRC_H5LS_TESTFILES/tdataregle.ls
@@ -357,6 +360,14 @@ TOOLTEST tempty.ls 0 -w80 -d tempty.h5
# enable -S for avoiding printing NATIVE types
TOOLTEST tattr2.ls 0 -w80 -v -S tattr2.h5
+# test for attribute with region references without verbose mode
+# ( HDFFV-7838, )
+if test $WORDS_BIGENDIAN != "yes"; then
+TOOLTEST tattrreg_le.ls 0 -w80 -v -d tattrreg.h5
+else
+TOOLTEST tattrreg_be.ls 0 -w80 -v -d tattrreg.h5
+fi
+
# tests for error handling.
# test for non-existing file
TOOLTEST nosuchfile.ls 1 nosuchfile.h5