summaryrefslogtreecommitdiffstats
path: root/hl/tools/h5watch
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-07-30 23:15:09 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-07-30 23:15:09 (GMT)
commit0bb87534a6a78d5a5bddd84b9aa4867826368d8b (patch)
tree830d41498d87478ea8cc22e2f6e36011008e8c6e /hl/tools/h5watch
parent3e91eeb270efaa2075c80e81895066bccf1b1a47 (diff)
parent88aa0d5c76545eabf08be069a684fd7328eb4185 (diff)
downloadhdf5-0bb87534a6a78d5a5bddd84b9aa4867826368d8b.zip
hdf5-0bb87534a6a78d5a5bddd84b9aa4867826368d8b.tar.gz
hdf5-0bb87534a6a78d5a5bddd84b9aa4867826368d8b.tar.bz2
Merge remote-tracking branch 'hdffv/develop' into rebased-fprintf-experiment
Diffstat (limited to 'hl/tools/h5watch')
-rw-r--r--hl/tools/h5watch/h5watch.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c
index 7ad737c..56f9b63 100644
--- a/hl/tools/h5watch/h5watch.c
+++ b/hl/tools/h5watch/h5watch.c
@@ -821,10 +821,6 @@ main(int argc, const char *argv[])
char drivername[50]; /* VFD name */
char *fname = NULL; /* File name */
char *dname = NULL; /* Dataset name */
- void *edata; /* Error reporting */
- void *tools_edata; /* Error reporting */
- H5E_auto2_t func; /* Error reporting */
- H5E_auto2_t tools_func; /* Error reporting */
char *x; /* Temporary string pointer */
hid_t fid = -1; /* File ID */
hid_t fapl = -1; /* File access property list */
@@ -833,17 +829,9 @@ main(int argc, const char *argv[])
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
- /* 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);
-
/* To exit from h5watch for SIGTERM signal */
if(HDsignal(SIGTERM, catch_signal) == SIG_ERR) {
error_msg("An error occurred while setting a signal handler.\n");
@@ -865,6 +853,9 @@ main(int argc, const char *argv[])
leave(EXIT_FAILURE);
}
+ /* enable error reporting if command line option */
+ h5tools_error_report();
+
/* Mostly copied from tools/h5ls coding & modified accordingly */
/*
* [OBJECT] is specified as
@@ -881,18 +872,22 @@ main(int argc, const char *argv[])
* doesn't exist).
*/
if((fname = HDstrdup(argv[opt_ind])) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
+ error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
/* Create a copy of file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- return -1;
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) {
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
/* Set to use the latest library format */
- if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
- return -1;
+ if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) {
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
do {
while(fname && *fname) {
@@ -917,30 +912,37 @@ main(int argc, const char *argv[])
if(fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
- if(fname) HDfree(fname);
- if(fapl >= 0) H5Pclose(fapl);
- leave(EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
if(!dname) {
error_msg("no dataset specified\n");
h5tools_setstatus(EXIT_FAILURE);
- } else {
+ goto done;
+ }
+ else {
*dname = '/';
x = dname;
if((dname = HDstrdup(dname)) == NULL) {
- error_msg("memory allocation failed (file %s:line %d)\n",
- __FILE__, __LINE__);
+ error_msg("memory allocation failed (file %s:line %d)\n", __FILE__, __LINE__);
h5tools_setstatus(EXIT_FAILURE);
- } else {
+ goto done;
+ }
+ else {
*x = '\0';
/* Validate dataset */
- if(check_dataset(fid, dname) < 0)
+ if(check_dataset(fid, dname) < 0) {
h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
/* Validate input "fields" */
- else if(g_list_of_fields && *g_list_of_fields)
- if(process_cmpd_fields(fid, dname) < 0)
+ else if(g_list_of_fields && *g_list_of_fields) {
+ if(process_cmpd_fields(fid, dname) < 0) {
h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+ }
}
}
@@ -949,15 +951,20 @@ main(int argc, const char *argv[])
if(monitor_dataset(fid, dname) < 0)
h5tools_setstatus(EXIT_FAILURE);
+done:
/* Free spaces */
- if(fname) HDfree(fname);
- if(dname) HDfree(dname);
- if(g_list_of_fields) HDfree(g_list_of_fields);
+ if(fname)
+ HDfree(fname);
+ if(dname)
+ HDfree(dname);
+ if(g_list_of_fields)
+ HDfree(g_list_of_fields);
if(g_listv) {
H5LD_clean_vector(g_listv);
HDfree(g_listv);
}
- if(g_dup_fields) HDfree(g_dup_fields);
+ if(g_dup_fields)
+ HDfree(g_dup_fields);
/* Close the file access property list */
if(fapl >= 0 && H5Pclose(fapl) < 0) {
@@ -966,14 +973,11 @@ main(int argc, const char *argv[])
}
/* Close the file */
- if(H5Fclose(fid) < 0) {
+ if(fid >= 0 && H5Fclose(fid) < 0) {
error_msg("unable to close file\n");
h5tools_setstatus(EXIT_FAILURE);
}
- H5Eset_auto2(H5E_DEFAULT, func, edata);
- H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
-
/* exit */
leave(h5tools_getstatus());
} /* main() */