diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2019-12-19 22:29:35 (GMT) |
---|---|---|
committer | David Young <dyoung@hdfgroup.org> | 2020-05-20 14:20:22 (GMT) |
commit | d486a9b27e00a4e11fb92fe5d0b2df072efef79d (patch) | |
tree | 7c18e2478e9aae0800a16c8723f8dbbd999cd955 /tools/lib/h5diff_attr.c | |
parent | b6b0567bdf6b9cb6658b8051343061ae10aec707 (diff) | |
download | hdf5-d486a9b27e00a4e11fb92fe5d0b2df072efef79d.zip hdf5-d486a9b27e00a4e11fb92fe5d0b2df072efef79d.tar.gz hdf5-d486a9b27e00a4e11fb92fe5d0b2df072efef79d.tar.bz2 |
HDFFV-10980 - h5diff uses new ref APIs
Diffstat (limited to 'tools/lib/h5diff_attr.c')
-rw-r--r-- | tools/lib/h5diff_attr.c | 469 |
1 files changed, 252 insertions, 217 deletions
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index cd906af..bd66567 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -139,10 +139,10 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta *------------------------------------------------------------------------*/ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts) { - int ret_value = 0; + H5TOOLS_ERR_INIT(herr_t, 0) H5O_info_t oinfo1, oinfo2; /* Object info */ - hid_t attr1_id = -1; /* attr ID */ - hid_t attr2_id = -1; /* attr ID */ + hid_t attr1_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr2_id = H5I_INVALID_HID; /* attr ID */ size_t curr1 = 0; size_t curr2 = 0; unsigned infile[2]; @@ -152,12 +152,17 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t unsigned i; table_attrs_t *table_lp = NULL; - h5difftrace("build_match_list_attrs start\n"); + H5TOOLS_PUSH_STACK(); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs start - errstat:%d", opts->err_stat); - if(H5Oget_info2(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) + if(H5Oget_info2(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) { H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info first object failed"); - if(H5Oget_info2(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) + } + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5Oget_info2 loc1id=%d", oinfo1.num_attrs); + if(H5Oget_info2(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) { H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Oget_info second object failed"); + } + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "H5Oget_info2 loc2id=%d", oinfo2.num_attrs); table_attrs_init(&table_lp); if (table_lp == NULL) @@ -167,8 +172,8 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t * build the list */ while(curr1 < oinfo1.num_attrs && curr2 < oinfo2.num_attrs) { - h5diffdebug3("build_match_list_attrs 1: %ld - %ld\n", curr1, oinfo1.num_attrs); - h5diffdebug3("build_match_list_attrs 2: %ld - %ld\n", curr2, oinfo2.num_attrs); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); /*------------------ * open attribute1 */ @@ -222,7 +227,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t infile[0] = 1; infile[1] = 0; while(curr1 < oinfo1.num_attrs) { - h5diffdebug3("build_match_list_attrs 1: %ld - %ld\n", curr1, oinfo1.num_attrs); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs 1: %ld - %ld", curr1, oinfo1.num_attrs); /*------------------ * open attribute1 */ @@ -231,7 +236,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /* get name */ if(H5Aget_name(attr1_id, (size_t)ATTR_NAME_MAX, name1) < 0) H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name first attribute failed"); - h5diffdebug2("build_match_list_attrs #1 name - %s\n", name1); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs #1 name - %s", name1); table_attr_mark_exist(infile, name1, table_lp); table_lp->nattrs_only1++; @@ -246,7 +251,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t infile[0] = 0; infile[1] = 1; while(curr2 < oinfo2.num_attrs) { - h5diffdebug3("build_match_list_attrs 2: %ld - %ld\n", curr2, oinfo2.num_attrs); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs 2: %ld - %ld", curr2, oinfo2.num_attrs); /*------------------ * open attribute2 */ if((attr2_id = H5Aopen_by_idx(loc2_id, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)curr2, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -254,7 +259,7 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t /* get name */ if(H5Aget_name(attr2_id, (size_t)ATTR_NAME_MAX, name2) < 0) H5TOOLS_GOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_name second attribute failed"); - h5diffdebug2("build_match_list_attrs #2 name - %s\n", name2); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs #2 name - %s", name2); table_attr_mark_exist(infile, name2, table_lp); table_lp->nattrs_only2++; @@ -294,39 +299,32 @@ done: H5Aclose(attr2_id); } H5E_END_TRY; - h5diffdebug2("build_match_list_attrs end - errstat:%d\n", opts->err_stat); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs end - errstat:%d", opts->err_stat); + H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit"); + H5TOOLS_POP_STACK(); return ret_value; } /*------------------------------------------------------------------------- - * Function: diff_attr + * Function: diff_attr_data * - * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are - * obtained either from - * loc_id = H5Gopen2(fid, name, H5P_DEFAULT); - * loc_id = H5Dopen2(fid, name); - * loc_id = H5Topen2(fid, name, H5P_DEFAULT); + * Purpose: compare attribute data located in attr1_id and attr2_id, which are + * obtained from open attributes * * Return: number of differences found *------------------------------------------------------------------------- */ -hsize_t diff_attr(hid_t loc1_id, - hid_t loc2_id, - const char *path1, - const char *path2, - diff_opt_t *opts) +hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char *name2, const char *path1, const char *path2, diff_opt_t *opts) { - int ret_value = opts->err_stat; - hid_t attr1_id = -1; /* attr ID */ - hid_t attr2_id = -1; /* attr ID */ - hid_t space1_id = -1; /* space 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 */ - hid_t mtype1_id = -1; /* memory data type ID */ - hid_t mtype2_id = -1; /* memory data type ID */ + H5TOOLS_ERR_INIT(int, opts->err_stat) + hid_t space1_id = H5I_INVALID_HID; /* space ID */ + hid_t space2_id = H5I_INVALID_HID; /* space ID */ + hid_t ftype1_id = H5I_INVALID_HID; /* file data type ID */ + hid_t ftype2_id = H5I_INVALID_HID; /* file data type ID */ + hid_t mtype1_id = H5I_INVALID_HID; /* memory data type ID */ + hid_t mtype2_id = H5I_INVALID_HID; /* memory data type ID */ size_t msize1; /* memory size of memory type */ size_t msize2; /* memory size of memory type */ void *buf1 = NULL; /* data buffer */ @@ -338,36 +336,243 @@ hsize_t diff_attr(hid_t loc1_id, int rank2; /* rank of dataset */ hsize_t dims1[H5S_MAX_RANK]; /* dimensions of dataset */ hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */ - char *name1 = NULL; - char *name2 = NULL; char np1[512]; char np2[512]; unsigned u; /* Local index variable */ hsize_t nfound = 0; - hsize_t nfound_total = 0; int j; + H5TOOLS_PUSH_STACK(); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr_data start - errstat:%d", opts->err_stat); + + /* get the datatypes */ + if((ftype1_id = H5Aget_type(attr1_id)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + if((ftype2_id = H5Aget_type(attr2_id)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + + if (H5Tget_class(ftype1_id) == H5T_REFERENCE) { + if((mtype1_id = H5Tcopy(H5T_STD_REF)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tcopy(H5T_STD_REF) first attribute ftype failed"); + } + else { + if((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed"); + } + if (H5Tget_class(ftype2_id) == H5T_REFERENCE) { + if((mtype2_id = H5Tcopy(H5T_STD_REF)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tcopy(H5T_STD_REF) second attribute ftype failed"); + } + else { + if((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed"); + } + if((msize1 = H5Tget_size(mtype1_id)) == 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed"); + if((msize2 = H5Tget_size(mtype2_id)) == 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed"); + + /* get the dataspace */ + if((space1_id = H5Aget_space(attr1_id)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space first attribute failed"); + if((space2_id = H5Aget_space(attr2_id)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space second attribute failed"); + + /* get dimensions */ + if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed"); + if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed"); + + /*---------------------------------------------------------------------- + * check for comparable TYPE and SPACE + *---------------------------------------------------------------------- + */ + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr_data check for comparable TYPE and SPACE"); + + /* pass dims1 and dims2 for maxdims as well since attribute's maxdims + * are always same */ + if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, dims1, dims2, name1, name2, opts, 0) == 1) { + /*----------------------------------------------------------------- + * "upgrade" the smaller memory size + *------------------------------------------------------------------ + */ + if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2)) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed"); + + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr_data read"); + /*--------------------------------------------------------------------- + * read + *---------------------------------------------------------------------- + */ + nelmts1 = 1; + for(j = 0; j < rank1; j++) + nelmts1 *= dims1[j]; + + buf1 = (void *)HDcalloc((size_t)(nelmts1), msize1); + buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2); + if(buf1 == NULL || buf2 == NULL) { + parallel_print("cannot read into memory\n"); + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "buffer allocation failed"); + } + if(H5Aread(attr1_id, mtype1_id, buf1) < 0) { + parallel_print("Failed reading attribute1 %s\n", name1); + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + } + else + buf1hasdata = TRUE; + + if(H5Aread(attr2_id, mtype2_id, buf2) < 0) { + parallel_print("Failed reading attribute2 %s\n", name2); + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + } + else + buf2hasdata = TRUE; + + /* format output string */ + HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1); + HDsnprintf(np2, sizeof(np1), "%s of <%s>", name2, path2); + + /*--------------------------------------------------------------------- + * array compare + *---------------------------------------------------------------------- + */ + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr_data array compare %s - %s", name1, name1); + + /* always print name */ + /* verbose (-v) and report (-r) mode */ + if(opts->m_verbose || opts->m_report) { + do_print_attrname("attribute", np1, np2); + + nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, + dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); + print_found(nfound); + } + /* quiet mode (-q), just count differences */ + else if(opts->m_quiet) { + nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, + dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); + } + /* the rest (-c, none, ...) */ + else { + nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, + dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); + + /* print info if compatible and difference found */ + if (nfound) { + do_print_attrname("attribute", np1, np2); + print_found(nfound); + } /* end if */ + } /* end else */ + } + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr_data check for comparable TYPE and SPACE complete nfound:%d - errstat:%d", nfound, opts->err_stat); + + /*---------------------------------------------------------------------- + * close + *---------------------------------------------------------------------- + */ + + /* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any + * VLEN memory first */ + if(TRUE == h5tools_detect_vlen(mtype1_id)) + H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); + HDfree(buf1); + buf1 = NULL; + + if(TRUE == h5tools_detect_vlen(mtype2_id)) + H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); + HDfree(buf2); + buf2 = NULL; + + if(H5Tclose(ftype1_id) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + if(H5Tclose(ftype2_id) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + if(H5Sclose(space1_id) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); + if(H5Sclose(space2_id) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + if(H5Tclose(mtype1_id) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); + if(H5Tclose(mtype2_id) < 0) + H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); + +done: + opts->err_stat = opts->err_stat | ret_value; + + H5E_BEGIN_TRY { + if(buf1) { + if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id)) + H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); + HDfree(buf1); + } /* end if */ + if(buf2) { + if(buf2hasdata && TRUE == h5tools_detect_vlen(mtype2_id)) + H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); + HDfree(buf2); + } /* end if */ + + H5Tclose(ftype1_id); + H5Tclose(ftype2_id); + H5Tclose(mtype1_id); + H5Tclose(mtype2_id); + H5Sclose(space1_id); + H5Sclose(space2_id); + } H5E_END_TRY; + + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr_data end - errstat:%d", opts->err_stat); + + H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit"); + H5TOOLS_POP_STACK(); + return nfound; +} + +/*------------------------------------------------------------------------- + * Function: diff_attr + * + * Purpose: compare attributes located in LOC1_ID and LOC2_ID, which are + * obtained either from + * loc_id = H5Gopen2(fid, name, H5P_DEFAULT); + * loc_id = H5Dopen2(fid, name); + * loc_id = H5Topen2(fid, name, H5P_DEFAULT); + * + * Return: number of differences found + *------------------------------------------------------------------------- + */ + +hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *path2, diff_opt_t *opts) +{ + H5TOOLS_ERR_INIT(int, opts->err_stat) + hid_t attr1_id = H5I_INVALID_HID; /* attr ID */ + hid_t attr2_id = H5I_INVALID_HID; /* attr ID */ + char *name1 = NULL; + char *name2 = NULL; + unsigned u; /* Local index variable */ + hsize_t nfound = 0; + hsize_t nfound_total = 0; + + H5TOOLS_PUSH_STACK(); table_attrs_t *match_list_attrs = NULL; - h5difftrace("diff_attr start\n"); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr start - errstat:%d", opts->err_stat); if(build_match_list_attrs(loc1_id, loc2_id, &match_list_attrs, opts) < 0) { H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "build_match_list_attrs failed"); } - h5diffdebug2("build_match_list_attrs - errstat:%d\n", opts->err_stat); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "build_match_list_attrs - errstat:%d", opts->err_stat); /* if detect any unique extra attr */ if(match_list_attrs->nattrs_only1 || match_list_attrs->nattrs_only2) { - h5difftrace("diff_attr attributes only in one file\n"); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr attributes only in one file"); /* exit will be 1 */ opts->contents = 0; } - h5diffdebug2("match_list_attrs info - errstat:%d\n", opts->err_stat); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g,"match_list_attrs info - errstat:%d", opts->err_stat); for(u = 0; u < (unsigned)match_list_attrs->nattrs; u++) { - h5diffdebug3("match_list_attrs loop[%d] - errstat:%d\n", u, opts->err_stat); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "match_list_attrs loop[%d] - errstat:%d", u, opts->err_stat); if((match_list_attrs->attrs[u].exist[0]) && (match_list_attrs->attrs[u].exist[1])) { name1 = name2 = match_list_attrs->attrs[u].name; - h5diffdebug2("diff_attr name - %s\n", name1); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr name - %s", name1); /*-------------- * attribute 1 */ @@ -379,167 +584,12 @@ hsize_t diff_attr(hid_t loc1_id, if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0) H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aopen second attribute failed"); - h5difftrace("diff_attr got attributes\n"); - /* get the datatypes */ - if((ftype1_id = H5Aget_type(attr1_id)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); - if((ftype2_id = H5Aget_type(attr2_id)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); - - if((mtype1_id = H5Tget_native_type(ftype1_id, H5T_DIR_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type first attribute ftype failed"); - if((mtype2_id = H5Tget_native_type(ftype2_id, H5T_DIR_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_native_type second attribute ftype failed"); - if((msize1 = H5Tget_size(mtype1_id)) == 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size first attribute mtype failed"); - if((msize2 = H5Tget_size(mtype2_id)) == 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tget_size second attribute mtype failed"); - - /* get the dataspace */ - if((space1_id = H5Aget_space(attr1_id)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space first attribute failed"); - if((space2_id = H5Aget_space(attr2_id)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_space second attribute failed"); - - /* get dimensions */ - if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims first attribute failed"); - if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sget_simple_extent_dims second attribute failed"); - - /*---------------------------------------------------------------------- - * check for comparable TYPE and SPACE - *---------------------------------------------------------------------- - */ - - /* pass dims1 and dims2 for maxdims as well since attribute's maxdims - * are always same */ - if(diff_can_type(ftype1_id, ftype2_id, rank1, rank2, dims1, dims2, - dims1, dims2, name1, name2, opts, 0) != 1) { - if(H5Tclose(ftype1_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute ftype failed"); - if(H5Tclose(ftype2_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute ftype failed"); - if(H5Sclose(space1_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose first attribute failed"); - if(H5Sclose(space2_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Sclose second attribute failed"); - if(H5Aclose(attr1_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose first attribute failed"); - if(H5Aclose(attr2_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aclose second attribute failed"); - if(H5Tclose(mtype1_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); - if(H5Tclose(mtype2_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); - - continue; - } - - /*----------------------------------------------------------------- - * "upgrade" the smaller memory size - *------------------------------------------------------------------ - */ - if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, - &mtype2_id, &msize1, &msize2)) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "match_up_memsize failed"); - - /*--------------------------------------------------------------------- - * read - *---------------------------------------------------------------------- - */ - nelmts1 = 1; - for(j = 0; j < rank1; j++) - nelmts1 *= dims1[j]; - - buf1 = (void *)HDcalloc((size_t)(nelmts1), msize1); - buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2); - if(buf1 == NULL || buf2 == NULL) { - parallel_print("cannot read into memory\n"); - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "buffer allocation failed"); - } - if(H5Aread(attr1_id, mtype1_id, buf1) < 0) { - parallel_print("Failed reading attribute1 %s/%s\n", path1, name1); - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); - } - else - buf1hasdata = TRUE; - - if(H5Aread(attr2_id, mtype2_id, buf2) < 0) { - parallel_print("Failed reading attribute2 %s/%s\n", path2, name2); - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); - } - else - buf2hasdata = TRUE; - - /* format output string */ - HDsnprintf(np1, sizeof(np1), "%s of <%s>", name1, path1); - HDsnprintf(np2, sizeof(np1), "%s of <%s>", name2, path2); - - /*--------------------------------------------------------------------- - * array compare - *---------------------------------------------------------------------- - */ - - /* always print name */ - /* verbose (-v) and report (-r) mode */ - if(opts->m_verbose || opts->m_report) { - do_print_attrname("attribute", np1, np2); - - nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); - print_found(nfound); - } - /* quiet mode (-q), just count differences */ - else if(opts->m_quiet) { - nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); - } - /* the rest (-c, none, ...) */ - else { - nfound = diff_array(buf1, buf2, nelmts1, (hsize_t) 0, rank1, - dims1, opts, np1, np2, mtype1_id, attr1_id, attr2_id); - - /* print info if compatible and difference found */ - if (nfound) { - do_print_attrname("attribute", np1, np2); - print_found(nfound); - } /* end if */ - } /* end else */ - - /*---------------------------------------------------------------------- - * close - *---------------------------------------------------------------------- - */ - - /* Free buf1 and buf2, check both VLEN-data VLEN-string to reclaim any - * VLEN memory first */ - if(TRUE == h5tools_detect_vlen(mtype1_id)) - H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); - HDfree(buf1); - buf1 = NULL; - - if(TRUE == h5tools_detect_vlen(mtype2_id)) - H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); - HDfree(buf2); - buf2 = NULL; - - if(H5Tclose(ftype1_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); - if(H5Tclose(ftype2_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); - if(H5Sclose(space1_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); - if(H5Sclose(space2_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr got attributes"); + nfound = diff_attr_data(attr1_id, attr2_id, name1, name2, path1, path2, opts); if(H5Aclose(attr1_id) < 0) H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type first attribute failed"); if(H5Aclose(attr2_id) < 0) H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Aget_type second attribute failed"); - if(H5Tclose(mtype1_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose first attribute mtype failed"); - if(H5Tclose(mtype2_id) < 0) - H5TOOLS_GOTO_ERROR(1, H5E_tools_min_id_g, "H5Tclose second attribute mtype failed"); nfound_total += nfound; } @@ -549,30 +599,15 @@ done: opts->err_stat = opts->err_stat | ret_value; H5E_BEGIN_TRY { - if(buf1) { - if(buf1hasdata && TRUE == h5tools_detect_vlen(mtype1_id)) - H5Treclaim(mtype1_id, space1_id, H5P_DEFAULT, buf1); - HDfree(buf1); - } /* end if */ - if(buf2) { - if(buf2hasdata && TRUE == h5tools_detect_vlen(mtype2_id)) - H5Treclaim(mtype2_id, space2_id, H5P_DEFAULT, buf2); - HDfree(buf2); - } /* end if */ - table_attrs_free(match_list_attrs); - H5Tclose(ftype1_id); - H5Tclose(ftype2_id); - H5Tclose(mtype1_id); - H5Tclose(mtype2_id); - H5Sclose(space1_id); - H5Sclose(space2_id); H5Aclose(attr1_id); H5Aclose(attr2_id); } H5E_END_TRY; - h5diffdebug2("diff_attr end - errstat:%d\n", opts->err_stat); + H5TOOLS_DEBUG(H5E_tools_min_dbg_id_g, "diff_attr end - errstat:%d", opts->err_stat); + H5TOOLS_ENDDEBUG(H5E_tools_min_dbg_id_g, "exit"); + H5TOOLS_POP_STACK(); return nfound_total; } |