mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-21 01:04:10 +08:00
[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
This commit is contained in:
parent
8d120c4d02
commit
8c77305a07
@ -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; j<in->rank;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)
|
||||
|
Loading…
Reference in New Issue
Block a user