From b8f131dc78aba5ce6998401bc6de2b4a69b44412 Mon Sep 17 00:00:00 2001 From: Elena Pourmal Date: Fri, 14 May 2010 23:28:50 -0500 Subject: [svn-r18820] Bug fix: Fixed a bug (1822) in the H5DSdetach_scale function when 0 bytes were allocated after the last reference to a dim. scale was removed from the list of references in a VL element of the DIMENSION_LIST attribute; modified the function to comply with the Spec: DIMENSION_LIST attribute is deleted now when no dimension scales left attached. Platforms tested: jam with electric fence, amani amd linew --- configure | 2 +- hl/src/H5DS.c | 206 +++++++++++++++++++++-------------------------- hl/test/Makefile.am | 2 +- hl/test/Makefile.in | 3 +- hl/test/test_ds.c | 147 +++++++++++++++++++++++++++++++++ release_docs/RELEASE.txt | 8 +- 6 files changed, 252 insertions(+), 116 deletions(-) diff --git a/configure b/configure index 81853fe..eac9eab 100755 --- a/configure +++ b/configure @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Id: configure.in 18748 2010-05-10 01:02:02Z hdftest . +# From configure.in Id: configure.in 18817 2010-05-14 22:05:48Z lrknox . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.65 for HDF5 1.8.4-snap22. # diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 245a2c5..936afd1 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -620,9 +620,11 @@ out: * * Date: December 20, 2004 * -* Comments: +* Comments: * -* Modifications: +* Modifications: Function didn't delete DIMENSION_LIST attribute, when +* all dimension scales were detached from a dataset; added. +* 2010/05/13 EIP * *------------------------------------------------------------------------- */ @@ -642,14 +644,15 @@ herr_t H5DSdetach_scale(hid_t did, hid_t aid = -1; /* attribute ID */ int rank; /* rank of dataset */ ds_list_t *dsbuf = NULL; /* array of attribute data in the DS pointing to the dataset */ - ds_list_t *dsbufn = NULL; /* array of attribute data in the DS pointing to the dataset */ - hsize_t *dims = NULL; /* dimension of the "REFERENCE_LIST" array */ + hsize_t dims[1]; /* dimension of the "REFERENCE_LIST" array */ hobj_ref_t ref; /* reference to the DS */ hvl_t *buf = NULL; /* VL buffer to store in the attribute */ - unsigned i, j, jj; - H5O_info_t oi1, oi2, oi3, oi4; + int i; + size_t j; + hssize_t ii; + H5O_info_t did_oi, dsid_oi, tmp_oi; int found_dset = 0, found_ds = 0; - H5I_type_t it1, it2; + int have_ds = 0; htri_t is_scale; /*------------------------------------------------------------------------- @@ -657,32 +660,28 @@ herr_t H5DSdetach_scale(hid_t did, *------------------------------------------------------------------------- */ - if ((is_scale = H5DSis_scale(did)) < 0) + /* check for valid types of identifiers */ + + if(H5I_DATASET!=H5Iget_type(did) || H5I_DATASET!=H5Iget_type(dsid)) + return FAIL; + + if((is_scale = H5DSis_scale(did)) < 0) return FAIL; /* the dataset cannot be a DS dataset */ - if ( is_scale == 1) + if( is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ - if(H5Oget_info(did, &oi1) < 0) + if(H5Oget_info(did, &did_oi) < 0) return FAIL; /* get info for the scale in the parameter list */ - if(H5Oget_info(dsid, &oi2) < 0) + if(H5Oget_info(dsid, &dsid_oi) < 0) return FAIL; /* same object, not valid */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) - return FAIL; - - /* get ID type */ - if ((it1 = H5Iget_type(did)) < 0) - return FAIL; - if ((it2 = H5Iget_type(dsid)) < 0) - return FAIL; - - if (H5I_DATASET!=it1 || H5I_DATASET!=it2) + if(did_oi.fileno == dsid_oi.fileno && did_oi.addr == dsid_oi.addr) return FAIL; @@ -761,46 +760,62 @@ herr_t H5DSdetach_scale(hid_t did, if ((dsid_j = H5Rdereference(did,H5R_OBJECT,&ref)) < 0) goto out; - /* get info for DS in the parameter list */ - if(H5Oget_info(dsid, &oi1) < 0) + /* get info for this DS */ + if(H5Oget_info(dsid_j, &tmp_oi) < 0) goto out; - /* get info for this DS */ - if(H5Oget_info(dsid_j, &oi2) < 0) + /* Close the dereferenced dataset */ + if (H5Dclose(dsid_j) < 0) goto out; /* same object, reset */ - if(oi1.fileno == oi2.fileno && oi1.addr == oi2.addr) + if(dsid_oi.fileno == tmp_oi.fileno && dsid_oi.addr == tmp_oi.addr) { - size_t len; - - for(jj=j; jj 0) { + have_ds = 1; + break; + } + } + if(have_ds) { + if(H5Awrite(aid,tid,buf) < 0) + goto out; + } + else { + if(H5Adelete(did,DIMENSION_LIST) < 0) + goto out; + } + /* close */ if (H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf) < 0) goto out; @@ -817,9 +832,6 @@ herr_t H5DSdetach_scale(hid_t did, buf = NULL; } - /* the scale must be present */ - if(found_ds == 0) - goto out; /*------------------------------------------------------------------------- * the "REFERENCE_LIST" array exists, update @@ -849,41 +861,36 @@ herr_t H5DSdetach_scale(hid_t did, if (H5Aread(aid,ntid,dsbuf) < 0) goto out; - for(i=0; i= 0) { + for (i=0; i<4; i++) { + sprintf(dname, "DS%d", i); + if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto out; + if(H5DSattach_scale(did, dsid, (unsigned int) i%3) < 0) + goto out; + if(H5Dclose(dsid) < 0) + goto out; + } + if(H5Dclose(did) < 0) + goto out; + } + else + goto out; + + /* attach scales to the second dataset */ + if((did = H5Dopen2(fid, "D1", H5P_DEFAULT)) >= 0) { + for (i=0; i<3; i++) { + sprintf(dname, "DS%d", i); + if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto out; + if(H5DSattach_scale(did, dsid, (unsigned int) i) < 0) + goto out; + if(H5Dclose(dsid) < 0) + goto out; + } + if(H5Dclose(did) < 0) + goto out; + } + else + goto out; + + /* detach DS0 from first dimension of D0 and D1; then check + that DS0 doesn't have attribute REFERENCE _LIST */ + + if((dsid = H5Dopen2(fid, "DS0", H5P_DEFAULT)) < 0) + goto out; + + for (i=0; i<2; i++) { + sprintf(dname, "D%d", i); + if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto out; + if(H5DSdetach_scale(did, dsid, (unsigned int)0) < 0) + goto out; + if(H5Dclose(did) < 0) + goto out; + } + /* Check that attribute "REFERENCE_LIST" doesn't exist anymore */ + if(H5Aexists(dsid, REFERENCE_LIST)!= 0) + goto out; + if(H5Dclose(dsid) < 0) + goto out; + /* Check that DS3 is the only dim. scale attached to the first + dimension of D0 */ + if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) < 0) + goto out; + if((dsid = H5Dopen2(fid, "DS3", H5P_DEFAULT)) < 0) + goto out; + if(H5DSis_attached(did, dsid, (unsigned int) 0) <= 0) + goto out; + if(H5Dclose(did) < 0) + goto out; + if(H5Dclose(dsid) < 0) + goto out; + + /* Detach the rest of the scales DS3, DS1, DS2 from D0 and make + sure that attribute "DIMENSION_LIST" doesn't exist anymore */ + if((did = H5Dopen2(fid, "D0", H5P_DEFAULT)) >= 0) { + for (i=1; i<4; i++) { + sprintf(dname, "DS%d", i); + if((dsid = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) + goto out; + if(H5DSdetach_scale(did, dsid, (unsigned int) i%3) < 0) + goto out; + if(H5Dclose(dsid) < 0) + goto out; + } + /* Check that attribute "DIMENSION_LIST" doesn't exist anymore */ + if(H5Aexists(did, DIMENSION_LIST)!= 0) + goto out; + if(H5Dclose(did) < 0) + goto out; + } + else + goto out; + + + PASSED(); + + H5Fclose(fid); + return SUCCEED; + +out: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Dclose(dsid); + H5Fclose(fid); + } H5E_END_TRY; + + H5_FAILED(); + + return FAIL; +} + static int test_char_attachscales(const char *fileext) { hid_t fid = -1; diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 3215f54..d2aa396 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -96,7 +96,13 @@ New Features High-Level APIs --------------- - - None + - Fixed a bug in the H5DSdetach_scale function when 0 bytes + were allocated after the last reference to a dim. scale + was removed from the list of references in a VL element of the + DIMENSION_LIST attribute; modified the function to comply + with the Spec: DIMENSION_LIST attribute is deleted now when no + dimension scales left attached. + (EIP - 2010/05/14 -1822) F90 API ------- -- cgit v0.12