diff options
-rw-r--r-- | tools/lib/h5diff.c | 133 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 98 | ||||
-rw-r--r-- | tools/lib/h5diff_attr.c | 107 | ||||
-rw-r--r-- | tools/lib/h5diff_dset.c | 88 | ||||
-rw-r--r-- | tools/lib/h5diff_util.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 128 | ||||
-rw-r--r-- | tools/lib/h5tools_dump.c | 315 | ||||
-rw-r--r-- | tools/lib/h5tools_error.h | 111 | ||||
-rw-r--r-- | tools/lib/h5tools_filters.c | 4 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 19 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 4 | ||||
-rw-r--r-- | tools/lib/h5trav.c | 26 | ||||
-rw-r--r-- | tools/src/h5copy/h5copy.c | 2 | ||||
-rw-r--r-- | tools/src/h5ls/h5ls.c | 67 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack.c | 110 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_copy.c | 232 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_filters.c | 80 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_opttable.c | 11 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_refs.c | 158 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_verify.c | 116 | ||||
-rw-r--r-- | tools/src/h5stat/h5stat.c | 8 | ||||
-rw-r--r-- | tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst | 2 |
22 files changed, 871 insertions, 952 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index d4a2d56..82c1a50 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -261,7 +261,6 @@ static void build_match_list (const char *objname1, trav_info_t *info1, const char *objname2, trav_info_t *info2, trav_table_t ** table_out, diff_opt_t *opts) { - H5TOOLS_ERR_INIT(int, 0) size_t curr1 = 0; size_t curr2 = 0; unsigned infile[2]; @@ -275,13 +274,14 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2 trav_table_t *table = NULL; size_t idx; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("build_match_list start - errstat:%d", opts->err_stat); /* init */ trav_table_init(&table); if (table == NULL) { - H5TOOLS_GOTO_ERROR(-1, "Cannot create traverse table"); + H5TOOLS_INFO("Cannot create traverse table"); + H5TOOLS_GOTO_DONE_NO_RET(); } + /* * This is necessary for the case that given objects are group and * have different names (ex: obj1 is /grp1 and obj2 is /grp5). @@ -373,9 +373,6 @@ done: *table_out = table; H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); - - H5TOOLS_DEBUG("build_match_list finish"); } @@ -402,20 +399,19 @@ trav_grp_objs(const char *path, const H5O_info_t *oinfo, static herr_t trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata) { - H5TOOLS_ERR_INIT(herr_t, 0) trav_info_t *tinfo = (trav_info_t *)udata; diff_opt_t *opts = (diff_opt_t *)tinfo->opts; h5tool_link_info_t lnk_info; const char *ext_fname; const char *ext_path; + herr_t ret_value = SUCCEED; /* init linkinfo struct */ HDmemset(&lnk_info, 0, sizeof(h5tool_link_info_t)); - H5TOOLS_PUSH_STACK(); if (!opts->follow_links) { trav_info_visit_lnk(path, linfo, tinfo); - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); } switch(linfo->type) { @@ -429,16 +425,16 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata) trav_info_visit_lnk(path, linfo, tinfo); if (opts->no_dangle_links) opts->err_stat = H5DIFF_ERR; /* make dangling link is error */ - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); } /* check if already visit the target object */ if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path)) - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); /* add this link as visited link */ if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, NULL, lnk_info.trg_path) < 0) - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) { @@ -458,19 +454,19 @@ trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata) trav_info_visit_lnk(path, linfo, tinfo); if (opts->no_dangle_links) opts->err_stat = H5DIFF_ERR; /* make dangling link is error */ - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); } if(H5Lunpack_elink_val(lnk_info.trg_path, linfo->u.val_size, NULL, &ext_fname, &ext_path) < 0) - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); /* check if already visit the target object */ if(symlink_is_visited( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path)) - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); /* add this link as visited link */ if(symlink_visit_add( &(tinfo->symlink_visited), linfo->type, ext_fname, ext_path) < 0) - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(SUCCEED); if(h5trav_visit(tinfo->fid, path, TRUE, TRUE, trav_grp_objs,trav_grp_symlinks, tinfo, H5O_INFO_BASIC) < 0) { @@ -494,7 +490,6 @@ done: if (lnk_info.trg_path) HDfree(lnk_info.trg_path); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -515,7 +510,6 @@ h5diff(const char *fname1, const char *objname2, diff_opt_t *opts) { - H5TOOLS_ERR_INIT(int, 0) hid_t file1_id = -1; hid_t file2_id = -1; char filenames[2][MAX_FILENAME]; @@ -546,8 +540,8 @@ h5diff(const char *fname1, h5tool_link_info_t trg_linfo2; /* list for common objects */ trav_table_t *match_list = NULL; + diff_err_t ret_value = H5DIFF_NO_ERR; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("h5diff start"); /* init filenames */ HDmemset(filenames, 0, MAX_FILENAME * 2); @@ -571,14 +565,14 @@ h5diff(const char *fname1, /* open file 1 */ if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname1); - H5TOOLS_GOTO_ERROR(1, "<%s>: unable to open file\n", fname1); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname1); } /* end if */ H5TOOLS_DEBUG("file1_id = %s", fname1); /* open file 2 */ if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) { parallel_print("h5diff: <%s>: unable to open file\n", fname2); - H5TOOLS_GOTO_ERROR(1, "<%s>: unable to open file\n", fname2); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname2); } /* end if */ H5TOOLS_DEBUG("file2_id = %s", fname2); @@ -597,11 +591,11 @@ h5diff(const char *fname1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj1fullname, "/%s", objname1) < 0) - H5TOOLS_GOTO_ERROR(1, "name buffer allocation failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ if ((obj1fullname = (char*)HDmalloc(HDstrlen(objname1) + 2)) == NULL) - H5TOOLS_GOTO_ERROR(1, "name buffer allocation failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); HDstrcpy(obj1fullname, "/"); HDstrcat(obj1fullname, objname1); @@ -615,11 +609,11 @@ h5diff(const char *fname1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj2fullname, "/%s", objname2) < 0) - H5TOOLS_GOTO_ERROR(1, "name buffer allocation failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); #else /* H5_HAVE_ASPRINTF */ /* (malloc 2 more for "/" and end-of-line) */ if ((obj2fullname = (char*)HDmalloc(HDstrlen(objname2) + 2)) == NULL) - H5TOOLS_GOTO_ERROR(1, "name buffer allocation failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "name buffer allocation failed"); HDstrcpy(obj2fullname, "/"); HDstrcat(obj2fullname, objname2); #endif /* H5_HAVE_ASPRINTF */ @@ -638,12 +632,12 @@ h5diff(const char *fname1, /* check if link itself exist */ if(H5Lexists(file1_id, obj1fullname, H5P_DEFAULT) <= 0) { parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); - H5TOOLS_GOTO_ERROR(1, "Error: Object could not be found"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found"); } /* get info from link */ if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj1fullname); - H5TOOLS_GOTO_ERROR(1, "H5Lget_info failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed"); } info1_lp = info1_obj; @@ -659,7 +653,7 @@ h5diff(const char *fname1, if(H5Oget_info_by_name2(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); - H5TOOLS_GOTO_ERROR(1, "Error: Could not get file contents"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents"); } obj1type = (h5trav_type_t)oinfo1.type; trav_info_add(info1_obj, obj1fullname, obj1type); @@ -688,12 +682,12 @@ h5diff(const char *fname1, /* check if link itself exist */ if(H5Lexists(file2_id, obj2fullname, H5P_DEFAULT) <= 0) { parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); - H5TOOLS_GOTO_ERROR(1, "Error: Object could not be found"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found"); } /* get info from link */ if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) { parallel_print("Unable to get link info from <%s>\n", obj2fullname); - H5TOOLS_GOTO_ERROR(1, "H5Lget_info failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed"); } info2_lp = info2_obj; @@ -709,7 +703,7 @@ h5diff(const char *fname1, if(H5Oget_info_by_name2(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) { parallel_print("Error: Could not get file contents\n"); - H5TOOLS_GOTO_ERROR(1, "Error: Could not get file contents"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents"); } obj2type = (h5trav_type_t)oinfo2.type; trav_info_add(info2_obj, obj2fullname, obj2type); @@ -761,7 +755,7 @@ h5diff(const char *fname1, /* treat dangling link as error */ if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj1fullname); - H5TOOLS_GOTO_ERROR(1, "treat dangling link as error"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error"); } else { if(opts->m_verbose) @@ -769,13 +763,13 @@ h5diff(const char *fname1, if (l_ret1 != 0 || l_ret2 != 0) { nfound++; print_found(nfound); - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); } } } else if(l_ret1 < 0) { /* fail */ parallel_print ("Object <%s> could not be found in <%s>\n", obj1fullname, fname1); - H5TOOLS_GOTO_ERROR(1, "Object could not be found"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Object could not be found"); } else if(l_ret1 != 2) { /* symbolic link */ obj1type = (h5trav_type_t)trg_linfo1.trg_type; @@ -802,7 +796,7 @@ h5diff(const char *fname1, /* treat dangling link as error */ if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", obj2fullname); - H5TOOLS_GOTO_ERROR(1, "treat dangling link as error"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "treat dangling link as error"); } else { if(opts->m_verbose) @@ -810,13 +804,13 @@ h5diff(const char *fname1, if (l_ret1 != 0 || l_ret2 != 0) { nfound++; print_found(nfound); - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); } } } else if(l_ret2 < 0) { /* fail */ parallel_print ("Object <%s> could not be found in <%s>\n", obj2fullname, fname2); - H5TOOLS_GOTO_ERROR(1, "Object could not be found"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Object could not be found"); } else if(l_ret2 != 2) { /* symbolic link */ obj2type = (h5trav_type_t)trg_linfo2.trg_type; @@ -844,7 +838,7 @@ h5diff(const char *fname1, /* if no danglink links */ if (l_ret1 > 0 && l_ret2 > 0) if (h5tools_is_obj_same(file1_id, obj1fullname, file2_id, obj2fullname) != 0) - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); } both_objs_grp = (obj1type == H5TRAV_TYPE_GROUP && obj2type == H5TRAV_TYPE_GROUP); @@ -860,7 +854,7 @@ h5diff(const char *fname1, if(h5trav_visit(file1_id, obj1fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info1_grp, H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); - H5TOOLS_GOTO_ERROR(1, "Could not get file contents"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not get file contents"); } info1_lp = info1_grp; @@ -874,7 +868,7 @@ h5diff(const char *fname1, if(h5trav_visit(file2_id, obj2fullname, TRUE, TRUE, trav_grp_objs, trav_grp_symlinks, info2_grp, H5O_INFO_BASIC) < 0) { parallel_print("Error: Could not get file contents\n"); - H5TOOLS_GOTO_ERROR(1, "Could not get file contents"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Could not get file contents"); } /* end if */ info2_lp = info2_grp; } @@ -971,7 +965,6 @@ done: H5TOOLS_DEBUG("h5diff finish - errstat:%d", opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound; } @@ -998,7 +991,6 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, hid_t file2_id, const char *grp2, trav_info_t *info2, trav_table_t *table, diff_opt_t *opts) { - H5TOOLS_ERR_INIT(int, opts->err_stat) hsize_t nfound = 0; unsigned i; const char *grp1_path = ""; @@ -1008,8 +1000,8 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, diff_args_t argdata; size_t idx1 = 0; size_t idx2 = 0; + diff_err_t ret_value = opts->err_stat; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff_match start - errstat:%d", opts->err_stat); /* * if not root, prepare object name to be pre-appended to group path to @@ -1069,11 +1061,11 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj1_fullpath, "%s%s", grp1_path, table->objs[i].name) < 0) { - H5TOOLS_ERROR(1, "name buffer allocation failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); } #else /* H5_HAVE_ASPRINTF */ if((obj1_fullpath = (char*)HDmalloc(HDstrlen(grp1_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { - H5TOOLS_ERROR(1, "name buffer allocation failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); } else { HDstrcpy(obj1_fullpath, grp1_path); @@ -1086,11 +1078,11 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, #ifdef H5_HAVE_ASPRINTF /* Use the asprintf() routine, since it does what we're trying to do below */ if(HDasprintf(&obj2_fullpath, "%s%s", grp2_path, table->objs[i].name) < 0) { - H5TOOLS_ERROR(1, "name buffer allocation failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); } #else /* H5_HAVE_ASPRINTF */ if((obj2_fullpath = (char*)HDmalloc(HDstrlen(grp2_path) + HDstrlen(table->objs[i].name) + 1)) == NULL) { - H5TOOLS_ERROR(1, "name buffer allocation failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "name buffer allocation failed"); } else { HDstrcpy(obj2_fullpath, grp2_path); @@ -1359,7 +1351,6 @@ diff_match(hid_t file1_id, const char *grp1, trav_info_t *info1, } #endif /* H5_HAVE_PARALLEL */ -done: opts->err_stat = opts->err_stat | ret_value; /* free table */ @@ -1369,7 +1360,6 @@ done: H5TOOLS_DEBUG("diff_match finish diffs=%d - errstat:%d", nfound, opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound; } @@ -1395,7 +1385,6 @@ diff(hid_t file1_id, diff_opt_t * opts, diff_args_t *argdata) { - H5TOOLS_ERR_INIT(int, opts->err_stat) int status = -1; hid_t dset1_id = H5I_INVALID_HID; hid_t dset2_id = H5I_INVALID_HID; @@ -1408,12 +1397,12 @@ diff(hid_t file1_id, hbool_t is_hard_link = FALSE; hsize_t nfound = 0; h5trav_type_t object_type; + diff_err_t ret_value = opts->err_stat; /* to get link info */ h5tool_link_info_t linkinfo1; h5tool_link_info_t linkinfo2; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff start - errstat:%d", opts->err_stat); /*init link info struct */ @@ -1437,7 +1426,7 @@ diff(hid_t file1_id, H5TOOLS_DEBUG("diff links"); /* target object1 - get type and name */ if ((status = H5tools_get_symlink_info(file1_id, path1, &linkinfo1, opts->follow_links)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5tools_get_symlink_info failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5tools_get_symlink_info failed"); /* dangling link */ if (status == 0) { @@ -1445,7 +1434,7 @@ diff(hid_t file1_id, /* dangling link is error */ if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path1); - H5TOOLS_GOTO_ERROR(1, "dangling link is error"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error"); } else is_dangle_link1 = TRUE; @@ -1453,14 +1442,14 @@ diff(hid_t file1_id, /* target object2 - get type and name */ if ((status = H5tools_get_symlink_info(file2_id, path2, &linkinfo2, opts->follow_links)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5tools_get_symlink_info failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5tools_get_symlink_info failed"); /* dangling link */ if (status == 0) { if (opts->no_dangle_links) { /* dangling link is error */ if(opts->m_verbose) parallel_print("Warning: <%s> is a dangling link.\n", path2); - H5TOOLS_GOTO_ERROR(1, "dangling link is error"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "dangling link is error"); } else is_dangle_link2 = TRUE; @@ -1468,7 +1457,7 @@ diff(hid_t file1_id, /* found dangling link */ if (is_dangle_link1 || is_dangle_link2) { - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); } /* follow symbolic link option */ @@ -1493,7 +1482,7 @@ diff(hid_t file1_id, /* TODO: will need to update non-comparable is different * opts->contents = 0; */ - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); } else /* now both object types are same */ object_type = argdata->type[0]; @@ -1545,7 +1534,7 @@ diff(hid_t file1_id, } /* if(opts->m_verbose || opts->m_report) */ /* exact same, so comparison is done */ - H5TOOLS_GOTO_DONE(0); + H5TOOLS_GOTO_DONE(H5DIFF_NO_ERR); } } @@ -1557,9 +1546,9 @@ diff(hid_t file1_id, case H5TRAV_TYPE_DATASET: H5TOOLS_DEBUG("diff object type H5TRAV_TYPE_DATASET - errstat:%d", opts->err_stat); if((dset1_id = H5Dopen2(file1_id, path1, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed"); if((dset2_id = H5Dopen2(file2_id, path2, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 failed"); /* verbose (-v) and report (-r) mode */ if(opts->m_verbose || opts->m_report) { do_print_objname("dataset", path1, path2, opts); @@ -1594,9 +1583,9 @@ diff(hid_t file1_id, } if(H5Dclose(dset1_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dclose failed"); if(H5Dclose(dset2_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dclose failed"); break; /*---------------------------------------------------------------------- @@ -1606,12 +1595,12 @@ diff(hid_t file1_id, case H5TRAV_TYPE_NAMED_DATATYPE: H5TOOLS_DEBUG("H5TRAV_TYPE_NAMED_DATATYPE 1:%s 2:%s ", path1, path2); if((type1_id = H5Topen2(file1_id, path1, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Topen2 failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Topen2 failed"); if((type2_id = H5Topen2(file2_id, path2, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Topen2 failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Topen2 failed"); if((status = H5Tequal(type1_id, type2_id)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tequal failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tequal failed"); /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ nfound = (status > 0) ? 0 : 1; @@ -1635,9 +1624,9 @@ diff(hid_t file1_id, } if(H5Tclose(type1_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose failed"); if(H5Tclose(type2_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose failed"); break; /*---------------------------------------------------------------------- @@ -1654,9 +1643,9 @@ diff(hid_t file1_id, print_found(nfound); if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); /*----------------------------------------------------------------- * compare attributes @@ -1670,9 +1659,9 @@ diff(hid_t file1_id, } if(H5Gclose(grp1_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); if(H5Gclose(grp2_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Gclose failed"); break; @@ -1694,7 +1683,6 @@ diff(hid_t file1_id, /* always print the number of differences found in verbose mode */ if(opts->m_verbose) print_found(nfound); - } break; @@ -1808,7 +1796,6 @@ done: H5TOOLS_DEBUG("diff finish:%d - errstat:%d", nfound, opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound; } diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 46de59d..98b9db3 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -275,7 +275,6 @@ hsize_t diff_array( hid_t container1_id, hid_t container2_id) /* dataset where the reference came from*/ { - H5TOOLS_ERR_INIT(int, 0) hsize_t nfound = 0; /* number of differences found */ size_t size; /* size of datum */ unsigned char *mem1 = (unsigned char*) _mem1; @@ -288,7 +287,6 @@ hsize_t diff_array( mcomp_t members; H5T_class_t type_class; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff_array start - errstat:%d", opts->err_stat); /* get the size. */ size = H5Tget_size(m_type); @@ -387,7 +385,6 @@ hsize_t diff_array( H5TOOLS_DEBUG("diff_array finish:%d - errstat:%d", nfound, opts->err_stat); H5TOOLS_ENDDEBUG("exit: %d", nfound); - H5TOOLS_POP_STACK(); return nfound; } @@ -441,7 +438,6 @@ static hsize_t diff_datum( int *ph, /*print header */ mcomp_t *members) /*compound members */ { - H5TOOLS_ERR_INIT(hsize_t, opts->err_stat) unsigned char *mem1 = (unsigned char*) _mem1; unsigned char *mem2 = (unsigned char*) _mem2; size_t u; @@ -458,8 +454,8 @@ static hsize_t diff_datum( hsize_t nfound = 0; /* differences found */ double per; hbool_t both_zero; + diff_err_t ret_value = opts->err_stat; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff_datum start - errstat:%d", opts->err_stat); type_size = H5Tget_size(m_type); @@ -481,7 +477,7 @@ static hsize_t diff_datum( case H5T_TIME: case H5T_NCLASSES: default: - H5TOOLS_GOTO_ERROR(1, "Invalid type class"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Invalid type class"); break; /*------------------------------------------------------------------------- @@ -813,9 +809,9 @@ static hsize_t diff_datum( H5TOOLS_INFO("H5Oclose H5R_OBJECT1 failed"); } if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_OBJECT1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT1 failed"); if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_OBJECT1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT1 failed"); break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); @@ -825,27 +821,27 @@ static hsize_t diff_datum( if((region2_id = H5Ropen_region(ref2_buf, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts); if(H5Sclose(region2_id) < 0) - H5TOOLS_ERROR(1, "H5Sclose H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION1 failed"); } if(H5Sclose(region1_id) < 0) - H5TOOLS_ERROR(1, "H5Sclose H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION1 failed"); } if(H5Oclose(obj2_id) < 0) - H5TOOLS_ERROR(1, "H5Oclose H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Oclose H5R_DATASET_REGION1 failed"); } else { - H5TOOLS_ERROR(1, "H5Ropen_object H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_object H5R_DATASET_REGION1 failed"); } if(H5Oclose(obj1_id) < 0) - H5TOOLS_ERROR(1, "H5Oclose H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Oclose H5R_DATASET_REGION1 failed"); } else { - H5TOOLS_ERROR(1, "H5Ropen_object H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_object H5R_DATASET_REGION1 failed"); } if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION1 failed"); if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_DATASET_REGION1 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION1 failed"); break; case H5R_OBJECT2: H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); @@ -914,9 +910,9 @@ static hsize_t diff_datum( H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); } if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_OBJECT2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT2 failed"); if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_OBJECT2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_OBJECT2 failed"); break; case H5R_DATASET_REGION2: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); @@ -925,7 +921,7 @@ static hsize_t diff_datum( obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT); obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT); if((obj1_id < 0) || (obj1_id < 0)) { - H5TOOLS_ERROR(opts->err_stat, "H5Ropen_object H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); } else { H5TOOLS_DEBUG("open_region - H5R_DATASET_REGION2"); @@ -942,16 +938,16 @@ static hsize_t diff_datum( nfound = diff_region(obj1_id, obj2_id, region1_id, region2_id, opts); } if(H5Sclose(region2_id) < 0) - H5TOOLS_ERROR(1, "H5Sclose H5R_DATASET_REGION2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION2 failed"); } else - H5TOOLS_ERROR(1, "H5Ropen_region H5R_DATASET_REGION2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed"); } /* end else to if (h5tools_is_zero(... */ if(H5Sclose(region1_id) < 0) - H5TOOLS_ERROR(1, "H5Sclose H5R_DATASET_REGION2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Sclose H5R_DATASET_REGION2 failed"); } else - H5TOOLS_ERROR(1, "H5Ropen_region H5R_DATASET_REGION2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Ropen_region H5R_DATASET_REGION2 failed"); if (obj1_id >= 0) if(H5Dclose(obj1_id) < 0) { opts->err_stat = H5DIFF_ERR; @@ -963,9 +959,9 @@ static hsize_t diff_datum( H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); } if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_DATASET_REGION2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION2 failed"); if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_DATASET_REGION2 failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_DATASET_REGION2 failed"); } break; case H5R_ATTR: @@ -984,15 +980,15 @@ static hsize_t diff_datum( } if((obj1_id < 0) || (obj1_id < 0)) { - H5TOOLS_ERROR(opts->err_stat, "H5Ropen_attr H5R_ATTR failed"); + H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); } else { /* get name */ if(H5Aget_name(obj1_id, (size_t)ATTR_NAME_MAX, name1) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_name first attribute failed"); /* get name */ if(H5Aget_name(obj2_id, (size_t)ATTR_NAME_MAX, name2) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_name second attribute failed"); H5TOOLS_DEBUG("H5R_ATTR diff_attr_data - name1=%s, name2=%s", name1, name2); nfound = diff_attr_data(obj1_id, obj2_id, name1, name2, NULL, NULL, opts); @@ -1009,9 +1005,9 @@ static hsize_t diff_datum( H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); } if(H5Rdestroy(ref2_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_ATTR failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_ATTR failed"); if(H5Rdestroy(ref1_buf) < 0) - H5TOOLS_ERROR(1, "H5Rdestroy H5R_ATTR failed"); + H5TOOLS_ERROR(H5DIFF_ERR, "H5Rdestroy H5R_ATTR failed"); } break; case H5R_BADTYPE: @@ -1151,7 +1147,7 @@ static hsize_t diff_datum( char temp2_char; if(type_size != sizeof(char)) - H5TOOLS_GOTO_ERROR(1, "Type size is not char size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not char size"); HDmemcpy(&temp1_char, mem1, sizeof(char)); HDmemcpy(&temp2_char, mem2, sizeof(char)); /* -d and !-p */ @@ -1226,7 +1222,7 @@ static hsize_t diff_datum( unsigned char temp2_uchar; if(type_size != sizeof(unsigned char)) - H5TOOLS_GOTO_ERROR(1, "Type size is not unsigned char size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned char size"); HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); @@ -1302,7 +1298,7 @@ static hsize_t diff_datum( short temp2_short; if(type_size != sizeof(short)) - H5TOOLS_GOTO_ERROR(1, "Type size is not short size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not short size"); HDmemcpy(&temp1_short, mem1, sizeof(short)); HDmemcpy(&temp2_short, mem2, sizeof(short)); @@ -1378,7 +1374,7 @@ static hsize_t diff_datum( unsigned short temp2_ushort; if(type_size != sizeof(unsigned short)) - H5TOOLS_GOTO_ERROR(1, "Type size is not unsigned short size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned short size"); HDmemcpy(&temp1_ushort, mem1, sizeof(unsigned short)); HDmemcpy(&temp2_ushort, mem2, sizeof(unsigned short)); @@ -1454,7 +1450,7 @@ static hsize_t diff_datum( int temp2_int; if(type_size != sizeof(int)) - H5TOOLS_GOTO_ERROR(1, "Type size is not int size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not int size"); HDmemcpy(&temp1_int, mem1, sizeof(int)); HDmemcpy(&temp2_int, mem2, sizeof(int)); @@ -1530,7 +1526,7 @@ static hsize_t diff_datum( unsigned int temp2_uint; if(type_size != sizeof(unsigned int)) - H5TOOLS_GOTO_ERROR(1, "Type size is not unsigned int size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned int size"); HDmemcpy(&temp1_uint, mem1, sizeof(unsigned int)); HDmemcpy(&temp2_uint, mem2, sizeof(unsigned int)); @@ -1606,7 +1602,7 @@ static hsize_t diff_datum( long temp2_long; if(type_size != sizeof(long)) - H5TOOLS_GOTO_ERROR(1, "Type size is not long size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long size"); HDmemcpy(&temp1_long, mem1, sizeof(long)); HDmemcpy(&temp2_long, mem2, sizeof(long)); @@ -1682,7 +1678,7 @@ static hsize_t diff_datum( unsigned long temp2_ulong; if(type_size != sizeof(unsigned long)) - H5TOOLS_GOTO_ERROR(1, "Type size is not unsigned long size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not unsigned long size"); HDmemcpy(&temp1_ulong, mem1, sizeof(unsigned long)); HDmemcpy(&temp2_ulong, mem2, sizeof(unsigned long)); @@ -1767,7 +1763,7 @@ static hsize_t diff_datum( hbool_t isnan2 = FALSE; if(type_size != sizeof(float)) - H5TOOLS_GOTO_ERROR(1, "Type size is not float size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size"); HDmemcpy(&temp1_float, mem1, sizeof(float)); HDmemcpy(&temp2_float, mem2, sizeof(float)); @@ -1926,7 +1922,7 @@ static hsize_t diff_datum( hbool_t isnan2 = FALSE; if(type_size != sizeof(double)) - H5TOOLS_GOTO_ERROR(1, "Type size is not double size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size"); HDmemcpy(&temp1_double, mem1, sizeof(double)); HDmemcpy(&temp2_double, mem2, sizeof(double)); @@ -2085,7 +2081,7 @@ static hsize_t diff_datum( hbool_t isnan2 = FALSE; if(type_size != sizeof(long double)) { - H5TOOLS_GOTO_ERROR(1, "Type size is not long double size"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size"); } HDmemcpy(&temp1_double, mem1, sizeof(long double)); @@ -2243,7 +2239,6 @@ done: H5TOOLS_DEBUG("diff_datum finish:%d - errstat:%d", nfound, opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound; } @@ -2320,7 +2315,6 @@ void print_points(int i, hsize_t *ptdata, int ndims) { static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t region2_id, diff_opt_t *opts) { - H5TOOLS_ERR_INIT(hsize_t, 0) hssize_t nblocks1, npoints1; hssize_t nblocks2, npoints2; hsize_t alloc_size; @@ -2331,8 +2325,8 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t int i, j; hsize_t nfound_b = 0; /* block differences found */ hsize_t nfound_p = 0; /* point differences found */ + hsize_t ret_value = 0; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff_region start"); ndims1 = H5Sget_simple_extent_ndims(region1_id); @@ -2370,7 +2364,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; - H5TOOLS_GOTO_ERROR(opts->err_stat, "Buffer allocation failed"); + H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); @@ -2378,7 +2372,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; - H5TOOLS_GOTO_ERROR(opts->err_stat, "Buffer allocation failed"); + H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); @@ -2434,7 +2428,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t if((ptdata1 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; - H5TOOLS_GOTO_ERROR(opts->err_stat, "Buffer allocation failed"); + H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); @@ -2442,7 +2436,7 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t if((ptdata2 = (hsize_t *) HDmalloc((size_t )alloc_size)) == NULL) { opts->err_stat = H5DIFF_ERR; - H5TOOLS_GOTO_ERROR(opts->err_stat, "Buffer allocation failed"); + H5TOOLS_INFO("Buffer allocation failed"); } else { H5_CHECK_OVERFLOW(npoints1, hssize_t, hsize_t); @@ -2507,7 +2501,6 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t done: H5TOOLS_ENDDEBUG("exit with diffs:%d", ret_value); - H5TOOLS_POP_STACK(); return ret_value; } @@ -2523,12 +2516,10 @@ done: static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, int rank, hsize_t *dims, hsize_t *acc, hsize_t *pos, diff_opt_t *opts, const char *obj1, const char *obj2, int *ph) { - H5TOOLS_ERR_INIT(int, 0) hsize_t nfound = 0; /* differences found */ char temp1_uchar; char temp2_uchar; - H5TOOLS_PUSH_STACK(); HDmemcpy(&temp1_uchar, mem1, sizeof(unsigned char)); HDmemcpy(&temp2_uchar, mem2, sizeof(unsigned char)); H5TOOLS_DEBUG("character_compare start %d=%d",temp1_uchar,temp2_uchar); @@ -2547,7 +2538,6 @@ static hsize_t character_compare(char *mem1, char *mem2, hsize_t i, size_t u, H5TOOLS_DEBUG("character_compare finish"); H5TOOLS_ENDDEBUG("exit: %d", nfound); - H5TOOLS_POP_STACK(); return nfound; } @@ -4519,13 +4509,12 @@ static hsize_t diff_ullong(unsigned char *mem1, unsigned char *mem2, static int ull2float(unsigned long long ull_value, float *f_value) { - H5TOOLS_ERR_INIT(int, SUCCEED) hid_t dxpl_id = -1; unsigned char *buf = NULL; size_t src_size; size_t dst_size; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("ull2float start"); if ((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed"); @@ -4554,7 +4543,6 @@ done: H5TOOLS_DEBUG("ull2float finish"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index 6b1857f..c93293b 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -139,20 +139,20 @@ 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) { - H5TOOLS_ERR_INIT(herr_t, 0) - H5O_info_t oinfo1, oinfo2; /* Object info */ - 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]; - char name1[ATTR_NAME_MAX]; - char name2[ATTR_NAME_MAX]; - int cmp; - unsigned i; table_attrs_t *table_lp = NULL; + H5O_info_t oinfo1, oinfo2; /* Object info */ + 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]; + char name1[ATTR_NAME_MAX]; + char name2[ATTR_NAME_MAX]; + int cmp; + unsigned i; + herr_t ret_value = SUCCEED; + - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("build_match_list_attrs start - errstat:%d", opts->err_stat); if(H5Oget_info2(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) { @@ -302,7 +302,6 @@ done: H5TOOLS_DEBUG("build_match_list_attrs end - errstat:%d", opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -318,7 +317,6 @@ done: 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) { - 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 */ @@ -327,8 +325,8 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const 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 */ - void *buf2 = NULL; /* data buffer */ + void *buf1 = NULL; /* data buffer */ + void *buf2 = NULL; /* data buffer */ hbool_t buf1hasdata = FALSE; /* buffer has data */ hbool_t buf2hasdata = FALSE; /* buffer has data */ hsize_t nelmts1; /* number of elements in dataset */ @@ -340,49 +338,49 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const char np2[512]; unsigned u; /* Local index variable */ hsize_t nfound = 0; - int j; + int j; + diff_err_t ret_value = opts->err_stat; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff_attr_data start - errstat:%d", opts->err_stat); /* get the datatypes */ if((ftype1_id = H5Aget_type(attr1_id)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_type first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); if((ftype2_id = H5Aget_type(attr2_id)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_type second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); if (H5Tget_class(ftype1_id) == H5T_REFERENCE) { if((mtype1_id = H5Tcopy(H5T_STD_REF)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tcopy(H5T_STD_REF) first attribute ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "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, "H5Tget_native_type first attribute ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "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, "H5Tcopy(H5T_STD_REF) second attribute ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "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, "H5Tget_native_type second attribute ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type second attribute ftype failed"); } if((msize1 = H5Tget_size(mtype1_id)) == 0) - H5TOOLS_GOTO_ERROR(1, "H5Tget_size first attribute mtype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_size first attribute mtype failed"); if((msize2 = H5Tget_size(mtype2_id)) == 0) - H5TOOLS_GOTO_ERROR(1, "H5Tget_size second attribute mtype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_size second attribute mtype failed"); /* get the dataspace */ if((space1_id = H5Aget_space(attr1_id)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_space first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_space first attribute failed"); if((space2_id = H5Aget_space(attr2_id)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_space second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_space second attribute failed"); /* get dimensions */ if((rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sget_simple_extent_dims first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims first attribute failed"); if((rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sget_simple_extent_dims second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims second attribute failed"); /*---------------------------------------------------------------------- * check for comparable TYPE and SPACE @@ -398,7 +396,7 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const *------------------------------------------------------------------ */ if(FAIL == match_up_memsize(ftype1_id, ftype2_id, &mtype1_id, &mtype2_id, &msize1, &msize2)) - H5TOOLS_GOTO_ERROR(1, "match_up_memsize failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed"); H5TOOLS_DEBUG("diff_attr_data read"); /*--------------------------------------------------------------------- @@ -413,18 +411,18 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2); if(buf1 == NULL || buf2 == NULL) { parallel_print("cannot read into memory\n"); - H5TOOLS_GOTO_ERROR(1, "buffer allocation failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "buffer allocation failed"); } if(H5Aread(attr1_id, mtype1_id, buf1) < 0) { parallel_print("Failed reading attribute1 %s\n", name1); - H5TOOLS_GOTO_ERROR(1, "H5Aget_type first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "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, "H5Aget_type second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); } else buf2hasdata = TRUE; @@ -485,17 +483,17 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const buf2 = NULL; if(H5Tclose(ftype1_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_type first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); if(H5Tclose(ftype2_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_type second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); if(H5Sclose(space1_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_type first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); if(H5Sclose(space2_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_type second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); if(H5Tclose(mtype1_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tclose first attribute mtype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose first attribute mtype failed"); if(H5Tclose(mtype2_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tclose second attribute mtype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tclose second attribute mtype failed"); done: opts->err_stat = opts->err_stat | ret_value; @@ -523,7 +521,6 @@ done: H5TOOLS_DEBUG("diff_attr_data end - errstat:%d", opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound; } @@ -542,21 +539,20 @@ done: 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; table_attrs_t *match_list_attrs = NULL; + 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; + diff_err_t ret_value = opts->err_stat; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("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, "build_match_list_attrs failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "build_match_list_attrs failed"); } H5TOOLS_DEBUG("build_match_list_attrs - errstat:%d", opts->err_stat); @@ -577,19 +573,19 @@ hsize_t diff_attr(hid_t loc1_id, hid_t loc2_id, const char *path1, const char *p /*-------------- * attribute 1 */ if((attr1_id = H5Aopen(loc1_id, name1, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aopen first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen first attribute failed"); /*-------------- * attribute 2 */ if((attr2_id = H5Aopen(loc2_id, name2, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aopen second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aopen second attribute failed"); H5TOOLS_DEBUG("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, "H5Aget_type first attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type first attribute failed"); if(H5Aclose(attr2_id) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Aget_type second attribute failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Aget_type second attribute failed"); nfound_total += nfound; } @@ -607,7 +603,6 @@ done: H5TOOLS_DEBUG("diff_attr end - errstat:%d", opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound_total; } diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c index ced72b3..8a6eeeb 100644 --- a/tools/lib/h5diff_dset.c +++ b/tools/lib/h5diff_dset.c @@ -33,15 +33,14 @@ hsize_t diff_dataset(hid_t file1_id, const char *obj2_name, diff_opt_t *opts) { - H5TOOLS_ERR_INIT(int, opts->err_stat) - int status = -1; - hid_t did1 = -1; - hid_t did2 = -1; - hid_t dcpl1 = -1; - hid_t dcpl2 = -1; - hsize_t nfound = 0; - - H5TOOLS_PUSH_STACK(); + int status = -1; + hid_t did1 = -1; + hid_t did2 = -1; + hid_t dcpl1 = -1; + hid_t dcpl2 = -1; + hsize_t nfound = 0; + diff_err_t ret_value = opts->err_stat; + H5TOOLS_DEBUG("diff_dataset start - errstat:%d", opts->err_stat); /*------------------------------------------------------------------------- * open the handles @@ -50,17 +49,17 @@ hsize_t diff_dataset(hid_t file1_id, /* Open the datasets */ if((did1 = H5Dopen2(file1_id, obj1_name, H5P_DEFAULT)) < 0) { parallel_print("Cannot open dataset <%s>\n", obj1_name); - H5TOOLS_GOTO_ERROR(1, "H5Dopen2 first dataset failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 first dataset failed"); } if((did2 = H5Dopen2(file2_id, obj2_name, H5P_DEFAULT)) < 0) { parallel_print("Cannot open dataset <%s>\n", obj2_name); - H5TOOLS_GOTO_ERROR(1, "H5Dopen2 second dataset failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dopen2 second dataset failed"); } if((dcpl1 = H5Dget_create_plist(did1)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dget_create_plist first dataset failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist first dataset failed"); if((dcpl2 = H5Dget_create_plist(did2)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dget_create_plist second dataset failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist second dataset failed"); /*------------------------------------------------------------------------- * check if the dataset creation property list has filters that @@ -74,7 +73,7 @@ hsize_t diff_dataset(hid_t file1_id, (status = h5tools_canreadf((opts->m_verbose ? obj2_name : NULL), dcpl2) == 1)) nfound = diff_datasetid(did1, did2, obj1_name, obj2_name, opts); else if (status < 0) { - H5TOOLS_GOTO_ERROR(1, "h5tools_canreadf failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "h5tools_canreadf failed"); } else { ret_value = 1; @@ -95,7 +94,6 @@ done: H5TOOLS_DEBUG("diff_dataset finish:%d - errstat:%d", nfound, opts->err_stat); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound; } @@ -156,7 +154,6 @@ hsize_t diff_datasetid(hid_t did1, const char *obj2_name, diff_opt_t *opts) { - H5TOOLS_ERR_INIT(int, opts->err_stat) hid_t sid1 = H5I_INVALID_HID; hid_t sid2 = H5I_INVALID_HID; hid_t f_tid1 = H5I_INVALID_HID; @@ -198,32 +195,32 @@ hsize_t diff_datasetid(hid_t did1, int i; unsigned int vl_data1 = 0; /*contains VL datatypes */ unsigned int vl_data2 = 0; /*contains VL datatypes */ + diff_err_t ret_value = opts->err_stat; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff_datasetid start - errstat:%d", opts->err_stat); /* Get the dataspace handle */ if((sid1 = H5Dget_space(did1)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_space failed"); /* Get rank */ if((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_ndims failed"); /* Get the dataspace handle */ if((sid2 = H5Dget_space(did2)) < 0 ) - H5TOOLS_GOTO_ERROR(1, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_space failed"); /* Get rank */ if((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_ndims failed"); /* Get dimensions */ if(H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims failed"); /* Get dimensions */ if(H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sget_simple_extent_dims failed"); H5TOOLS_DEBUG("rank: %ld - %ld", rank1, rank2); /*------------------------------------------------------------------------- @@ -233,25 +230,25 @@ hsize_t diff_datasetid(hid_t did1, /* Get the data type */ if((f_tid1 = H5Dget_type(did1)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dget_type failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_type failed"); /* Get the data type */ if((f_tid2 = H5Dget_type(did2)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dget_type failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_type failed"); /*------------------------------------------------------------------------- * get the storage layout type *------------------------------------------------------------------------- */ if((dcpl1 = H5Dget_create_plist(did1)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed"); if((dcpl2 = H5Dget_create_plist(did2)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dget_create_plist failed"); if((stl1 = H5Pget_layout(dcpl1)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Pget_layout failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed"); if((stl2 = H5Pget_layout(dcpl2)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Pget_layout failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Pget_layout failed"); /*------------------------------------------------------------------------- * check for empty datasets @@ -294,20 +291,20 @@ hsize_t diff_datasetid(hid_t did1, H5TOOLS_DEBUG("check for memory type and sizes"); if (H5Tget_class(f_tid1) == H5T_REFERENCE) { if((m_tid1 = H5Tcopy(H5T_STD_REF)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tcopy(H5T_STD_REF) first ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) first ftype failed"); } else { if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tget_native_type first ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type first ftype failed"); } if (H5Tget_class(f_tid2) == H5T_REFERENCE) { if((m_tid2 = H5Tcopy(H5T_STD_REF)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tcopy(H5T_STD_REF) second ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tcopy(H5T_STD_REF) second ftype failed"); } else { if((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Tget_native_type second ftype failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Tget_native_type second ftype failed"); } m_size1 = H5Tget_size(m_tid1); @@ -375,7 +372,7 @@ hsize_t diff_datasetid(hid_t did1, if (FAIL == match_up_memsize (f_tid1, f_tid2, &m_tid1, &m_tid2, &m_size1, &m_size2)) - H5TOOLS_GOTO_ERROR(1, "match_up_memsize failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "match_up_memsize failed"); H5TOOLS_DEBUG("m_size: %ld - %ld", m_size1, m_size2); dadims = dims1; dam_size = m_size1; @@ -423,10 +420,10 @@ hsize_t diff_datasetid(hid_t did1, H5TOOLS_DEBUG("buf1 != NULL && buf2 != NULL"); H5TOOLS_DEBUG("H5Dread did1"); if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dread failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); H5TOOLS_DEBUG("H5Dread did2"); if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dread failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); /* array diff */ nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims, @@ -490,9 +487,9 @@ hsize_t diff_datasetid(hid_t did1, * E.g., sm_space. */ if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL) - H5TOOLS_GOTO_ERROR(1, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "HDmalloc failed"); if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL) - H5TOOLS_GOTO_ERROR(1, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "HDmalloc failed"); sm_nelmts = sm_nbytes / p_type_nbytes; sm_space = H5Screate_simple(1, &sm_nelmts, NULL); @@ -509,19 +506,19 @@ hsize_t diff_datasetid(hid_t did1, hs_nelmts *= hs_size[i]; } /* end for */ if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sselect_hyperslab failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sselect_hyperslab failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Sselect_hyperslab failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Sselect_hyperslab failed"); } /* end if */ else hs_nelmts = 1; if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dread failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0) - H5TOOLS_GOTO_ERROR(1, "H5Dread failed"); + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Dread failed"); /* get array differences. in the case of hyperslab read, increment the number of differences found in each hyperslab and pass the position at the beginning for printing */ @@ -611,7 +608,6 @@ done: H5TOOLS_DEBUG("diff_datasetid return:%d with nfound:%d", ret_value, nfound); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return nfound; } @@ -640,14 +636,13 @@ int diff_can_type(hid_t f_tid1, /* file data type */ diff_opt_t *opts, int is_compound) { - H5TOOLS_ERR_INIT(int, 1) /* can_compare value */ H5T_class_t tclass1; H5T_class_t tclass2; int maxdim_diff = 0; /* maximum dimensions are different */ int dim_diff = 0; /* current dimensions are different */ int i; + int ret_value = 1; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("diff_can_type start"); /*------------------------------------------------------------------------- * check for the same class @@ -858,7 +853,6 @@ done: H5TOOLS_DEBUG("diff_can_type end - %d", ret_value); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index 98df0c7..8da995a 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -339,9 +339,8 @@ herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id, hid_t *m_tid1, hid_t *m_tid2, size_t *m_size1, size_t *m_size2) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) + herr_t ret_value = SUCCEED; - H5TOOLS_PUSH_STACK(); if((*m_size1) != (*m_size2)) { if((*m_size1) < (*m_size2)) { H5Tclose(*m_tid1); @@ -365,7 +364,6 @@ herr_t match_up_memsize (hid_t f_tid1_id, hid_t f_tid2_id, done: H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 8eaa805..7a184e6 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -430,8 +430,8 @@ h5tools_set_error_file(const char *fname, int is_bin) static hid_t h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) { - H5TOOLS_ERR_INIT(int, SUCCEED) - hid_t new_fapl = -1; /* Copy of file access property list passed in, or new property list */ + hid_t new_fapl = -1; /* Copy of file access property list passed in, or new property list */ + herr_t ret_value = SUCCEED; /* Make a copy of the FAPL, for the file open call to use, eventually */ if (fapl == H5P_DEFAULT) { @@ -479,7 +479,7 @@ h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum) H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed"); if(drivernum) - *drivernum = MULTI_IDX; + *drivernum = MULTI_IDX; } #ifdef H5_HAVE_PARALLEL else if(!HDstrcmp(driver, drivernames[MPIO_IDX])) { @@ -730,7 +730,6 @@ void h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hsize_t elmtno, int secnum) { - H5TOOLS_ERR_INIT(int, SUCCEED) h5tools_str_t prefix; h5tools_str_t str; /*temporary for indentation */ size_t templength = 0; @@ -742,7 +741,6 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, if (!ctx->need_prefix) return; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); HDmemset(&prefix, 0, sizeof(h5tools_str_t)); @@ -812,7 +810,6 @@ h5tools_simple_prefix(FILE *stream, const h5tool_format_t *info, h5tools_str_close(&str); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } /*------------------------------------------------------------------------- @@ -928,7 +925,6 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t local_elmt_counter, hsize_t elmt_counter) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; char *s = NULL; char *section = NULL; /* a section of output */ @@ -938,7 +934,6 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, if (stream == NULL) return dimension_break; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter need_prefix=%d", ctx->need_prefix); H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter); @@ -1067,7 +1062,6 @@ h5tools_render_element(FILE *stream, const h5tool_format_t *info, ctx->prev_multiline = multiline; H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return dimension_break; } @@ -1102,14 +1096,12 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t *ptdata, hsize_t local_elmt_counter, hsize_t elmt_counter) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; char *s = NULL; char *section = NULL; /* a section of output */ int secnum; /* section sequence number */ int multiline; /* datum was multiline */ - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); H5TOOLS_DEBUG("elmt_counter=%ld - local_elmt_counter=%ld", elmt_counter, local_elmt_counter); @@ -1221,7 +1213,6 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, ctx->prev_multiline = multiline; H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return dimension_break; } @@ -1237,11 +1228,9 @@ h5tools_render_region_element(FILE *stream, const h5tool_format_t *info, void init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) { - H5TOOLS_ERR_INIT(int, SUCCEED) int i; unsigned j; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); if(ctx->ndims > 0) { @@ -1255,7 +1244,6 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) } H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } /*------------------------------------------------------------------------- @@ -1270,19 +1258,19 @@ init_acc_pos(h5tools_context_t *ctx, hsize_t *dims) int render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) { - H5TOOLS_ERR_INIT(int, SUCCEED) - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ - hsize_t block_index; - H5T_class_t type_class; + unsigned char *mem = (unsigned char*)_mem; + size_t size; /* datum size */ + hsize_t block_index; + H5T_class_t type_class; + hbool_t past_catch = FALSE; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); if((size = H5Tget_size(tid)) == 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + H5TOOLS_THROW((-1), "H5Tget_size failed"); if((type_class = H5Tget_class(tid)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed"); + H5TOOLS_THROW((-1), "H5Tget_class failed"); switch (type_class) { case H5T_INTEGER: @@ -1303,7 +1291,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t bytes_wrote = HDfwrite(mem, 1, bytes_in, stream); if(bytes_wrote != bytes_in || (0 == bytes_wrote && HDferror(stream))) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + H5TOOLS_THROW((-1), "fwrite failed"); block_index -= (hsize_t)bytes_wrote; mem = mem + bytes_wrote; @@ -1327,7 +1315,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t if (s != NULL) size = HDstrlen(s); else - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "NULL string"); + H5TOOLS_THROW((-1), "NULL string"); } else { s = (char *) mem; @@ -1335,7 +1323,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); if (1 != HDfwrite(&tempuchar, sizeof(unsigned char), 1, stream)) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + H5TOOLS_THROW((-1), "fwrite failed"); } /* i */ } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ } @@ -1347,7 +1335,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t H5TOOLS_DEBUG("H5T_COMPOUND"); if((snmembs = H5Tget_nmembers(tid)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers of compound failed"); + H5TOOLS_THROW((-1), "H5Tget_nmembers of compound failed"); nmembs = (unsigned)snmembs; for (block_index = 0; block_index < block_nelmts; block_index++) { @@ -1363,7 +1351,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t if (render_bin_output(stream, container, memb, mem + offset, 1) < 0) { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output of compound member failed"); + H5TOOLS_THROW((-1), "render_bin_output of compound member failed"); } H5Tclose(memb); @@ -1392,7 +1380,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t } else { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "calculate the number of array elements failed"); + H5TOOLS_THROW((-1), "calculate the number of array elements failed"); } for (block_index = 0; block_index < block_nelmts; block_index++) { @@ -1400,7 +1388,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t /* dump the array element */ if (render_bin_output(stream, container, memb, mem, nelmts) < 0) { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + H5TOOLS_THROW((-1), "render_bin_output failed"); } } H5Tclose(memb); @@ -1423,7 +1411,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t /* dump the array element */ if (render_bin_output(stream, container, memb, ((char *) (((hvl_t *)((void *)mem))->p)), nelmts) < 0) { H5Tclose(memb); - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "render_bin_output failed"); + H5TOOLS_THROW((-1), "render_bin_output failed"); } } H5Tclose(memb); @@ -1443,7 +1431,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (block_index = 0; block_index < block_nelmts; block_index++) { mem = ((unsigned char*)_mem) + block_index * size; if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Ropen_object H5T_STD_REF failed"); + H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed"); else { if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) { @@ -1454,7 +1442,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t render_bin_output_region_blocks(region_space, region_id, stream, container); } else { - H5TOOLS_GOTO_ERROR(FAIL, "H5Ropen_object H5T_STD_REF NULL"); + H5TOOLS_INFO("H5Ropen_object H5T_STD_REF NULL"); } H5Sclose(region_space); } /* end if (region_space >= 0) */ @@ -1480,7 +1468,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t for (block_index = 0; block_index < block_nelmts; block_index++) { mem = ((unsigned char*)_mem) + block_index * size; if (size != HDfwrite(mem, sizeof(char), size, stream)) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "fwrite failed"); + H5TOOLS_THROW((-1), "fwrite failed"); } /* end for */ break; @@ -1488,7 +1476,7 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t case H5T_NCLASSES: default: /* Badness */ - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "bad type class"); + H5TOOLS_THROW((-1), "bad type class"); break; } /* end switch */ @@ -1496,7 +1484,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1515,7 +1502,6 @@ int render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, hid_t container, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata) { - H5TOOLS_ERR_INIT(int, SUCCEED) hsize_t *dims1 = NULL; hsize_t *start = NULL; hsize_t *count = NULL; @@ -1525,17 +1511,18 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, size_t type_size; hid_t mem_space = -1; void *region_buf = NULL; + hbool_t past_catch = FALSE; hsize_t blkndx; hid_t sid1 = -1; + int ret_value = -1; - H5TOOLS_PUSH_STACK(); /* Get the dataspace of the dataset */ if((sid1 = H5Dget_space(region_id)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + H5TOOLS_THROW((-1), "H5Dget_space failed"); /* Allocate space for the dimension array */ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims"); + H5TOOLS_THROW((-1), "Could not allocate buffer for dims"); /* find the dimensions of each data space from the block coordinates */ numelem = 1; @@ -1546,21 +1533,21 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, /* Create dataspace for reading buffer */ if((mem_space = H5Screate_simple((int)ndims, dims1, NULL)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed"); + H5TOOLS_THROW((-1), "H5Screate_simple failed"); if((type_size = H5Tget_size(type_id)) == 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + H5TOOLS_THROW((-1), "H5Tget_size failed"); if((region_buf = HDmalloc(type_size * (size_t)numelem)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate region buffer"); + H5TOOLS_THROW((-1), "Could not allocate region buffer"); /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ /* 1 2 n 1 2 n */ if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for start"); + H5TOOLS_THROW((-1), "Could not allocate buffer for start"); if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for count"); + H5TOOLS_THROW((-1), "Could not allocate buffer for count"); for (blkndx = 0; blkndx < nblocks; blkndx++) { for (jndx = 0; jndx < ndims; jndx++) { @@ -1569,16 +1556,16 @@ render_bin_output_region_data_blocks(hid_t region_id, FILE *stream, } if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); if(render_bin_output(stream, container, type_id, (char*)region_buf, numelem) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "render_bin_output of data region failed"); + H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data region failed"); /* Render the region data element end */ done: ; @@ -1591,12 +1578,11 @@ CATCH HDfree(dims1); if(H5Sclose(mem_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); if(H5Sclose(sid1) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1614,7 +1600,6 @@ hbool_t render_bin_output_region_blocks(hid_t region_space, hid_t region_id, FILE *stream, hid_t container) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hssize_t snblocks; hsize_t nblocks; hsize_t alloc_size; @@ -1623,15 +1608,16 @@ render_bin_output_region_blocks(hid_t region_space, hid_t region_id, unsigned ndims; hid_t dtype = -1; hid_t type_id = -1; + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; - H5TOOLS_PUSH_STACK(); if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed"); + H5TOOLS_THROW(FALSE, "H5Sget_select_hyper_nblocks failed"); nblocks = (hsize_t)snblocks; /* Print block information */ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; alloc_size = nblocks * ndims * 2 * sizeof(ptdata[0]); @@ -1661,7 +1647,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1687,44 +1672,42 @@ render_bin_output_region_data_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container, unsigned ndims, hid_t type_id, hsize_t npoints) { - H5TOOLS_ERR_INIT(int, SUCCEED) hsize_t *dims1 = NULL; size_t type_size; hid_t mem_space = -1; void *region_buf = NULL; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); if((type_size = H5Tget_size(type_id)) == 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_size failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL) - H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for region"); + H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for region"); /* Allocate space for the dimension array */ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_GOTO_ERROR(FAIL, "Could not allocate buffer for dims"); + H5TOOLS_GOTO_ERROR((-1), "Could not allocate buffer for dims"); dims1[0] = npoints; if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Screate_simple failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Screate_simple failed"); if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); if(H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); if(render_bin_output(stream, container, type_id, (char*)region_buf, npoints) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "render_bin_output of data points failed"); + H5TOOLS_GOTO_ERROR((-1), "render_bin_output of data points failed"); done: HDfree(region_buf); HDfree(dims1); if(H5Sclose(mem_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1742,22 +1725,22 @@ hbool_t render_bin_output_region_points(hid_t region_space, hid_t region_id, FILE *stream, hid_t container) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hssize_t snpoints; hsize_t npoints; int sndims; unsigned ndims; hid_t dtype = -1; hid_t type_id = -1; + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; - H5TOOLS_PUSH_STACK(); if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed"); + H5TOOLS_THROW(FALSE, "H5Sget_select_elem_npoints failed"); npoints = (hsize_t)snpoints; /* Allocate space for the dimension array */ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) - H5TOOLS_THROW(FALSE, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_THROW(FALSE, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; if((dtype = H5Dget_type(region_id)) < 0) @@ -1778,7 +1761,6 @@ done: H5_LEAVE(ret_value) CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index ada7ae8..b177a31 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -257,7 +257,6 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai h5tools_context_t *ctx, /* in,out */ unsigned flags, hsize_t nelmts, hid_t type, void *_mem) { - H5TOOLS_ERR_INIT(int, SUCCEED) unsigned char *mem = (unsigned char*) _mem; hsize_t i; /* element counter */ size_t size; /* size of each datum */ @@ -272,8 +271,8 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai * this var to count elements and * break after we see a number equal * to the ctx->size_last_dim. */ + int ret_value = 0; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter file=%p", (void*)stream); H5TOOLS_DEBUG("rawdata file=%p", (void*)rawdatastream); /* binary dump */ @@ -321,7 +320,6 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai }/* else bin */ H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -357,19 +355,18 @@ h5tools_dump_region_attribute(hid_t region_id, size_t ncols, hsize_t region_elmt_counter, /* element counter */ hsize_t elmt_counter) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) - hbool_t dimension_break = TRUE; - hid_t atype = H5I_INVALID_HID; - hid_t type_id = H5I_INVALID_HID; - hid_t region_space = H5I_INVALID_HID; - h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ + hbool_t dimension_break = TRUE; + hid_t atype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + hid_t region_space = H5I_INVALID_HID; + h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; HDassert(info); HDassert(ctx); HDassert(buffer); - H5TOOLS_PUSH_STACK(); - outputformat = *info; outputformat.idx_fmt = ""; outputformat.idx_n_fmt = ""; @@ -464,7 +461,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -493,7 +489,6 @@ h5tools_print_region_data_blocks(hid_t region_id, h5tools_str_t *buffer, /* string into which to render */ size_t ncols, unsigned ndims, hid_t type_id, hsize_t nblocks, hsize_t *ptdata) { - H5TOOLS_ERR_INIT(int, SUCCEED) hbool_t dimension_break = TRUE; hsize_t *dims1 = NULL; hsize_t *start = NULL; @@ -507,11 +502,13 @@ h5tools_print_region_data_blocks(hid_t region_id, hsize_t numindex; unsigned indx; unsigned jndx; + hbool_t past_catch = FALSE; size_t type_size; hid_t mem_space = -1; hid_t sid1 = -1; h5tools_context_t ctx; void *region_buf = NULL; + int ret_value = 0; HDassert(info); HDassert(cur_ctx); @@ -520,11 +517,10 @@ h5tools_print_region_data_blocks(hid_t region_id, HDmemset(&ctx, 0, sizeof(ctx)); - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); if((type_size = H5Tget_size(type_id)) == 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + H5TOOLS_THROW(FAIL, "H5Tget_size failed"); /* Get the dataspace of the dataset */ if((sid1 = H5Dget_space(region_id)) < 0) @@ -614,17 +610,16 @@ h5tools_print_region_data_blocks(hid_t region_id, } /* end for (numindex = 0; numindex < numelem; numindex++, elmtno++, ctx.cur_elmt++) */ } else { - ctx.indent_level--; - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); } ctx.indent_level--; } else { - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_ERROR(FAIL, "H5Dread failed"); } } else { - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_hyperslab failed"); + H5TOOLS_ERROR(FAIL, "H5Sselect_hyperslab failed"); } } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ @@ -641,7 +636,6 @@ done: H5TOOLS_ERROR(FAIL, "H5Sclose failed"); CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -678,7 +672,6 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, size_t ncols, hsize_t region_elmt_counter, /* element counter */ hsize_t elmt_counter) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; hssize_t snblocks; hsize_t nblocks; @@ -690,13 +683,13 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, hid_t dtype = H5I_INVALID_HID; hid_t type_id = H5I_INVALID_HID; h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; HDassert(info); HDassert(ctx); HDassert(buffer); - H5TOOLS_PUSH_STACK(); - outputformat = *info; outputformat.idx_fmt = ""; outputformat.idx_n_fmt = ""; @@ -704,12 +697,12 @@ h5tools_dump_region_data_blocks(hid_t region_space, hid_t region_id, outputformat.line_pre = ""; if((snblocks = H5Sget_select_hyper_nblocks(region_space)) <= 0) - H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_hyper_nblocks failed"); + H5TOOLS_THROW(dimension_break, "H5Sget_select_hyper_nblocks failed"); nblocks = (hsize_t)snblocks; /* Print block information */ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) - H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; H5TOOLS_DEBUG("enter ndims=%d", ndims); @@ -861,7 +854,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -890,7 +882,6 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, h5tools_str_t *buffer, size_t ncols, unsigned ndims, hid_t type_id, hsize_t npoints, hsize_t *ptdata) { - H5TOOLS_ERR_INIT(int, SUCCEED) hbool_t dimension_break = TRUE; hsize_t *dims1 = NULL; hsize_t elmtno; /* elemnt index */ @@ -903,6 +894,8 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, hid_t mem_space = H5I_INVALID_HID; void *region_buf = NULL; h5tools_context_t ctx; + hbool_t past_catch = FALSE; + int ret_value = 0; HDassert(info); HDassert(cur_ctx); @@ -910,25 +903,24 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, HDassert(ptdata); HDassert(ndims > 0); - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); HDmemset(&ctx, 0, sizeof(ctx)); /* Allocate space for the dimension array */ if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for dims"); + H5TOOLS_THROW((-1), "Could not allocate buffer for dims"); dims1[0] = npoints; /* Create dataspace for reading buffer */ if((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed"); + H5TOOLS_THROW((-1), "H5Screate_simple failed"); if((type_size = H5Tget_size(type_id)) == 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + H5TOOLS_THROW((-1), "H5Tget_size failed"); if((region_buf = HDmalloc(type_size * (size_t)npoints)) == NULL) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for region"); + H5TOOLS_THROW((-1), "Could not allocate buffer for region"); curr_pos = 0; ctx.indent_level = cur_ctx->indent_level; @@ -937,7 +929,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, ctx.ndims = ndims; if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); H5TOOLS_DEBUG("data render start:%ld", npoints); elmtno = 0; @@ -986,8 +978,7 @@ h5tools_print_region_data_points(hid_t region_space, hid_t region_id, elmtno = 0; } else { - ctx.indent_level--; - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_ERROR((-1), "H5Sget_simple_extent_dims failed"); } ctx.indent_level--; } /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */ @@ -998,10 +989,9 @@ CATCH HDfree(dims1); if(H5Sclose(mem_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1035,7 +1025,6 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, h5tools_str_t *buffer, hsize_t *curr_pos, size_t ncols, hsize_t region_elmt_counter, hsize_t elmt_counter) { - H5TOOLS_ERR_INIT(hbool_t, TRUE) hbool_t dimension_break = TRUE; hssize_t snpoints; hsize_t npoints; @@ -1047,13 +1036,13 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, hid_t dtype = H5I_INVALID_HID; hid_t type_id = H5I_INVALID_HID; h5tool_format_t outputformat; /* Use to disable prefix for DATA attribute display */ + hbool_t past_catch = FALSE; + hbool_t ret_value = TRUE; HDassert(info); HDassert(ctx); HDassert(buffer); - H5TOOLS_PUSH_STACK(); - outputformat = *info; outputformat.idx_fmt = ""; outputformat.idx_n_fmt = ""; @@ -1061,12 +1050,12 @@ h5tools_dump_region_data_points(hid_t region_space, hid_t region_id, outputformat.line_pre = ""; if((snpoints = H5Sget_select_elem_npoints(region_space)) <= 0) - H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_select_elem_npoints failed"); + H5TOOLS_THROW(dimension_break, "H5Sget_select_elem_npoints failed"); npoints = (hsize_t)snpoints; /* Allocate space for the dimension array */ if((sndims = H5Sget_simple_extent_ndims(region_space)) < 0) - H5TOOLS_THROW(dimension_break, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_THROW(dimension_break, "H5Sget_simple_extent_ndims failed"); ndims = (unsigned)sndims; H5TOOLS_DEBUG("enter ndims=%d", ndims); @@ -1214,7 +1203,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1262,7 +1250,6 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c hsize_t *total_size, /* total size of dataset */ unsigned int row_dim) /* index of row_counter dimension */ { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) size_t i; /* counters */ size_t j; /* counters */ hsize_t zero[1] = {0}; /* vector of zeros */ @@ -1279,13 +1266,13 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ hsize_t size_row_block; /* size for blocks along rows */ hsize_t row_counter = 0; - + hbool_t past_catch = FALSE; /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ + unsigned int vl_data = 0; /* contains VL datatypes */ + herr_t ret_value = SUCCEED; - H5TOOLS_PUSH_STACK(); if ((size_t) ctx->ndims > NELMTS(sm_size)) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "ndims and sm_size comparision failed"); + H5TOOLS_THROW(FAIL, "ndims and sm_size comparision failed"); if (ctx->ndims > 0) init_acc_pos(ctx, total_size); @@ -1313,10 +1300,10 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c /* calculate the potential number of elements we're going to print */ if(H5Sselect_hyperslab(f_space, H5S_SELECT_SET, temp_start, temp_stride, temp_count, temp_block) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed"); if((ssm_nelmts = H5Sget_select_npoints(f_space)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_npoints failed"); + H5TOOLS_THROW(FAIL, "H5Sget_select_npoints failed"); sm_nelmts = (hsize_t)ssm_nelmts; if (sm_nelmts > 0) { @@ -1325,7 +1312,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c * a hyperslab whose size is manageable. */ if((sm_nbytes = p_type_nbytes = H5Tget_size(p_type)) == 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size failed"); + H5TOOLS_THROW(FAIL, "H5Tget_size failed"); if (ctx->ndims > 0) for (i = ctx->ndims; i > 0; --i) { @@ -1339,17 +1326,17 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c HDassert(sm_nbytes == (hsize_t) ((size_t) sm_nbytes)); /*check for overflow*/ if(NULL == (sm_buf = (unsigned char *)HDmalloc((size_t) sm_nelmts * p_type_nbytes))) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for strip-mine"); + H5TOOLS_THROW(FAIL, "Could not allocate buffer for strip-mine"); if((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Screate_simple failed"); + H5TOOLS_THROW(FAIL, "H5Screate_simple failed"); if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &sm_nelmts, NULL) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + H5TOOLS_THROW(FAIL, "H5Sselect_hyperslab failed"); /* read the data */ if(H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dread failed"); + H5TOOLS_THROW(FAIL, "H5Dread failed"); /* print the data */ flags = START_OF_DATA; @@ -1363,7 +1350,7 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c /* print array indices. get the lower bound of the hyperslab and calulate the element position at the start of hyperslab */ if(H5Sget_select_bounds(f_space, low, high) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_select_bounds failed"); + H5TOOLS_THROW(FAIL, "H5Sget_select_bounds failed"); elmtno = 0; for (i = 0; i < (size_t) ctx->ndims - 1; i++) { @@ -1381,20 +1368,20 @@ h5tools_print_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_c ctx->need_prefix = TRUE; if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, sm_nelmts, p_type, sm_buf) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "h5tools_dump_simple_data failed"); + H5TOOLS_THROW(FAIL, "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ if (vl_data) H5Treclaim(p_type, sm_space, H5P_DEFAULT, sm_buf); if(H5Sclose(sm_space) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + H5TOOLS_THROW(FAIL, "H5Sclose failed"); if(sm_buf) HDfree(sm_buf); sm_buf = NULL; } else - H5TOOLS_THROW(SUCCEED, H5E_tools_min_id_g, "nothing to print"); + H5TOOLS_THROW(SUCCEED, "nothing to print"); ctx->continuation++; @@ -1405,7 +1392,6 @@ CATCH HDfree(sm_buf); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1585,18 +1571,18 @@ static herr_t h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) - int sndims; - hid_t f_space = H5I_INVALID_HID; /* file data space */ - size_t i; /* counters */ - hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/ + int sndims; + hid_t f_space = H5I_INVALID_HID; /* file data space */ + size_t i; /* counters */ + hsize_t total_size[H5S_MAX_RANK];/* total size of dataset*/ + hbool_t past_catch = FALSE; + herr_t ret_value = SUCCEED; - H5TOOLS_PUSH_STACK(); if((f_space = H5Dget_space(dset)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); + H5TOOLS_THROW(FAIL, "H5Dget_space failed"); if((sndims = H5Sget_simple_extent_ndims(f_space)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_ndims failed"); ctx->ndims = (unsigned)sndims; /* assume entire data space to be printed */ @@ -1605,7 +1591,7 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co ctx->p_min_idx[i] = 0; if(H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + H5TOOLS_THROW(FAIL, "H5Sget_simple_extent_dims failed"); ctx->size_last_dim = total_size[ctx->ndims - 1]; /* Set the compound datatype field list for display */ @@ -1615,10 +1601,9 @@ h5tools_dump_simple_subset(FILE *stream, const h5tool_format_t *info, h5tools_co CATCH if(f_space >= 0 && H5Sclose(f_space) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sclose failed"); + H5TOOLS_THROW(FAIL, "H5Sclose failed"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1641,7 +1626,6 @@ static int h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset, hid_t p_type) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) hid_t f_space = H5I_INVALID_HID; /* file data space */ hsize_t elmtno; /* counter */ size_t i; /* counter */ @@ -1650,6 +1634,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont hsize_t zero[8]; /* vector of zeros */ unsigned int flags; /* buffer extent flags */ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + hbool_t past_catch = FALSE; /* Print info */ size_t p_type_nbytes; /* size of memory type */ @@ -1669,20 +1654,20 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont /* VL data special information */ unsigned int vl_data = 0; /* contains VL datatypes */ + int ret_value = 0; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); - if (FAIL == (f_space = H5Dget_space(dset))) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); + if (H5I_INVALID_HID == (f_space = H5Dget_space(dset))) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); sndims = H5Sget_simple_extent_ndims(f_space); if(sndims < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_simple_extent_ndims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_simple_extent_ndims failed"); ctx->ndims = (unsigned)sndims; H5TOOLS_DEBUG("sndims:%d", sndims); if ((size_t)ctx->ndims > NELMTS(sm_size)) - H5TOOLS_GOTO_ERROR(FAIL, "ctx->ndims > NELMTS(sm_size) failed"); + H5TOOLS_GOTO_ERROR((-1), "ctx->ndims > NELMTS(sm_size) failed"); /* Assume entire data space to be printed */ if (ctx->ndims > 0) @@ -1754,15 +1739,15 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont } if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_hyperslab hs_offset failed"); + H5TOOLS_ERROR((-1), "H5Sselect_hyperslab hs_offset failed"); if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_hyperslab zero failed"); + H5TOOLS_ERROR((-1), "H5Sselect_hyperslab zero failed"); } else { if (H5Sselect_all(f_space) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_all f_space failed"); + H5TOOLS_ERROR((-1), "H5Sselect_all f_space failed"); if (H5Sselect_all(sm_space) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_all sm_space failed"); + H5TOOLS_ERROR((-1), "H5Sselect_all sm_space failed"); hs_nelmts = 1; } @@ -1778,7 +1763,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont ctx->sm_pos = elmtno; if(h5tools_dump_simple_data(stream, info, dset, ctx, flags, hs_nelmts, p_type, sm_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5tools_dump_simple_data failed"); + H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ if (vl_data) @@ -1797,7 +1782,7 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont } } else - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_ERROR((-1), "H5Dread failed"); ctx->continuation++; H5TOOLS_DEBUG("stripmine read loop:%d complete", i); @@ -1807,12 +1792,11 @@ h5tools_dump_simple_dset(FILE *stream, const h5tool_format_t *info, h5tools_cont done: if(sm_space >= 0 && H5Sclose(sm_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); if(f_space >= 0 && H5Sclose(f_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1830,31 +1814,31 @@ static int h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id, hid_t p_type) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) hid_t f_space = H5I_INVALID_HID; /* file data space */ hsize_t alloc_size; int sndims; /* rank of dataspace */ unsigned i; /* counters */ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ hsize_t p_nelmts; /* total selected elmts */ - unsigned char *buf = NULL; /* buffer for raw data */ + hbool_t past_catch = FALSE; + unsigned char *buf = NULL; /* buffer for raw data */ + int ret_value = 0; /* VL data special information */ unsigned int vl_data = 0; /* contains VL datatypes */ - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); - if (FAIL == (f_space = H5Aget_space(attr_id))) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); + if (H5I_INVALID_HID == (f_space = H5Aget_space(attr_id))) + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); sndims = H5Sget_simple_extent_ndims(f_space); if(sndims < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Dget_simple_extent_ndims failed"); + H5TOOLS_THROW((-1), "H5Dget_simple_extent_ndims failed"); ctx->ndims = (unsigned)sndims; H5TOOLS_DEBUG("sndims:%d", sndims); if ((size_t) ctx->ndims > NELMTS(ctx->p_min_idx)) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "ctx->ndims > NELMTS(ctx->p_min_idx) failed"); + H5TOOLS_THROW((-1), "ctx->ndims > NELMTS(ctx->p_min_idx) failed"); /* Assume entire data space to be printed */ if (ctx->ndims > 0) @@ -1892,22 +1876,21 @@ h5tools_dump_simple_mem(FILE *stream, const h5tool_format_t *info, h5tools_conte /* Read the data */ if (H5Aread(attr_id, p_type, buf) >= 0) { if(h5tools_dump_simple_data(stream, info, attr_id, ctx, START_OF_DATA | END_OF_DATA, p_nelmts, p_type, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5tools_dump_simple_data failed"); + H5TOOLS_ERROR((-1), "h5tools_dump_simple_data failed"); /* Reclaim any VL memory, if necessary */ if (vl_data) H5Treclaim(p_type, f_space, H5P_DEFAULT, buf); } else - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread failed"); + H5TOOLS_ERROR((-1), "H5Aread failed"); HDfree(buf); } /* if (NULL != (buf...)) */ done: if(f_space >= 0 && H5Sclose(f_space) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_ERROR((-1), "H5Sclose failed"); CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1932,12 +1915,13 @@ CATCH int h5tools_dump_dset(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t dset) { - H5TOOLS_ERR_INIT(int, SUCCEED) hid_t f_space = H5I_INVALID_HID; hid_t p_type = H5I_INVALID_HID; hid_t f_type = H5I_INVALID_HID; H5S_class_t space_type; h5tool_format_t info_dflt; + int ret_value = 0; + /* Use default values */ if (!stream) stream = rawoutstream; @@ -1990,7 +1974,6 @@ done: H5Sclose(f_space); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -2008,13 +1991,12 @@ done: int h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t attr_id) { - H5TOOLS_ERR_INIT(int, SUCCEED) hid_t f_space = H5I_INVALID_HID; hid_t p_type = H5I_INVALID_HID; hid_t f_type = H5I_INVALID_HID; h5tool_format_t info_dflt; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); /* Use default values */ if (!stream) stream = rawoutstream; @@ -2047,7 +2029,7 @@ h5tools_dump_mem(FILE *stream, const h5tool_format_t *info, h5tools_context_t *c /* Check the data space */ if (H5Sis_simple(f_space) <= 0) { - H5TOOLS_GOTO_ERROR(FAIL, "H5Sis_simple failed"); + H5TOOLS_ERROR((-1), "H5Sis_simple failed"); } else { ret_value = h5tools_dump_simple_mem(rawattrstream, info, ctx, attr_id, p_type); @@ -2061,7 +2043,6 @@ done: H5Sclose(f_space); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -2080,7 +2061,6 @@ int h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type, int object_search) { - H5TOOLS_ERR_INIT(int, SUCCEED) char *mname; hid_t mtype = -1; hid_t str_type = -1; @@ -2100,12 +2080,13 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ H5T_class_t type_class; H5T_sign_t sign; /* sign scheme value */ htri_t is_vlstr = FALSE; + hbool_t past_catch = FALSE; const char *sign_s = NULL; /* sign scheme string */ const char *order_s = NULL; /* byte order string */ + int ret_value = 0; - H5TOOLS_PUSH_STACK(); if((type_class = H5Tget_class(type)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_class failed"); + H5TOOLS_THROW((-1), "H5Tget_class failed"); if (object_search && H5Tcommitted(type) > 0) { H5O_info_t oinfo; obj_t *obj = NULL; /* Found object */ @@ -2395,11 +2376,11 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ order = H5Tget_order(tmp_type); if(order == H5T_ORDER_LE) { if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tset_order failed"); + H5TOOLS_ERROR((-1), "H5Tset_order failed"); } /* end if */ else if(order == H5T_ORDER_BE) { if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tset_order failed"); + H5TOOLS_ERROR((-1), "H5Tset_order failed"); } /* end if */ if(H5Tequal(tmp_type, str_type)) { @@ -2409,7 +2390,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ /* If not equal to C variable-length string, check Fortran type. */ if(H5Tclose(str_type) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_ERROR((-1), "H5Tclose failed"); str_type = H5Tcopy(H5T_FORTRAN_S1); H5Tset_cset(str_type, cset); @@ -2426,11 +2407,11 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ order = H5Tget_order(tmp_type); if(order == H5T_ORDER_LE) { if(H5Tset_order(str_type, H5T_ORDER_LE) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tset_order failed"); + H5TOOLS_ERROR((-1), "H5Tset_order failed"); } /* end if */ else if(order == H5T_ORDER_BE) { if(H5Tset_order(str_type, H5T_ORDER_BE) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tset_order failed"); + H5TOOLS_ERROR((-1), "H5Tset_order failed"); } /* end if */ if(H5Tequal(tmp_type, str_type)) { @@ -2449,9 +2430,9 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_str_reset(buffer); if(H5Tclose(str_type) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_ERROR((-1), "H5Tclose failed"); if(H5Tclose(tmp_type) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_ERROR((-1), "H5Tclose failed"); h5tools_str_append(buffer, "%s", h5tools_dump_header_format->strblockend); break; @@ -2485,7 +2466,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ char *ttag; if(NULL == (ttag = H5Tget_tag(type))) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_tag failed"); + H5TOOLS_THROW((-1), "H5Tget_tag failed"); ctx->need_prefix = TRUE; @@ -2513,7 +2494,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ case H5T_COMPOUND: if((snmembers = H5Tget_nmembers(type)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + H5TOOLS_THROW((-1), "H5Tget_nmembers failed"); nmembers = (unsigned)snmembers; h5tools_str_append(buffer, "H5T_COMPOUND %s", h5tools_dump_header_format->structblockbegin); @@ -2531,10 +2512,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_str_append(buffer, " \"%s\";", mname); h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); if(H5Tclose(mtype) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_ERROR((-1), "H5Tclose failed"); } else - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_member_type failed"); + H5TOOLS_ERROR((-1), "H5Tget_member_type failed"); H5free_memory(mname); } ctx->indent_level--; @@ -2563,7 +2544,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ case H5T_ENUM: if((super = H5Tget_super(type)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed"); + H5TOOLS_THROW((-1), "H5Tget_super failed"); h5tools_str_append(buffer, "H5T_ENUM %s", h5tools_dump_header_format->enumblockbegin); h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); @@ -2575,7 +2556,7 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); if(H5Tclose(super) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_ERROR((-1), "H5Tclose failed"); h5tools_str_append(buffer, ";"); h5tools_render_element(stream, info, ctx, buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); @@ -2593,14 +2574,14 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ case H5T_VLEN: if((super = H5Tget_super(type)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed"); + H5TOOLS_THROW((-1), "H5Tget_super failed"); h5tools_str_append(buffer, "H5T_VLEN %s ", h5tools_dump_header_format->vlenblockbegin); h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); if(H5Tclose(super) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_ERROR((-1), "H5Tclose failed"); h5tools_str_append(buffer, "%s", h5tools_dump_header_format->vlenblockend); @@ -2621,10 +2602,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_str_append(buffer, " "); } else - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_array_dims2 failed"); + H5TOOLS_ERROR((-1), "H5Tget_array_dims2 failed"); } else - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_array_ndims failed"); + H5TOOLS_ERROR((-1), "H5Tget_array_ndims failed"); /* Get array base type */ if((super = H5Tget_super(type)) >= 0) { @@ -2632,10 +2613,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_print_datatype(stream, buffer, info, ctx, super, TRUE); /* Close array base type */ if(H5Tclose(super) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_ERROR((-1), "H5Tclose failed"); } else - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_super failed"); + H5TOOLS_ERROR((-1), "H5Tget_super failed"); h5tools_str_append(buffer, " }"); @@ -2652,7 +2633,6 @@ done: CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -2670,19 +2650,19 @@ CATCH int h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space) { - H5TOOLS_ERR_INIT(int, SUCCEED) hsize_t size[H5TOOLS_DUMP_MAX_RANK]; hsize_t maxsize[H5TOOLS_DUMP_MAX_RANK]; int ndims = -1; H5S_class_t space_type = -1; + hbool_t past_catch = FALSE; int i; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); if((ndims = H5Sget_simple_extent_dims(space, size, maxsize)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); + H5TOOLS_THROW((-1), "H5Sget_simple_extent_dims failed"); if((space_type = H5Sget_simple_extent_type(space)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_type failed"); + H5TOOLS_THROW((-1), "H5Sget_simple_extent_type failed"); switch(space_type) { case H5S_SCALAR: @@ -2730,7 +2710,6 @@ h5tools_print_dataspace(h5tools_str_t *buffer, hid_t space) CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -2749,7 +2728,6 @@ CATCH int h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t type) { - H5TOOLS_ERR_INIT(int, SUCCEED) char **name = NULL; /*member names */ unsigned char *value = NULL; /*value array */ unsigned char *copy = NULL; /*a pointer to value array */ @@ -2763,21 +2741,22 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i size_t dst_size; /*destination value type size */ size_t ncols = 80; /*available output width */ hsize_t curr_pos = 0; /* total data element position */ + hbool_t past_catch = FALSE; + int ret_value = 0; - H5TOOLS_PUSH_STACK(); if (info->line_ncols > 0) ncols = info->line_ncols; if((snmembs = H5Tget_nmembers(type)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_nmembers failed"); + H5TOOLS_THROW((-1), "H5Tget_nmembers failed"); nmembs = (unsigned)snmembs; HDassert(nmembs > 0); if((super = H5Tget_super(type)) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_super failed"); + H5TOOLS_THROW((-1), "H5Tget_super failed"); if((type_size = H5Tget_size(type)) <= 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_size(type) failed"); + H5TOOLS_THROW((-1), "H5Tget_size(type) failed"); /* * Determine what datatype to use for the native values. To simplify @@ -2790,7 +2769,7 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i dst_size = sizeof(long long); if((sign_type = H5Tget_sign(type))<0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_sign failed"); + H5TOOLS_THROW((-1), "H5Tget_sign failed"); if(H5T_SGN_NONE == sign_type) native = H5T_NATIVE_ULLONG; else @@ -2801,20 +2780,20 @@ h5tools_print_enum(FILE *stream, h5tools_str_t *buffer, const h5tool_format_t *i /* Get the names and raw values of all members */ if(NULL == (name = (char **)HDcalloc((size_t)nmembs, sizeof(char *)))) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member name"); + H5TOOLS_THROW((-1), "Could not allocate buffer for member name"); if(NULL == (value = (unsigned char *)HDcalloc((size_t)nmembs, MAX(type_size, dst_size)))) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not allocate buffer for member value"); + H5TOOLS_THROW((-1), "Could not allocate buffer for member value"); for (i = 0; i < nmembs; i++) { name[i] = H5Tget_member_name(type, i); if(H5Tget_member_value(type, i, value + i * type_size) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tget_member_value failed"); + H5TOOLS_THROW((-1), "H5Tget_member_value failed"); } /* Convert values to native datatype */ if (native > 0) if(H5Tconvert(super, native, (size_t)nmembs, value, NULL, H5P_DEFAULT) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "H5Tconvert failed"); + H5TOOLS_THROW((-1), "H5Tconvert failed"); /* * Sort members by increasing value @@ -2871,13 +2850,12 @@ CATCH HDfree(value); if(super >= 0 && H5Tclose(super) < 0) - H5TOOLS_THROW(FAIL, H5E_tools_min_id_g, "Could not close datatype's super class"); + H5TOOLS_THROW((-1), "Could not close datatype's super class"); if(0 == nmembs) h5tools_str_append(buffer, "\n<empty>"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return ret_value; } @@ -3992,7 +3970,6 @@ h5tools_dump_subsetting_header(FILE *stream, const h5tool_format_t *info, h5tool void h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t obj_id, int obj_data) { - H5TOOLS_ERR_INIT(int, SUCCEED) H5S_class_t space_type; int ndims; size_t i; @@ -4011,7 +3988,6 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * h5tool_format_t outputformat; H5R_ref_t *ref_buf = NULL; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter file=%p", (void*)stream); H5TOOLS_DEBUG("rawdata file=%p", (void*)rawdatastream); /* setup */ @@ -4060,7 +4036,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * datactx = *ctx; H5TOOLS_DEBUG("reference class type"); if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { - H5TOOLS_GOTO_DONE(SUCCEED); + H5TOOLS_GOTO_DONE_NO_RET(); } ndims = (int)H5Sget_simple_extent_npoints(space); @@ -4080,13 +4056,15 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * if(obj_data) { if(H5Dread(obj_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) { HDfree(ref_buf); - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread reference failed"); + H5TOOLS_INFO("H5Dread reference failed"); + H5TOOLS_GOTO_DONE_NO_RET(); } } else { if(H5Aread(obj_id, H5T_STD_REF, ref_buf) < 0) { HDfree(ref_buf); - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread reference failed"); + H5TOOLS_INFO("H5Aread reference failed"); + H5TOOLS_GOTO_DONE_NO_RET(); } } for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) { @@ -4113,12 +4091,12 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); datactx.indent_level--; if(H5Dclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); + H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_OBJECT1:H5O_TYPE_DATASET failed"); + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1:H5O_TYPE_DATASET failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed"); + H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed"); break; case H5O_TYPE_GROUP: @@ -4131,7 +4109,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * } /* end switch */ } else - H5TOOLS_ERROR(FAIL, "H5Rget_obj_type3 H5R_OBJECT1 failed"); + H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed"); break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); @@ -4140,12 +4118,12 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); datactx.indent_level--; if(H5Dclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Dclose H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION1 failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); break; case H5R_OBJECT2: H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); @@ -4160,12 +4138,12 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE); datactx.indent_level--; if(H5Oclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Oclose H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT2 failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed"); break; case H5O_TYPE_NAMED_DATATYPE: @@ -4179,7 +4157,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * } /* end switch */ } else - H5TOOLS_ERROR(FAIL, "H5Rget_obj_type3 H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed"); break; case H5R_DATASET_REGION2: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); @@ -4189,7 +4167,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); else { if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { @@ -4230,17 +4208,17 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * &buffer, &curr_pos, ncols, i, elmt_counter); } else - H5TOOLS_ERROR(FAIL, "invalid region type"); + H5TOOLS_INFO("invalid region type"); } /* end else to if (h5tools_is_zero(... */ if(H5Sclose(new_obj_sid) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_region H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); if(H5Dclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Dclose H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION2 failed"); } break; case H5R_ATTR: @@ -4249,9 +4227,9 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * h5tools_dump_region_attribute(new_obj_id, stream, &outputformat, &datactx, &buffer, &curr_pos, ncols, i, elmt_counter); if(H5Aclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Aclose H5R_ATTR failed"); + H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_ATTR failed"); + H5TOOLS_INFO("H5Rdestroy H5R_ATTR failed"); } else { H5TOOLS_DEBUG("NULL H5R_ATTR"); @@ -4276,7 +4254,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t * h5tools_str_append(&buffer, "}"); h5tools_render_element(stream, &outputformat, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - H5TOOLS_ERROR(FAIL, "H5Ropen_attr H5R_ATTR failed"); + H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); } break; case H5R_BADTYPE: @@ -4392,6 +4370,5 @@ done: h5tools_str_close(&buffer); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h index 9ad54bc..784b86a 100644 --- a/tools/lib/h5tools_error.h +++ b/tools/lib/h5tools_error.h @@ -22,7 +22,9 @@ /* tools-HDF5 Error variables */ H5TOOLS_DLLVAR hid_t H5tools_ERR_STACK_g; +H5TOOLS_DLLVAR hid_t H5tools_DBG_ERR_STACK_g; H5TOOLS_DLLVAR hid_t H5tools_ERR_CLS_g; +H5TOOLS_DLLVAR hid_t H5tools_DBG_ERR_CLS_g; H5TOOLS_DLLVAR hid_t H5E_tools_g; H5TOOLS_DLLVAR hid_t H5E_tools_min_id_g; H5TOOLS_DLLVAR hid_t H5E_tools_min_info_id_g; @@ -51,6 +53,9 @@ do { if ((H5tools_ERR_STACK_g = H5Ecreate_stack()) < 0) \ HDfprintf(stderr, "Failed to create HDF5 tools error stack\n"); \ \ + /* Create new HDF5 error stack for debugging, if tools debugging is enabled */ \ + H5TOOLS_CREATE_DEBUG_STACK(); \ + \ /* Register errors from the HDF5 tools as a new error class */ \ if ((H5tools_ERR_CLS_g = H5Eregister_class("H5tools", "HDF5:tools", lib_str)) < 0) \ HDfprintf(stderr, "Failed to register HDF5 tools error class\n"); \ @@ -91,41 +96,15 @@ do { if (H5Eunregister_class(H5tools_ERR_CLS_g) < 0) \ HDfprintf(stderr, "Failed to unregister the HDF5 tools error class\n"); \ \ + /* Close the tools debugging error stack, if it was created */ \ + H5TOOLS_CLOSE_DEBUG_STACK(); \ + \ /* Close the tools error stack */ \ if (H5Eclose_stack(H5tools_ERR_STACK_g) < 0) \ HDfprintf(stderr, "Failed to close HDF5 tools error stack\n"); \ } while(0) /* - * H5TOOLS_ERR_INIT macro, used to facilitate error reporting. Declaration and assignments of error variables. - * Use at the beginning of a function using error handling macros. - */ -#define H5TOOLS_ERR_INIT(ret_typ, ret_init) \ - hid_t pstack_id = H5I_INVALID_HID; \ - hid_t estack_id = H5tools_ERR_STACK_g; \ - hbool_t past_catch = FALSE; \ - ret_typ ret_value = ret_init; - -/* - * H5TOOLS_PUSH_STACK macro, used to create a new error stack. - */ -#define H5TOOLS_PUSH_STACK() { \ - pstack_id = estack_id; \ - estack_id = H5Ecreate_stack(); \ -} - -/* - * H5TOOLS_POP_STACK macro, used to release a new error stack. - */ -#define H5TOOLS_POP_STACK() { \ - if (H5I_INVALID_HID != pstack_id) { \ - H5Eclose_stack(estack_id); \ - estack_id = pstack_id; \ - pstack_id = H5I_INVALID_HID; \ - } \ -} - -/* * H5TOOLS_PUSH_ERROR macro, used to push an error to an error stack. Not meant to * be called directly. */ @@ -176,6 +155,15 @@ do { \ } while(0) /* + * H5TOOLS_GOTO_DONE_NO_RET macro, used to facilitate normal return within a function body. + * Control simply branches to the `done' label without setting any return value. + */ +#define H5TOOLS_GOTO_DONE_NO_RET() \ +do { \ + goto done; \ +} while(0) + +/* * H5TOOLS_INFO macro, used to facilitate error reporting. The arguments are * a description of the error. */ @@ -184,29 +172,63 @@ do { H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_info_id_g, __VA_ARGS__); \ } while(0) -/* - * H5TOOLS_DEBUG macro, used to facilitate error reporting. The arguments are the - * minor error number, and a description of the error. - */ #ifdef H5_TOOLS_DEBUG -#define H5TOOLS_DEBUG(...) \ -do { \ - H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_dbg_id_g, __VA_ARGS__); \ + +#define H5TOOLS_CREATE_DEBUG_STACK() \ +do { \ + /* Create new HDF5 error stack for debugging */ \ + if ((H5tools_DBG_ERR_STACK_g = H5Ecreate_stack()) < 0) \ + HDfprintf(stderr, "Failed to create HDF5 tools debugging error stack\n"); \ + \ + /* Register debugging output from the HDF5 tools as a new error class */ \ + if ((H5tools_DBG_ERR_CLS_g = H5Eregister_class("H5tools-debug", "HDF5:tools", lib_str)) < 0) \ + HDfprintf(stderr, "Failed to register HDF5 tools debugging error class\n"); \ } while(0) -#define H5TOOLS_ENDDEBUG(...) \ -do { \ - H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_dbg_id_g, __VA_ARGS__); \ - H5Eprint2(H5tools_ERR_STACK_g, stderr); \ + +#define H5TOOLS_CLOSE_DEBUG_STACK() \ +do { \ + /* Unregister the HDF5 tools debugging error class */ \ + if (H5Eunregister_class(H5tools_DBG_ERR_CLS_g) < 0) \ + HDfprintf(stderr, "Failed to unregister the HDF5 tools debugging error class\n"); \ + \ + /* Close the tools debugging error stack */ \ + if (H5Eclose_stack(H5tools_DBG_ERR_STACK_g) < 0) \ + HDfprintf(stderr, "Failed to close HDF5 tools debugging error stack\n"); \ +} while(0) + +#define H5TOOLS_DEBUG(...) \ +do { \ + H5TOOLS_PUSH_ERROR(H5tools_DBG_ERR_STACK_g, H5tools_DBG_ERR_CLS_g, H5E_tools_g, H5E_tools_min_dbg_id_g, __VA_ARGS__); \ } while(0) + +#define H5TOOLS_ENDDEBUG(...) \ +do { \ + H5TOOLS_PUSH_ERROR(H5tools_DBG_ERR_STACK_g, H5tools_DBG_ERR_CLS_g, H5E_tools_g, H5E_tools_min_dbg_id_g, __VA_ARGS__); \ + H5Eprint2(H5tools_DBG_ERR_STACK_g, stderr); \ +} while(0) + #else + +#define H5TOOLS_CREATE_DEBUG_STACK() \ +do { \ + ; \ +} while(0) + +#define H5TOOLS_CLOSE_DEBUG_STACK() \ +do { \ + ; \ +} while(0) + #define H5TOOLS_DEBUG(...) \ do { \ ; \ } while(0) + #define H5TOOLS_ENDDEBUG(...) \ do { \ ; \ } while(0) + #endif @@ -236,10 +258,11 @@ do { \ * The return value is assigned to a variable `ret_value' and control branches * to the `catch_except' label, if we're not already past it. */ -#define H5TOOLS_THROW(fail_value, min_id, ...) { \ - H5Epush2(estack_id, __FILE__, FUNC, __LINE__, H5tools_ERR_CLS_g, H5E_tools_g, min_id, __VA_ARGS__); \ - H5_LEAVE(fail_value) \ -} +#define H5TOOLS_THROW(ret_val, ...) \ +do { \ + H5TOOLS_PUSH_ERROR(H5tools_ERR_STACK_g, H5tools_ERR_CLS_g, H5E_tools_g, H5E_tools_min_id_g, __VA_ARGS__); \ + H5_LEAVE(ret_val) \ +} while(0) #endif /* H5TOOLS_ERROR_H_ */ diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c index 13e075b..0e4c476 100644 --- a/tools/lib/h5tools_filters.c +++ b/tools/lib/h5tools_filters.c @@ -43,11 +43,11 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean print */ hid_t dcpl_id) /* dataset creation property list */ { - H5TOOLS_ERR_INIT(int, 1) int nfilters; /* number of filters */ H5Z_filter_t filtn; /* filter identification number */ int i; /* index */ int udfilter_avail; /* index */ + int ret_value = 1; /* get information about filters */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) @@ -144,7 +144,7 @@ done: H5_ATTR_CONST int h5tools_can_encode(H5Z_filter_t filtn) { - H5TOOLS_ERR_INIT(int, 1) + int ret_value = 1; switch (filtn) { /* user defined filter */ diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index c555a61..0aa5152 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -289,11 +289,9 @@ char * h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, hsize_t elmtno, unsigned ndims, h5tools_context_t *ctx) { - H5TOOLS_ERR_INIT(int, SUCCEED) size_t i = 0; hsize_t curr_pos = elmtno; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); H5TOOLS_DEBUG("elmtno=%ld, ctx->ndims=%d", elmtno, ctx->ndims); @@ -328,7 +326,6 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, H5TOOLS_DEBUG("str=%s", str->s); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); /* Add prefix and suffix to the index */ return h5tools_str_fmt(str, (size_t)0, OPT(info->idx_fmt, "%s: ")); @@ -684,7 +681,6 @@ char * h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, hid_t type, void *vp, h5tools_context_t *ctx) { - H5TOOLS_ERR_INIT(char*, NULL) size_t nsize, offset, size=0, nelmts, start; H5T_sign_t nsign; char *name = NULL; @@ -695,8 +691,8 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; H5T_class_t type_class; + char *ret_value = NULL; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); /* Build default formats for long long types */ if(!fmt_llong[0]) { @@ -1110,10 +1106,10 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) { H5Oget_info2(obj, &oi, H5O_INFO_BASIC); if(H5Oclose(obj) < 0) - H5TOOLS_GOTO_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed"); + H5TOOLS_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed"); } else - H5TOOLS_GOTO_ERROR(NULL, "H5Ropen_object H5R_OBJECT1 failed"); + H5TOOLS_ERROR(NULL, "H5Ropen_object H5R_OBJECT1 failed"); /* Print object type and close object */ switch (obj_type) { @@ -1339,12 +1335,9 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } done: - -CATCH ret_value = h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s")); H5TOOLS_ENDDEBUG("exit with %s", ret_value); - H5TOOLS_POP_STACK(); return ret_value; } @@ -1361,10 +1354,8 @@ void h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, H5R_ref_t *ref_vp) { - H5TOOLS_ERR_INIT(int, SUCCEED) - ssize_t buf_size; + ssize_t buf_size; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); h5tools_str_append(str, " \""); @@ -1407,9 +1398,7 @@ h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, } h5tools_str_append(str, "\""); -CATCH H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } /*------------------------------------------------------------------------- diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index 4924e4e..1036199 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -788,7 +788,7 @@ herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) + herr_t ret_value = SUCCEED; /* Initialize the tables */ init_table(group_table); @@ -1047,9 +1047,9 @@ h5tools_getstatus(void) int h5tools_getenv_update_hyperslab_bufsize(void) { - H5TOOLS_ERR_INIT(int, 1) const char *env_str = NULL; long hyperslab_bufsize_mb; + int ret_value = 1; /* check if environment variable is set for the hyperslab buffer size */ if (NULL != (env_str = HDgetenv ("H5TOOLS_BUFSIZE"))) { diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index a30da9b..1ecd5c0 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -254,12 +254,12 @@ static int traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, hbool_t recurse, const trav_visitor_t *visitor, unsigned fields) { - H5TOOLS_ERR_INIT(int, SUCCEED) H5O_info_t oinfo; /* Object info for starting group */ + int ret_value = 0; /* Get info for starting object */ if(H5Oget_info_by_name2(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info_by_name failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Oget_info_by_name failed"); /* Visit the starting object */ if(visit_start && visitor->visit_obj) @@ -289,12 +289,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start, if(recurse) { /* Visit all links in group, recursively */ if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Lvisit_by_name failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Lvisit_by_name failed"); } /* end if */ else { /* Iterate over links in group */ if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Literate_by_name failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Literate_by_name failed"); } /* end else */ /* Free visited addresses table */ @@ -429,8 +429,8 @@ trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) int h5trav_getinfo(hid_t file_id, trav_info_t *info) { - H5TOOLS_ERR_INIT(int, SUCCEED) trav_visitor_t info_visitor; /* Visitor structure for trav_info_t's */ + int ret_value = 0; /* Init visitor structure */ info_visitor.visit_obj = trav_info_visit_obj; @@ -439,7 +439,7 @@ h5trav_getinfo(hid_t file_id, trav_info_t *info) /* Traverse all objects in the file, visiting each object & link */ if(traverse(file_id, "/", TRUE, TRUE, &info_visitor, H5O_INFO_BASIC) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "traverse failed"); + H5TOOLS_GOTO_ERROR((-1), "traverse failed"); done: return ret_value; @@ -595,8 +595,8 @@ trav_table_visit_lnk(const char *path, const H5L_info_t H5_ATTR_UNUSED *linfo, v int h5trav_gettable(hid_t fid, trav_table_t *table) { - H5TOOLS_ERR_INIT(int, SUCCEED) trav_visitor_t table_visitor; /* Visitor structure for trav_table_t's */ + int ret_value = 0; /* Init visitor structure */ table_visitor.visit_obj = trav_table_visit_obj; @@ -605,7 +605,7 @@ h5trav_gettable(hid_t fid, trav_table_t *table) /* Traverse all objects in the file, visiting each object & link */ if(traverse(fid, "/", TRUE, TRUE, &table_visitor, H5O_INFO_BASIC) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "traverse failed"); + H5TOOLS_GOTO_ERROR((-1), "traverse failed"); done: return ret_value; @@ -1017,9 +1017,9 @@ trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) int h5trav_print(hid_t fid) { - H5TOOLS_ERR_INIT(int, SUCCEED) trav_print_udata_t print_udata; /* User data for traversal */ trav_visitor_t print_visitor; /* Visitor structure for printing objects */ + int ret_value = 0; /* Init user data for printing */ print_udata.fid = fid; @@ -1052,8 +1052,8 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, hbool_t recurse, h5trav_obj_func_t visit_obj, h5trav_lnk_func_t visit_lnk, void *udata, unsigned fields) { - H5TOOLS_ERR_INIT(int, SUCCEED) trav_visitor_t visitor; /* Visitor structure for objects */ + int ret_value = 0; /* Init visitor structure */ visitor.visit_obj = visit_obj; @@ -1062,7 +1062,7 @@ h5trav_visit(hid_t fid, const char *grp_name, hbool_t visit_start, /* Traverse all objects in the file, visiting each object & link */ if(traverse(fid, grp_name, visit_start, recurse, &visitor, fields) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "traverse failed"); + H5TOOLS_GOTO_ERROR((-1), "traverse failed"); done: return ret_value; @@ -1080,8 +1080,8 @@ done: herr_t symlink_visit_add(symlink_trav_t *visited, H5L_type_t type, const char *file, const char *path) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) - size_t idx; /* Index of address to use */ + size_t idx; /* Index of address to use */ + herr_t ret_value = SUCCEED; /* Allocate space if necessary */ if(visited->nused == visited->nalloc) { diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c index fee8777..86bd6f6 100644 --- a/tools/src/h5copy/h5copy.c +++ b/tools/src/h5copy/h5copy.c @@ -207,7 +207,6 @@ static int parse_flag(const char* s_flag, unsigned *flag) int main (int argc, const char *argv[]) { - H5TOOLS_ERR_INIT(int, 0) H5E_auto2_t func; H5E_auto2_t tools_func; void *edata; @@ -222,6 +221,7 @@ main (int argc, const char *argv[]) int opt; int li_ret; h5tool_link_info_t linkinfo; + int ret_value = 0; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index fe24868..03e7bed 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -1291,7 +1291,6 @@ print_type(h5tools_str_t *buffer, hid_t type, int ind) static void dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx, hid_t container, H5R_ref_t *ref_buf, int ndims) { - H5TOOLS_ERR_INIT(int, SUCCEED) hid_t new_obj_id = H5I_INVALID_HID; hid_t new_obj_sid = H5I_INVALID_HID; hsize_t elmt_counter = 0; /*counts the # elements printed. */ @@ -1301,7 +1300,6 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx h5tools_str_t buffer; /* string into which to render */ h5tools_context_t datactx; /* print context */ - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); datactx = *ctx; /* print context */ @@ -1336,12 +1334,12 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; if(H5Dclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); + H5TOOLS_INFO("H5Dclose H5R_OBJECT1:H5O_TYPE_DATASET failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_OBJECT1:H5O_TYPE_DATASET failed"); + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT1:H5O_TYPE_DATASET failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed"); + H5TOOLS_INFO("H5Ropen_object H5R_OBJECT1:H5O_TYPE_DATASET failed"); break; case H5O_TYPE_GROUP: @@ -1354,7 +1352,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx } /* end switch */ } else - H5TOOLS_ERROR(FAIL, "H5Rget_obj_type3 H5R_OBJECT1 failed"); + H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT1 failed"); break; case H5R_DATASET_REGION1: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1"); @@ -1363,12 +1361,12 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; if(H5Dclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Dclose H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION1 failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION1 failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_DATASET_REGION1 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION1 failed"); break; case H5R_OBJECT2: H5TOOLS_DEBUG("ref_type is H5R_OBJECT2"); @@ -1383,12 +1381,12 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx h5tools_dump_dset(stream, info, &datactx, new_obj_id); datactx.indent_level--; if(H5Oclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Oclose H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Oclose H5R_OBJECT2 failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Rdestroy H5R_OBJECT2 failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_OBJECT2 failed"); break; case H5O_TYPE_NAMED_DATATYPE: @@ -1402,7 +1400,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx } /* end switch */ } else - H5TOOLS_ERROR(FAIL, "H5Rget_obj_type3 H5R_OBJECT2 failed"); + H5TOOLS_INFO("H5Rget_obj_type3 H5R_OBJECT2 failed"); break; case H5R_DATASET_REGION2: H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2"); @@ -1412,7 +1410,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx /* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */ if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_ERROR(FAIL, "H5Ropen_object H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed"); else { if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) { @@ -1451,17 +1449,17 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx &buffer, &curr_pos, ncols, i, elmt_counter); } else - H5TOOLS_ERROR(FAIL, "invalid region type"); + H5TOOLS_INFO("invalid region type"); } /* end else to if (h5tools_is_zero(... */ if(H5Sclose(new_obj_sid) < 0) - H5TOOLS_ERROR(FAIL, "H5Sclose H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Sclose H5R_DATASET_REGION2 failed"); } else - H5TOOLS_ERROR(FAIL, "H5Ropen_region H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Ropen_region H5R_DATASET_REGION2 failed"); if(H5Dclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Dclose H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Dclose H5R_DATASET_REGION2 failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_DATASET_REGION2 failed"); + H5TOOLS_INFO("H5Rdestroy H5R_DATASET_REGION2 failed"); } break; case H5R_ATTR: @@ -1469,9 +1467,9 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) { h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); if(H5Aclose(new_obj_id) < 0) - H5TOOLS_ERROR(FAIL, "H5Aclose H5R_ATTR failed"); + H5TOOLS_INFO("H5Aclose H5R_ATTR failed"); if(H5Rdestroy(&ref_buf[i]) < 0) - H5TOOLS_ERROR(FAIL, "H5Rdestroy H5R_ATTR failed"); + H5TOOLS_INFO("H5Rdestroy H5R_ATTR failed"); } else { H5TOOLS_DEBUG("NULL H5R_ATTR"); @@ -1492,7 +1490,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx h5tools_str_append(&buffer, "}"); h5tools_render_element(stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0); - H5TOOLS_ERROR(FAIL, "H5Ropen_attr H5R_ATTR failed"); + H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed"); } break; case H5R_BADTYPE: @@ -1503,13 +1501,12 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx H5TOOLS_DEBUG("finished reference loop:%d",i); } /* end for(i = 0; i < ndims; i++, ctx->cur_elmt++, elmt_counter++) */ -done: + h5tools_str_close(&buffer); PRINTVALSTREAM(stream, "\n"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } /*------------------------------------------------------------------------- @@ -1523,7 +1520,6 @@ done: static void dump_dataset_values(hid_t dset) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) hid_t f_type = H5I_INVALID_HID; hid_t space = H5I_INVALID_HID; hsize_t total_size[H5S_MAX_RANK]; @@ -1539,7 +1535,6 @@ dump_dataset_values(hid_t dset) h5tool_format_t *info = &ls_dataformat; H5R_ref_t *ref_buf = NULL; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); f_type = H5Dget_type(dset); @@ -1638,7 +1633,7 @@ dump_dataset_values(hid_t dset) if (H5Tget_class(f_type) == H5T_REFERENCE) { H5TOOLS_DEBUG("reference class type"); if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { - H5TOOLS_GOTO_DONE(SUCCEED); + H5TOOLS_GOTO_DONE_NO_RET(); } ndims = (int)H5Sget_simple_extent_npoints(space); @@ -1658,7 +1653,8 @@ dump_dataset_values(hid_t dset) H5TOOLS_DEBUG("H5Dread reference read"); if(H5Dread(dset, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) { HDfree(ref_buf); - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread reference failed"); + H5TOOLS_INFO("H5Dread reference failed"); + H5TOOLS_GOTO_DONE_NO_RET(); } dump_reference(rawoutstream, info, &ctx, dset, ref_buf, ndims); HDfree(ref_buf); @@ -1680,7 +1676,6 @@ done: PRINTVALSTREAM(rawoutstream, "\n"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } @@ -1695,7 +1690,6 @@ done: static void dump_attribute_values(hid_t attr, const char *attr_name) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) hid_t f_type = H5I_INVALID_HID; hid_t space = H5I_INVALID_HID; hsize_t total_size[H5S_MAX_RANK]; @@ -1711,7 +1705,6 @@ dump_attribute_values(hid_t attr, const char *attr_name) h5tool_format_t *info = &ls_dataformat; H5R_ref_t *ref_buf = NULL; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); f_type = H5Aget_type(attr); @@ -1811,7 +1804,7 @@ dump_attribute_values(hid_t attr, const char *attr_name) if (H5Tget_class(f_type) == H5T_REFERENCE) { H5TOOLS_DEBUG("reference class type"); if (!H5Tequal(f_type, H5T_STD_REF) && !H5Tequal(f_type, H5T_STD_REF_DSETREG) && !H5Tequal(f_type, H5T_STD_REF_OBJ)) { - H5TOOLS_GOTO_DONE(SUCCEED); + H5TOOLS_GOTO_DONE_NO_RET(); } ndims = (int)H5Sget_simple_extent_npoints(space); @@ -1831,7 +1824,8 @@ dump_attribute_values(hid_t attr, const char *attr_name) H5TOOLS_DEBUG("H5Aread reference read"); if(H5Aread(attr, H5T_STD_REF, ref_buf) < 0) { HDfree(ref_buf); - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread reference failed"); + H5TOOLS_INFO("H5Aread reference failed"); + H5TOOLS_GOTO_DONE_NO_RET(); } ctx.indent_level++; dump_reference(rawoutstream, info, &ctx, attr, ref_buf, ndims); @@ -1859,7 +1853,6 @@ done: PRINTVALSTREAM(rawoutstream, "\n"); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); } /*------------------------------------------------------------------------- @@ -1875,7 +1868,6 @@ static herr_t list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ainfo, void H5_ATTR_UNUSED *op_data) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) hid_t attr = H5I_INVALID_HID; hid_t space = H5I_INVALID_HID; hid_t type = H5I_INVALID_HID; @@ -1889,7 +1881,6 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain h5tools_context_t ctx; /* print context */ h5tool_format_t *info = &ls_dataformat; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); HDmemset(&ctx, 0, sizeof(ctx)); @@ -1965,7 +1956,6 @@ list_attr(hid_t obj, const char *attr_name, const H5A_info_t H5_ATTR_UNUSED *ain h5tools_str_close(&buffer); } H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return 0; } @@ -2296,7 +2286,6 @@ datatype_list2(hid_t type, const char H5_ATTR_UNUSED *name) static herr_t list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void *_iter) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) H5O_type_t obj_type = oinfo->type; /* Type of the object */ iter_t *iter = (iter_t*)_iter; hsize_t curr_pos = 0; /* total data element position */ @@ -2304,7 +2293,6 @@ list_obj(const char *name, const H5O_info_t *oinfo, const char *first_seen, void h5tools_context_t ctx; /* print context */ h5tool_format_t *info = &ls_dataformat; - H5TOOLS_PUSH_STACK(); H5TOOLS_DEBUG("enter"); HDmemset(&ctx, 0, sizeof(ctx)); @@ -2439,7 +2427,6 @@ done: h5tools_str_close(&buffer); H5TOOLS_ENDDEBUG("exit"); - H5TOOLS_POP_STACK(); return 0; } /* end list_obj() */ diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index 0f77626..6f0e4eb 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -222,13 +222,13 @@ h5repack_addlayout(const char *str, pack_opt_t *options) hid_t copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { - H5TOOLS_ERR_INIT(hid_t, H5I_INVALID_HID) named_dt_t *dt = *named_dt_head_p; /* Stack pointer */ named_dt_t *dt_ret = NULL; /* Datatype to return */ H5O_info_t oinfo; /* Object info of input dtype */ + hid_t ret_value = H5I_INVALID_HID; if (H5Oget_info2(type_in, &oinfo, H5O_INFO_BASIC) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Oget_info failed"); if (*named_dt_head_p) { /* Stack already exists, search for the datatype */ @@ -244,7 +244,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t if (travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { /* Push onto the stack */ if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) - H5TOOLS_GOTO_ERROR(FAIL, "buffer allocation failed failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed"); dt->next = *named_dt_head_p; *named_dt_head_p = dt; @@ -266,7 +266,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t if (!dt_ret) { /* Push the new datatype onto the stack */ if (NULL == (dt_ret = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) - H5TOOLS_GOTO_ERROR(FAIL, "buffer allocation failed failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "buffer allocation failed failed"); dt_ret->next = *named_dt_head_p; *named_dt_head_p = dt_ret; @@ -284,9 +284,9 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t else dt_ret->id_out = H5Tcopy(type_in); if (dt_ret->id_out < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_native_type-H5Tcopy failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Tget_native_type-H5Tcopy failed"); if (H5Tcommit_anon(fidout, dt_ret->id_out, H5P_DEFAULT, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tcommit_anon failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Tcommit_anon failed"); } /* end if named datatype not yet in output file */ /* Set return value */ @@ -296,7 +296,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t * to close it. (TODO: fix scope envy) */ if (H5Iinc_ref(ret_value) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Iinc_ref failed"); + H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Iinc_ref failed"); done: return ret_value; @@ -311,13 +311,13 @@ done: int named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err) { - H5TOOLS_ERR_INIT(int, -1) named_dt_t *dt = *named_dt_head_p; + int ret_value = -1; while (dt) { /* Pop the datatype off the stack and free it */ if (H5Tclose(dt->id_out) < 0 && !ignore_err) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); dt = dt->next; HDfree(*named_dt_head_p); *named_dt_head_p = dt; @@ -343,7 +343,6 @@ done: int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_t *travt, pack_opt_t *options) { - H5TOOLS_ERR_INIT(int, 0) hid_t attr_id = -1; /* attr ID */ hid_t attr_out = -1; /* attr ID */ hid_t space_id = -1; /* space ID */ @@ -361,9 +360,10 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ unsigned u; hbool_t is_ref = 0; H5T_class_t type_class = -1; + int ret_value = 0; if (H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); /*------------------------------------------------------------------------- * copy all attributes @@ -372,33 +372,33 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ for (u = 0; u < (unsigned) oinfo.num_attrs; u++) { /* open attribute */ if ((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t) u, H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed"); if (H5Aget_name(attr_id, (size_t) 255, name) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); /* get the file datatype */ if ((ftype_id = H5Aget_type(attr_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed"); /* Check if the datatype is committed */ if ((is_named = H5Tcommitted(ftype_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tcommitted failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed"); if (is_named && travt) { hid_t fidout = -1; /* Create out file id */ if ((fidout = H5Iget_file_id(loc_out)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Iget_file_id failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Iget_file_id failed"); /* Copy named dt */ if ((wtype_id = copy_named_datatype(ftype_id, fidout, named_dt_head_p, travt, options)) < 0) { H5Fclose(fidout); - H5TOOLS_GOTO_ERROR(FAIL, "copy_named_datatype failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); } if (H5Fclose(fidout) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Fclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Fclose failed"); } /* end if datatype is committed and we have a traversal table */ else { if (options->use_native == 1) @@ -409,18 +409,18 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ /* get the dataspace handle */ if ((space_id = H5Aget_space(attr_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed"); /* get dimensions */ if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); nelmts = 1; for (j = 0; j < rank; j++) nelmts *= dims[j]; if ((msize = H5Tget_size(wtype_id)) == 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_size failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); /*--------------------------------------------------------------------- * object references are a special case. We cannot just copy the @@ -437,7 +437,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ base_type = H5Tget_super(ftype_id); is_ref = (is_ref || (H5Tget_class(base_type) == H5T_REFERENCE)); if (H5Tclose(base_type) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose base_type failed"); + H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); } /* end if type_class is variable length or array */ if (type_class == H5T_COMPOUND) { @@ -447,7 +447,7 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ hid_t mtid = H5Tget_member_type(wtype_id, (unsigned)j); H5T_class_t mtclass = H5Tget_class(mtid); if (H5Tclose(mtid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose mtid failed"); + H5TOOLS_ERROR((-1), "H5Tclose mtid failed"); if (mtclass == H5T_REFERENCE) { is_ref = 1; @@ -464,10 +464,10 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ buf = (void *)HDmalloc((size_t)(nelmts * msize)); if (buf == NULL) { - H5TOOLS_GOTO_ERROR(FAIL, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if (H5Aread(attr_id, wtype_id, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); /*----------------------------------------------------------------- * copy @@ -475,13 +475,13 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ */ if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Acreate2 failed on ,%s>", name); + H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed on ,%s>", name); if (H5Awrite(attr_out, wtype_id, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Awrite failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed"); /*close*/ if (H5Aclose(attr_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); /* Check if we have VL data and string in the attribute's datatype that must * be reclaimed */ @@ -499,16 +499,16 @@ copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, trav_table_ *--------------------------------------------------------------------- */ if (H5Sclose(space_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); space_id = -1; if (H5Tclose(wtype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); wtype_id = -1; if (H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); ftype_id = -1; if (H5Aclose(attr_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); attr_id = -1; } /* for u (each attribute) */ @@ -546,10 +546,10 @@ done: static int check_options(pack_opt_t *options) { - H5TOOLS_ERR_INIT(int, 0) unsigned int i; int k, j, has_cp = 0, has_ck = 0; char slayout[30]; + int ret_value = 0; /*------------------------------------------------------------------------- * Objects to layout @@ -573,11 +573,11 @@ check_options(pack_opt_t *options) break; case H5D_LAYOUT_ERROR: case H5D_NLAYOUTS: - H5TOOLS_GOTO_ERROR(FAIL, "invalid layout"); + H5TOOLS_GOTO_ERROR((-1), "invalid layout"); break; default: strcpy(slayout, "invalid layout\n"); - H5TOOLS_GOTO_DONE(FAIL); + H5TOOLS_GOTO_DONE((-1)); } HDprintf(" Apply %s layout to all", slayout); if (H5D_CHUNKED == options->layout_g) { @@ -612,7 +612,7 @@ check_options(pack_opt_t *options) } /* end for each object in options */ if (options->all_layout == 1 && has_ck) - H5TOOLS_GOTO_ERROR(FAIL, "invalid chunking input: 'all' option is present with other objects"); + H5TOOLS_GOTO_ERROR((-1), "invalid chunking input: 'all' option is present with other objects"); /*------------------------------------------------------------------------- * Objects to filter @@ -670,7 +670,7 @@ check_options(pack_opt_t *options) } /* end for each object in options table */ if (options->all_filter == 1 && has_cp) - H5TOOLS_GOTO_ERROR(FAIL, "invalid compression input: 'all' option is present with other objects"); + H5TOOLS_GOTO_ERROR((-1), "invalid compression input: 'all' option is present with other objects"); /*------------------------------------------------------------------------- * Check options for the latest format @@ -678,14 +678,14 @@ check_options(pack_opt_t *options) */ if (options->grp_compact < 0) - H5TOOLS_GOTO_ERROR(FAIL, "invalid maximum number of links to store as header messages"); + H5TOOLS_GOTO_ERROR((-1), "invalid maximum number of links to store as header messages"); if (options->grp_indexed < 0) - H5TOOLS_GOTO_ERROR(FAIL, "invalid minimum number of links to store in the indexed format"); + H5TOOLS_GOTO_ERROR((-1), "invalid minimum number of links to store in the indexed format"); if (options->grp_indexed > options->grp_compact) - H5TOOLS_GOTO_ERROR(FAIL, "minimum indexed size is greater than the maximum compact size"); + H5TOOLS_GOTO_ERROR((-1), "minimum indexed size is greater than the maximum compact size"); for (i = 0; i < 8; i++) if (options->msg_size[i] < 0) - H5TOOLS_GOTO_ERROR(FAIL, "invalid shared message size"); + H5TOOLS_GOTO_ERROR((-1), "invalid shared message size"); /*------------------------------------------------------------------------ * Verify new user userblock options; file name must be present @@ -699,7 +699,7 @@ check_options(pack_opt_t *options) } if (options->ublock_filename == NULL && options->ublock_size != 0) - H5TOOLS_GOTO_ERROR(FAIL, "file name missing for user block", options->ublock_filename); + H5TOOLS_GOTO_ERROR((-1), "file name missing for user block", options->ublock_filename); /*------------------------------------------------------------------------ * Verify alignment options; threshold is zero default but alignment not @@ -707,7 +707,7 @@ check_options(pack_opt_t *options) */ if (options->alignment == 0 && options->threshold != 0) - H5TOOLS_GOTO_ERROR(FAIL, "alignment for H5Pset_alignment missing"); + H5TOOLS_GOTO_ERROR((-1), "alignment for H5Pset_alignment missing"); done: return ret_value; @@ -725,13 +725,13 @@ done: static int check_objects(const char* fname, pack_opt_t *options) { - H5TOOLS_ERR_INIT(int, 0) hid_t fid = -1; hid_t did = -1; hid_t sid = -1; unsigned int i; - int ifil; + int ifil; trav_table_t *travt = NULL; + int ret_value = 0; /* nothing to do */ if (options->op_tbl->nelems == 0) @@ -742,7 +742,7 @@ check_objects(const char* fname, pack_opt_t *options) *------------------------------------------------------------------------- */ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); /*------------------------------------------------------------------------- * get the list of objects in the file @@ -756,7 +756,7 @@ check_objects(const char* fname, pack_opt_t *options) /* get the list of objects in the file */ if (h5trav_gettable(fid, travt) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5trav_gettable failed"); + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); /*------------------------------------------------------------------------- * compare with user supplied list @@ -775,14 +775,14 @@ check_objects(const char* fname, pack_opt_t *options) /* the input object names are present in the file and are valid */ if (h5trav_getindext(name, travt) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "%s Could not find <%s> in file <%s>. Exiting...\n", + H5TOOLS_GOTO_ERROR((-1), "%s Could not find <%s> in file <%s>. Exiting...\n", (options->verbose ? "\n" : ""), name, fname); if (options->verbose) HDprintf("...Found\n"); for (ifil = 0; ifil < obj.nfilters; ifil++) { if (obj.filter[ifil].filtn < 0) - H5TOOLS_GOTO_ERROR(FAIL, "invalid filter"); + H5TOOLS_GOTO_ERROR((-1), "invalid filter"); /* check for extra filter conditions */ switch (obj.filter[ifil].filtn) { /* chunk size must be smaller than pixels per block */ @@ -801,20 +801,20 @@ check_objects(const char* fname, pack_opt_t *options) } else { if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if ((sid = H5Dget_space(did)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); if (H5Sget_simple_extent_dims(sid, dims, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); for (j = 0; j < rank; j++) csize *= dims[j]; if (H5Sclose(sid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if (H5Dclose(did) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } if (csize < ppb) { diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index c20219e..613606f 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -61,7 +61,6 @@ static void print_user_block(const char *filename, hid_t fid); int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) { - H5TOOLS_ERR_INIT(int, 0) hid_t fidin = -1; hid_t fidout = -1; hid_t fcpl_in = -1; /* file creation property list ID for input file */ @@ -80,65 +79,66 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) hsize_t in_threshold; /* Free-space section threshold from input file */ hsize_t in_pagesize; /* File space page size from input file */ unsigned crt_order_flags; /* group creation order flag */ + int ret_value = 0; /*------------------------------------------------------------------------- * open input file *------------------------------------------------------------------------- */ if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR); + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR); /* get user block size and file space strategy/persist/threshold */ { if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Fget_create_plist failed to retrieve file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); if (H5Pget_userblock(fcpl_in, &ub_size) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_userblock failed to retrieve userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_userblock failed to retrieve userblock size"); /* If the -S option is not set, get "strategy" from the input file */ if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_file_space_strategy failed to retrieve file space strategy"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy"); /* If the -G option is not set, get "pagesize" from the input file */ if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_file_space_page_size failed to retrieve file space threshold"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space threshold"); /* open root group */ if ((grp_in = H5Gopen2(fidin, "/", H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); /* get root group creation property list */ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); /* query and set the group creation properties */ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); if (H5Pclose(fcpl_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed to close property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list"); } if(options->latest) options->low_bound = options->high_bound = H5F_LIBVER_LATEST; /* Create file access property list */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed to create file access property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); /* It can be default, latest or other settings by users */ if(H5Pset_libver_bounds(fapl, options->low_bound, options->high_bound) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_libver_bounds failed to set format version bounds"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds"); /* Check if we need to create a non-default file creation property list */ if (options->low_bound >= H5F_LIBVER_V18 || ub_size > 0) { /* Create file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed to create a file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list"); if (ub_size > 0) if (H5Pset_userblock(fcpl, ub_size) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_userblock failed to set non-default userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_userblock failed to set non-default userblock size"); if (options->low_bound >= H5F_LIBVER_V18) { unsigned i = 0, nindex = 0, mesg_type_flags[5], min_mesg_sizes[5]; @@ -146,7 +146,7 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) /* Adjust group creation parameters for root group */ /* (So that it is created in "dense storage" form) */ if (H5Pset_link_phase_change(fcpl, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_link_phase_change failed to adjust group creation parameters for root group"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed to adjust group creation parameters for root group"); for (i = 0; i < 5; i++) { if (options->msg_size[i] > 0) { @@ -182,12 +182,12 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) if (nindex > 0) { if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_nindexes failed to set the number of shared object header message indexes"); /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */ for (i = 0; i < (nindex - 1); i++) if (H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_shared_mesg_index failed to configure the specified shared object header message index"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shared_mesg_index failed to configure the specified shared object header message index"); } /* if (nindex>0) */ } /* end if */ @@ -205,11 +205,11 @@ print_user_block(fnamein, fidin); if (fcpl == H5P_DEFAULT) /* create a file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed to create a file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list"); /* set user block size */ if (H5Pset_userblock(fcpl, options->ublock_size) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_userblock failed to set userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_userblock failed to set userblock size"); } /*------------------------------------------------------------------------- @@ -221,10 +221,10 @@ print_user_block(fnamein, fidin); if (fapl == H5P_DEFAULT) /* create a file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed to create file access property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_alignment failed to set alignment"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_alignment failed to set alignment"); } /*------------------------------------------------------------------------- @@ -236,10 +236,10 @@ print_user_block(fnamein, fidin); if (fapl == H5P_DEFAULT) /* create a file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed to create file access property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list"); if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_meta_block_size failed to set metadata block size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_meta_block_size failed to set metadata block size"); } /*------------------------------------------------------------------------- @@ -251,10 +251,10 @@ print_user_block(fnamein, fidin); if (fcpl == H5P_DEFAULT) /* create a file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed to create a file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create a file creation property list"); if(H5Pset_link_creation_order(fcpl, crt_order_flags ) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed"); /* Set file space info to those from input file */ set_strategy = in_strategy; @@ -279,7 +279,7 @@ print_user_block(fnamein, fidin); /* Set file space information as specified */ if(H5Pset_file_space_strategy(fcpl, set_strategy, set_persist, set_threshold) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_file_space_strategy failed to set file space strategy"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_strategy failed to set file space strategy"); if(options->fs_pagesize == -1) /* A "0" file space page size is specified by user */ set_pagesize = (hsize_t)0; @@ -288,7 +288,7 @@ print_user_block(fnamein, fidin); if(set_pagesize != FS_PAGESIZE_DEF) /* Set non-default file space page size as specified */ if(H5Pset_file_space_page_size(fcpl, set_pagesize) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_file_space_page_size failed to set file space page size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_file_space_page_size failed to set file space page size"); /*------------------------------------------------------------------------- * create the output file @@ -298,7 +298,7 @@ print_user_block(fnamein, fidin); HDprintf("Making new file ...\n"); if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Fcreate could not create file <%s>:", fnameout); + H5TOOLS_GOTO_ERROR((-1), "H5Fcreate could not create file <%s>:", fnameout); /*------------------------------------------------------------------------- * write a new user block if requested @@ -306,7 +306,7 @@ print_user_block(fnamein, fidin); */ if (options->ublock_size > 0) if (copy_user_block(options->ublock_filename, fnameout, options->ublock_size) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "Could not copy user block. Exiting..."); + H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting..."); /*------------------------------------------------------------------------- * get list of objects @@ -321,14 +321,14 @@ print_user_block(fnamein, fidin); if (travt) { /* get the list of objects in the file */ if (h5trav_gettable(fidin, travt) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5trav_gettable failed"); + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); /*------------------------------------------------------------------------- * do the copy *------------------------------------------------------------------------- */ if (do_copy_objects(fidin, fidout, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout); + H5TOOLS_GOTO_ERROR((-1), "do_copy_objects from <%s> could not copy data to <%s>", fnamein, fnameout); /*------------------------------------------------------------------------- * do the copy of referenced objects @@ -336,7 +336,7 @@ print_user_block(fnamein, fidin); *------------------------------------------------------------------------- */ if (do_copy_refobjs(fidin, fidout, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout); + H5TOOLS_GOTO_ERROR((-1), "do_copy_refobjs from <%s> could not copy data to <%s>", fnamein, fnameout); } /*------------------------------------------------------------------------- @@ -346,7 +346,7 @@ print_user_block(fnamein, fidin); if (ub_size > 0 && options->ublock_size == 0) if (copy_user_block(fnamein, fnameout, ub_size) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "Could not copy user block. Exiting..."); + H5TOOLS_GOTO_ERROR((-1), "Could not copy user block. Exiting..."); done: H5E_BEGIN_TRY { @@ -402,7 +402,6 @@ int get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p) { - H5TOOLS_ERR_INIT(int, 0) int k; H5D_layout_t dset_layout; int rank_chunk; @@ -413,6 +412,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], hsize_t chunk_dims_map[H5S_MAX_RANK]; /* mapped chunk dimentions */ hsize_t hs_dims_map[H5S_MAX_RANK]; /* mapped hyperslab dimentions */ hsize_t hslab_nbytes; /* size of hyperslab in byte */ + int ret_value = 0; /* init to set as size of a data element */ hslab_nbytes = size_datum; @@ -425,7 +425,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], /* get chunk dims */ rank_chunk = H5Pget_chunk(dcpl_id, rank_dset, dims_chunk); if (rank_chunk < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); for (k = rank_dset; k > 0; --k) size_chunk *= dims_chunk[k - 1]; @@ -487,7 +487,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], hslab_nbytes *= dims_hslab[k - 1]; if (hslab_nbytes <= 0) - H5TOOLS_GOTO_ERROR(FAIL, "calculate total size for the hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "calculate total size for the hyperslab failed"); } } } @@ -511,7 +511,7 @@ get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], hslab_nbytes *= dims_hslab[k - 1]; if (hslab_nbytes <= 0) - H5TOOLS_GOTO_ERROR(FAIL, "calculate total size for the hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "calculate total size for the hyperslab failed"); } } @@ -580,7 +580,6 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - H5TOOLS_ERR_INIT(int, 0) hid_t grp_in = -1; /* group ID */ hid_t grp_out = -1; /* group ID */ hid_t dset_in = -1; /* read dataset ID */ @@ -617,6 +616,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, htri_t is_named; hbool_t limit_maxdims; hsize_t size_dset; + int ret_value = 0; /*------------------------------------------------------------------------- * copy the supplied object list @@ -649,22 +649,22 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* open input group */ if ((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); /* get input group creation property list */ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); /* query and set the group creation properties */ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); /* set up group creation property list */ if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_creation_order failed"); /*------------------------------------------------------------------------- * the root is a special case, we get an ID for the root group @@ -673,15 +673,15 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ if (HDstrcmp(travt->objs[i].name, "/") == 0) { if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); } else { if (options->grp_compact > 0 || options->grp_indexed > 0) if (H5Pset_link_phase_change(gcpl_out, (unsigned) options->grp_compact, (unsigned) options->grp_indexed) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_link_phase_change failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_link_phase_change failed"); if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gcreate2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gcreate2 failed"); } /*------------------------------------------------------------------------- @@ -689,16 +689,16 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, *------------------------------------------------------------------------- */ if (copy_attr(grp_in, grp_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); if (H5Pclose(gcpl_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Pclose(gcpl_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Gclose(grp_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); if (H5Gclose(grp_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); break; @@ -740,23 +740,23 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* early detection of references */ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if ((ftype_id = H5Dget_type(dset_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); if (H5T_REFERENCE == H5Tget_class(ftype_id)) is_ref = 1; /* Check if the datatype is committed */ if ((is_named = H5Tcommitted(ftype_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tcommitted failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tcommitted failed"); if (is_named) if ((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_named_datatype failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); if (H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if (H5Dclose(dset_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); /*------------------------------------------------------------------------- * check if we should use H5Ocopy or not @@ -770,20 +770,20 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, int j; if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if ((f_space_id = H5Dget_space(dset_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); if ((ftype_id = H5Dget_type(dset_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); if (H5Dget_space_status(dset_in, &space_status) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space_status failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space_status failed"); /* If the input dataset has external storage, it must be contiguous. * Accordingly, there would be no filter or chunk properties to preserve, @@ -792,10 +792,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ if (H5Pget_external_count(dcpl_in)) { if ((dcpl_out = H5Pcreate(H5P_DATASET_CREATE)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); } else if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) { - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcopy failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcopy failed"); } nelmts = 1; @@ -811,7 +811,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, } if ((msize = H5Tget_size(wtype_id)) == 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_size failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); /* size of current dset */ size_dset = nelmts * msize; @@ -848,7 +848,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* apply the filter */ if (apply_s) if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "apply_filters failed"); + H5TOOLS_GOTO_ERROR((-1), "apply_filters failed"); /* only if layout change requested for entire file or * individual obj */ @@ -888,13 +888,13 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, *------------------------------------------------------------------------- */ dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); - if (dset_out == FAIL) { + if (dset_out == H5I_INVALID_HID) { H5TOOLS_INFO("H5Dcreate2 failed"); if (options->verbose) HDprintf(" warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name); if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dcreate2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); apply_f = 0; } /* end if retry dataset create */ @@ -911,15 +911,15 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (buf != NULL) { if(H5Dread(dset_in, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); if(H5Dwrite(dset_out, wtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dwrite failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); /* Check if we have VL data in the dataset's * datatype that must be reclaimed */ if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) if (H5Treclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Treclaim failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Treclaim failed"); if (buf != NULL) { /* TODO: is buf potentially released by H5Dvlen_reclaim()? */ HDfree(buf); @@ -965,11 +965,11 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* get hyperslab dims and size in byte */ if (get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "get_hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "get_hyperslab failed"); hslab_buf = HDmalloc((size_t)hslab_nbytes); if (hslab_buf == NULL) - H5TOOLS_GOTO_ERROR(FAIL, "can't allocate space for hyperslab"); + H5TOOLS_GOTO_ERROR((-1), "can't allocate space for hyperslab"); hslab_nelmts = hslab_nbytes / p_type_nbytes; hslab_space = H5Screate_simple(1, &hslab_nelmts, NULL); @@ -993,9 +993,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, } if (H5Sselect_hyperslab(f_space_id, H5S_SELECT_SET, hs_sel_offset, NULL, hs_sel_count, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sselect_hyperslab failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sselect_hyperslab failed"); } /* end if rank > 0 */ else { H5Sselect_all(f_space_id); @@ -1004,9 +1004,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, } /* end (else) rank == 0 */ if(H5Dread(dset_in, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); if(H5Dwrite(dset_out, wtype_id, hslab_space, f_space_id, H5P_DEFAULT, hslab_buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dwrite failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); /* reclaim any VL memory, if necessary */ if (vl_data) @@ -1066,10 +1066,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, *------------------------------------------------------------------------- */ if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); if (H5Dclose(dset_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /* end if not a reference */ } /* end if h5tools_canreadf (filter availability check) */ @@ -1078,17 +1078,17 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, *------------------------------------------------------------------------- */ if (H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if (H5Tclose(wtype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if (H5Pclose(dcpl_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Pclose(dcpl_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Sclose(f_space_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if (H5Dclose(dset_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /*------------------------------------------------------------------------- * We do not have request for filter/chunking; use H5Ocopy instead @@ -1099,11 +1099,11 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* create property to pass copy options */ if ((pid = H5Pcreate(H5P_OBJECT_COPY)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed"); /* set options for object copy */ if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_copy_object failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_copy_object failed"); if (H5Ocopy(fidin, /* Source file or group identifier */ travt->objs[i].name, /* Name of the source object to be copied */ @@ -1111,25 +1111,25 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, travt->objs[i].name, /* Name of the destination object */ pid, /* Properties which apply to the copy */ H5P_DEFAULT) < 0) /* Properties which apply to the new hard link */ - H5TOOLS_GOTO_ERROR(FAIL, "H5Ocopy failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Ocopy failed"); if (H5Pclose(pid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); /*------------------------------------------------------------------------- * Copy attrs manually *------------------------------------------------------------------------- */ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); if (H5Dclose(dset_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); if (H5Dclose(dset_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); if (options->verbose) HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name); @@ -1146,27 +1146,27 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HDprintf(FORMAT_OBJ, "type", travt->objs[i].name); if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Topen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed"); /* Copy the datatype anonymously */ if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_named_datatype failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_named_datatype failed"); /* Link in to group structure */ if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Lcreate_hard failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Lcreate_hard failed"); /*------------------------------------------------------------------------- * copy attrs *------------------------------------------------------------------------- */ if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); if (H5Tclose(type_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if (H5Tclose(type_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); type_out = -1; /* named datatypes stack, named_dt_head, manages allocation */ break; @@ -1185,14 +1185,14 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Lcopy failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Lcopy failed"); if (options->verbose) HDprintf(FORMAT_OBJ, "link", travt->objs[i].name); break; default: - H5TOOLS_GOTO_ERROR(FAIL, "Object type not found"); + H5TOOLS_GOTO_ERROR((-1), "Object type not found"); } /* switch */ } /* end for each object to traverse */ } /* end if there are objects */ @@ -1203,7 +1203,7 @@ done: * because of reference counting */ if (0 == ret_value && named_dt_head != NULL) { if (named_datatype_free(&named_dt_head, 0) < 0) - H5TOOLS_ERROR(FAIL, "named_datatype_free failed"); + H5TOOLS_ERROR((-1), "named_datatype_free failed"); } else H5E_BEGIN_TRY { @@ -1354,16 +1354,16 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) static int copy_user_block(const char *infile, const char *outfile, hsize_t size) { - H5TOOLS_ERR_INIT(int, 0) int infid = -1, outfid = -1; /* File descriptors */ + int ret_value = 0; /* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */ /* Open files */ if ((infid = HDopen(infile, O_RDONLY)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "HDopen failed input file <%s>", infile); + H5TOOLS_GOTO_ERROR((-1), "HDopen failed input file <%s>", infile); if ((outfid = HDopen(outfile, O_WRONLY)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "HDopen failed output file <%s>", outfile); + H5TOOLS_GOTO_ERROR((-1), "HDopen failed output file <%s>", outfile); /* Copy the userblock from the input file to the output file */ while (size > 0) { @@ -1377,7 +1377,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) else nread = HDread(infid, rbuf, (size_t)size); if (nread < 0) - H5TOOLS_GOTO_ERROR(FAIL, "HDread failed to read userblock"); + H5TOOLS_GOTO_ERROR((-1), "HDread failed to read userblock"); /* Write buffer to destination file */ /* (compensating for interrupted writes & checking for errors, etc.) */ @@ -1390,7 +1390,7 @@ copy_user_block(const char *infile, const char *outfile, hsize_t size) nwritten = HDwrite(outfid, wbuf, (size_t)nbytes); } while (-1 == nwritten && EINTR == errno); if (-1 == nwritten) /* error */ - H5TOOLS_GOTO_ERROR(FAIL, "HDwrite failed"); + H5TOOLS_GOTO_ERROR((-1), "HDwrite failed"); HDassert(nwritten > 0); HDassert(nwritten <= nbytes); @@ -1426,29 +1426,29 @@ static void print_user_block(const char *filename, hid_t fid) { - H5TOOLS_ERR_INIT(int, 0) int fh = -1; /* file handle */ hsize_t ub_size; /* user block size */ hsize_t size; /* size read */ hid_t fcpl = -1; /* file creation property list ID for HDF5 file */ int i; + int ret_value = 0; /* get user block size */ if ((fcpl = H5Fget_create_plist(fid)) < 0) { - H5TOOLS_GOTO_ERROR(FAIL, "H5Fget_create_plist failed to retrieve file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); } if (H5Pget_userblock(fcpl, &ub_size) < 0) { - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_userblock failed to retrieve userblock size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_userblock failed to retrieve userblock size"); } if (H5Pclose(fcpl) < 0) { - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed to close property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed to close property list"); } /* open file */ if ((fh = HDopen(filename, O_RDONLY)) < 0) { - H5TOOLS_GOTO_ERROR(FAIL, "HDopen failed to open file <%s>", filename); + H5TOOLS_GOTO_ERROR((-1), "HDopen failed to open file <%s>", filename); } size = ub_size; @@ -1472,7 +1472,7 @@ print_user_block(const char *filename, hid_t fid) HDprintf("\n"); if (nread < 0) { - H5TOOLS_GOTO_ERROR(FAIL, "nread < 0"); + H5TOOLS_GOTO_ERROR((-1), "nread < 0"); } /* update size of userblock left to transfer */ diff --git a/tools/src/h5repack/h5repack_filters.c b/tools/src/h5repack/h5repack_filters.c index 407dac0..d1179fb 100644 --- a/tools/src/h5repack/h5repack_filters.c +++ b/tools/src/h5repack/h5repack_filters.c @@ -36,35 +36,35 @@ static int aux_copy_obj(hid_t dcpl_id, /* dataset creation property list */ const char* name, /* object name from traverse list */ pack_info_t *objout /*OUT*/) /* info about object to filter */ { - H5TOOLS_ERR_INIT(int, 0) int nfilters; /* number of filters in DCPL */ char f_objname[256]; /* filter objname */ H5D_layout_t layout; int rank; /* rank of dataset */ hsize_t chsize[64]; /* chunk size in elements */ - int i; - unsigned u; + int i; + unsigned u; + int ret_value = 0; /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_nfilters failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); /* copy filter_info_t structure */ for (i = 0; i < nfilters; i++) { if ((objout->filter[i].filtn = H5Pget_filter2(dcpl_id, (unsigned) i, &objout->filter[i].filt_flag, &objout->filter[i].cd_nelmts, objout->filter[i].cd_values, sizeof(f_objname), f_objname, NULL)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_filter2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_filter2 failed"); } objout->nfilters = nfilters; HDstrcpy(objout->path, name); if ((layout = H5Pget_layout(dcpl_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_layout failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed"); objout->layout = layout; if (layout == H5D_CHUNKED) { if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); objout->chunk.rank = rank; for (u = 0; u < (unsigned)rank; u++) objout->chunk.chunk_lengths[u] = chsize[u]; @@ -238,13 +238,13 @@ int apply_filters(const char* name, /* object name from traverse list */ pack_opt_t *options, /* repack options */ int *has_filter) /* (OUT) object NAME has a filter */ { - H5TOOLS_ERR_INIT(int, 0) - int nfilters; /* number of filters in DCPL */ - hsize_t chsize[64]; /* chunk size in elements */ + int nfilters; /* number of filters in DCPL */ + hsize_t chsize[64]; /* chunk size in elements */ H5D_layout_t layout; - int i; - pack_info_t obj; - pack_info_t filtobj; + int i; + pack_info_t obj; + pack_info_t filtobj; + int ret_value = 0; *has_filter = 0; @@ -267,7 +267,7 @@ int apply_filters(const char* name, /* object name from traverse list */ /* get information about input filters */ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_nfilters failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_nfilters failed"); /*------------------------------------------------------------------------- @@ -279,12 +279,12 @@ int apply_filters(const char* name, /* object name from traverse list */ if (nfilters && obj.nfilters) { *has_filter = 1; if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Premove_filter failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed"); } else if(nfilters) { *has_filter = 1; if (aux_copy_obj(dcpl_id, name, &filtobj) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "aux_copy_obj failed"); + H5TOOLS_GOTO_ERROR((-1), "aux_copy_obj failed"); } /*------------------------------------------------------------------------- @@ -294,11 +294,11 @@ int apply_filters(const char* name, /* object name from traverse list */ */ if (obj.layout == -1) { if ((layout = H5Pget_layout(dcpl_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_layout failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_layout failed"); if (layout == H5D_CHUNKED) { if ((rank = H5Pget_chunk(dcpl_id, NELMTS(chsize), chsize/*out*/)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_chunk failed"); obj.layout = H5D_CHUNKED; obj.chunk.rank = rank; for (i = 0; i < rank; i++) @@ -340,7 +340,7 @@ int apply_filters(const char* name, /* object name from traverse list */ for (i = rank; i > 0; --i) { hsize_t size = 0; if(sm_nbytes == 0) - H5TOOLS_GOTO_ERROR(FAIL, "number of bytes per stripmine must be > 0"); + H5TOOLS_GOTO_ERROR((-1), "number of bytes per stripmine must be > 0"); size = H5TOOLS_BUFSIZE / sm_nbytes; if (size == 0) /* datum size > H5TOOLS_BUFSIZE */ size = 1; @@ -355,7 +355,7 @@ int apply_filters(const char* name, /* object name from traverse list */ for (i = 0; i < obj.nfilters; i++) { if (obj.filter[i].filtn < 0) - H5TOOLS_GOTO_ERROR(FAIL, "invalid filter"); + H5TOOLS_GOTO_ERROR((-1), "invalid filter"); switch (obj.filter[i].filtn) { /*------------------------------------------------------------------------- @@ -376,9 +376,9 @@ int apply_filters(const char* name, /* object name from traverse list */ aggression = obj.filter[i].cd_values[0]; /* set up for deflated data */ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_deflate(dcpl_id, aggression) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_deflate failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_deflate failed"); } break; @@ -396,9 +396,9 @@ int apply_filters(const char* name, /* object name from traverse list */ /* set up for szip data */ if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_szip(dcpl_id, options_mask, pixels_per_block) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_szip failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_szip failed"); } break; @@ -408,9 +408,9 @@ int apply_filters(const char* name, /* object name from traverse list */ */ case H5Z_FILTER_SHUFFLE: if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_shuffle(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_shuffle failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_shuffle failed"); break; /*------------------------------------------------------------------------- @@ -419,9 +419,9 @@ int apply_filters(const char* name, /* object name from traverse list */ */ case H5Z_FILTER_FLETCHER32: if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_fletcher32(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fletcher32 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_fletcher32 failed"); break; /*----------- ------------------------------------------------------------- * H5Z_FILTER_NBIT , NBIT compression @@ -429,9 +429,9 @@ int apply_filters(const char* name, /* object name from traverse list */ */ case H5Z_FILTER_NBIT: if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_nbit(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_nbit failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_nbit failed"); break; /*----------- ------------------------------------------------------------- * H5Z_FILTER_SCALEOFFSET , scale+offset compression @@ -446,19 +446,19 @@ int apply_filters(const char* name, /* object name from traverse list */ scale_factor = (int) obj.filter[i].cd_values[1]; if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_scaleoffset(dcpl_id, scale_type, scale_factor) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_scaleoffset failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_scaleoffset failed"); } break; default: { if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); if (H5Pset_filter(dcpl_id, obj.filter[i].filtn, obj.filter[i].filt_flag, obj.filter[i].cd_nelmts, obj.filter[i].cd_values) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_filter failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_filter failed"); } break; } /* switch */ @@ -469,10 +469,10 @@ int apply_filters(const char* name, /* object name from traverse list */ if (filtobj.nfilters) { for (i = 0; i < filtobj.nfilters; i++) { if (filtobj.filter[i].filtn < 0) - H5TOOLS_GOTO_ERROR(FAIL, "invalid filter"); + H5TOOLS_GOTO_ERROR((-1), "invalid filter"); if (H5Zfilter_avail(filtobj.filter[i].filtn) <= 0) - H5TOOLS_GOTO_ERROR(FAIL, "%d filter unavailable", filtobj.filter[i].filtn); + H5TOOLS_GOTO_ERROR((-1), "%d filter unavailable", filtobj.filter[i].filtn); } /* for */ } /* nfilters */ @@ -484,20 +484,20 @@ int apply_filters(const char* name, /* object name from traverse list */ if (obj.layout >= 0) { /* a layout was defined */ if (H5Pset_layout(dcpl_id, obj.layout) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_layout failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_layout failed"); if (H5D_CHUNKED == obj.layout) { if (H5Pset_chunk(dcpl_id, obj.chunk.rank, obj.chunk.chunk_lengths) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_chunk failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_chunk failed"); } else if (H5D_COMPACT == obj.layout) { if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_alloc_time failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pset_alloc_time failed"); } /* remove filters for the H5D_CONTIGUOUS case */ else if (H5D_CONTIGUOUS == obj.layout) { if (H5Premove_filter(dcpl_id, H5Z_FILTER_ALL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Premove_filter failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Premove_filter failed"); } } diff --git a/tools/src/h5repack/h5repack_opttable.c b/tools/src/h5repack/h5repack_opttable.c index b1e4fbc..56fc12d 100644 --- a/tools/src/h5repack/h5repack_opttable.c +++ b/tools/src/h5repack/h5repack_opttable.c @@ -52,7 +52,6 @@ void init_packobject(pack_info_t *obj) static void aux_tblinsert_filter(pack_opttbl_t *table, unsigned int I, filter_info_t filt) { - H5TOOLS_ERR_INIT(int, 0) if (table->objs[I].nfilters < H5_REPACK_MAX_NFILTERS) table->objs[I].filter[table->objs[I].nfilters++] = filt; else @@ -100,8 +99,8 @@ static void aux_tblinsert_layout(pack_opttbl_t *table, unsigned int I, pack_info static int aux_inctable(pack_opttbl_t *table, unsigned n_objs) { - H5TOOLS_ERR_INIT(int, 0) unsigned u; + int ret_value = 0; table->size += n_objs; table->objs = (pack_info_t*) HDrealloc(table->objs, table->size * sizeof(pack_info_t)); @@ -127,19 +126,19 @@ aux_inctable(pack_opttbl_t *table, unsigned n_objs) *------------------------------------------------------------------------- */ int options_table_init(pack_opttbl_t **tbl) { - H5TOOLS_ERR_INIT(int, 0) unsigned int i; pack_opttbl_t *table; + int ret_value = 0; if (NULL == (table = (pack_opttbl_t *) HDmalloc(sizeof(pack_opttbl_t)))) { - H5TOOLS_GOTO_ERROR(-1, "not enough memory for options table"); + H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table"); } table->size = 30; table->nelems = 0; if (NULL == (table->objs = (pack_info_t*) HDmalloc(table->size * sizeof(pack_info_t)))) { HDfree(table); - H5TOOLS_GOTO_ERROR(-1, "not enough memory for options table"); + H5TOOLS_GOTO_ERROR((-1), "not enough memory for options table"); } for (i = 0; i < table->size; i++) @@ -177,10 +176,10 @@ int options_table_free(pack_opttbl_t *table) { int options_add_layout(obj_list_t *obj_list, unsigned n_objs, pack_info_t *pack, pack_opttbl_t *table) { - H5TOOLS_ERR_INIT(herr_t, 0) unsigned i, j, I; unsigned added = 0; hbool_t found = FALSE; + int ret_value = 0; /* increase the size of the collection by N_OBJS if necessary */ if (table->nelems + n_objs >= table->size) diff --git a/tools/src/h5repack/h5repack_refs.c b/tools/src/h5repack/h5repack_refs.c index 01ef1d3..a7fbd3a 100644 --- a/tools/src/h5repack/h5repack_refs.c +++ b/tools/src/h5repack/h5repack_refs.c @@ -42,7 +42,6 @@ int do_copy_refobjs(hid_t fidin, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - H5TOOLS_ERR_INIT(int, 0) hid_t grp_in = -1; /* read group ID */ hid_t grp_out = -1; /* write group ID */ hid_t dset_in = -1; /* read dataset ID */ @@ -59,6 +58,7 @@ int do_copy_refobjs(hid_t fidin, unsigned int i, j; int k; named_dt_t *named_dt_head = NULL; /* Pointer to the stack of named datatypes copied */ + int ret_value = 0; /*------------------------------------------------------------------------- * browse @@ -76,18 +76,18 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed"); if(copy_refs_attr(grp_in, grp_out, travt, fidout) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_refs_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed"); if(H5Gclose(grp_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); if(H5Gclose(grp_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); /*------------------------------------------------------------------------- * check for hard links @@ -104,26 +104,26 @@ int do_copy_refobjs(hid_t fidin, */ case H5TRAV_TYPE_DATASET: if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); if((space_id = H5Dget_space(dset_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); if((ftype_id = H5Dget_type(dset_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); if((dcpl_id = H5Dget_create_plist(dset_in)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); if((rank = H5Sget_simple_extent_ndims(space_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_ndims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_ndims failed"); if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); nelmts = 1; for(k = 0; k < rank; k++) nelmts *= dims[k]; if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_native_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed"); if((msize = H5Tget_size(mtype_id)) == 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_size failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); /*------------------------------------------------------------------------- * check if the dataset creation property list has filters that @@ -159,15 +159,15 @@ int do_copy_refobjs(hid_t fidin, buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf==NULL) { HDprintf("cannot read into memory\n" ); - H5TOOLS_GOTO_ERROR(FAIL, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize); if(refbuf == NULL){ HDprintf("cannot allocate memory\n" ); - H5TOOLS_GOTO_ERROR(FAIL, "HDcalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ for(u = 0; u < nelmts; u++) { H5E_BEGIN_TRY { @@ -181,7 +181,7 @@ int do_copy_refobjs(hid_t fidin, if((refname = MapIdToName(refobj_id, travt)) != NULL) { /* create the reference, -1 parameter for objects */ if(H5Rcreate(&refbuf[u], fidout, refname, H5R_OBJECT, (hid_t)-1) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Rcreate failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); if(options->verbose) { HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name ); HDprintf("object <%s> object reference created to <%s>\n", @@ -190,7 +190,7 @@ int do_copy_refobjs(hid_t fidin, } } /*refname*/ if (H5Oclose(refobj_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Oclose refob failed"); + H5TOOLS_ERROR((-1), "H5Oclose refob failed"); } /* u */ } /*nelmts*/ @@ -199,10 +199,10 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dcreate2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); if(nelmts) if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dwrite failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); if(buf) HDfree(buf); @@ -213,7 +213,7 @@ int do_copy_refobjs(hid_t fidin, * copy attrs *----------------------------------------------------*/ if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); } /*H5T_STD_REF_OBJ*/ /*------------------------------------------------------------------------- @@ -235,10 +235,10 @@ int do_copy_refobjs(hid_t fidin, buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf == NULL) { HDprintf("cannot read into memory\n"); - H5TOOLS_GOTO_ERROR(FAIL, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dread failed"); /*------------------------------------------------------------------------- * create output @@ -247,7 +247,7 @@ int do_copy_refobjs(hid_t fidin, refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ if(refbuf == NULL) { HDprintf("cannot allocate memory\n"); - H5TOOLS_GOTO_ERROR(FAIL, "HDcalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ for(u = 0; u < nelmts; u++) { @@ -263,13 +263,13 @@ int do_copy_refobjs(hid_t fidin, hid_t region_id = -1; /* region id of the referenced dataset */ if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Rget_region failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Rget_region failed"); /* create the reference, we need the space_id */ if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Rcreate failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Rcreate failed"); if(H5Sclose(region_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if(options->verbose) { HDprintf(FORMAT_OBJ,"dset",travt->objs[i].name ); HDprintf("object <%s> region reference created to <%s>\n", @@ -278,7 +278,7 @@ int do_copy_refobjs(hid_t fidin, } } /*refname*/ if (H5Oclose(refobj_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Oclose refobj_id failed"); + H5TOOLS_ERROR((-1), "H5Oclose refobj_id failed"); } /* u */ } /*nelmts*/ @@ -287,10 +287,10 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if((dset_out = H5Dcreate2(fidout, travt->objs[i].name, mtype_id, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dcreate2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dcreate2 failed"); if(nelmts) if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dwrite failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dwrite failed"); if(buf) HDfree(buf); @@ -301,7 +301,7 @@ int do_copy_refobjs(hid_t fidin, * copy attrs *----------------------------------------------------*/ if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_attr failed"); } /* H5T_STD_REF_DSETREG */ /*------------------------------------------------------------------------- * not references, open previously created object in 1st traversal @@ -309,7 +309,7 @@ int do_copy_refobjs(hid_t fidin, */ else { if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed"); } /* end else */ /*------------------------------------------------------------------------- @@ -317,7 +317,7 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if(copy_refs_attr(dset_in, dset_out, travt, fidout) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "copy_refs_attr failed"); + H5TOOLS_GOTO_ERROR((-1), "copy_refs_attr failed"); /*------------------------------------------------------------------------- * check for hard links @@ -328,7 +328,7 @@ int do_copy_refobjs(hid_t fidin, H5Lcreate_hard(fidout, travt->objs[i].name, H5L_SAME_LOC, travt->objs[i].links[j].new_name, H5P_DEFAULT, H5P_DEFAULT); if(H5Dclose(dset_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /*can_read*/ /*------------------------------------------------------------------------- @@ -336,15 +336,15 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if(H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if(H5Tclose(mtype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if(H5Pclose(dcpl_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if(H5Sclose(space_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if(H5Dclose(dset_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); break; /*------------------------------------------------------------------------- @@ -353,9 +353,9 @@ int do_copy_refobjs(hid_t fidin, */ case H5TRAV_TYPE_NAMED_DATATYPE: if((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Topen2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Topen2 failed"); if(H5Tclose(type_in) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); break; /*------------------------------------------------------------------------- @@ -368,7 +368,7 @@ int do_copy_refobjs(hid_t fidin, case H5TRAV_TYPE_UNKNOWN: case H5TRAV_TYPE_UDLINK: - H5TOOLS_GOTO_ERROR(FAIL, "H5TRAV invalid type"); + H5TOOLS_GOTO_ERROR((-1), "H5TRAV invalid type"); break; default: @@ -381,7 +381,7 @@ int do_copy_refobjs(hid_t fidin, * in copy_attr(), so need to free. */ if (named_datatype_free(&named_dt_head, 0) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "named_datatype_free failed"); + H5TOOLS_ERROR((-1), "named_datatype_free failed"); return ret_value; @@ -430,7 +430,6 @@ static int copy_refs_attr(hid_t loc_in, trav_table_t *travt, hid_t fidout) /* for saving references */ { - H5TOOLS_ERR_INIT(int, 0) hid_t attr_id = -1; /* attr ID */ hid_t attr_out = -1; /* attr ID */ hid_t space_id = -1; /* space ID */ @@ -453,28 +452,29 @@ static int copy_refs_attr(hid_t loc_in, unsigned *ref_comp_index = NULL; size_t *ref_comp_size = NULL; int ref_comp_field_n = 0; + int ret_value = 0; if(H5Oget_info2(loc_in, &oinfo, H5O_INFO_NUM_ATTRS) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Oget_info failed"); for(u = 0; u < (unsigned)oinfo.num_attrs; u++) { is_ref = is_ref_vlen = is_ref_array = is_ref_comp = 0; /* open attribute */ if((attr_id = H5Aopen_by_idx(loc_in, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)u, H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aopen_by_idx failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aopen_by_idx failed"); /* get the file datatype */ if((ftype_id = H5Aget_type(attr_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aget_type failed"); type_class = H5Tget_class(ftype_id); if((mtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_native_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_native_type failed"); if((msize = H5Tget_size(mtype_id)) == 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_size failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_size failed"); is_ref = (type_class == H5T_REFERENCE); @@ -484,7 +484,7 @@ static int copy_refs_attr(hid_t loc_in, is_ref_vlen = (H5Tget_class(base_type) == H5T_REFERENCE); msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose base_type failed"); + H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); } else if(type_class == H5T_ARRAY ) { hid_t base_type = H5Tget_super(ftype_id); @@ -492,13 +492,13 @@ static int copy_refs_attr(hid_t loc_in, is_ref_array = (H5Tget_class(base_type) == H5T_REFERENCE); msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose base_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose base_type failed"); } else if(type_class == H5T_COMPOUND) { int nmembers = H5Tget_nmembers(ftype_id) ; if (nmembers < 1) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tget_nmembers failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tget_nmembers failed"); ref_comp_index = (unsigned *)HDmalloc((size_t)nmembers*sizeof(unsigned)); ref_comp_size = (size_t *)HDmalloc((size_t)nmembers*sizeof(ref_comp_size)); @@ -513,7 +513,7 @@ static int copy_refs_attr(hid_t loc_in, ref_comp_field_n++; } if (H5Tclose(mtid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose mtid failed"); + H5TOOLS_ERROR((-1), "H5Tclose mtid failed"); } /* if compound don't contain reference type member, free the above @@ -536,25 +536,25 @@ static int copy_refs_attr(hid_t loc_in, if (!(is_ref || is_ref_vlen || is_ref_array || is_ref_comp)) { if (H5Tclose(mtype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose mtype_id failed"); + H5TOOLS_ERROR((-1), "H5Tclose mtype_id failed"); if (H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose ftype_id failed"); + H5TOOLS_ERROR((-1), "H5Tclose ftype_id failed"); if (H5Aclose(attr_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aclose attr_id failed"); + H5TOOLS_ERROR((-1), "H5Aclose attr_id failed"); continue; } /* get name */ if(H5Aget_name(attr_id, 255, name) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_name failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aget_name failed"); /* get the dataspace handle */ if((space_id = H5Aget_space(attr_id)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aget_space failed"); /* get dimensions */ if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sget_simple_extent_dims failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sget_simple_extent_dims failed"); /*------------------------------------------------------------------------- @@ -573,7 +573,7 @@ static int copy_refs_attr(hid_t loc_in, msize = H5Tget_size(base_type); if (H5Tclose(base_type) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose base_type failed"); + H5TOOLS_ERROR((-1), "H5Tclose base_type failed"); array_rank = (unsigned)H5Tget_array_ndims(mtype_id); H5Tget_array_dims2(mtype_id, array_dims); @@ -583,7 +583,7 @@ static int copy_refs_attr(hid_t loc_in, } if((attr_out = H5Acreate2(loc_out, name, ftype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Acreate2 failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Acreate2 failed"); if (nelmts>0) { /* handle object references */ @@ -591,15 +591,15 @@ static int copy_refs_attr(hid_t loc_in, buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf == NULL) { HDprintf("cannot read into memory\n"); - H5TOOLS_GOTO_ERROR(FAIL, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize); if(refbuf == NULL) { HDprintf("cannot allocate memory\n"); - H5TOOLS_GOTO_ERROR(FAIL, "HDcalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ for(i = 0; i < (unsigned)nelmts; i++) @@ -612,10 +612,10 @@ static int copy_refs_attr(hid_t loc_in, if(buf == NULL) { HDprintf( "cannot read into memory\n" ); - H5TOOLS_GOTO_ERROR(FAIL, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); /*------------------------------------------------------------------------- * create output @@ -624,7 +624,7 @@ static int copy_refs_attr(hid_t loc_in, refbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)nelmts); /*init to zero */ if(refbuf == NULL) { HDprintf( "cannot allocate memory\n" ); - H5TOOLS_GOTO_ERROR(FAIL, "HDcalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDcalloc failed"); } /* end if */ for(i = 0; i < (unsigned)nelmts; i++) @@ -639,11 +639,11 @@ static int copy_refs_attr(hid_t loc_in, if(buf == NULL) { HDprintf( "cannot read into memory\n" ); - H5TOOLS_GOTO_ERROR(FAIL, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); if (H5R_OBJ_REF_BUF_SIZE==msize) { hobj_ref_t ref_out; @@ -680,11 +680,11 @@ static int copy_refs_attr(hid_t loc_in, if(buf == NULL) { HDprintf( "cannot read into memory\n" ); - H5TOOLS_GOTO_ERROR(FAIL, "HDmalloc failed"); + H5TOOLS_GOTO_ERROR((-1), "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aread failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aread failed"); for (i=0; i<(unsigned)nelmts; i++) { for (j=0; j<(unsigned)ref_comp_field_n; j++) { @@ -709,7 +709,7 @@ static int copy_refs_attr(hid_t loc_in, } /* else if (is_ref_comp) */ if(H5Awrite(attr_out, mtype_id, refbuf) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Awrite failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Awrite failed"); if (is_ref_vlen && buf) H5Treclaim (mtype_id, space_id, H5P_DEFAULT, buf); @@ -739,20 +739,20 @@ static int copy_refs_attr(hid_t loc_in, } if(H5Aclose(attr_out) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ if(H5Tclose(ftype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if(H5Tclose(mtype_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); if(H5Sclose(space_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if(H5Aclose(attr_id) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Aclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Aclose failed"); } /* for(u = 0; u < (unsigned)oinfo.num_attrs; u++) */ done: @@ -822,10 +822,10 @@ out: static herr_t update_ref_value(hid_t obj_id, H5R_type_t ref_type, void *ref_in, hid_t fid_out, void *ref_out, trav_table_t *travt) { - H5TOOLS_ERR_INIT(int, 0) const char *ref_obj_name; hid_t space_id = -1; hid_t ref_obj_id = -1; + herr_t ret_value = SUCCEED; ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in); if (ref_obj_id < 0) diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c index f874476..d84766a 100644 --- a/tools/src/h5repack/h5repack_verify.c +++ b/tools/src/h5repack/h5repack_verify.c @@ -39,7 +39,6 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options) { - H5TOOLS_ERR_INIT(int, 0) hid_t fidin = -1; /* file ID for input file*/ hid_t fidout = -1; /* file ID for output file*/ hid_t did = -1; /* dataset ID */ @@ -55,10 +54,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options hbool_t in_persist, out_persist; /* free-space persist status for in/output file */ hsize_t in_threshold, out_threshold; /* free-space section threshold for in/output file */ hsize_t in_pagesize, out_pagesize; /* file space page size for input/output file */ + int ret_value = 0; /* open the output file */ if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 ) - H5TOOLS_GOTO_ERROR(FAIL, "H5Fopen failed on <%s>", out_fname); + H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on <%s>", out_fname); for(i = 0; i < options->op_tbl->nelems; i++) { char *name = options->op_tbl->objs[i].path; @@ -69,13 +69,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed on <%s>", name); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name); if((sid = H5Dget_space(did)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); if((pid = H5Dget_create_plist(did)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); if((tid = H5Dget_type(did)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); /*------------------------------------------------------------------------- * filter check @@ -96,13 +96,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if(H5Pclose(pid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Sclose(sid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if (H5Dclose(did) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); if (H5Tclose(tid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); } /*------------------------------------------------------------------------- @@ -118,7 +118,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options /* get the list of objects in the file */ if(h5trav_gettable(fidout, travt) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5trav_gettable failed"); + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); for(i = 0; i < travt->nobjs; i++) { char *name = travt->objs[i].name; @@ -129,13 +129,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed on <%s>", name); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on <%s>", name); if((sid = H5Dget_space(did)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_space failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_space failed"); if((pid = H5Dget_create_plist(did)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); if((tid = H5Dget_type(did)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_type failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_type failed"); /*------------------------------------------------------------------------- * filter check @@ -165,13 +165,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if (H5Pclose(pid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Sclose(sid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Sclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Sclose failed"); if (H5Dclose(did) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); if (H5Tclose(tid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Tclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Tclose failed"); } /* if */ } /* i */ @@ -187,32 +187,32 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options /* open the input file */ if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Fopen failed on file <%s>", in_fname); + H5TOOLS_GOTO_ERROR((-1), "H5Fopen failed on file <%s>", in_fname); /* Get file creation property list for input file */ if((fcpl_in = H5Fget_create_plist(fidin)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Fget_create_plist failed to retrieve file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); /* Get file space info for input file */ if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); /* Get file space page size for input file */ if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_file_space_page_size failed to retrieve file space page size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size"); /* Output file is already opened */ /* Get file creation property list for output file */ if((fcpl_out = H5Fget_create_plist(fidout)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Fget_create_plist failed to retrieve file creation property list"); + H5TOOLS_GOTO_ERROR((-1), "H5Fget_create_plist failed to retrieve file creation property list"); /* Get file space info for output file */ if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold"); /* Get file space page size for output file */ if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_file_space_page_size failed to retrieve file space page size"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_file_space_page_size failed to retrieve file space page size"); /* * If -S option is set, the file space handling strategy should be set as specified. @@ -221,11 +221,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options */ if(options->fs_strategy) { if(out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy)) - H5TOOLS_GOTO_ERROR(FAIL, "file space strategy not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected"); } else { if(out_strategy != in_strategy) - H5TOOLS_GOTO_ERROR(FAIL, "file space strategy not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "file space strategy not set as unexpected"); } /* @@ -235,11 +235,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options */ if(options->fs_persist) { if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist)) - H5TOOLS_GOTO_ERROR(FAIL, "free-space persist status not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected"); } else { if(out_persist != in_persist) - H5TOOLS_GOTO_ERROR(FAIL, "free-space persist status not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "free-space persist status not set as unexpected"); } /* @@ -249,11 +249,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options */ if(options->fs_threshold) { if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold)) - H5TOOLS_GOTO_ERROR(FAIL, "threshold not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected"); } else { if(out_threshold != in_threshold) - H5TOOLS_GOTO_ERROR(FAIL, "threshold not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "threshold not set as unexpected"); } /* @@ -263,11 +263,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options */ if(options->fs_pagesize) { if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize)) - H5TOOLS_GOTO_ERROR(FAIL, "file space page size not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected"); } else { /* "-G" is not set */ if(out_pagesize != in_pagesize) - H5TOOLS_GOTO_ERROR(FAIL, "file space page size not set as unexpected"); + H5TOOLS_GOTO_ERROR((-1), "file space page size not set as unexpected"); } @@ -355,7 +355,6 @@ int verify_layout(hid_t pid, pack_info_t *obj) int h5repack_cmp_pl(const char *fname1, const char *fname2) { - H5TOOLS_ERR_INIT(int, 1) hid_t fid1 =-1; /* file ID */ hid_t fid2 =-1; /* file ID */ hid_t dset1 =-1; /* dataset ID */ @@ -366,8 +365,9 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2) hid_t gcplid =-1; /* group creation property list */ unsigned crt_order_flag1; /* group creation order flag */ unsigned crt_order_flag2; /* group creation order flag */ - trav_table_t *trav = NULL; + trav_table_t *trav = NULL; unsigned int i; + int ret_value = 1; /*------------------------------------------------------------------------- * open the files @@ -375,9 +375,9 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2) */ /* Open the files */ if ((fid1 = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR); + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR); if ((fid2 = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR); + H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR); /*------------------------------------------------------------------------- * get file table list of objects @@ -388,7 +388,7 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2) /* init table */ trav_table_init(&trav); if(h5trav_gettable(fid1, trav) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "h5trav_gettable failed"); + H5TOOLS_GOTO_ERROR((-1), "h5trav_gettable failed"); /*------------------------------------------------------------------------- * traverse the suppplied object list @@ -397,46 +397,46 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2) for(i = 0; i < trav->nobjs; i++) { if(trav->objs[i].type == H5TRAV_TYPE_GROUP) { if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gopen2 failed on first <%s>", trav->objs[i].name); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on first <%s>", trav->objs[i].name); if ((gcplid = H5Gget_create_plist(gid)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Gclose(gid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gopen2 failed on second <%s>", trav->objs[i].name); + H5TOOLS_GOTO_ERROR((-1), "H5Gopen2 failed on second <%s>", trav->objs[i].name); if ((gcplid = H5Gget_create_plist(gid)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pget_link_creation_order failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if (H5Gclose(gid) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Gclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Gclose failed"); if (crt_order_flag1 != crt_order_flag2) H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name); } else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) { if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed on first <%s>", trav->objs[i].name); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on first <%s>", trav->objs[i].name); if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dopen2 failed on second <%s>", trav->objs[i].name); + H5TOOLS_GOTO_ERROR((-1), "H5Dopen2 failed on second <%s>", trav->objs[i].name); if((dcpl1 = H5Dget_create_plist(dset1)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); if((dcpl2 = H5Dget_create_plist(dset2)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dget_create_plist failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dget_create_plist failed"); /*------------------------------------------------------------------------- * compare the property lists *------------------------------------------------------------------------- */ if((ret_value = H5Pequal(dcpl1, dcpl2)) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pequal failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pequal failed"); if(ret_value == 0) H5TOOLS_GOTO_ERROR(0, "property lists failed for <%s> are different", trav->objs[i].name); @@ -446,13 +446,13 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2) *------------------------------------------------------------------------- */ if(H5Pclose(dcpl1) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if(H5Pclose(dcpl2) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Pclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Pclose failed"); if(H5Dclose(dset1) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); if(H5Dclose(dset2) < 0) - H5TOOLS_GOTO_ERROR(FAIL, "H5Dclose failed"); + H5TOOLS_GOTO_ERROR((-1), "H5Dclose failed"); } /*if*/ } /*for*/ diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c index f9e5816..2ba95f2 100644 --- a/tools/src/h5stat/h5stat.c +++ b/tools/src/h5stat/h5stat.c @@ -442,9 +442,9 @@ attribute_stats(iter_t *iter, const H5O_info_t *oi) static herr_t group_stats(iter_t *iter, const char *name, const H5O_info_t *oi) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) H5G_info_t ginfo; /* Group information */ unsigned bin; /* "bin" the number of objects falls in */ + herr_t ret_value = SUCCEED; /* Gather statistics about this type of object */ iter->uniq_groups++; @@ -512,7 +512,6 @@ done: static herr_t dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) unsigned bin; /* "bin" the number of objects falls in */ hid_t did; /* Dataset ID */ hid_t sid; /* Dataspace ID */ @@ -528,6 +527,7 @@ dataset_stats(iter_t *iter, const char *name, const H5O_info_t *oi) int num_ext; /* Number of external files for a dataset */ int nfltr; /* Number of filters for a dataset */ H5Z_filter_t fltr; /* Filter identifier */ + herr_t ret_value = SUCCEED; /* Gather statistics about this type of object */ iter->uniq_dsets++; @@ -704,7 +704,7 @@ done: static herr_t datatype_stats(iter_t *iter, const H5O_info_t *oi) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) + herr_t ret_value = SUCCEED; /* Gather statistics about this type of object */ iter->uniq_dtypes++; @@ -738,8 +738,8 @@ static herr_t obj_stats(const char *path, const H5O_info_t *oi, const char *already_visited, void *_iter) { - H5TOOLS_ERR_INIT(herr_t, SUCCEED) iter_t *iter = (iter_t *)_iter; + herr_t ret_value = SUCCEED; /* If the object has already been seen then just return */ if(NULL == already_visited) { diff --git a/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst b/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst index 4e69148..9e83ff8 100644 --- a/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst +++ b/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst @@ -44,4 +44,4 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): #000: (file name) line (number) in do_copy_objects(): H5Dcreate2 failed major: Failure in tools library - minor: error in function + minor: function info |