diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2011-05-04 20:07:38 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2011-05-04 20:07:38 (GMT) |
commit | fbba9db9559924c5fab5ad969884e86ca0cc1418 (patch) | |
tree | d48ee2a7907a23ec50415eb568cb863bdf3e0b37 /tools/lib | |
parent | 2ee184118709356cfada5dd510d26148183b9259 (diff) | |
download | hdf5-fbba9db9559924c5fab5ad969884e86ca0cc1418.zip hdf5-fbba9db9559924c5fab5ad969884e86ca0cc1418.tar.gz hdf5-fbba9db9559924c5fab5ad969884e86ca0cc1418.tar.bz2 |
[svn-r20724] Purpose: Fix a bug in h5diff when enum values are compared that do
not represent a valid enum value.
Description:
The h5diff code compares enum values by converting them to strings and
then comparing them. When the enum value is out of range and can't be
converted to an enum string representation, the comparison was skipped.
The code now flags differences when one of the two enum values is out
of range (two out of range values are compared in memory). A test has
been added to the tools test script.
This fixes JIRA HDFFV-7527
Tested on: jam, koala, heiwa (h5committest)
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff_array.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index c4c8dbf..6c5744f 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -621,12 +621,43 @@ hsize_t diff_datum(void *_mem1, char enum_name1[1024]; char enum_name2[1024]; + herr_t err1; + herr_t err2; + /* disable error reporting */ H5E_BEGIN_TRY { - if ((H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1) >= 0) && - (H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2) >= 0)) + /* If the enum value cannot be converted to a string + * it is set to an error string for later output. + */ + err1 = H5Tenum_nameof(m_type, mem1, enum_name1, sizeof enum_name1); + if(err1 < 0) + strcpy(enum_name1, "**INVALID VALUE**"); + + err2 = H5Tenum_nameof(m_type, mem2, enum_name2, sizeof enum_name2); + if(err2 < 0) + strcpy(enum_name2, "**INVALID VALUE**"); + + if(err1 < 0 || err2 < 0) { + /* One or more bad enum values */ + + /* If the two values cannot be converted to a string + * (probably due to them being invalid enum values), + * don't attempt to convert them - just report errors. + */ + nfound += 1; + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(S_FORMAT,enum_name1,enum_name2); + } + } + else + { + /* Both enum values were valid */ + if (HDstrcmp(enum_name1,enum_name2)!=0) { nfound=1; |