diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-08 15:17:30 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-08 15:17:30 (GMT) |
commit | 837ab64fa733ce7587827380061e4a91b2e07b58 (patch) | |
tree | f22cefec5f2714420b9c949f3facdec0888ff272 /hl | |
parent | 41cea953dd4a69e4d375265f490b8f8e498bcf76 (diff) | |
download | hdf5-837ab64fa733ce7587827380061e4a91b2e07b58.zip hdf5-837ab64fa733ce7587827380061e4a91b2e07b58.tar.gz hdf5-837ab64fa733ce7587827380061e4a91b2e07b58.tar.bz2 |
[svn-r16696] #1538 (B2) Problems with Dim Scale APIs reported by Mathworks
ISSUE: When some functions are called with an invalid dimension index (for example, greater than the rank of the dataset) the function does not immediately fail, rather asserts down the code.
SOLUTION: added this check for H5DSdetach_scale, H5DSset_label, H5DSget_label (the other functions have this check) . H5DSiterate_scales also added a check for an invalid dimension scale index
TEST: added some test cases with calls to invalid indices
DOCS: Nothing added
Diffstat (limited to 'hl')
-rw-r--r-- | hl/src/H5DS.c | 162 | ||||
-rw-r--r-- | hl/test/test_ds.c | 259 |
2 files changed, 330 insertions, 91 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c index 10e552b..1d1e245 100644 --- a/hl/src/H5DS.c +++ b/hl/src/H5DS.c @@ -142,13 +142,18 @@ herr_t H5DSattach_scale(hid_t did, H5I_type_t it1, it2; int i, len; int found_ds=0; + htri_t is_scale; /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- */ + + if ((is_scale = H5DSis_scale(did)) < 0) + return FAIL; + /* the dataset cannot be a DS dataset */ - if ((H5DSis_scale(did))==1) + if ( is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ @@ -637,13 +642,18 @@ herr_t H5DSdetach_scale(hid_t did, H5O_info_t oi1, oi2, oi3, oi4; int found_dset = 0, found_ds = 0; H5I_type_t it1, it2; + htri_t is_scale; /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- */ + + if ((is_scale = H5DSis_scale(did)) < 0) + return FAIL; + /* the dataset cannot be a DS dataset */ - if ((H5DSis_scale(did))==1) + if ( is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ @@ -691,6 +701,9 @@ herr_t H5DSdetach_scale(hid_t did, if (H5Sclose(sid) < 0) return FAIL; + /* parameter range checking */ + if (idx>(unsigned)rank-1) + return FAIL; /*------------------------------------------------------------------------- * find "REFERENCE_LIST" @@ -1022,13 +1035,18 @@ htri_t H5DSis_attached(hid_t did, H5I_type_t it1, it2; int i; int found_dset=0, found_ds=0; + htri_t is_scale; /*------------------------------------------------------------------------- * parameter checking *------------------------------------------------------------------------- */ + + if ((is_scale = H5DSis_scale(did)) < 0) + return FAIL; + /* the dataset cannot be a DS dataset */ - if ((H5DSis_scale(did))==1) + if ( is_scale == 1) return FAIL; /* get info for the dataset in the parameter list */ @@ -1071,7 +1089,7 @@ htri_t H5DSis_attached(hid_t did, /* parameter range checking */ if(idx > ((unsigned)rank - 1)) - goto out; + return FAIL; /* try to find the attribute "DIMENSION_LIST" on the >>data<< dataset */ if((has_dimlist = H5LT_find_attribute(did, DIMENSION_LIST)) < 0) @@ -1339,6 +1357,13 @@ herr_t H5DSiterate_scales(hid_t did, if ((nscales = H5DSget_num_scales(did,dim)) < 0) return FAIL; + /* parameter range checking */ + if (idx!=NULL) + { + if (*idx>=nscales) + return FAIL; + } + /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; @@ -1470,16 +1495,17 @@ out: *------------------------------------------------------------------------- */ -herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { - int has_labels; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - hsize_t dims[1]; /* dimensions of dataset */ - const char **buf = NULL; /* buffer to store in the attribute */ - H5I_type_t it; /* ID type */ - unsigned int i; +herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) +{ + int has_labels; + hid_t sid = -1; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + hsize_t dims[1]; /* dimensions of dataset */ + const char **buf = NULL; /* buffer to store in the attribute */ + H5I_type_t it; /* ID type */ + unsigned int i; /*------------------------------------------------------------------------- * parameter checking @@ -1492,16 +1518,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { if (H5I_DATASET != it) return FAIL; - /*------------------------------------------------------------------------- - * attribute "DIMENSION_LABELS" - *------------------------------------------------------------------------- - */ - - /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ - if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) - return FAIL; - - /* get dataset space */ + /* get dataset space */ if ((sid = H5Dget_space(did)) < 0) return FAIL; @@ -1513,12 +1530,25 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { if (H5Sclose(sid) < 0) goto out; + if ( idx >= (unsigned)rank ) + return FAIL; + + /*------------------------------------------------------------------------- + * attribute "DIMENSION_LABELS" + *------------------------------------------------------------------------- + */ + + /* try to find the attribute "DIMENSION_LABELS" on the >>data<< dataset */ + if ((has_labels = H5LT_find_attribute(did, DIMENSION_LABELS)) < 0) + return FAIL; + /*------------------------------------------------------------------------- * make the attribute and insert label *------------------------------------------------------------------------- */ - if (has_labels == 0) { + if (has_labels == 0) + { dims[0] = rank; /* space for the attribute */ @@ -1532,8 +1562,7 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { goto out; /* create the attribute */ - if ((aid = H5Acreate2(did, DIMENSION_LABELS, tid, sid, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((aid = H5Acreate2(did, DIMENSION_LABELS, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* allocate and initialize */ @@ -1571,7 +1600,8 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { *------------------------------------------------------------------------- */ - else { + else + { if ((aid = H5Aopen(did, DIMENSION_LABELS, H5P_DEFAULT)) < 0) goto out; @@ -1603,7 +1633,8 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { buf[idx] = NULL; /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < (unsigned int) rank; i++) + { if (buf[i]) free(buf[i]); } @@ -1624,11 +1655,13 @@ herr_t H5DSset_label(hid_t did, unsigned int idx, const char *label) { /* error zone */ out: - if (buf) { + if (buf) + { if (buf[idx]) /* check if we errored during H5Awrite */ buf[idx] = NULL; /* don't free label */ /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < (unsigned int) rank; i++) + { if (buf[i]) free(buf[i]); } @@ -1664,17 +1697,18 @@ out: * *------------------------------------------------------------------------- */ -ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { - int has_labels; - hid_t sid; /* space ID */ - hid_t tid = -1; /* attribute type ID */ - hid_t aid = -1; /* attribute ID */ - int rank; /* rank of dataset */ - char **buf = NULL; /* buffer to store in the attribute */ - H5I_type_t it; /* ID type */ - size_t nbytes; - size_t copy_len; - int i; +ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) +{ + int has_labels; + hid_t sid = -1; /* space ID */ + hid_t tid = -1; /* attribute type ID */ + hid_t aid = -1; /* attribute ID */ + int rank; /* rank of dataset */ + char **buf = NULL; /* buffer to store in the attribute */ + H5I_type_t it; /* ID type */ + size_t nbytes; + size_t copy_len; + int i; /*------------------------------------------------------------------------- * parameter checking @@ -1687,6 +1721,21 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { if (H5I_DATASET != it) return FAIL; + /* get dataset space */ + if ((sid = H5Dget_space(did)) < 0) + return FAIL; + + /* get rank */ + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) + goto out; + + /* close dataset space */ + if (H5Sclose(sid) < 0) + goto out; + + if ( idx >= (unsigned)rank ) + return FAIL; + /*------------------------------------------------------------------------- * attribute "DIMENSION_LABELS" *------------------------------------------------------------------------- @@ -1702,19 +1751,7 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { if (label) label[0] = 0; return 0; - } - - /* get dataset space */ - if ((sid = H5Dget_space(did)) < 0) - return FAIL; - - /* get rank */ - if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) - goto out; - - /* close dataset space */ - if (H5Sclose(sid) < 0) - goto out; + } /*------------------------------------------------------------------------- * open the attribute and read label @@ -1745,7 +1782,8 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { copy_len = MIN(size-1, nbytes); /* copy all/some of the name */ - if (label) { + if (label) + { memcpy(label, buf[idx], copy_len); /* terminate the string */ @@ -1753,7 +1791,8 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { } /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < rank; i++) + { if (buf[i]) free(buf[i]); } @@ -1773,9 +1812,11 @@ ssize_t H5DSget_label(hid_t did, unsigned int idx, char *label, size_t size) { /* error zone */ out: - if (buf) { + if (buf) + { /* free all the ptr's from the H5Aread() */ - for (i = 0; i < (unsigned int) rank; i++) { + for (i = 0; i < rank; i++) + { if (buf[i]) free(buf[i]); } @@ -2194,7 +2235,8 @@ herr_t H5DS_is_reserved(hid_t did) /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Tclose(tid); H5Aclose(aid); } H5E_END_TRY; diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index e4d4260..48f149a 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -24,11 +24,13 @@ static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale, void *visitor_data); static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); -static herr_t op_bogus(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); +static herr_t op_continue(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); +static herr_t op_stop(hid_t did, unsigned dim, hid_t dsid, void *visitor_data); /* prototypes */ static int test_simple(void); static int test_errors(void); +static int test_errors2(void); static int test_rank(void); static int test_types(void); static int test_iterators(void); @@ -67,6 +69,8 @@ static int read_data( const char* fname, int ndims, hsize_t *dims, float **buf ) #define FILE4 "test_ds4.h5" #define FILE5 "test_ds5.h5" #define FILE6 "test_ds6.h5" +#define FILE7 "test_ds7.h5" + @@ -84,6 +88,7 @@ int main(void) nerrors += test_iterators() < 0 ?1:0; nerrors += test_types() < 0 ?1:0; nerrors += test_data() < 0 ?1:0; + nerrors += test_errors2() < 0 ?1:0; if(nerrors) goto error; printf("All dimension scales tests passed.\n"); @@ -116,13 +121,13 @@ error: static int test_simple(void) { - hid_t fid; /* file ID */ + hid_t fid = -1; /* file ID */ hid_t did = -1; /* dataset ID */ - hid_t dsid; /* DS dataset ID */ - hid_t sid; /* space ID */ - hid_t gid; /* group ID */ - int rank = RANK; /* rank of data dataset */ - int rankds = 1; /* rank of DS dataset */ + hid_t dsid = -1; /* DS dataset ID */ + hid_t sid = -1; /* space ID */ + hid_t gid = -1; /* group ID */ + int rank = RANK; /* rank of data dataset */ + int rankds = 1; /* rank of DS dataset */ hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; /* data of data dataset */ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ @@ -1434,11 +1439,15 @@ static int test_simple(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); + H5Dclose(dsid); H5Fclose(fid); + H5Sclose(sid); + H5Gclose(gid); } H5E_END_TRY; H5_FAILED(); return FAIL; @@ -1508,7 +1517,7 @@ static herr_t verify_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visit static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) { int ret = 0; /* define a default zero value for return. This will cause the iterator to continue */ - hid_t sid; /* space ID */ + hid_t sid = -1; /* space ID */ hid_t tid = -1; /* file type ID */ hid_t mtid = -1; /* memory type ID */ hssize_t nelmts; /* number of data elements */ @@ -1568,14 +1577,17 @@ static herr_t read_scale(hid_t dset, unsigned dim, hid_t scale_id, void *visitor return ret; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Tclose(tid); H5Tclose(mtid); if(buf) + { free(buf); + } } H5E_END_TRY; return FAIL; @@ -1657,7 +1669,8 @@ static herr_t match_dim_scale(hid_t did, unsigned dim, hid_t dsid, void *visitor return ret; out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); } H5E_END_TRY; return FAIL; @@ -1665,7 +1678,7 @@ out: /*------------------------------------------------------------------------- - * Function: op_bogus + * Function: op_continue * * Purpose: example operator function used by H5DSiterate_scales, that does nothing * @@ -1680,7 +1693,7 @@ out: *------------------------------------------------------------------------- */ -static herr_t op_bogus(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) +static herr_t op_continue(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) { /* Stop compiler from whining about "unused parameters" */ dset = dset; @@ -1693,6 +1706,36 @@ static herr_t op_bogus(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_d } +/*------------------------------------------------------------------------- + * Function: op_stop + * + * Purpose: example operator function used by H5DSiterate_scales, that does nothing + * + * Return: + * The return values from an operator are: + * Zero causes the iterator to continue, returning zero when all group members have been processed. + * Positive causes the iterator to immediately return that positive value, indicating + * short-circuit success. The iterator can be restarted at the next group member. + * Negative causes the iterator to immediately return that value, indicating failure. + * The iterator can be restarted at the next group member. + * + *------------------------------------------------------------------------- + */ + +static herr_t op_stop(hid_t dset, unsigned dim, hid_t scale_id, void *visitor_data) +{ + /* Stop compiler from whining about "unused parameters" */ + dset = dset; + dim = dim; + scale_id = scale_id; + visitor_data = visitor_data; + + /* define a default 1 value for return. This will cause the iterator to stop */ + return 1; +} + + + /*------------------------------------------------------------------------- * test error conditions @@ -2057,9 +2100,10 @@ static int test_errors(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Sclose(sid); H5Sclose(sidds); H5Dclose(did); @@ -2086,8 +2130,8 @@ static int test_iterators(void) hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */ hid_t gid = -1; /* group ID */ - hid_t did; /* dataset ID */ - hid_t dsid; /* scale ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* scale ID */ char dname[30]; /* dataset name */ int i; @@ -2186,7 +2230,7 @@ static int test_iterators(void) } /* iterate trough the 1st dimension of "dset_a" */ - if(H5DSiterate_scales(did,0,NULL,op_bogus,NULL) < 0) + if(H5DSiterate_scales(did,0,NULL,op_continue,NULL) < 0) goto out; /* close */ @@ -2232,7 +2276,7 @@ static int test_iterators(void) goto out; /* iterate */ - if(H5DSiterate_scales(did, 0, NULL, op_bogus, NULL) == SUCCEED) + if(H5DSiterate_scales(did, 0, NULL, op_continue, NULL) == SUCCEED) goto out; /* close */ @@ -2248,10 +2292,12 @@ static int test_iterators(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Gclose(gid); + H5Dclose(did); H5Fclose(fid); } H5E_END_TRY; H5_FAILED(); @@ -2269,8 +2315,8 @@ static int test_rank(void) hid_t fid; /* file ID */ hid_t did = -1; /* dataset ID */ hid_t dsid = -1; /* scale ID */ - hid_t sid; /* space ID */ - hid_t sidds; /* space ID */ + hid_t sid = -1; /* space ID */ + hid_t sidds = -1; /* space ID */ hsize_t dims1[1] = {DIM1_SIZE}; /* size of data dataset */ hsize_t dims2[2] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */ hsize_t dims3[3] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE}; /* size of data dataset */ @@ -2455,11 +2501,14 @@ static int test_rank(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(dsid); + H5Sclose(sidds); + H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; H5_FAILED(); @@ -2632,9 +2681,10 @@ static int test_types(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(dsid); H5Fclose(fid); @@ -2790,9 +2840,10 @@ static int test_data(void) return 0; - /* error zone, gracefully close */ + /* error zone */ out: - H5E_BEGIN_TRY { + H5E_BEGIN_TRY + { H5Dclose(did); H5Dclose(dsid); H5Fclose(fid); @@ -2882,3 +2933,149 @@ static int read_data( const char* fname, } +/*------------------------------------------------------------------------- + * test parameter errors + *------------------------------------------------------------------------- + */ + +static int test_errors2(void) +{ + hid_t fid; /* file ID */ + hid_t did = -1; /* dataset ID */ + hid_t dsid = -1; /* scale ID */ + hsize_t dimd[2] = {3,3}; /* size of data dataset */ + hsize_t dims[1] = {3}; /* size of scale dataset */ + char lbuf[255]; /* label buffer */ + size_t label_len; + int ds_idx; + + printf("Testing parameter errors\n"); + + /*------------------------------------------------------------------------- + * create a file, a dataset, scales + *------------------------------------------------------------------------- + */ + + /* create a file using default properties */ + if ((fid=H5Fcreate(FILE7,H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT)) < 0) + goto out; + + /* make a dataset */ + if (H5LTmake_dataset_int(fid,"dset",2,dimd,NULL) < 0) + goto out; + + /* make a scale dataset */ + if(H5LTmake_dataset_int(fid,"ds1",1,dims,NULL) < 0) + goto out; + + + /*------------------------------------------------------------------------- + * attach with invalid indices + *------------------------------------------------------------------------- + */ + + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0) + goto out; + if (H5DSattach_scale(did,dsid,2) == SUCCEED) + goto out; + if (H5DSattach_scale(did,dsid,0) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + + /*------------------------------------------------------------------------- + * detach with invalid indices + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0) + goto out; + if (H5DSdetach_scale(did,dsid,2) == SUCCEED) + goto out; + if (H5DSdetach_scale(did,dsid,0) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + + /*------------------------------------------------------------------------- + * set/get label invalid indices + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + if (H5DSset_label(did,2,"label")== SUCCEED) + goto out; + if (H5DSset_label(did,0,"label") < 0) + goto out; + if (H5DSget_label(did,2,lbuf,sizeof(lbuf)) == SUCCEED) + goto out; + if ((label_len=H5DSget_label(did,0,NULL,0)) < 0) + goto out; + if ( label_len != strlen("label") ) + goto out; + if (H5DSget_label(did,0,lbuf,sizeof(lbuf)) < 0) + goto out; + if (H5Dclose(did) < 0) + goto out; + + + /*------------------------------------------------------------------------- + * iterate_scales invalid indices + *------------------------------------------------------------------------- + */ + if ((did = H5Dopen2(fid,"dset", H5P_DEFAULT)) < 0) + goto out; + if ((dsid = H5Dopen2(fid,"ds1", H5P_DEFAULT)) < 0) + goto out; + if (H5DSattach_scale(did,dsid,0) < 0) + goto out; + if (H5Dclose(dsid) < 0) + goto out; + + + if (H5DSiterate_scales(did,2,NULL,op_continue,NULL)== SUCCEED) + goto out; + ds_idx = 2; /* invalid */ + if (H5DSiterate_scales(did,0,&ds_idx,op_continue,NULL)== SUCCEED) + goto out; + if (H5DSiterate_scales(did,0,NULL,op_continue,NULL) < 0) + goto out; + ds_idx = 0; + /* stop at first scale iteration and return ds_idx*/ + if (H5DSiterate_scales(did,0,&ds_idx,op_stop,NULL) < 0) + goto out; + if ( ds_idx != 0 ) + { + goto out; + } + + if (H5Dclose(did) < 0) + goto out; + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + if(H5Fclose(fid) < 0) + goto out; + + return 0; + + /* error zone */ +out: + H5E_BEGIN_TRY + { + H5Dclose(did); + H5Dclose(dsid); + H5Fclose(fid); + } H5E_END_TRY; + H5_FAILED(); + return FAIL; +}
\ No newline at end of file |