summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5diff_attr.c
diff options
context:
space:
mode:
authorAlbert Cheng <acheng@hdfgroup.org>2014-04-22 22:25:51 (GMT)
committerAlbert Cheng <acheng@hdfgroup.org>2014-04-22 22:25:51 (GMT)
commit3dc1e6dd38d665409560f79af6863019ebaa91d8 (patch)
tree1475e4d0de9b6e5ad65cf58d3ee4df01ef6ee7f5 /tools/lib/h5diff_attr.c
parent2b11123a200e4595f8bd563476486987c6cc03f4 (diff)
downloadhdf5-3dc1e6dd38d665409560f79af6863019ebaa91d8.zip
hdf5-3dc1e6dd38d665409560f79af6863019ebaa91d8.tar.gz
hdf5-3dc1e6dd38d665409560f79af6863019ebaa91d8.tar.bz2
[svn-r25081] Bug HDFFV-8625, HDFFV-8639, HDFFV-8745:
h5diff issues "unable to read attribute" error message when comparing two files Description: h5diff did not handle attributes of variable length strings correctly. It created the wrong memory type if one but not both compared attributes are of the variable strings type. It ended in H5Aread() failure. Solution: We decided to treat the case when one type is variable length string and the other is not as incomparable. That bypassed the above error. We still need to figure out the proper way, if possible, to compare variable string with non-variable string types. Tested: h5committested plus tested in Swallow (OS X 10.8).
Diffstat (limited to 'tools/lib/h5diff_attr.c')
-rw-r--r--tools/lib/h5diff_attr.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 3078369..6474082 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -326,6 +326,8 @@ hsize_t diff_attr(hid_t loc1_id,
hid_t space2_id=-1; /* space ID */
hid_t ftype1_id=-1; /* file data type ID */
hid_t ftype2_id=-1; /* file data type ID */
+ int vstrtype1=0; /* ftype1 is a variable string */
+ int vstrtype2=0; /* ftype2 is a variable string */
hid_t mtype1_id=-1; /* memory data type ID */
hid_t mtype2_id=-1; /* memory data type ID */
size_t msize1; /* memory size of memory type */
@@ -378,8 +380,19 @@ hsize_t diff_attr(hid_t loc1_id,
/* get the datatypes */
if((ftype1_id = H5Aget_type(attr1_id)) < 0)
goto error;
+ vstrtype1 = H5Tis_variable_str(ftype1_id);
if((ftype2_id = H5Aget_type(attr2_id)) < 0)
goto error;
+ vstrtype2 = H5Tis_variable_str(ftype2_id);
+ /* no compare if either one but not both are variable string type */
+ if (vstrtype1 != vstrtype2){
+ if ((options->m_verbose||options->m_list_not_cmp))
+ parallel_print("Not comparable: one of attribute <%s/%s> or <%s/%s> is of variable length type\n",
+ path1, name1, path2, name2);
+ options->not_cmp = 1;
+ return 0;
+ }
+
if((mtype1_id = h5tools_get_native_type(ftype1_id))<0)
goto error;
if((mtype2_id = h5tools_get_native_type(ftype2_id))<0)
@@ -451,16 +464,20 @@ hsize_t diff_attr(hid_t loc1_id,
buf1 = (void *)HDmalloc((size_t)(nelmts1 * msize1));
buf2 = (void *)HDmalloc((size_t)(nelmts1 * msize2));
- if(buf1 == NULL || buf2 == NULL) {
+ if(buf1 == NULL || buf2 == NULL){
parallel_print( "cannot read into memory\n" );
goto error;
}
- if(H5Aread(attr1_id,mtype1_id,buf1) < 0)
- goto error;
- buf1hasdata = 1;
- if(H5Aread(attr2_id,mtype2_id,buf2) < 0)
- goto error;
- buf2hasdata = 1;
+ if(H5Aread(attr1_id,mtype1_id,buf1) < 0){
+ parallel_print("Failed reading attribute1 %s/%s\n", path1, name1);
+ goto error;
+ }else
+ buf1hasdata = 1;
+ if(H5Aread(attr2_id,mtype2_id,buf2) < 0){
+ parallel_print("Failed reading attribute2 %s/%s\n", path2, name2);
+ goto error;
+ }else
+ buf2hasdata = 1;
/* format output string */
HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1);