diff options
-rw-r--r-- | tools/h5copy/h5copy.c | 154 | ||||
-rw-r--r-- | tools/h5dump/h5dump.h | 1 | ||||
-rw-r--r-- | tools/h5dump/h5dump_extern.h | 1 | ||||
-rw-r--r-- | tools/h5repack/h5repack.c | 63 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 530 | ||||
-rw-r--r-- | tools/h5repack/h5repack_main.c | 402 | ||||
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 151 | ||||
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 139 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 1 | ||||
-rw-r--r-- | tools/lib/h5tools.h | 13 |
10 files changed, 755 insertions, 700 deletions
diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c index 278cd3e..9947168 100644 --- a/tools/h5copy/h5copy.c +++ b/tools/h5copy/h5copy.c @@ -23,7 +23,7 @@ #define PROGRAMNAME "h5copy" /* command-line options: short and long-named parameters */ -static const char *s_opts = "d:f:hi:o:ps:vV"; +static const char *s_opts = "d:f:hi:o:ps:vVE"; static struct long_options l_opts[] = { { "destination", require_arg, 'd' }, { "flag", require_arg, 'f' }, @@ -34,6 +34,7 @@ static struct long_options l_opts[] = { { "source", require_arg, 's' }, { "verbose", no_arg, 'v' }, { "version", no_arg, 'V' }, + { "enable-error-stack", no_arg, 'E' }, { NULL, 0, '\0' } }; char *fname_src = NULL; @@ -89,45 +90,46 @@ leave(int ret) *------------------------------------------------------------------------- */ static void -usage (void) +usage (const char *prog) { - HDfprintf(stdout, "\ -usage: h5copy [OPTIONS] [OBJECTS...]\n\ - OBJECTS\n\ - -i, --input input file name\n\ - -o, --output output file name\n\ - -s, --source source object name\n\ - -d, --destination destination object name\n\ - OPTIONS\n\ - -h, --help Print a usage message and exit\n\ - -p, --parents No error if existing, make parent groups as needed\n\ - -v, --verbose Print information about OBJECTS and OPTIONS\n\ - -V, --version Print version number and exit\n\ - -f, --flag Flag type\n\n\ - Flag type is one of the following strings:\n\n\ - shallow Copy only immediate members for groups\n\n\ - soft Expand soft links into new objects\n\n\ - ext Expand external links into new objects\n\n\ - ref Copy references and any referenced objects, i.e., objects\n\ - that the references point to.\n\ - Referenced objects are copied in addition to the objects\n\ - specified on the command line and reference datasets are\n\ - populated with correct reference values. Copies of referenced\n\ - datasets outside the copy range specified on the command line\n\ - will normally have a different name from the original.\n\ - (Default:Without this option, reference value(s) in any\n\ - reference datasets are set to NULL and referenced objects are\n\ - not copied unless they are otherwise within the copy range\n\ - specified on the command line.)\n\n\ - noattr Copy object without copying attributes\n\n\ - allflags Switches all flags from the default to the non-default setting\n\n\ - These flag types correspond to the following API symbols\n\n\ - H5O_COPY_SHALLOW_HIERARCHY_FLAG\n\ - H5O_COPY_EXPAND_SOFT_LINK_FLAG\n\ - H5O_COPY_EXPAND_EXT_LINK_FLAG\n\ - H5O_COPY_EXPAND_REFERENCE_FLAG\n\ - H5O_COPY_WITHOUT_ATTR_FLAG\n\ - H5O_COPY_ALL\n"); + FLUSHSTREAM(rawoutstream); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "usage: h5copy [OPTIONS] [OBJECTS...]\n"); + PRINTVALSTREAM(rawoutstream, " OBJECTS\n"); + PRINTVALSTREAM(rawoutstream, " -i, --input input file name\n"); + PRINTVALSTREAM(rawoutstream, " -o, --output output file name\n"); + PRINTVALSTREAM(rawoutstream, " -s, --source source object name\n"); + PRINTVALSTREAM(rawoutstream, " -d, --destination destination object name\n"); + PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); + PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); + PRINTVALSTREAM(rawoutstream, " -p, --parents No error if existing, make parent groups as needed\n"); + PRINTVALSTREAM(rawoutstream, " -v, --verbose Print information about OBJECTS and OPTIONS\n"); + PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); + PRINTVALSTREAM(rawoutstream, " -f, --flag Flag type\n\n"); + PRINTVALSTREAM(rawoutstream, " Flag type is one of the following strings:\n\n"); + PRINTVALSTREAM(rawoutstream, " shallow Copy only immediate members for groups\n\n"); + PRINTVALSTREAM(rawoutstream, " soft Expand soft links into new objects\n\n"); + PRINTVALSTREAM(rawoutstream, " ext Expand external links into new objects\n\n"); + PRINTVALSTREAM(rawoutstream, " ref Copy references and any referenced objects, i.e., objects\n"); + PRINTVALSTREAM(rawoutstream, " that the references point to.\n"); + PRINTVALSTREAM(rawoutstream, " Referenced objects are copied in addition to the objects\n"); + PRINTVALSTREAM(rawoutstream, " specified on the command line and reference datasets are\n"); + PRINTVALSTREAM(rawoutstream, " populated with correct reference values. Copies of referenced\n"); + PRINTVALSTREAM(rawoutstream, " datasets outside the copy range specified on the command line\n"); + PRINTVALSTREAM(rawoutstream, " will normally have a different name from the original.\n"); + PRINTVALSTREAM(rawoutstream, " (Default:Without this option, reference value(s) in any\n"); + PRINTVALSTREAM(rawoutstream, " reference datasets are set to NULL and referenced objects are\n"); + PRINTVALSTREAM(rawoutstream, " not copied unless they are otherwise within the copy range\n"); + PRINTVALSTREAM(rawoutstream, " specified on the command line.)\n\n"); + PRINTVALSTREAM(rawoutstream, " noattr Copy object without copying attributes\n\n"); + PRINTVALSTREAM(rawoutstream, " allflags Switches all flags from the default to the non-default setting\n\n"); + PRINTVALSTREAM(rawoutstream, " These flag types correspond to the following API symbols\n\n"); + PRINTVALSTREAM(rawoutstream, " H5O_COPY_SHALLOW_HIERARCHY_FLAG\n"); + PRINTVALSTREAM(rawoutstream, " H5O_COPY_EXPAND_SOFT_LINK_FLAG\n"); + PRINTVALSTREAM(rawoutstream, " H5O_COPY_EXPAND_EXT_LINK_FLAG\n"); + PRINTVALSTREAM(rawoutstream, " H5O_COPY_EXPAND_REFERENCE_FLAG\n"); + PRINTVALSTREAM(rawoutstream, " H5O_COPY_WITHOUT_ATTR_FLAG\n"); + PRINTVALSTREAM(rawoutstream, " H5O_COPY_ALL\n"); } @@ -215,6 +217,11 @@ static int parse_flag(const char* s_flag, unsigned *flag) int main (int argc, const char *argv[]) { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + H5E_auto2_t func; + H5E_auto2_t tools_func; + void *edata; + void *tools_edata; hid_t fid_src = -1; hid_t fid_dst = -1; unsigned flag = 0; @@ -229,16 +236,24 @@ main (int argc, const char *argv[]) h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* initialize h5tools lib */ + /* Disable error reporting */ + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + /* Initialize h5tools lib */ h5tools_init(); + /* Disable tools error reporting */ + H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); + H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); + /* init linkinfo struct */ HDmemset(&linkinfo, 0, sizeof(h5tool_link_info_t)); /* Check for no command line parameters */ - if(argc == 1) + if(argc == 1) { - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } /* end if */ @@ -255,14 +270,14 @@ main (int argc, const char *argv[]) /* validate flag */ if (parse_flag(opt_arg,&flag)<0) { - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } str_flag = HDstrdup(opt_arg); break; case 'h': - usage(); + usage(h5tools_getprogname()); leave(EXIT_SUCCESS); break; @@ -291,8 +306,12 @@ main (int argc, const char *argv[]) verbose = 1; break; + case 'E': + enable_error_stack = TRUE; + break; + default: - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } } /* end of while */ @@ -304,31 +323,36 @@ main (int argc, const char *argv[]) if (fname_src==NULL) { error_msg("Input file name missing\n"); - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } if (fname_dst==NULL) { error_msg("Output file name missing\n"); - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } if (oname_src==NULL) { error_msg("Source object name missing\n"); - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } if (oname_dst==NULL) { error_msg("Destination object name missing\n"); - usage(); + usage(h5tools_getprogname()); leave(EXIT_FAILURE); } + if (enable_error_stack) { + H5Eset_auto2(H5E_DEFAULT, func, edata); + H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); + } + /*------------------------------------------------------------------------- * open output file *-------------------------------------------------------------------------*/ @@ -393,19 +417,19 @@ main (int argc, const char *argv[]) /* create property to pass copy options */ if ( (ocpl_id = H5Pcreate(H5P_OBJECT_COPY)) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); /* set options for object copy */ if (flag) { if ( H5Pset_copy_object(ocpl_id, flag) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_copy_object failed"); } /* Create link creation property list */ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) { error_msg("Could not create link creation property list\n"); - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pcreate failed"); } /* end if */ /* Check for creating intermediate groups */ @@ -413,7 +437,7 @@ main (int argc, const char *argv[]) /* Set the intermediate group creation property */ if(H5Pset_create_intermediate_group(lcpl_id, 1) < 0) { error_msg("Could not set property for creating parent groups\n"); - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pset_create_intermediate_group failed"); } /* end if */ /* Display some output if requested */ @@ -424,7 +448,7 @@ main (int argc, const char *argv[]) { size_t i, len; - len = HDstrlen(oname_dst); + len = HDstrlen(oname_dst); /* check if all the parents groups exist. skip root group */ for (i = 1; i < len; i++) @@ -440,7 +464,7 @@ main (int argc, const char *argv[]) { error_msg("group <%s> doesn't exist. Use -p to create parent groups.\n", str_ptr); HDfree(str_ptr); - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lexists failed"); } HDfree(str_ptr); } @@ -450,17 +474,17 @@ main (int argc, const char *argv[]) /*------------------------------------------------------------------------- * do the copy *-------------------------------------------------------------------------*/ - + if(verbose) linkinfo.opt.msg_mode = 1; - + li_ret = H5tools_get_symlink_info(fid_src, oname_src, &linkinfo, 1); if (li_ret == 0) /* dangling link */ { - if(H5Lcopy(fid_src, oname_src, + if(H5Lcopy(fid_src, oname_src, fid_dst, oname_dst, H5P_DEFAULT, H5P_DEFAULT) < 0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Lcopy failed"); } else /* valid link */ { @@ -470,7 +494,7 @@ main (int argc, const char *argv[]) oname_dst, /* Name of the destination object */ ocpl_id, /* Object copy property list */ lcpl_id)<0) /* Link creation property list */ - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Ocopy failed"); } /* free link info path */ @@ -479,19 +503,19 @@ main (int argc, const char *argv[]) /* close propertis */ if(H5Pclose(ocpl_id)<0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); if(H5Pclose(lcpl_id)<0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); /* close files */ if (H5Fclose(fid_src)<0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); if (H5Fclose(fid_dst)<0) - goto error; + HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); leave(EXIT_SUCCESS); -error: +done: printf("Error in copy...Exiting\n"); /* free link info path */ diff --git a/tools/h5dump/h5dump.h b/tools/h5dump/h5dump.h index 7cf4efd..8f86567 100644 --- a/tools/h5dump/h5dump.h +++ b/tools/h5dump/h5dump.h @@ -74,7 +74,6 @@ int display_fi = FALSE; /*file index */ int display_ai = TRUE; /*array index */ int display_escape = FALSE; /*escape non printable characters */ int display_region = FALSE; /*print region reference data */ -int enable_error_stack= FALSE; /* re-enable error stack */ int disable_compact_subset= FALSE; /* disable compact form of subset notation */ int display_packed_bits = FALSE; /*print 1-8 byte numbers as packed bits*/ int include_attrs = TRUE; /* Display attributes */ diff --git a/tools/h5dump/h5dump_extern.h b/tools/h5dump/h5dump_extern.h index 62477d0..262cef1 100644 --- a/tools/h5dump/h5dump_extern.h +++ b/tools/h5dump/h5dump_extern.h @@ -73,7 +73,6 @@ extern int display_fi; /*file index */ extern int display_ai; /*array index */ extern int display_escape; /*escape non printable characters */ extern int display_region; /*print region reference data */ -extern int enable_error_stack; /* re-enable error stack */ extern int disable_compact_subset; /* disable compact form of subset notation */ extern int display_packed_bits; /*print 1-8 byte numbers as packed bits*/ extern int include_attrs; /* Display attributes */ diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c index 286d7f0..cf30b2b 100644 --- a/tools/h5repack/h5repack.c +++ b/tools/h5repack/h5repack.c @@ -372,7 +372,8 @@ 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) { - hid_t attr_id = -1; /* attr ID */ + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hid_t attr_id = -1; /* attr ID */ hid_t attr_out = -1; /* attr ID */ hid_t space_id = -1; /* space ID */ hid_t ftype_id = -1; /* file type ID */ @@ -391,7 +392,7 @@ int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, H5T_class_t type_class = -1; if (H5Oget_info(loc_in, &oinfo) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Oget_info failed"); /*------------------------------------------------------------------------- * copy all attributes @@ -401,36 +402,36 @@ int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, /* 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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); /* get name */ if (H5Aget_name(attr_id, (size_t) 255, name) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); /* get the file datatype */ if ((ftype_id = H5Aget_type(attr_id)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_type failed"); /* Check if the datatype is committed */ if ((is_named = H5Tcommitted(ftype_id)) < 0) - goto error; - if (is_named && travt) { + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tcommitted failed"); + if (is_named && travt) { hid_t fidout; /* Create out file id */ if ((fidout = H5Iget_file_id(loc_out)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "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); - goto error; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_named_datatype failed"); + } /* end if */ if (H5Fclose(fidout) < 0) - goto error; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed"); + } /* end if */ else { if (options->use_native == 1) wtype_id = h5tools_get_native_type(ftype_id); @@ -440,18 +441,18 @@ int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, /* get the dataspace handle */ if ((space_id = H5Aget_space(attr_id)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_space failed"); /* get dimensions */ if ((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); nelmts = 1; for (j = 0; j < rank; j++) nelmts *= dims[j]; if ((msize = H5Tget_size(wtype_id)) == 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed"); /*------------------------------------------------------------------------- * object references are a special case. We cannot just copy the buffers, @@ -495,10 +496,10 @@ int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, buf = (void *) HDmalloc((size_t)(nelmts * msize)); if (buf == NULL) { error_msg("h5repack", "cannot read into memory\n"); - goto error; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); + } /* end if */ if (H5Aread(attr_id, wtype_id, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed"); /*------------------------------------------------------------------------- * copy @@ -507,13 +508,13 @@ int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, if ((attr_out = H5Acreate2(loc_out, name, wtype_id, space_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - if (H5Awrite(attr_out, wtype_id, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Acreate2 failed"); + if (H5Awrite(attr_out, wtype_id, buf) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Awrite failed"); /*close*/ if (H5Aclose(attr_out) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed"); /* Check if we have VL data and string in the attribute's datatype that must * be reclaimed */ @@ -532,18 +533,18 @@ int copy_attr(hid_t loc_in, hid_t loc_out, named_dt_t **named_dt_head_p, */ if (H5Tclose(ftype_id) < 0) - goto error; - if (H5Tclose(wtype_id) < 0) - goto error; - if (H5Sclose(space_id) < 0) - goto error; - if (H5Aclose(attr_id) < 0) - goto error; - } /* u */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Tclose(wtype_id) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Sclose(space_id) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); + if (H5Aclose(attr_id) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed"); + } /* u */ return 0; -error: +done: H5E_BEGIN_TRY { if (buf) { diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 1171ab8..9c01b7e 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -44,7 +44,7 @@ H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &_err_num); \ H5Eget_msg(_err_num, NULL, _msg, (size_t)80); \ error_msg("%s %s -- %s\n", #_fun, "failed", _msg); \ - goto error; \ + goto done; \ } \ } H5E_END_TRY; \ } @@ -98,7 +98,8 @@ static herr_t walk_error_callback(H5_ATTR_UNUSED unsigned n, const H5E_error2_t */ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) { - hid_t fidin; + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hid_t fidin; hid_t fidout = -1; trav_table_t *travt = NULL; hsize_t ub_size = 0; /* size of user block */ @@ -112,8 +113,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0) { error_msg("<%s>: %s\n", fnamein, H5FOPENERROR); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /* get user block size and file space strategy/threshold */ { @@ -121,32 +122,32 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) if ((fcpl_in = H5Fget_create_plist(fidin)) < 0) { error_msg("failed to retrieve file creation property list\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } if (H5Pget_userblock(fcpl_in, &ub_size) < 0) { error_msg("failed to retrieve userblock size\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } if (!options->fs_strategy) { if (H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0) { error_msg("failed to retrieve file space strategy\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } } if (!options->fs_threshold) { if (H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0) { error_msg("failed to retrieve file space threshold\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } } if (H5Pclose(fcpl_in) < 0) { error_msg("failed to close property list\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } } /* Check if we need to create a non-default file creation property list */ @@ -154,14 +155,14 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) /* Create file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { error_msg("fail to create a file creation property list\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } if (ub_size > 0) { if (H5Pset_userblock(fcpl, ub_size) < 0) { error_msg("failed to set non-default userblock size\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } } if (options->latest) { @@ -173,8 +174,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) (unsigned) options->grp_indexed) < 0) { error_msg( "fail to adjust group creation parameters for root group\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } for (i = 0; i < 5; i++) { if (options->msg_size[i] > 0) { @@ -211,8 +212,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) if (H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0) { error_msg( "fail to set the number of shared object header message indexes\n"); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /* msg_size[0]=dataspace, 1=datatype, 2=file value, 3=filter pipleline, 4=attribute */ for (i = 0; i < (nindex - 1); i++) { @@ -220,22 +221,22 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) min_mesg_sizes[i]) < 0) { error_msg( "fail to configure the specified shared object header message index\n"); - goto out; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /* end if */ } /* end for */ } /* if (nindex>0) */ /* Create file access property list */ if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { error_msg("Could not create file access property list\n"); - goto out; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /* end if */ if (H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) { error_msg( "Could not set property for using latest version of the format\n"); - goto out; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /* end if */ } /* end if */ } /* end if */ #if defined (H5REPACK_DEBUG_USER_BLOCK) @@ -252,101 +253,100 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) /* create a file creation property list */ if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { error_msg("fail to create a file creation property list\n"); - goto out; - } - } - - /* set user block size */ - if (H5Pset_userblock(fcpl, options->ublock_size) < 0) { - error_msg("failed to set userblock size\n"); - goto out; - } - } - - /*------------------------------------------------------------------------- - * set alignment options - *------------------------------------------------------------------------- - */ - if (options->alignment > 0) { - /* either use the FAPL already created or create a new one */ - if (fapl == H5P_DEFAULT) { - /* create a file access property list */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { - error_msg("Could not create file access property list\n"); - goto out; - } - } - - if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) { - error_msg("failed to set alignment\n"); - goto out; - } - } - - /*------------------------------------------------------------------------- - * set metadata block size option - *------------------------------------------------------------------------- - */ - if (options->meta_block_size > 0) { - /* either use the FAPL already created or create a new one */ - if (fapl == H5P_DEFAULT) { - /* create a file access property list */ - if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { - error_msg("Could not create file access property list\n"); - goto out; - } - } - - if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) { - error_msg("failed to set metadata block size\n"); - goto out; - } - } - - /*------------------------------------------------------------------------- - * set free-space strategy options - *------------------------------------------------------------------------- - */ - - /* either use the FCPL already created or create a new one */ - if (fcpl == H5P_DEFAULT) { - /* create a file creation property list */ - if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { - error_msg("fail to create a file creation property list\n"); - goto out; - } - } - - /* set file space strategy and free space threshold */ - if (H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) { - error_msg("failed to set file space strategy & threshold \n"); - goto out; - } - - /*------------------------------------------------------------------------- - * create the output file - *------------------------------------------------------------------------- - */ - if (options->verbose) - printf("Making file <%s>...\n", fnameout); - - if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { - error_msg("<%s>: Could not create file\n", fnameout); - goto out; - } - - /*------------------------------------------------------------------------- - * write a new user block if requested - *------------------------------------------------------------------------- - */ - if (options->ublock_size > 0) { - if (copy_user_block(options->ublock_filename, fnameout, - options->ublock_size) < 0) { - error_msg("Could not copy user block. Exiting...\n"); - goto out; - - } - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } + + /* set user block size */ + if (H5Pset_userblock(fcpl, options->ublock_size) < 0) { + error_msg("failed to set userblock size\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } + + /*------------------------------------------------------------------------- + * set alignment options + *------------------------------------------------------------------------- + */ + if (options->alignment > 0) { + /* either use the FAPL already created or create a new one */ + if (fapl == H5P_DEFAULT) { + /* create a file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + error_msg("Could not create file access property list\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } + + if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0) { + error_msg("failed to set alignment\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } + + /*------------------------------------------------------------------------- + * set metadata block size option + *------------------------------------------------------------------------- + */ + if (options->meta_block_size > 0) { + /* either use the FAPL already created or create a new one */ + if (fapl == H5P_DEFAULT) { + /* create a file access property list */ + if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + error_msg("Could not create file access property list\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } + + if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0) { + error_msg("failed to set metadata block size\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } + + /*------------------------------------------------------------------------- + * set free-space strategy options + *------------------------------------------------------------------------- + */ + + /* either use the FCPL already created or create a new one */ + if (fcpl == H5P_DEFAULT) { + /* create a file creation property list */ + if ((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) { + error_msg("fail to create a file creation property list\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } + + /* set file space strategy and free space threshold */ + if (H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0) { + error_msg("failed to set file space strategy & threshold \n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + + /*------------------------------------------------------------------------- + * create the output file + *------------------------------------------------------------------------- + */ + if (options->verbose) + printf("Making file <%s>...\n", fnameout); + + if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0) { + error_msg("<%s>: Could not create file\n", fnameout); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + + /*------------------------------------------------------------------------- + * write a new user block if requested + *------------------------------------------------------------------------- + */ + if (options->ublock_size > 0) { + if (copy_user_block(options->ublock_filename, fnameout, + options->ublock_size) < 0) { + error_msg("Could not copy user block. Exiting...\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } + } /*------------------------------------------------------------------------- * get list of objects @@ -358,7 +358,7 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) /* get the list of objects in the file */ if (h5trav_gettable(fidin, travt) < 0) - goto out; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); /*------------------------------------------------------------------------- * do the copy @@ -366,8 +366,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) */ if (do_copy_objects(fidin, fidout, travt, options) < 0) { error_msg("<%s>: Could not copy data to: %s\n", fnamein, fnameout); - goto out; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /* end if */ /*------------------------------------------------------------------------- * do the copy of referenced objects @@ -377,8 +377,8 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) if (do_copy_refobjs(fidin, fidout, travt, options) < 0) { printf("h5repack: <%s>: Could not copy data to: %s\n", fnamein, fnameout); - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /*------------------------------------------------------------------------- * close @@ -406,7 +406,7 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) if (ub_size > 0 && options->ublock_size == 0) { if (copy_user_block(fnamein, fnameout, ub_size) < 0) { error_msg("Could not copy user block. Exiting...\n"); - goto out; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); } } @@ -418,7 +418,7 @@ int copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options) *------------------------------------------------------------------------- */ -out: +done: H5E_BEGIN_TRY { H5Pclose(fapl); @@ -470,8 +470,9 @@ out: *-----------------------------------------*/ 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) { - int status = 0; + size_t size_datum, hsize_t dims_hslab[], hsize_t * hslab_nbytes_p) { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int status = 0; int k; H5D_layout_t dset_layout; int rank_chunk; @@ -495,8 +496,8 @@ int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], rank_chunk = H5Pget_chunk(dcpl_id, rank_dset, dims_chunk); if (rank_chunk < 0) { status = -1; - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } for (k = rank_dset; k > 0; --k) size_chunk *= dims_chunk[k - 1]; @@ -560,8 +561,8 @@ int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], if (hslab_nbytes <= 0) { status = -1; - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } } } } @@ -586,15 +587,15 @@ int Get_hyperslab(hid_t dcpl_id, int rank_dset, hsize_t dims_dset[], if (hslab_nbytes <= 0) { status = -1; - goto out; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } } } /* pass out the hyperslab size*/ *hslab_nbytes_p = hslab_nbytes; -out: +done: return status; } @@ -695,7 +696,8 @@ out: int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, pack_opt_t *options) /* repack options */ { - hid_t grp_in = -1; /* group ID */ + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + hid_t grp_in = -1; /* group ID */ hid_t grp_out = -1; /* group ID */ hid_t dset_in = -1; /* read dataset ID */ hid_t dset_out = -1; /* write dataset ID */ @@ -765,22 +767,22 @@ int 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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed"); /* get input group creation property list */ if ((gcpl_in = H5Gget_create_plist(grp_in)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed"); /* query and set the group creation properties */ if (H5Pget_link_creation_order(gcpl_in, &crt_order_flags) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); /* set up group creation property list */ if ((gcpl_out = H5Pcreate(H5P_GROUP_CREATE)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pcreate failed"); if (H5Pset_link_creation_order(gcpl_out, crt_order_flags) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pset_link_creation_order failed"); /*------------------------------------------------------------------------- * the root is a special case, we get an ID for the root group @@ -789,20 +791,20 @@ int 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) - goto error; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "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) - goto error; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pset_link_phase_change failed"); + } if ((grp_out = H5Gcreate2(fidout, travt->objs[i].name, H5P_DEFAULT, gcpl_out, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gcreate2 failed"); } @@ -811,16 +813,16 @@ int 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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed"); - if (H5Pclose(gcpl_out) < 0) - goto error; - if (H5Pclose(gcpl_in) < 0) - goto error; - if (H5Gclose(grp_out) < 0) - goto error; - if (H5Gclose(grp_in) < 0) - goto error; + if (H5Pclose(gcpl_out) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + if (H5Pclose(gcpl_in) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + if (H5Gclose(grp_out) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); + if (H5Gclose(grp_in) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); break; @@ -864,24 +866,24 @@ int 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) - goto error; - if ((ftype_id = H5Dget_type(dset_in)) < 0) - goto error; - if (H5T_REFERENCE == H5Tget_class(ftype_id)) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + if ((ftype_id = H5Dget_type(dset_in)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "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) - goto error; - if (is_named) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tcommitted failed"); + if (is_named) if ((wtype_id = copy_named_datatype(ftype_id, fidout, &named_dt_head, travt, options)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_named_datatype failed"); if (H5Tclose(ftype_id) < 0) - goto error; - if (H5Dclose(dset_in) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Dclose(dset_in) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); /*------------------------------------------------------------------------- * check if we should use H5Ocopy or not @@ -895,23 +897,23 @@ int 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) - goto error; - if ((f_space_id = H5Dget_space(dset_in)) < 0) - goto error; - if ((ftype_id = H5Dget_type(dset_in)) < 0) - goto error; - if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) - goto error; - if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) - goto error; - if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) - goto error; - HDmemset(dims, 0, sizeof dims); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + if ((f_space_id = H5Dget_space(dset_in)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed"); + if ((ftype_id = H5Dget_type(dset_in)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed"); + if ((dcpl_in = H5Dget_create_plist(dset_in)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); + if ((dcpl_out = H5Pcopy(dcpl_in)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pcopy failed"); + if ((rank = H5Sget_simple_extent_ndims(f_space_id)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); + HDmemset(dims, 0, sizeof dims); if (H5Sget_simple_extent_dims(f_space_id, dims, NULL) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); if (H5Dget_space_status(dset_in, &space_status) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space_status failed"); nelmts = 1; for (j = 0; j < rank; j++) @@ -926,7 +928,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, } /* end if */ if ((msize = H5Tget_size(wtype_id)) == 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed"); /* size of current dset */ size_dset = nelmts * msize; @@ -965,8 +967,8 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (apply_s) { if (apply_filters(travt->objs[i].name, rank, dims, msize, dcpl_out, options, &has_filter) < 0) - goto error; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "apply_filters failed"); + } /* only if layout change requested for entire file or * individual obj */ @@ -1009,16 +1011,14 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, * modified dcpl; in that case use the original instead *------------------------------------------------------------------------- */ - H5E_BEGIN_TRY - { - dset_out = H5Dcreate2(fidout, + dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); - }H5E_END_TRY; if (dset_out == FAIL) { - if (options->verbose) + HERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed"); + if (options->verbose) printf( " warning: could not create dataset <%s>. Applying original settings\n", travt->objs[i].name); @@ -1026,8 +1026,8 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if ((dset_out = H5Dcreate2(fidout, travt->objs[i].name, wtype_id, f_space_id, H5P_DEFAULT, dcpl_in, H5P_DEFAULT)) < 0) - goto error; - apply_f = 0; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed"); + apply_f = 0; } /*------------------------------------------------------------------------- @@ -1053,8 +1053,8 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (TRUE == H5Tdetect_class(wtype_id, H5T_VLEN)) if (H5Dvlen_reclaim(wtype_id, f_space_id, H5P_DEFAULT, buf) < 0) - goto error; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dvlen_reclaim failed"); + } else { /* possibly not enough memory, read/write by hyperslabs */ size_t p_type_nbytes = msize; /*size of memory type */ hsize_t p_nelmts = nelmts; /*total elements */ @@ -1096,7 +1096,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (Get_hyperslab(dcpl_tmp, rank, dims, p_type_nbytes, hslab_dims, &hslab_nbytes) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "Get_hyperslab failed"); hslab_buf = HDmalloc((size_t)hslab_nbytes); @@ -1126,12 +1126,12 @@ int 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) - goto error; - if (H5Sselect_hyperslab(hslab_space, + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + if (H5Sselect_hyperslab(hslab_space, H5S_SELECT_SET, zero, NULL, &hs_select_nelmts, NULL) < 0) - goto error; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sselect_hyperslab failed"); + } else { H5Sselect_all(f_space_id); H5Sselect_all(hslab_space); @@ -1219,10 +1219,10 @@ int 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) - goto error; - /*close */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed"); + /*close */ if (H5Dclose(dset_out) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); }/*!H5T_REFERENCE*/ }/*h5tools_canreadf*/ @@ -1232,17 +1232,17 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, *------------------------------------------------------------------------- */ if (H5Tclose(ftype_id) < 0) - goto error; - if (H5Tclose(wtype_id) < 0) - goto error; - if (H5Pclose(dcpl_in) < 0) - goto error; - if (H5Pclose(dcpl_out) < 0) - goto error; - if (H5Sclose(f_space_id) < 0) - goto error; - if (H5Dclose(dset_in) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Tclose(wtype_id) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Pclose(dcpl_in) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + if (H5Pclose(dcpl_out) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + if (H5Sclose(f_space_id) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); + if (H5Dclose(dset_in) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); } /*------------------------------------------------------------------------- @@ -1254,11 +1254,11 @@ int 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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pcreate failed"); /* set options for object copy */ if (H5Pset_copy_object(pid, H5O_COPY_WITHOUT_ATTR_FLAG) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pset_copy_object failed"); /*------------------------------------------------------------------------- * do the copy @@ -1271,11 +1271,11 @@ int 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 */ - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Ocopy failed"); /* close property */ if (H5Pclose(pid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); /*------------------------------------------------------------------------- * copy attrs manually @@ -1283,17 +1283,15 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, */ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; - if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, - H5P_DEFAULT)) < 0) - goto error; - if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) - < 0) - goto error; - if (H5Dclose(dset_in) < 0) - goto error; - if (H5Dclose(dset_out) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + if ((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); + if (copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed"); + if (H5Dclose(dset_in) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); + if (H5Dclose(dset_out) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); if (options->verbose) printf(FORMAT_OBJ, "dset", travt->objs[i].name); @@ -1311,32 +1309,30 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (options->verbose) printf(FORMAT_OBJ, "type", travt->objs[i].name); - if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) - < 0) - goto error; + if ((type_in = H5Topen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Topen2 failed"); /* Copy the datatype anonymously */ if ((type_out = copy_named_datatype(type_in, fidout, &named_dt_head, travt, options)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_named_datatype failed"); /* Link in to group structure */ if (H5Lcreate_hard(type_out, ".", fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Lcreate_hard failed"); /*------------------------------------------------------------------------- * copy attrs *------------------------------------------------------------------------- */ - if (copy_attr(type_in, type_out, &named_dt_head, travt, options) - < 0) - goto error; + if (copy_attr(type_in, type_out, &named_dt_head, travt, options) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed"); if (H5Tclose(type_in) < 0) - goto error; - if (H5Tclose(type_out) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); + if (H5Tclose(type_out) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); break; @@ -1356,8 +1352,8 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, printf(FORMAT_OBJ, "link", travt->objs[i].name); if (H5Lcopy(fidin, travt->objs[i].name, fidout, travt->objs[i].name, - H5P_DEFAULT, H5P_DEFAULT) < 0) - goto error; + H5P_DEFAULT, H5P_DEFAULT) < 0) + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Lcopy failed"); if (options->verbose) printf(FORMAT_OBJ, "link", travt->objs[i].name); @@ -1366,8 +1362,8 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, break; default: - goto error; - } /* switch */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "Object type not found"); + } /* switch */ /* free */ if (buf != NULL) { @@ -1382,7 +1378,7 @@ int do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, return 0; -error: +done: H5E_BEGIN_TRY { H5Gclose(grp_in); @@ -1526,8 +1522,9 @@ static void print_dataset_info(hid_t dcpl_id, char *objname, double ratio, *------------------------------------------------------------------------- */ static int copy_user_block(const char *infile, const char *outfile, - hsize_t size) { - int infid = -1, outfid = -1; /* File descriptors */ + hsize_t size) { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int infid = -1, outfid = -1; /* File descriptors */ int status = 0; /* Return value */ /* User block must be any power of 2 equal to 512 or greater (512, 1024, 2048, etc.) */ @@ -1536,12 +1533,12 @@ static int copy_user_block(const char *infile, const char *outfile, /* Open files */ if ((infid = HDopen(infile, O_RDONLY, 0)) < 0) { status = -1; - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed"); + } if ((outfid = HDopen(outfile, O_WRONLY, 0644)) < 0) { status = -1; - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed"); + } /* Copy the userblock from the input file to the output file */ while (size > 0) { @@ -1556,8 +1553,8 @@ static int copy_user_block(const char *infile, const char *outfile, nread = HDread(infid, rbuf, (size_t)size); if (nread < 0) { status = -1; - goto done; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDread failed"); + } /* end if */ /* Write buffer to destination file */ /* (compensating for interrupted writes & checking for errors, etc.) */ @@ -1571,8 +1568,8 @@ static int copy_user_block(const char *infile, const char *outfile, } while (-1 == nwritten && EINTR == errno); if (-1 == nwritten) { /* error */ status = -1; - goto done; - } /* end if */ + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDwrite failed"); + } /* end if */ HDassert(nwritten > 0); HDassert(nwritten <= nbytes); @@ -1612,7 +1609,8 @@ done: static void print_user_block(const char *filename, hid_t fid) { - int fh; /* file handle */ + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + int fh; /* file handle */ hsize_t ub_size; /* user block size */ hsize_t size; /* size read */ hid_t fcpl; /* file creation property list ID for HDF5 file */ @@ -1621,23 +1619,23 @@ void print_user_block(const char *filename, hid_t fid) /* get user block size */ if(( fcpl = H5Fget_create_plist(fid)) < 0) { error_msg("failed to retrieve file creation property list\n"); - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed"); + } if(H5Pget_userblock(fcpl, &ub_size) < 0) { error_msg("failed to retrieve userblock size\n"); - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_userblock failed"); + } if(H5Pclose(fcpl) < 0) { error_msg("failed to close property list\n"); - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); + } /* open file */ if((fh = HDopen(filename, O_RDONLY, 0)) < 0) { - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDopen failed"); + } size = ub_size; @@ -1660,8 +1658,8 @@ void print_user_block(const char *filename, hid_t fid) printf("\n"); if(nread < 0) { - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "nread < 0"); + } /* update size of userblock left to transfer */ size -= nread; diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c index c03b7a7..7745860 100644 --- a/tools/h5repack/h5repack_main.c +++ b/tools/h5repack/h5repack_main.c @@ -33,30 +33,31 @@ const char *outfile = NULL; * Command-line options: The user can specify short or long-named * parameters. */ -static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:T:"; +static const char *s_opts = "hVvf:l:m:e:nLc:d:s:u:b:M:t:a:i:o:S:T:E"; static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "version", no_arg, 'V' }, - { "verbose", no_arg, 'v' }, - { "filter", require_arg, 'f' }, - { "layout", require_arg, 'l' }, - { "minimum", require_arg, 'm' }, - { "file", require_arg, 'e' }, - { "native", no_arg, 'n' }, - { "latest", no_arg, 'L' }, - { "compact", require_arg, 'c' }, - { "indexed", require_arg, 'd' }, - { "ssize", require_arg, 's' }, - { "ublock", require_arg, 'u' }, - { "block", require_arg, 'b' }, - { "metadata_block_size", require_arg, 'M' }, - { "threshold", require_arg, 't' }, - { "alignment", require_arg, 'a' }, - { "infile", require_arg, 'i' }, /* -i for backward compability */ - { "outfile", require_arg, 'o' }, /* -o for backward compability */ - { "fs_strategy", require_arg, 'S' }, - { "fs_threshold", require_arg, 'T' }, - { NULL, 0, '\0' } + { "help", no_arg, 'h' }, + { "version", no_arg, 'V' }, + { "verbose", no_arg, 'v' }, + { "filter", require_arg, 'f' }, + { "layout", require_arg, 'l' }, + { "minimum", require_arg, 'm' }, + { "file", require_arg, 'e' }, + { "native", no_arg, 'n' }, + { "latest", no_arg, 'L' }, + { "compact", require_arg, 'c' }, + { "indexed", require_arg, 'd' }, + { "ssize", require_arg, 's' }, + { "ublock", require_arg, 'u' }, + { "block", require_arg, 'b' }, + { "metadata_block_size", require_arg, 'M' }, + { "threshold", require_arg, 't' }, + { "alignment", require_arg, 'a' }, + { "infile", require_arg, 'i' }, /* -i for backward compability */ + { "outfile", require_arg, 'o' }, /* -o for backward compability */ + { "fs_strategy", require_arg, 'S' }, + { "fs_threshold", require_arg, 'T' }, + { "enable-error-stack", no_arg, 'E' }, + { NULL, 0, '\0' } }; /*------------------------------------------------------------------------- @@ -69,128 +70,132 @@ static struct long_options l_opts[] = { *------------------------------------------------------------------------- */ static void usage(const char *prog) { - printf("usage: %s [OPTIONS] file1 file2\n", prog); - printf(" file1 Input HDF5 File\n"); - printf(" file2 Output HDF5 File\n"); - printf(" OPTIONS\n"); - printf(" -h, --help Print a usage message and exit\n"); - printf(" -v, --verbose Verbose mode, print object information\n"); - printf(" -V, --version Print version number and exit\n"); - printf(" -n, --native Use a native HDF5 type when repacking\n"); - printf(" -L, --latest Use latest version of file format\n"); - printf(" -c L1, --compact=L1 Maximum number of links in header messages\n"); - printf(" -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); - printf(" -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); - printf(" -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); - printf(" -e E, --file=E Name of file E with the -f and -l options\n"); - printf(" -u U, --ublock=U Name of file U with user block data to be added\n"); - printf(" -b B, --block=B Size of user block to be added\n"); - printf(" -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n"); - printf(" -t T, --threshold=T Threshold value for H5Pset_alignment\n"); - printf(" -a A, --alignment=A Alignment value for H5Pset_alignment\n"); - printf(" -f FILT, --filter=FILT Filter type\n"); - printf(" -l LAYT, --layout=LAYT Layout type\n"); - printf(" -S FS_STRGY, --fs_strategy=FS_STRGY File space management strategy\n"); - printf(" -T FS_THRD, --fs_threshold=FS_THRD Free-space section threshold\n"); - printf("\n"); - printf(" M - is an integer greater than 1, size of dataset in bytes (default is 0) \n"); - printf(" E - is a filename.\n"); - printf(" S - is an integer\n"); - printf(" U - is a filename.\n"); - printf(" T - is an integer\n"); - printf(" A - is an integer greater than zero\n"); - printf(" B - is the user block size, any value that is 512 or greater and is\n"); - printf(" a power of 2 (1024 default)\n"); - printf(" F - is the shared object header message type, any of <dspace|dtype|fill|\n"); - printf(" pline|attr>. If F is not specified, S applies to all messages\n"); - printf("\n"); - printf(" FS_STRGY is the file space management strategy to use for the output file.\n"); - printf(" It is a string as listed below:\n"); - printf(" ALL_PERSIST - Use persistent free-space managers, aggregators and virtual file driver\n"); - printf(" for file space allocation\n"); - printf(" ALL - Use non-persistent free-space managers, aggregators and virtual file driver\n"); - printf(" for file space allocation\n"); - printf(" AGGR_VFD - Use aggregators and virtual file driver for file space allocation\n"); - printf(" VFD - Use virtual file driver for file space allocation\n"); - printf("\n"); - printf(" FS_THRD is the free-space section threshold to use for the output file.\n"); - printf(" It is the minimum size (in bytes) of free-space sections to be tracked\n"); - printf(" by the the library's free-space managers.\n"); - printf("\n"); - printf(" FILT - is a string with the format:\n"); - printf("\n"); - printf(" <list of objects>:<name of filter>=<filter parameters>\n"); - printf("\n"); - printf(" <list of objects> is a comma separated list of object names, meaning apply\n"); - printf(" compression only to those objects. If no names are specified, the filter\n"); - printf(" is applied to all objects\n"); - printf(" <name of filter> can be:\n"); - printf(" GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n"); - printf(" SZIP, to apply the HDF5 SZIP filter (SZIP compression)\n"); - printf(" SHUF, to apply the HDF5 shuffle filter\n"); - printf(" FLET, to apply the HDF5 checksum filter\n"); - printf(" NBIT, to apply the HDF5 NBIT filter (NBIT compression)\n"); - printf(" SOFF, to apply the HDF5 Scale/Offset filter\n"); - printf(" UD, to apply a user defined filter\n"); - printf(" NONE, to remove all filters\n"); - printf(" <filter parameters> is optional filter parameter information\n"); - printf(" GZIP=<deflation level> from 1-9\n"); - printf(" SZIP=<pixels per block,coding> pixels per block is a even number in\n"); - printf(" 2-32 and coding method is either EC or NN\n"); - printf(" SHUF (no parameter)\n"); - printf(" FLET (no parameter)\n"); - printf(" NBIT (no parameter)\n"); - printf(" SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n"); - printf(" is either IN or DS\n"); - printf(" UD=<filter_number,cd_value_count,value_1[,value_2,...,value_N]>\n"); - printf(" required values for filter_number,cd_value_count,value_1\n"); - printf(" optional values for value_2 to value_N\n"); - printf(" NONE (no parameter)\n"); - printf("\n"); - printf(" LAYT - is a string with the format:\n"); - printf("\n"); - printf(" <list of objects>:<layout type>=<layout parameters>\n"); - printf("\n"); - printf(" <list of objects> is a comma separated list of object names, meaning that\n"); - printf(" layout information is supplied for those objects. If no names are\n"); - printf(" specified, the layout type is applied to all objects\n"); - printf(" <layout type> can be:\n"); - printf(" CHUNK, to apply chunking layout\n"); - printf(" COMPA, to apply compact layout\n"); - printf(" CONTI, to apply contiguous layout\n"); - printf(" <layout parameters> is optional layout information\n"); - printf(" CHUNK=DIM[xDIM...xDIM], the chunk size of each dimension\n"); - printf(" COMPA (no parameter)\n"); - printf(" CONTI (no parameter)\n"); - printf("\n"); - printf("Examples of use:\n"); - printf("\n"); - printf("1) h5repack -v -f GZIP=1 file1 file2\n"); - printf("\n"); - printf(" GZIP compression with level 1 to all objects\n"); - printf("\n"); - printf("2) h5repack -v -f dset1:SZIP=8,NN file1 file2\n"); - printf("\n"); - printf(" SZIP compression with 8 pixels per block and NN coding method to object dset1\n"); - printf("\n"); - printf("3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n"); - printf("\n"); - printf(" Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n"); - printf(" and remove filters to objects dset3, dset4, dset5\n"); - printf("\n"); - printf("4) h5repack -L -c 10 -s 20:dtype file1 file2 \n"); - printf("\n"); - printf(" Using latest file format with maximum compact group size of 10 and\n"); - printf(" and minimum shared datatype size of 20\n"); - printf("\n"); - printf("5) h5repack -f SHUF -f GZIP=1 file1 file2 \n"); - printf("\n"); - printf(" Add both filters SHUF and GZIP in this order to all datasets\n"); - printf("\n"); - printf("6) h5repack -f UD=307,1,9 file1 file2 \n"); - printf("\n"); - printf(" Add bzip2 filter to all datasets\n"); - printf("\n"); + FLUSHSTREAM(rawoutstream); + PRINTSTREAM(rawoutstream, "usage: %s [OPTIONS] file1 file2\n", prog); + PRINTVALSTREAM(rawoutstream, " file1 Input HDF5 File\n"); + PRINTVALSTREAM(rawoutstream, " file2 Output HDF5 File\n"); + PRINTVALSTREAM(rawoutstream, " OPTIONS\n"); + PRINTVALSTREAM(rawoutstream, " -h, --help Print a usage message and exit\n"); + PRINTVALSTREAM(rawoutstream, " -v, --verbose Verbose mode, print object information\n"); + PRINTVALSTREAM(rawoutstream, " -V, --version Print version number and exit\n"); + PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n"); + PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n"); + PRINTVALSTREAM(rawoutstream, " -c L1, --compact=L1 Maximum number of links in header messages\n"); + PRINTVALSTREAM(rawoutstream, " -d L2, --indexed=L2 Minimum number of links in the indexed format\n"); + PRINTVALSTREAM(rawoutstream, " -s S[:F], --ssize=S[:F] Shared object header message minimum size\n"); + PRINTVALSTREAM(rawoutstream, " -m M, --minimum=M Do not apply the filter to datasets smaller than M\n"); + PRINTVALSTREAM(rawoutstream, " -e E, --file=E Name of file E with the -f and -l options\n"); + PRINTVALSTREAM(rawoutstream, " -u U, --ublock=U Name of file U with user block data to be added\n"); + PRINTVALSTREAM(rawoutstream, " -b B, --block=B Size of user block to be added\n"); + PRINTVALSTREAM(rawoutstream, " -M A, --metadata_block_size=A Metadata block size for H5Pset_meta_block_size\n"); + PRINTVALSTREAM(rawoutstream, " -t T, --threshold=T Threshold value for H5Pset_alignment\n"); + PRINTVALSTREAM(rawoutstream, " -a A, --alignment=A Alignment value for H5Pset_alignment\n"); + PRINTVALSTREAM(rawoutstream, " -f FILT, --filter=FILT Filter type\n"); + PRINTVALSTREAM(rawoutstream, " -l LAYT, --layout=LAYT Layout type\n"); + PRINTVALSTREAM(rawoutstream, " -S FS_STRGY, --fs_strategy=FS_STRGY File space management strategy\n"); + PRINTVALSTREAM(rawoutstream, " -T FS_THRD, --fs_threshold=FS_THRD Free-space section threshold\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " M - is an integer greater than 1, size of dataset in bytes (default is 0) \n"); + PRINTVALSTREAM(rawoutstream, " E - is a filename.\n"); + PRINTVALSTREAM(rawoutstream, " S - is an integer\n"); + PRINTVALSTREAM(rawoutstream, " U - is a filename.\n"); + PRINTVALSTREAM(rawoutstream, " T - is an integer\n"); + PRINTVALSTREAM(rawoutstream, " A - is an integer greater than zero\n"); + PRINTVALSTREAM(rawoutstream, " B - is the user block size, any value that is 512 or greater and is\n"); + PRINTVALSTREAM(rawoutstream, " a power of 2 (1024 default)\n"); + PRINTVALSTREAM(rawoutstream, " F - is the shared object header message type, any of <dspace|dtype|fill|\n"); + PRINTVALSTREAM(rawoutstream, " pline|attr>. If F is not specified, S applies to all messages\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n"); + PRINTVALSTREAM(rawoutstream, " occur.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " FS_STRGY is the file space management strategy to use for the output file.\n"); + PRINTVALSTREAM(rawoutstream, " It is a string as listed below:\n"); + PRINTVALSTREAM(rawoutstream, " ALL_PERSIST - Use persistent free-space managers, aggregators and virtual file driver\n"); + PRINTVALSTREAM(rawoutstream, " for file space allocation\n"); + PRINTVALSTREAM(rawoutstream, " ALL - Use non-persistent free-space managers, aggregators and virtual file driver\n"); + PRINTVALSTREAM(rawoutstream, " for file space allocation\n"); + PRINTVALSTREAM(rawoutstream, " AGGR_VFD - Use aggregators and virtual file driver for file space allocation\n"); + PRINTVALSTREAM(rawoutstream, " VFD - Use virtual file driver for file space allocation\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " FS_THRD is the free-space section threshold to use for the output file.\n"); + PRINTVALSTREAM(rawoutstream, " It is the minimum size (in bytes) of free-space sections to be tracked\n"); + PRINTVALSTREAM(rawoutstream, " by the the library's free-space managers.\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " FILT - is a string with the format:\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " <list of objects>:<name of filter>=<filter parameters>\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning apply\n"); + PRINTVALSTREAM(rawoutstream, " compression only to those objects. If no names are specified, the filter\n"); + PRINTVALSTREAM(rawoutstream, " is applied to all objects\n"); + PRINTVALSTREAM(rawoutstream, " <name of filter> can be:\n"); + PRINTVALSTREAM(rawoutstream, " GZIP, to apply the HDF5 GZIP filter (GZIP compression)\n"); + PRINTVALSTREAM(rawoutstream, " SZIP, to apply the HDF5 SZIP filter (SZIP compression)\n"); + PRINTVALSTREAM(rawoutstream, " SHUF, to apply the HDF5 shuffle filter\n"); + PRINTVALSTREAM(rawoutstream, " FLET, to apply the HDF5 checksum filter\n"); + PRINTVALSTREAM(rawoutstream, " NBIT, to apply the HDF5 NBIT filter (NBIT compression)\n"); + PRINTVALSTREAM(rawoutstream, " SOFF, to apply the HDF5 Scale/Offset filter\n"); + PRINTVALSTREAM(rawoutstream, " UD, to apply a user defined filter\n"); + PRINTVALSTREAM(rawoutstream, " NONE, to remove all filters\n"); + PRINTVALSTREAM(rawoutstream, " <filter parameters> is optional filter parameter information\n"); + PRINTVALSTREAM(rawoutstream, " GZIP=<deflation level> from 1-9\n"); + PRINTVALSTREAM(rawoutstream, " SZIP=<pixels per block,coding> pixels per block is a even number in\n"); + PRINTVALSTREAM(rawoutstream, " 2-32 and coding method is either EC or NN\n"); + PRINTVALSTREAM(rawoutstream, " SHUF (no parameter)\n"); + PRINTVALSTREAM(rawoutstream, " FLET (no parameter)\n"); + PRINTVALSTREAM(rawoutstream, " NBIT (no parameter)\n"); + PRINTVALSTREAM(rawoutstream, " SOFF=<scale_factor,scale_type> scale_factor is an integer and scale_type\n"); + PRINTVALSTREAM(rawoutstream, " is either IN or DS\n"); + PRINTVALSTREAM(rawoutstream, " UD=<filter_number,cd_value_count,value_1[,value_2,...,value_N]>\n"); + PRINTVALSTREAM(rawoutstream, " required values for filter_number,cd_value_count,value_1\n"); + PRINTVALSTREAM(rawoutstream, " optional values for value_2 to value_N\n"); + PRINTVALSTREAM(rawoutstream, " NONE (no parameter)\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " LAYT - is a string with the format:\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " <list of objects>:<layout type>=<layout parameters>\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " <list of objects> is a comma separated list of object names, meaning that\n"); + PRINTVALSTREAM(rawoutstream, " layout information is supplied for those objects. If no names are\n"); + PRINTVALSTREAM(rawoutstream, " specified, the layout type is applied to all objects\n"); + PRINTVALSTREAM(rawoutstream, " <layout type> can be:\n"); + PRINTVALSTREAM(rawoutstream, " CHUNK, to apply chunking layout\n"); + PRINTVALSTREAM(rawoutstream, " COMPA, to apply compact layout\n"); + PRINTVALSTREAM(rawoutstream, " CONTI, to apply contiguous layout\n"); + PRINTVALSTREAM(rawoutstream, " <layout parameters> is optional layout information\n"); + PRINTVALSTREAM(rawoutstream, " CHUNK=DIM[xDIM...xDIM], the chunk size of each dimension\n"); + PRINTVALSTREAM(rawoutstream, " COMPA (no parameter)\n"); + PRINTVALSTREAM(rawoutstream, " CONTI (no parameter)\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "Examples of use:\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "1) h5repack -v -f GZIP=1 file1 file2\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " GZIP compression with level 1 to all objects\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "2) h5repack -v -f dset1:SZIP=8,NN file1 file2\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " SZIP compression with 8 pixels per block and NN coding method to object dset1\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "3) h5repack -v -l dset1,dset2:CHUNK=20x10 -f dset3,dset4,dset5:NONE file1 file2\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Chunked layout, with a layout size of 20x10, to objects dset1 and dset2\n"); + PRINTVALSTREAM(rawoutstream, " and remove filters to objects dset3, dset4, dset5\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "4) h5repack -L -c 10 -s 20:dtype file1 file2 \n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Using latest file format with maximum compact group size of 10 and\n"); + PRINTVALSTREAM(rawoutstream, " and minimum shared datatype size of 20\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "5) h5repack -f SHUF -f GZIP=1 file1 file2 \n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Add both filters SHUF and GZIP in this order to all datasets\n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, "6) h5repack -f UD=307,1,9 file1 file2 \n"); + PRINTVALSTREAM(rawoutstream, "\n"); + PRINTVALSTREAM(rawoutstream, " Add bzip2 filter to all datasets\n"); + PRINTVALSTREAM(rawoutstream, "\n"); } /*------------------------------------------------------------------------- @@ -525,13 +530,17 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) { options->fs_threshold = (hsize_t) HDatol( opt_arg ); break; - default: - break; - } /* switch */ + case 'E': + enable_error_stack = TRUE; + break; + + default: + break; + } /* switch */ - } /* while */ + } /* while */ - if (has_i_o == 0) { + if (has_i_o == 0) { /* check for file names to be processed */ if (argc <= opt_ind || argv[opt_ind + 1] == NULL) { error_msg("missing file names\n"); @@ -563,50 +572,67 @@ done: *------------------------------------------------------------------------- */ int main(int argc, const char **argv) { + H5E_auto2_t func; + H5E_auto2_t tools_func; + void *edata; + void *tools_edata; pack_opt_t options; /*the global options */ h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Initialize h5tools lib */ - h5tools_init(); - - /* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */ - if (h5tools_getenv_update_hyperslab_bufsize() < 0) { - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - /* initialize options */ - h5repack_init(&options, 0, FALSE, H5F_FILE_SPACE_DEFAULT, (hsize_t) 0); - - if (parse_command_line(argc, argv, &options) < 0) - goto done; - - /* get file names if they were not yet got */ - if (has_i_o == 0) { - - if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { - infile = argv[opt_ind]; - outfile = argv[opt_ind + 1]; - - if ( HDstrcmp( infile, outfile ) == 0) { - error_msg("file names cannot be the same\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - else { - error_msg("file names missing\n"); - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - - /* pack it */ + /* Disable error reporting */ + H5Eget_auto2(H5E_DEFAULT, &func, &edata); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + /* Initialize h5tools lib */ + h5tools_init(); + + /* Disable tools error reporting */ + H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata); + H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL); + + /* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */ + if (h5tools_getenv_update_hyperslab_bufsize() < 0) { + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + + /* initialize options */ + h5repack_init(&options, 0, FALSE, H5F_FILE_SPACE_DEFAULT, (hsize_t) 0); + + if (parse_command_line(argc, argv, &options) < 0) + goto done; + + /* get file names if they were not yet got */ + if (has_i_o == 0) { + + if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) { + infile = argv[opt_ind]; + outfile = argv[opt_ind + 1]; + + if ( HDstrcmp( infile, outfile ) == 0) { + error_msg("file names cannot be the same\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + } + else { + error_msg("file names missing\n"); + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_FAILURE); + goto done; + } + } + + if (enable_error_stack) { + H5Eset_auto2(H5E_DEFAULT, func, edata); + H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata); + } + + /* pack it */ h5tools_setstatus(h5repack(infile, outfile, &options)); done: diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index 3f99704..b2755c2 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -50,6 +50,7 @@ int do_copy_refobjs(hid_t fidin, trav_table_t *travt, pack_opt_t *options) /* repack options */ { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t grp_in = (-1); /* read group ID */ hid_t grp_out = (-1); /* write group ID */ hid_t dset_in = (-1); /* read dataset ID */ @@ -85,18 +86,18 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if((grp_out = H5Gopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed"); if((grp_in = H5Gopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed"); if(copy_refs_attr(grp_in, grp_out, options, travt, fidout) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_refs_attr failed"); if(H5Gclose(grp_out) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); if(H5Gclose(grp_in) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); /*------------------------------------------------------------------------- * check for hard links @@ -113,26 +114,26 @@ int do_copy_refobjs(hid_t fidin, */ case H5TRAV_TYPE_DATASET: if((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); if((space_id = H5Dget_space(dset_in)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed"); if((ftype_id = H5Dget_type(dset_in)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed"); if((dcpl_id = H5Dget_create_plist(dset_in)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((rank = H5Sget_simple_extent_ndims(space_id)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); if(H5Sget_simple_extent_dims(space_id, dims, NULL) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); nelmts = 1; for(k = 0; k < rank; k++) nelmts *= dims[k]; if((mtype_id = h5tools_get_native_type(ftype_id)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_get_native_type failed"); if((msize = H5Tget_size(mtype_id)) == 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed"); /*------------------------------------------------------------------------- * check if the dataset creation property list has filters that @@ -168,15 +169,15 @@ int do_copy_refobjs(hid_t fidin, buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf==NULL) { printf("cannot read into memory\n" ); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); } /* end if */ if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed"); refbuf = (hobj_ref_t*) HDcalloc((unsigned)nelmts, msize); if(refbuf == NULL){ printf("cannot allocate memory\n" ); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed"); } /* end if */ for(u = 0; u < nelmts; u++) { H5E_BEGIN_TRY { @@ -190,7 +191,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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rcreate failed"); if(options->verbose) { printf(FORMAT_OBJ,"dset",travt->objs[i].name ); @@ -208,10 +209,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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed"); if(nelmts) if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dwrite failed"); if(buf) HDfree(buf); @@ -222,7 +223,7 @@ int do_copy_refobjs(hid_t fidin, * copy attrs *----------------------------------------------------*/ if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed"); } /*H5T_STD_REF_OBJ*/ /*------------------------------------------------------------------------- @@ -245,10 +246,10 @@ int do_copy_refobjs(hid_t fidin, buf = (hdset_reg_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf == NULL) { printf("cannot read into memory\n"); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); } /* end if */ if(H5Dread(dset_in, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dread failed"); /*------------------------------------------------------------------------- * create output @@ -257,7 +258,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) { printf("cannot allocate memory\n"); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed"); } /* end if */ for(u = 0; u < nelmts; u++) { @@ -273,13 +274,13 @@ int do_copy_refobjs(hid_t fidin, hid_t region_id; /* region id of the referenced dataset */ if((region_id = H5Rget_region(dset_in, H5R_DATASET_REGION, &buf[u])) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed"); /* create the reference, we need the space_id */ if(H5Rcreate(&refbuf[u], fidout, refname, H5R_DATASET_REGION, region_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rcreate failed"); if(H5Sclose(region_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); if(options->verbose) { @@ -300,10 +301,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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dcreate2 failed"); if(nelmts) if(H5Dwrite(dset_out, mtype_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, refbuf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dwrite failed"); if(buf) HDfree(buf); @@ -314,7 +315,7 @@ int do_copy_refobjs(hid_t fidin, * copy attrs *----------------------------------------------------*/ if(copy_attr(dset_in, dset_out, &named_dt_head, travt, options) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_attr failed"); } /* H5T_STD_REF_DSETREG */ /*------------------------------------------------------------------------- * not references, open previously created object in 1st traversal @@ -322,7 +323,7 @@ int do_copy_refobjs(hid_t fidin, */ else { if((dset_out = H5Dopen2(fidout, travt->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); } /* end else */ HDassert(dset_out != FAIL); @@ -332,7 +333,7 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if(copy_refs_attr(dset_in, dset_out, options, travt, fidout) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "copy_refs_attr failed"); /*------------------------------------------------------------------------- * check for hard links @@ -343,7 +344,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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); } /*can_read*/ /*------------------------------------------------------------------------- @@ -351,15 +352,15 @@ int do_copy_refobjs(hid_t fidin, *------------------------------------------------------------------------- */ if(H5Tclose(ftype_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); if(H5Tclose(mtype_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); if(H5Pclose(dcpl_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if(H5Sclose(space_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); if(H5Dclose(dset_in) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); break; /*------------------------------------------------------------------------- @@ -368,9 +369,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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Topen2 failed"); if(H5Tclose(type_in) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); break; /*------------------------------------------------------------------------- @@ -383,7 +384,7 @@ int do_copy_refobjs(hid_t fidin, case H5TRAV_TYPE_UNKNOWN: case H5TRAV_TYPE_UDLINK: - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5TRAV invalid type"); default: break; @@ -398,7 +399,7 @@ int do_copy_refobjs(hid_t fidin, return 0; -error: +done: H5E_BEGIN_TRY { H5Gclose(grp_in); H5Gclose(grp_out); @@ -450,6 +451,7 @@ static int copy_refs_attr(hid_t loc_in, hid_t fidout /* for saving references */ ) { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t attr_id = -1; /* attr ID */ hid_t attr_out = -1; /* attr ID */ hid_t space_id = -1; /* space ID */ @@ -473,26 +475,26 @@ static int copy_refs_attr(hid_t loc_in, if(H5Oget_info(loc_in, &oinfo) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aopen_by_idx failed"); /* get the file datatype */ if((ftype_id = H5Aget_type(attr_id)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_type failed"); type_class = H5Tget_class(ftype_id); if((mtype_id = h5tools_get_native_type(ftype_id)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5tools_get_native_type failed"); if((msize = H5Tget_size(mtype_id)) == 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_size failed"); is_ref = (type_class == H5T_REFERENCE); @@ -516,7 +518,7 @@ static int copy_refs_attr(hid_t loc_in, int nmembers = H5Tget_nmembers(ftype_id) ; if (nmembers < 1) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tget_nmembers failed"); ref_comp_index = (int *)HDmalloc(nmembers*sizeof (int)); ref_comp_size = (size_t *)HDmalloc(nmembers*sizeof(ref_comp_size)); @@ -560,15 +562,15 @@ static int copy_refs_attr(hid_t loc_in, /* get name */ if(H5Aget_name(attr_id, 255, name) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_name failed"); /* get the dataspace handle */ if((space_id = H5Aget_space(attr_id)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aget_space failed"); /* get dimensions */ if((rank = H5Sget_simple_extent_dims(space_id, dims, NULL)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed"); /*------------------------------------------------------------------------- @@ -597,7 +599,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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Acreate2 failed"); if (nelmts>0) { /* handle object references */ @@ -605,15 +607,15 @@ static int copy_refs_attr(hid_t loc_in, buf = (hobj_ref_t *)HDmalloc((unsigned)(nelmts * msize)); if(buf == NULL) { printf("cannot read into memory\n"); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed"); refbuf = (hobj_ref_t *)HDcalloc((unsigned)nelmts, msize); if(refbuf == NULL) { printf("cannot allocate memory\n"); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed"); } /* end if */ for(i = 0; i < (unsigned)nelmts; i++) { @@ -629,10 +631,10 @@ static int copy_refs_attr(hid_t loc_in, if(buf == NULL) { printf( "cannot read into memory\n" ); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed"); /*------------------------------------------------------------------------- * create output @@ -641,7 +643,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) { printf( "cannot allocate memory\n" ); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDcalloc failed"); } /* end if */ for(i = 0; i < (unsigned)nelmts; i++) { @@ -659,11 +661,11 @@ static int copy_refs_attr(hid_t loc_in, if(buf == NULL) { printf( "cannot read into memory\n" ); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed"); if (H5R_OBJ_REF_BUF_SIZE==msize) { hobj_ref_t ref_out; @@ -700,11 +702,11 @@ static int copy_refs_attr(hid_t loc_in, if(buf == NULL) { printf( "cannot read into memory\n" ); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "HDmalloc failed"); } /* end if */ if(H5Aread(attr_id, mtype_id, buf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aread failed"); for (i=0; i<(unsigned)nelmts; i++) { for (j=0; j<(unsigned)ref_comp_field_n; j++) { @@ -727,7 +729,7 @@ static int copy_refs_attr(hid_t loc_in, } /* else if (is_ref_comp) */ if(H5Awrite(attr_out, mtype_id, refbuf) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Awrite failed"); if (is_ref_vlen && buf) H5Dvlen_reclaim (mtype_id, space_id, H5P_DEFAULT, buf); @@ -757,25 +759,25 @@ static int copy_refs_attr(hid_t loc_in, } if(H5Aclose(attr_out) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed"); /*------------------------------------------------------------------------- * close *------------------------------------------------------------------------- */ if(H5Tclose(ftype_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); if(H5Tclose(mtype_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); if(H5Sclose(space_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); if(H5Aclose(attr_id) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Aclose failed"); } /* for(u = 0; u < (unsigned)oinfo.num_attrs; u++) */ return 0; -error: +done: if(refbuf) HDfree(refbuf); if(buf) @@ -845,28 +847,29 @@ 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) { - herr_t ret = -1; + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ + herr_t ret = -1; const char* ref_obj_name; hid_t space_id=-1, ref_obj_id=-1; ref_obj_id = H5Rdereference2(obj_id, H5P_DEFAULT, ref_type, ref_in); if (ref_obj_id<0) - goto done; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rdereference2 failed"); ref_obj_name = MapIdToName(ref_obj_id, travt); if (ref_obj_name == NULL) - goto done; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "MapIdToName failed"); if (ref_type == H5R_DATASET_REGION) { space_id = H5Rget_region(obj_id, H5R_DATASET_REGION, ref_in); if (space_id < 0) - goto done; - } + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rget_region failed"); + } ret = H5Rcreate(ref_out, fid_out, ref_obj_name, ref_type, space_id); if (ret < 0) - goto done; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Rcreate failed"); ret = 0; diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 52423f1..9565ce3 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -51,6 +51,7 @@ 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) { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t fidin = -1; /* file ID for input file*/ hid_t fidout = -1; /* file ID for output file*/ hid_t did = -1; /* dataset ID */ @@ -79,13 +80,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); if((sid = H5Dget_space(did)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed"); if((pid = H5Dget_create_plist(did)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((tid = H5Dget_type(did)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed"); /*------------------------------------------------------------------------- * filter check @@ -107,13 +108,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if(H5Pclose(pid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Sclose(sid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); if (H5Dclose(did) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); if (H5Tclose(tid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); } @@ -131,7 +132,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) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5trav_gettable failed"); for(i = 0; i < travt->nobjs; i++) { @@ -145,13 +146,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); if((sid = H5Dget_space(did)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_space failed"); if((pid = H5Dget_create_plist(did)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((tid = H5Dget_type(did)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_type failed"); /*------------------------------------------------------------------------- * filter check @@ -184,13 +185,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options *------------------------------------------------------------------------- */ if (H5Pclose(pid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Sclose(sid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Sclose failed"); if (H5Dclose(did) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); if (H5Tclose(tid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Tclose failed"); } /* if */ } /* i */ @@ -207,31 +208,31 @@ 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 ) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fopen failed"); /* Get file creation property list for input file */ if((fcpl_in = H5Fget_create_plist(fidin)) < 0) { - error_msg("failed to retrieve file creation property list\n"); - goto error; + error_msg("failed to retrieve file creation property list\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed"); } /* Get file space management info for input file */ if(H5Pget_file_space(fcpl_in, &in_strat, &in_thresh) < 0) { - error_msg("failed to retrieve file space strategy & threshold\n"); - goto error; + error_msg("failed to retrieve file space strategy & threshold\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_file_space failed"); } /* Output file is already opened */ /* Get file creation property list for output file */ if((fcpl_out = H5Fget_create_plist(fidout)) < 0) { - error_msg("failed to retrieve file creation property list\n"); - goto error; + error_msg("failed to retrieve file creation property list\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fget_create_plist failed"); } /* Get file space management info for output file */ if(H5Pget_file_space(fcpl_out, &out_strat, &out_thresh) < 0) { - error_msg("failed to retrieve file space strategy & threshold\n"); - goto error; + error_msg("failed to retrieve file space strategy & threshold\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_file_space failed"); } /* @@ -243,12 +244,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options * as what is set via the strategy option */ if(!options->fs_strategy && out_strat != in_strat) { - error_msg("file space strategy not set as unexpected\n"); - goto error; + error_msg("file space strategy not set as unexpected\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "file space strategy not set as unexpected"); - } else if(options->fs_strategy && out_strat!= options->fs_strategy) { - error_msg("file space strategy not set as unexpectec\n"); - goto error; + } + else if(options->fs_strategy && out_strat!= options->fs_strategy) { + error_msg("file space strategy not set as unexpected\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "file space strategy not set as unexpected"); } /* @@ -260,27 +262,27 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options * as what is set via the threshold option. */ if(!options->fs_threshold && out_thresh != in_thresh) { - error_msg("free space threshold not set as unexpected\n"); - goto error; - - } else if(options->fs_threshold && out_thresh != options->fs_threshold) { - error_msg("free space threshold not set as unexpectec\n"); - goto error; + error_msg("free space threshold not set as unexpected\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "free space threshold not set as unexpected"); + } + else if(options->fs_threshold && out_thresh != options->fs_threshold) { + error_msg("free space threshold not set as unexpected\n"); + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "free space threshold not set as unexpected"); } /* Closing */ if (H5Pclose(fcpl_in) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Pclose(fcpl_out) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Fclose(fidin) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed"); if (H5Fclose(fidout) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Fclose failed"); return ok; -error: +done: H5E_BEGIN_TRY { H5Pclose(fcpl_in); H5Pclose(fcpl_out); @@ -370,6 +372,7 @@ int verify_layout(hid_t pid, int h5repack_cmp_pl(const char *fname1, const char *fname2) { + int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */ hid_t fid1=-1; /* file ID */ hid_t fid2=-1; /* file ID */ hid_t dset1=-1; /* dataset ID */ @@ -414,7 +417,7 @@ int h5repack_cmp_pl(const char *fname1, */ trav_table_init(&trav); if(h5trav_gettable(fid1, trav) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "h5trav_gettable failed"); /*------------------------------------------------------------------------- * traverse the suppplied object list @@ -427,31 +430,30 @@ int h5repack_cmp_pl(const char *fname1, { if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed"); if ((gcplid = H5Gget_create_plist(gid)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Gclose(gid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gopen2 failed"); if ((gcplid = H5Gget_create_plist(gid)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gget_create_plist failed"); if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pget_link_creation_order failed"); if (H5Pclose(gcplid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if (H5Gclose(gid) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Gclose failed"); - if ( crt_order_flag1 != crt_order_flag2 ) - { + if (crt_order_flag1 != crt_order_flag2) { error_msg("property lists for <%s> are different\n",trav->objs[i].name); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "property lists failed"); } } @@ -461,25 +463,24 @@ int h5repack_cmp_pl(const char *fname1, else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) { if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dopen2 failed"); if((dcpl1 = H5Dget_create_plist(dset1)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); if((dcpl2 = H5Dget_create_plist(dset2)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dget_create_plist failed"); /*------------------------------------------------------------------------- * compare the property lists *------------------------------------------------------------------------- */ if((ret = H5Pequal(dcpl1, dcpl2)) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pequal failed"); - if(ret == 0) - { + if(ret == 0) { error_msg("property lists for <%s> are different\n",trav->objs[i].name); - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "property lists failed"); } /*------------------------------------------------------------------------- @@ -487,13 +488,13 @@ int h5repack_cmp_pl(const char *fname1, *------------------------------------------------------------------------- */ if(H5Pclose(dcpl1) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if(H5Pclose(dcpl2) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Pclose failed"); if(H5Dclose(dset1) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); if(H5Dclose(dset2) < 0) - goto error; + HGOTO_ERROR(H5E_tools_g, H5E_tools_min_id_g, "H5Dclose failed"); } /*if*/ } /*i*/ @@ -518,7 +519,7 @@ int h5repack_cmp_pl(const char *fname1, *------------------------------------------------------------------------- */ -error: +done: H5E_BEGIN_TRY { H5Pclose(dcpl1); diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 19d71bb..22c611f 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -51,6 +51,7 @@ int packed_bits_num; /* number of packed bits to display */ int packed_data_offset; /* offset of packed bits to display */ int packed_data_length; /* lengtht of packed bits to display */ unsigned long long packed_data_mask; /* mask in which packed bits to display */ +int enable_error_stack= FALSE; /* re-enable error stack */ /* module-scoped variables */ static int h5tools_init_g; /* if h5tools lib has been initialized */ diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h index cec3b9d..ca2b39a 100644 --- a/tools/lib/h5tools.h +++ b/tools/lib/h5tools.h @@ -561,6 +561,9 @@ H5TOOLS_DLLVAR int oid_output; /* oid output */ H5TOOLS_DLLVAR int data_output; /* data output */ H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */ +/* things to display or which are set via command line parameters */ +H5TOOLS_DLLVAR int enable_error_stack; /* re-enable error stack */ + /* Strings for output */ #define H5_TOOLS_GROUP "GROUP" #define H5_TOOLS_DATASET "DATASET" @@ -569,11 +572,11 @@ H5TOOLS_DLLVAR int attr_data_output; /* attribute data output */ /* Definitions of useful routines */ H5TOOLS_DLL void h5tools_init(void); H5TOOLS_DLL void h5tools_close(void); -H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin); -H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_data_output_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin); +H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin); H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver, char *drivername, size_t drivername_len); H5TOOLS_DLL hid_t h5tools_get_native_type(hid_t type); |