From 8c77305a07f3c5bc967f82eba0cdc8cbe80b3e4c Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Fri, 8 Aug 2003 14:08:54 -0500 Subject: [svn-r7312] Purpose: Code cleanup Description: Use H5E_BEGIN_TRY/H5E_END_TRY macros around code which shouldn't display the error stack on failure, instead of setting and resetting the automatic error printing routines. Platforms tested: h5committested --- tools/h5import/h5import.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/tools/h5import/h5import.c b/tools/h5import/h5import.c index c48b565..a59098f 100755 --- a/tools/h5import/h5import.c +++ b/tools/h5import/h5import.c @@ -2177,8 +2177,6 @@ process(struct Options *opt) hid_t intype, outtype; hid_t proplist; hsize_t numOfElements = 1; - H5E_auto_t func; - void *client_data; int j,k; const char *err1 = "Error creating HDF output file: %s.\n"; @@ -2187,18 +2185,16 @@ process(struct Options *opt) const char *err4 = "Error in creating or opening external file.\n"; const char *err5 = "Error in creating the output data set. Dataset with the same name may exist at the specified path\n"; const char *err6 = "Error in writing the output data set.\n"; - H5Eget_auto(H5E_DEFAULT, &func, &client_data); - - /* disable error reporting */ - H5Eset_auto(H5E_DEFAULT, NULL, NULL); - if ((file_id = H5Fopen(opt->outfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) - if ((file_id = H5Fcreate(opt->outfile, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) == FAIL) - { - (void) fprintf(stderr, err1, opt->outfile); - return (-1); - } - /*enable error reporting */ - H5Eset_auto(H5E_DEFAULT, func, client_data); + + H5E_BEGIN_TRY { + if ((file_id = H5Fopen(opt->outfile, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) { + if ((file_id = H5Fcreate(opt->outfile, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) == FAIL) + { + (void) fprintf(stderr, err1, opt->outfile); + return (-1); + } + } + } H5E_END_TRY; for (k = 0; k < opt->fcount; k++) { @@ -2221,11 +2217,8 @@ process(struct Options *opt) for (j=0; jrank;j++) numOfElements *= in->sizeOfDimension[j]; - /* store error reporting parameters */ - H5Eget_auto(H5E_DEFAULT, &func, &client_data); - /* disable error reporting */ - H5Eset_auto(H5E_DEFAULT, NULL, NULL); + H5E_BEGIN_TRY { /* create parent groups */ if (in->path.count > 1) @@ -2253,7 +2246,7 @@ process(struct Options *opt) } /*enable error reporting */ - H5Eset_auto(H5E_DEFAULT, func, client_data); + } H5E_END_TRY; /*create data type */ intype = createInputDataType(*in); @@ -2297,10 +2290,9 @@ process(struct Options *opt) { dataspace = H5Screate_simple(in->rank, in->sizeOfDimension, NULL); } - H5Eget_auto(H5E_DEFAULT, &func, &client_data); /* disable error reporting */ - H5Eset_auto(H5E_DEFAULT, NULL, NULL); + H5E_BEGIN_TRY { /* create data set */ if ((dataset = H5Dcreate(handle, in->path.group[j], outtype, dataspace, proplist)) < 0) { @@ -2312,7 +2304,7 @@ process(struct Options *opt) } /*enable error reporting */ - H5Eset_auto(H5E_DEFAULT, func, client_data); + } H5E_END_TRY; /* write dataset */ if (H5Dwrite(dataset, intype, H5S_ALL, H5S_ALL, H5P_DEFAULT, (VOIDP)in->data) < 0) -- cgit v0.12