diff --git a/src/h5core/h5_attachments.c b/src/h5core/h5_attachments.c index a6c9858..700f8a5 100644 --- a/src/h5core/h5_attachments.c +++ b/src/h5core/h5_attachments.c @@ -38,11 +38,10 @@ h5_add_attachment ( struct stat st; if (stat (fname, &st) < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot stat file '%s'", - fname)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot stat file '%s'", + fname); } hsize_t fsize = st.st_size; hsize_t write_length; @@ -52,30 +51,27 @@ h5_add_attachment ( write_length = fsize; int fd; if ((fd = open (fname, O_RDONLY)) < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot open file '%s' for reading", - fname)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot open file '%s' for reading", + fname); } again: if (read (fd, buf, fsize) < 0) { if (errno == EINTR) { goto again; } else { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot read file '%s'", - fname)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot read file '%s'", + fname); } } if (close (fd) < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot close file '%s'", - fname)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot close file '%s'", + fname); } } else { @@ -284,25 +280,22 @@ h5_get_attachment ( if (f->myproc == 0) { int fd; if ((fd = open (fname, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_H5, - "Error opening file '%s': %s", - fname, strerror(errno))); + H5_RETURN_ERROR ( + H5_ERR_H5, + "Error opening file '%s': %s", + fname, strerror(errno)); } if (write (fd, buf, fsize) != fsize) { - H5_LEAVE ( - h5_error ( - H5_ERR_H5, - "Error writing to file '%s': %s", - fname, strerror(errno))); + H5_RETURN_ERROR ( + H5_ERR_H5, + "Error writing to file '%s': %s", + fname, strerror(errno)); } if (close (fd) < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_H5, - "Error closing file '%s': %s", - fname, strerror(errno))); + H5_RETURN_ERROR ( + H5_ERR_H5, + "Error closing file '%s': %s", + fname, strerror(errno)); } } TRY (h5_free (buf)); diff --git a/src/h5core/h5_file.c b/src/h5core/h5_file.c index e62a6ff..cf5113c 100644 --- a/src/h5core/h5_file.c +++ b/src/h5core/h5_file.c @@ -193,11 +193,10 @@ h5_set_prop_file_mpio_collective ( H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm); if (props->class != H5_PROP_FILE) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)props->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)props->class); } props->flags &= ~(H5_VFD_MPIO_POSIX | H5_VFD_MPIO_INDEPENDENT | H5_VFD_CORE); props->flags |= H5_VFD_MPIO_COLLECTIVE; @@ -219,11 +218,10 @@ h5_set_prop_file_mpio_independent ( H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm); if (props->class != H5_PROP_FILE) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)props->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)props->class); } props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE); props->flags |= H5_VFD_MPIO_INDEPENDENT; @@ -241,11 +239,10 @@ h5_set_prop_file_mpio_posix ( H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm); if (props->class != H5_PROP_FILE) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)props->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)props->class); } props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE); props->flags |= H5_VFD_MPIO_INDEPENDENT; @@ -263,11 +260,10 @@ h5_set_prop_file_core_vfd ( H5_CORE_API_ENTER (h5_err_t, "props=%p, increment=%lld", props, (long long int)increment); if (props->class != H5_PROP_FILE) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)props->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)props->class); } props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_INDEPENDENT | H5_VFD_MPIO_POSIX); props->flags |= H5_VFD_MPIO_INDEPENDENT; @@ -292,11 +288,10 @@ h5_set_prop_file_align ( "props=%p, align=%lld", props, (long long int)align); if (props->class != H5_PROP_FILE) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)props->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)props->class); } props->align = align; H5_RETURN (H5_SUCCESS); @@ -313,11 +308,10 @@ h5_set_prop_file_throttle ( "props=%p, throttle=%lld", props, (long long int)throttle); if (props->class != H5_PROP_FILE) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)props->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)props->class); } // throttle only if VFD is MPIO independent od POSIX h5_int64_t mask = H5_VFD_MPIO_INDEPENDENT; @@ -357,11 +351,10 @@ h5_create_prop ( set_default_file_props ((h5_prop_file_t*)prop); break; default: - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)class); } H5_RETURN ((h5_prop_t)prop); } @@ -379,11 +372,10 @@ h5_close_prop ( break; } default: - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld", - (long long int)prop->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld", + (long long int)prop->class); } H5_RETURN (h5_free (prop)); } @@ -441,19 +433,17 @@ open_file ( } } else { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid file access mode '%lld'.", - (long long int)f->props->flags & 0xff)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid file access mode '%lld'.", + (long long int)f->props->flags & 0xff); } if (f->file < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot open file '%s' with mode '%s'", - filename, H5_O_MODES[f->props->flags & 0xff])); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot open file '%s' with mode '%s'", + filename, H5_O_MODES[f->props->flags & 0xff]); TRY (f->root_gid = hdf5_open_group (f->file, "/" )); TRY (h5upriv_open_file (f)); @@ -482,11 +472,10 @@ h5_open_file2 ( if (props != H5_PROP_DEFAULT) { if (props->class != H5_PROP_FILE) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Invalid property class: %lld.", - (long long int)props->class)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid property class: %lld.", + (long long int)props->class); } f->props->comm = props->comm; f->props->flags = props->flags; diff --git a/src/h5core/h5_model.c b/src/h5core/h5_model.c index 3334985..b3d75a9 100644 --- a/src/h5core/h5_model.c +++ b/src/h5core/h5_model.c @@ -93,12 +93,11 @@ h5priv_normalize_dataset_name ( } if ( strcmp( name2, H5BLOCK_GROUPNAME_BLOCK ) == 0 ) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Can't create dataset or field with name '%s'" - " because it is reserved by H5Block.", - H5BLOCK_GROUPNAME_BLOCK)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Can't create dataset or field with name '%s'" + " because it is reserved by H5Block.", + H5BLOCK_GROUPNAME_BLOCK); } H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5b_io.c b/src/h5core/h5b_io.c index 1286153..ad07d0f 100644 --- a/src/h5core/h5b_io.c +++ b/src/h5core/h5b_io.c @@ -215,14 +215,13 @@ _write_data ( hid_t type_file; TRY( type_file = hdf5_get_dataset_type (dataset) ); if ( type != type_file ) { - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Field '%s' already has type '%s' " - "but was written as '%s'.", - field_name, - hdf5_get_type_name (type_file), - hdf5_get_type_name (type))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Field '%s' already has type '%s' " + "but was written as '%s'.", + field_name, + hdf5_get_type_name (type_file), + hdf5_get_type_name (type)); } } else { TRY (dataset = hdf5_create_dataset( @@ -328,21 +327,20 @@ _select_hyperslab_for_reading ( TRY (rank = hdf5_get_dims_of_dataspace(b->diskshape, field_dims, NULL)); if (rank != 3) - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "H5Block dataset has bad rank '%d' instead" - " of rank 3! Is the file corrupt?", - rank)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "H5Block dataset has bad rank '%d' instead" + " of rank 3! Is the file corrupt?", + rank); if ( (field_dims[0] < (hsize_t)b->k_max) || (field_dims[1] < (hsize_t)b->j_max) || (field_dims[2] < (hsize_t)b->i_max) ) - H5_LEAVE ( - h5_error( - H5_ERR_VIEW, - "H5Block dataset has invalid view. " - "Is the file corrupt?")); + H5_RETURN_ERROR ( + H5_ERR_VIEW, + "%s", + "H5Block dataset has invalid view. " + "Is the file corrupt?"); h5_debug ( "field_dims: (%lld,%lld,%lld)", diff --git a/src/h5core/h5b_model.c b/src/h5core/h5b_model.c index c0def82..7b6f2ee 100644 --- a/src/h5core/h5b_model.c +++ b/src/h5core/h5b_model.c @@ -454,9 +454,10 @@ h5bpriv_open_block_group ( TRY (hdf5_close_group (b->block_gid)); b->block_gid = hdf5_open_group (f->step_gid, H5BLOCK_GROUPNAME_BLOCK); if (f->b->block_gid < 0) - H5_LEAVE (h5_error( - H5_ERR_INVAL, - "Time step does not contain H5Block data!")); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Time step does not contain H5Block data!"); H5_RETURN (H5_SUCCESS); } @@ -761,14 +762,14 @@ h5b_3d_set_grid ( (long long unsigned)j, (long long unsigned)k); if (i*j*k != f->nprocs) { - H5_LEAVE ( - h5_error(H5_ERR_INVAL, - "Grid dimensions (%lld,%lld,%lld) do not multiply " - "out to %d MPI processors!", - (long long)i, - (long long)j, - (long long)k, - f->nprocs)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Grid dimensions (%lld,%lld,%lld) do not multiply " + "out to %d MPI processors!", + (long long)i, + (long long)j, + (long long)k, + f->nprocs); } f->b->k_grid = i; @@ -798,9 +799,10 @@ h5b_3d_get_grid_coords ( "f=%p, proc=%d, i=%p, j=%p, k=%p", f, proc, i, j, k); if ( !f->b->have_grid ) - H5_LEAVE ( - h5_error(H5_ERR_INVAL, - "Grid dimensions have not been set!")); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Grid dimensions have not been set!"); int coords[3]; TRY( h5priv_mpi_cart_coords(f->b->cart_comm, proc, 3, coords) ); @@ -825,9 +827,10 @@ h5b_3d_set_dims ( (long long unsigned)j, (long long unsigned)k); if ( !f->b->have_grid ) - H5_LEAVE ( - h5_error(H5_ERR_INVAL, - "Grid dimensions have not been set!")); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Grid dimensions have not been set!"); h5_size_t dims[3] = { k, j, i }; h5_size_t check_dims[3] = { k, j, i }; @@ -839,17 +842,17 @@ h5b_3d_set_dims ( dims[1] != check_dims[1] || dims[2] != check_dims[2] ) { - H5_LEAVE ( - h5_error(H5_ERR_INVAL, - "[%d] Block dimensions do not agree: " - "(%lld,%lld,%lld) != (%lld,%lld,%lld)!", - f->myproc, - (long long)dims[0], - (long long)dims[1], - (long long)dims[2], - (long long)check_dims[0], - (long long)check_dims[1], - (long long)check_dims[2])); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "[%d] Block dimensions do not agree: " + "(%lld,%lld,%lld) != (%lld,%lld,%lld)!", + f->myproc, + (long long)dims[0], + (long long)dims[1], + (long long)dims[2], + (long long)check_dims[0], + (long long)check_dims[1], + (long long)check_dims[2]); } h5_int64_t coords[3]; TRY( h5b_3d_get_grid_coords((h5_file_t)f, @@ -892,13 +895,15 @@ h5b_3d_set_halo ( (long long unsigned)k); if ( !f->b->have_grid ) { - H5_LEAVE ( - h5_error(H5_ERR_INVAL, - "Grid dimensions have not been set!")); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Grid dimensions have not been set!"); } else if ( !f->b->have_layout ) { - H5_LEAVE ( - h5_error(H5_ERR_INVAL, - "Block dimensions for grid have not been set!")); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Block dimensions for grid have not been set!"); } h5b_fdata_t *b = f->b; diff --git a/src/h5core/h5t_io.c b/src/h5core/h5t_io.c index 15e2446..9a1fad4 100644 --- a/src/h5core/h5t_io.c +++ b/src/h5core/h5t_io.c @@ -1317,8 +1317,9 @@ part_kway ( &m->f->props->comm ); if (rc != METIS_OK) { - H5_LEAVE( - h5_error (H5_ERR, "ParMETIS failed")); + H5_RETURN_ERROR ( + H5_ERR, + "ParMETIS failed"); } TRY (h5_free (vtxdist)); TRY (h5_free (xadj)); @@ -2150,8 +2151,9 @@ distribute_octree_parmetis ( &m->f->props->comm ); if (rc != METIS_OK) { - H5_LEAVE( - h5_error (H5_ERR, "ParMETIS failed")); + H5_RETURN_ERROR ( + H5_ERR, + "ParMETIS failed"); } TRY (h5_free (xadj)); @@ -2709,11 +2711,10 @@ read_elems_part ( i++; hcount++; } if (hstart+hcount > num_glb_elems) { - H5_LEAVE ( - h5_error ( - H5_ERR_H5FED, - "invalid selection: start=%lld, count=%lld", - (long long)hstart, (long long)hcount)); + H5_RETURN_ERROR ( + H5_ERR_H5FED, + "invalid selection: start=%lld, count=%lld", + (long long)hstart, (long long)hcount); } TRY (hdf5_select_hyperslab_of_dataspace ( dspace_id, diff --git a/src/h5core/h5t_map.c b/src/h5core/h5t_map.c index fff6906..b6c65a8 100644 --- a/src/h5core/h5t_map.c +++ b/src/h5core/h5t_map.c @@ -500,12 +500,11 @@ h5priv_exchange_loc_list_to_glb ( // loc -> glb for (int i = 0; i < m->marked_entities->num_items; i++) { if (m->marked_entities->items[i] > m->last_stored_eid) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Element chosen to be refined is %d but there are only %d elements", - m->marked_entities->items[i], - m->last_stored_eid + 1 )); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Element chosen to be refined is %d but there are only %d elements", + m->marked_entities->items[i], + m->last_stored_eid + 1); } sendbuf[i] = h5tpriv_get_loc_elem_glb_idx (m, m->marked_entities->items[i]); diff --git a/src/h5core/h5t_model.c b/src/h5core/h5t_model.c index 8087e50..7bc3e19 100644 --- a/src/h5core/h5t_model.c +++ b/src/h5core/h5t_model.c @@ -386,10 +386,10 @@ h5t_close_mesh ( #endif // check if tagsets are still open if (m->mtagsets && m->mtagsets->num_items > 0) - H5_LEAVE ( - h5_error ( - H5_ERR_H5FED, - "Mesh cannot be closed: Mesh is referenced by open tagsets")); + H5_RETURN_ERROR ( + H5_ERR_H5FED, + "%s", + "Mesh cannot be closed: Mesh is referenced by open tagsets"); if (!(m->f->props->flags & H5_O_RDONLY)) { TRY (h5tpriv_write_mesh (m)); diff --git a/src/h5core/h5t_octree.c b/src/h5core/h5t_octree.c index 986adf5..8b573a2 100644 --- a/src/h5core/h5t_octree.c +++ b/src/h5core/h5t_octree.c @@ -591,10 +591,10 @@ update_userdata ( for (int j = i + 1; j < nbr_glb_oct_changed; j++) { if (oct_idx_to_check == changed_oct_idx[j]) { /*** an octant was changed twice! ***/ - H5_LEAVE( h5_error ( - H5_ERR_INVAL, - "Multiple cores tried to update the same userdata with idx: %d", - oct_idx_to_check)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Multiple cores tried to update the same userdata with idx: %d", + oct_idx_to_check); }; }; }; @@ -3195,7 +3195,7 @@ complete_level( parent = get_parent(octree, parent); } if (parent == -1){ - H5_LEAVE (H5_ERR_INTERNAL ); + H5_LEAVE (H5_ERR_INTERNAL); } done = 0; // mark all parents of parent as not on level diff --git a/src/h5core/h5t_tags.c b/src/h5core/h5t_tags.c index 5f8e60f..1e66f3f 100644 --- a/src/h5core/h5t_tags.c +++ b/src/h5core/h5t_tags.c @@ -203,24 +203,27 @@ h5t_create_mtagset ( m, name, (long long unsigned)type, set); // validate name if (name == NULL || name[0] == '\0') { - H5_LEAVE ( - h5_error (H5_ERR_INVAL, "Invalid name" )); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Invalid name"); } // validate type if (type != H5_INT64_T && type != H5_FLOAT64_T) { - H5_LEAVE ( - h5_error (H5_ERR_INVAL, "Unsupported data type." )); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Unsupported data type."); } // check if a tagset with given name already exists h5_err_t exists; TRY (exists = h5priv_link_exists (m->mesh_gid, "Tags", name)); if (exists || h5priv_find_strlist (m->mtagsets, name) >= 0) - H5_LEAVE ( - h5_error ( - H5_ERR_H5FED, - "Cannot create tagset '%s': Tagset exists", name)); + H5_RETURN_ERROR ( + H5_ERR_H5FED, + "Cannot create tagset '%s': Tagset exists", name); TRY (ret_value = new_tagset (m, m->mesh_gid, name, type, set)); H5_RETURN (ret_value); } @@ -509,23 +512,27 @@ h5t_open_mtagset ( m, name, set); // validate name if (name == NULL || name[0] == '\0') { - H5_LEAVE ( - h5_error (H5_ERR_INVAL, "Invalid name" )); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "Invalid name"); } // check if a tagset with given name exists h5_err_t exists; TRY (exists = h5priv_link_exists (m->mesh_gid, "Tags", name)); - if (!exists) H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Cannot open tagset '%s': No such tagset ", name)); + if (!exists) + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Cannot open tagset '%s': No such tagset ", + name); // check if tagset has already been opened - if (h5priv_find_strlist (m->mtagsets, name) >= 0) H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Cannot open tagset '%s': Already open ", name)); + if (h5priv_find_strlist (m->mtagsets, name) >= 0) + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Cannot open tagset '%s': Already open ", + name); TRY (new_tagset (m, m->mesh_gid, name, -1, set)); @@ -765,10 +772,11 @@ h5t_remove_mtagset ( H5_CORE_API_ENTER (h5_err_t, "m=%p, name='%s'", m, name); // check if tagset has a copy in memory - if (h5priv_find_strlist (m->mtagsets, name) >= 0) H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Cannot remove tagset '%s': Still open ", name)); + if (h5priv_find_strlist (m->mtagsets, name) >= 0) + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Cannot remove tagset '%s': Still open ", + name); hid_t loc_id; TRY (loc_id = hdf5_open_group (m->mesh_gid, "Tags")); diff --git a/src/h5core/h5u_model.c b/src/h5core/h5u_model.c index cb043d0..eee1fd3 100644 --- a/src/h5core/h5u_model.c +++ b/src/h5core/h5u_model.c @@ -50,10 +50,10 @@ h5u_get_num_points_in_view ( h5_ssize_t nparticles; if (!h5u_has_view (fh)) { - H5_LEAVE ( - h5_error ( - H5_ERR_H5PART, - "No view has been set.")); + H5_RETURN_ERROR ( + H5_ERR_H5PART, + "%s", + "No view has been set."); } TRY (nparticles = hdf5_get_selected_npoints_of_dataspace(f->u->diskshape)); h5_debug ("Found %lld particles in view.", (long long)nparticles ); @@ -118,11 +118,10 @@ h5u_set_num_points ( hsize_t dmax = H5S_UNLIMITED; if (nparticles < 0) - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "Invalid number of particles: %lld!\n", - (long long)nparticles)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid number of particles: %lld!\n", + (long long)nparticles); #ifndef PARALLEL_IO /* @@ -285,23 +284,19 @@ h5u_set_view ( :FIXME: why not gather total size? */ if (start < 0) { - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "Start of selection '%lld' out of range: " - "must be >= 0", - (long long)start) - ); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Start of selection '%lld' out of range: " + "must be >= 0", + (long long)start); } if (end < start) { - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "End of selection '%lld' out of range: " - "must be >= %lld", - (long long)end, - (long long)start) - ); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "End of selection '%lld' out of range: " + "must be >= %lld", + (long long)end, + (long long)start); } #if PARALLEL_IO TRY ( @@ -322,25 +317,22 @@ h5u_set_view ( } if (start < 0 || start >= total) { - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "Start of selection '%lld' out of range: " - "must be in [0..%lld]", - (long long)start, (long long)total-1)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Start of selection '%lld' out of range: " + "must be in [0..%lld]", + (long long)start, (long long)total-1); } else if (end < 0 || end >= total) { - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "End of selection '%lld' out of range: " - "must be in [0..%lld]", - (long long)end, (long long)total-1)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "End of selection '%lld' out of range: " + "must be in [0..%lld]", + (long long)end, (long long)total-1); } else if (end+1 < start) { - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "Invalid selection: start=%lld > end=%lld!\n", - (long long)start, (long long)end)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid selection: start=%lld > end=%lld!\n", + (long long)start, (long long)end); } } @@ -408,12 +400,11 @@ h5u_set_view_length ( } if (start < 0 || length < 0 || start+length > total) - H5_LEAVE ( - h5_error( - H5_ERR_INVAL, - "Invalid view: start=%lld, length=%lld, total=%lld", - (long long)start, (long long)length, - (long long)total)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Invalid view: start=%lld, length=%lld, total=%lld", + (long long)start, (long long)length, + (long long)total); /* setting up the new view */ u->viewstart = start; @@ -517,11 +508,11 @@ h5u_get_view ( struct h5u_fdata *u = f->u; if ( u->viewindexed ) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "The current view has an index selection, but " - "this function only works for ranged views." )); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "%s", + "The current view has an index selection, but " + "this function only works for ranged views." ); } h5_int64_t viewstart = 0; diff --git a/src/h5core/private/h5_attribs.h b/src/h5core/private/h5_attribs.h index ff61b9b..cf6317c 100644 --- a/src/h5core/private/h5_attribs.h +++ b/src/h5core/private/h5_attribs.h @@ -65,14 +65,13 @@ h5priv_read_attrib ( hid_t normalized_file_type; TRY (normalized_file_type = h5priv_normalize_type (file_type)); if (normalized_file_type != normalized_type) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Attribute '%s' has type '%s' but " - "was requested as '%s'.", - attrib_name, - hdf5_get_type_name (normalized_file_type), - hdf5_get_type_name (normalized_type))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Attribute '%s' has type '%s' but " + "was requested as '%s'.", + attrib_name, + hdf5_get_type_name (normalized_file_type), + hdf5_get_type_name (normalized_type)); if (normalized_type == H5_STRING) { mem_type = file_type; } else { @@ -120,10 +119,10 @@ h5priv_write_attrib ( if (overwrite) { TRY (hdf5_delete_attribute (id, attrib_name)); } else { - H5_LEAVE ( - h5_error (H5_ERR_H5, - "Cannot overwrite attribute %s/%s", - hdf5_get_objname (id), attrib_name)); + H5_RETURN_ERROR ( + H5_ERR, + "Cannot overwrite attribute %s/%s", + hdf5_get_objname (id), attrib_name); } } TRY (attrib_id = hdf5_create_attribute ( diff --git a/src/h5core/private/h5_hdf5.c b/src/h5core/private/h5_hdf5.c index c212144..d6863a8 100644 --- a/src/h5core/private/h5_hdf5.c +++ b/src/h5core/private/h5_hdf5.c @@ -40,10 +40,10 @@ h5priv_link_exists_ ( *s++ = '/'; *s = '\0'; } - if (s+strlen(path[i])+1 >= end) H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "path %s... to long", name)); + if (s+strlen(path[i])+1 >= end) + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "path %s... to long", name); s = stpcpy (s, path[i]); // return ptr to end!!! h5_err_t exists; TRY (exists = hdf5_link_exists (loc_id, name)); @@ -73,12 +73,11 @@ h5priv_open_group_ ( } else if (create_intermediate) { TRY (hid2 = hdf5_create_group (hid, path[i])); } else { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "No such group '%s/%s'.", - hdf5_get_objname (hid), - path[i])); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "No such group '%s/%s'.", + hdf5_get_objname (hid), + path[i]); } if (hid != loc_id) { @@ -237,11 +236,10 @@ hdf5_get_num_groups ( &start_idx, iter_op_count, &op_data); if (herr < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get number of groups in '%s'.", - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get number of groups in '%s'.", + hdf5_get_objname (loc_id)); } H5_RETURN (op_data.cnt); } @@ -263,12 +261,11 @@ hdf5_get_num_groups_matching_prefix ( &start_idx, iter_op_count_match, &op_data); if (herr < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get number of groups with prefix" - " '%s' in '%s'.", - prefix, hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get number of groups with prefix" + " '%s' in '%s'.", + prefix, hdf5_get_objname (loc_id)); } H5_RETURN (op_data.cnt); } @@ -296,13 +293,12 @@ hdf5_get_name_of_group_by_idx ( &start_idx, iter_op_idx, &op_data); if (herr < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get name of group with index" - " '%lu' in '%s'.", - (long unsigned int)idx, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get name of group with index" + " '%lu' in '%s'.", + (long unsigned int)idx, + hdf5_get_objname (loc_id)); } H5_RETURN (H5_SUCCESS); } @@ -322,11 +318,10 @@ hdf5_get_num_datasets ( &start_idx, iter_op_count, &op_data); if (herr < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get number of datasets in '%s'.", - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get number of datasets in '%s'.", + hdf5_get_objname (loc_id)); } H5_RETURN (op_data.cnt); } @@ -357,13 +352,12 @@ hdf5_get_name_of_dataset_by_idx ( &start_idx, iter_op_idx, &op_data); if (herr < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get name of dataset with index" - " '%lu' in '%s'.", - (long unsigned int)idx, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get name of dataset with index" + " '%lu' in '%s'.", + (long unsigned int)idx, + hdf5_get_objname (loc_id)); } if (op_data.cnt < 0) H5_LEAVE (H5_NOK); diff --git a/src/h5core/private/h5_hdf5.h b/src/h5core/private/h5_hdf5.h index 0d3b904..f25fc66 100644 --- a/src/h5core/private/h5_hdf5.h +++ b/src/h5core/private/h5_hdf5.h @@ -91,11 +91,10 @@ hdf5_link_exists ( H5Eset_auto(H5E_DEFAULT, old_func, old_client_data); if (exists < 0 ) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot query link %s/%s.", - hdf5_get_objname (loc_id), name)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot query link %s/%s.", + hdf5_get_objname (loc_id), name); H5_RETURN (exists); } @@ -110,11 +109,10 @@ hdf5_delete_link ( (long long int)loc_id, hdf5_get_objname (loc_id), name, (long long int)lapl_id); if (H5Ldelete (loc_id, name, lapl_id) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot delete link %s/%s.", - hdf5_get_objname (loc_id), name)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot delete link %s/%s.", + hdf5_get_objname (loc_id), name); H5_RETURN (H5_SUCCESS); } @@ -133,12 +131,11 @@ hdf5_open_group ( group_name); hid_t group_id = H5Gopen (loc_id, group_name, H5P_DEFAULT); if (group_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot open group '%s/%s'.", - hdf5_get_objname (loc_id), - group_name)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot open group '%s/%s'.", + hdf5_get_objname (loc_id), + group_name); H5_RETURN (group_id); } @@ -155,12 +152,11 @@ hdf5_create_group ( hid_t group_id = H5Gcreate ( loc_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (group_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot create group '%s/%s'.", - hdf5_get_objname (loc_id), - group_name)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot create group '%s/%s'.", + hdf5_get_objname (loc_id), + group_name); H5_RETURN (group_id); } @@ -197,11 +193,10 @@ hdf5_close_group ( if (group_id == 0 || group_id == -1) H5_LEAVE (H5_SUCCESS); if (H5Gclose (group_id) < 0 ) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot terminate access to group '%s').", - hdf5_get_objname (group_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot terminate access to group '%s').", + hdf5_get_objname (group_id)); } H5_RETURN (H5_SUCCESS); } @@ -216,11 +211,10 @@ hdf5_get_num_objs_in_group ( hdf5_get_objname (group_id)); H5G_info_t group_info; if (H5Gget_info (group_id, &group_info) < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get number of objects in group '%s'.", - hdf5_get_objname(group_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get number of objects in group '%s'.", + hdf5_get_objname(group_id)); } H5_RETURN ((h5_ssize_t)group_info.nlinks); } @@ -248,12 +242,11 @@ hdf5_get_objname_by_idx ( name, size, H5P_DEFAULT); if (len < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get name of object %llu in group '%s'.", - (unsigned long long)idx, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get name of object %llu in group '%s'.", + (unsigned long long)idx, + hdf5_get_objname (loc_id)); H5_RETURN (len); } @@ -275,11 +268,10 @@ hdf5_create_dataspace ( ); hid_t dataspace_id = H5Screate_simple (rank, dims, maxdims); if (dataspace_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot create dataspace with rank %d.", - rank)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot create dataspace with rank %d.", + rank); H5_RETURN (dataspace_id); } @@ -290,10 +282,10 @@ hdf5_create_dataspace_scalar ( HDF5_WRAPPER_ENTER (hid_t, "%s", "void"); hid_t dataspace_id = H5Screate (H5S_SCALAR); if (dataspace_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot create scalar dataspace.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot create scalar dataspace."); H5_RETURN (dataspace_id); } @@ -315,11 +307,11 @@ hdf5_select_hyperslab_of_dataspace ( count, block); if (herr < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot set select hyperslap region or add the " - "specified region")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot set select hyperslap region or add the " + "specified region"); H5_RETURN (H5_SUCCESS); } @@ -342,11 +334,11 @@ hdf5_select_elements_of_dataspace ( herr = H5Sselect_none ( space_id ); } if (herr < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot set select hyperslap region or add the " - "specified region")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot set select hyperslap region or add the " + "specified region"); H5_RETURN (H5_SUCCESS); } @@ -359,10 +351,10 @@ hdf5_select_none ( (long long int)space_id); herr_t herr = H5Sselect_none (space_id); if (herr < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Selection for writing zero-length data failed")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Selection for writing zero-length data failed"); } H5_RETURN (H5_SUCCESS); } @@ -374,11 +366,11 @@ hdf5_get_selected_npoints_of_dataspace ( HDF5_WRAPPER_ENTER (h5_ssize_t, "%lld", (long long int)space_id); hssize_t size = H5Sget_select_npoints (space_id); if (size < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Cannot determine number of " - "selected elements in dataspace.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot determine number of " + "selected elements in dataspace."); H5_RETURN (size); } @@ -389,11 +381,11 @@ hdf5_get_npoints_of_dataspace ( HDF5_WRAPPER_ENTER (h5_ssize_t, "%lld", (long long int)space_id); hssize_t size = H5Sget_simple_extent_npoints (space_id); if (size < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Cannot determine number of" - "elements in dataspace.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot determine number of" + "elements in dataspace."); H5_RETURN (size); } @@ -406,10 +398,10 @@ hdf5_get_dims_of_dataspace ( HDF5_WRAPPER_ENTER (int, "%lld", (long long int)space_id); int rank = H5Sget_simple_extent_dims (space_id, dims, maxdims); if (rank < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot determine rank of dataspace.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot determine rank of dataspace."); H5_RETURN (rank); } @@ -427,10 +419,10 @@ hdf5_close_dataspace ( herr_t herr = H5Sclose (dataspace_id); if (herr < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Cannot terminate access to dataspace!")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot terminate access to dataspace!"); H5_RETURN (H5_SUCCESS); } @@ -454,12 +446,11 @@ hdf5_open_dataset_by_name ( dataset_name, H5P_DEFAULT); if (dataset_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot open dataset '%s/%s'.", - hdf5_get_objname (loc_id), - dataset_name)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot open dataset '%s/%s'.", + hdf5_get_objname (loc_id), + dataset_name); H5_RETURN (dataset_id); } @@ -492,12 +483,11 @@ hdf5_create_dataset ( create_proplist, H5P_DEFAULT); if (dataset_id < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Cannot create dataset '%s/%s'", - hdf5_get_objname (loc_id), - dataset_name)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot create dataset '%s/%s'", + hdf5_get_objname (loc_id), + dataset_name); H5_RETURN (dataset_id); } @@ -516,11 +506,10 @@ hdf5_close_dataset ( H5_LEAVE (H5_SUCCESS); if (H5Dclose (dataset_id) < 0) { - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Close of dataset '%s' failed.", - hdf5_get_objname (dataset_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Close of dataset '%s' failed.", + hdf5_get_objname (dataset_id)); } H5_RETURN (H5_SUCCESS); } @@ -538,11 +527,10 @@ hdf5_get_dataset_space ( hdf5_get_objname(dataset_id)); hid_t dataspace_id = H5Dget_space (dataset_id); if (dataspace_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get dataspace for dataset '%s'.", - hdf5_get_objname (dataset_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get dataspace for dataset '%s'.", + hdf5_get_objname (dataset_id)); H5_RETURN (dataspace_id); } @@ -572,12 +560,11 @@ hdf5_write_dataset ( xfer_prop, buf); if (herr < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Write to dataset '%s' failed.", \ - hdf5_get_objname (dataset_id))); - + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Write to dataset '%s' failed.", + hdf5_get_objname (dataset_id)); + H5_RETURN (H5_SUCCESS); } @@ -605,11 +592,10 @@ hdf5_read_dataset ( xfer_prop, buf); if (herr < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Error reading dataset '%s'.", - hdf5_get_objname (dataset_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Error reading dataset '%s'.", + hdf5_get_objname (dataset_id)); H5_RETURN (H5_SUCCESS); } @@ -624,10 +610,10 @@ hdf5_get_dataset_type ( hdf5_get_objname(dataset_id)); hid_t datatype_id = H5Dget_type (dataset_id); if (datatype_id < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Cannot determine dataset type.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot determine dataset type."); H5_RETURN (datatype_id); } @@ -643,11 +629,10 @@ hdf5_set_dataset_extent ( hdf5_get_objname(dataset_id), *size); if (H5Dset_extent(dataset_id, size) < 0) { - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Changing size of dataset '%s' dimensions failed.", - hdf5_get_objname (dataset_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Changing size of dataset '%s' dimensions failed.", + hdf5_get_objname (dataset_id)); } H5_RETURN (H5_SUCCESS); } @@ -764,13 +749,12 @@ hdf5_create_array_type ( rank); hid_t type_id = H5Tarray_create (base_type_id, rank, dims); if (type_id < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Can't create array datatype object with base " - "type %s and rank %d", - hdf5_get_type_name (base_type_id), - rank)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Can't create array datatype object with base " + "type %s and rank %d", + hdf5_get_type_name (base_type_id), + rank); } H5_RETURN (type_id); } @@ -786,11 +770,10 @@ hdf5_create_type ( get_class_type_name (class)); hid_t type_id = H5Tcreate (class, size); if (type_id < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Can't create datatype object of class %s.", - get_class_type_name (class))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Can't create datatype object of class %s.", + get_class_type_name (class)); } H5_RETURN (type_id); } @@ -802,17 +785,17 @@ hdf5_create_string_type( HDF5_WRAPPER_ENTER (hid_t, "len = %llu", len); hid_t type_id = H5Tcopy (H5T_C_S1); if (type_id < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Can't duplicate C string type.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Can't duplicate C string type."); herr_t herr = H5Tset_size (type_id, len); if (herr < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Can't set length of C string type.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Can't set length of C string type."); H5_RETURN (type_id); } @@ -828,11 +811,10 @@ hdf5_insert_type ( (long long int)type_id, name); herr_t herr = H5Tinsert (type_id, name, offset, field_id); if (herr < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Can't insert field %s to compound datatype.", - name)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Can't insert field %s to compound datatype.", + name); H5_RETURN (H5_SUCCESS); } @@ -843,11 +825,10 @@ hdf5_get_class_type ( HDF5_WRAPPER_ENTER (h5_err_t, "dtype_id=%lld", (long long int)dtype_id); H5T_class_t class = H5Tget_class (dtype_id); if (class < 0) - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Can't determine class of type %lld.", - (long long int)dtype_id)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Can't determine class of type %lld.", + (long long int)dtype_id); H5_RETURN (class); } @@ -860,11 +841,10 @@ hdf5_get_sizeof_type ( (long long int)dtype_id); h5_ssize_t size = H5Tget_size (dtype_id); if (size == 0) { - H5_LEAVE ( - h5_error( - H5_ERR_HDF5, - "Can't determine size of type %lld.", - (long long int)dtype_id)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Can't determine size of type %lld.", + (long long int)dtype_id); } H5_RETURN (size); } @@ -879,10 +859,10 @@ hdf5_close_type ( (long long int)dtype_id); herr_t herr = H5Tclose (dtype_id); if (herr < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot release datatype.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot release datatype."); H5_RETURN (H5_SUCCESS); } @@ -897,10 +877,10 @@ hdf5_create_property ( (long long int)cls_id); hid_t prop_id = H5Pcreate (cls_id); if (prop_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot create property list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot create property list."); H5_RETURN (prop_id); } @@ -917,11 +897,10 @@ hdf5_get_dataset_create_plist ( hdf5_get_objname (dataset_id)); hid_t plist_id = H5Dget_create_plist (dataset_id); if (plist_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get create properties for dataset '%s'.", - hdf5_get_objname (dataset_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get create properties for dataset '%s'.", + hdf5_get_objname (dataset_id)); H5_RETURN (plist_id); } @@ -935,10 +914,10 @@ hdf5_set_chunk_property ( "plist=%lld, rank=%d, dims[0]=%llu ...", (long long int)plist, rank, dims[0]); if (H5Pset_chunk (plist, rank, dims) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot add chunking property to list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot add chunking property to list."); H5_RETURN (H5_SUCCESS); } @@ -953,10 +932,10 @@ hdf5_get_chunk_property ( "plist=%lld, rank=%d", (long long int)plist, rank); if (H5Pget_chunk (plist, rank, dims) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get chunking property from list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot get chunking property from list."); H5_RETURN (H5_SUCCESS); } @@ -970,10 +949,10 @@ hdf5_set_layout_property ( "plist=%lld", (long long int)plist); if (H5Pset_layout (plist, layout) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot add layout property to list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot add layout property to list."); H5_RETURN (H5_SUCCESS); } @@ -989,11 +968,11 @@ hdf5_set_fapl_mpio_property ( "fapl_id=%lld, comm=..., info=...", (long long int)fapl_id); if (H5Pset_fapl_mpio (fapl_id, comm, info) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot store IO communicator information to the " - "file access property list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot store IO communicator information to the " + "file access property list."); H5_RETURN (H5_SUCCESS); } @@ -1008,11 +987,11 @@ hdf5_set_fapl_mpiposix_property ( "fapl_id=%lld, comm=..., use_gpfs=%d", (long long int)fapl_id, (int)use_gpfs); if ( H5Pset_fapl_mpiposix (fapl_id, comm, use_gpfs) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot store IO communicator information to" - " the file access property list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot store IO communicator information to" + " the file access property list."); H5_RETURN (H5_SUCCESS); } #endif @@ -1026,11 +1005,11 @@ hdf5_set_dxpl_mpio_property ( "dxpl_id=%lld, mode=%d", (long long int)dxpl_id, (int)mode); if (H5Pset_dxpl_mpio (dxpl_id, mode) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot store IO communicator information to" - " the dataset transfer property list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot store IO communicator information to" + " the dataset transfer property list."); H5_RETURN (H5_SUCCESS); } #endif @@ -1044,11 +1023,11 @@ hdf5_set_mdc_property ( "fapl_id=%lld, config=%p", (long long int)fapl_id, config); if (H5Pset_mdc_config (fapl_id, config) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot store metadata cache configuration in" - " the file access property list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot store metadata cache configuration in" + " the file access property list."); H5_RETURN (H5_SUCCESS); } @@ -1061,11 +1040,11 @@ hdf5_get_mdc_property ( "fapl_id=%lld, config=%p", (long long int)fapl_id, config); if (H5Pget_mdc_config (fapl_id, config) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get metadata cache configuration in" - " the file access property list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot get metadata cache configuration in" + " the file access property list."); H5_RETURN (H5_SUCCESS); } @@ -1078,11 +1057,11 @@ hdf5_set_btree_ik_property ( "fapl_id=%lld, btree_ik=%llu", (long long int)fcpl_id, btree_ik); if (H5Pset_istore_k (fcpl_id, btree_ik) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot set btree size in the " - "file access property list.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot set btree size in the " + "file access property list."); H5_RETURN (H5_SUCCESS); } @@ -1096,12 +1075,11 @@ hdf5_set_alignment_property ( "plist=%lld, threshold=%llu, alignment=%llu", (long long int)plist, threshold, alignment); if (H5Pset_alignment (plist, threshold, alignment) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot set alignment property to %llu " - "and threshold %llu", - alignment, threshold)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot set alignment property to %llu " + "and threshold %llu", + alignment, threshold); H5_RETURN (H5_SUCCESS); } @@ -1114,11 +1092,10 @@ hdf5_set_meta_block_size ( "fapl_id=%lld, size=%llu", (long long int)fapl_id, size); if (H5Pset_meta_block_size (fapl_id, size) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot set meta block size property to %llu", - size)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot set meta block size property to %llu", + size); H5_RETURN (H5_SUCCESS); } @@ -1132,10 +1109,10 @@ hdf5_set_fapl_core ( "fapl_id=%lld, size=%zu, backing_store=%d", (long long int)fapl_id, increment, backing_store); if (H5Pset_fapl_core (fapl_id, increment, backing_store)) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot set property to use the H5FD_CORE driver.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot set property to use the H5FD_CORE driver."); H5_RETURN (H5_SUCCESS); } @@ -1147,10 +1124,9 @@ hdf5_close_property ( "prop=%lld", (long long int)prop); if (H5Pclose (prop) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot close property %lld.", (long long)prop)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot close property %lld.", (long long)prop); H5_RETURN (H5_SUCCESS); } @@ -1163,10 +1139,9 @@ hdf5_close_object ( "object_id=%lld", (long long int)object_id); if (H5Oclose (object_id) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot close object %lld.", (long long)object_id)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot close object %lld.", (long long)object_id); H5_RETURN (H5_SUCCESS); } @@ -1180,11 +1155,10 @@ hdf5_get_object_count ( (long long int)file_id, hdf5_get_objname (file_id), types); if ((ret_value = H5Fget_obj_count (file_id, types)) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get open object count for file %lld.", - (long long)file_id)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get open object count for file %lld.", + (long long)file_id); H5_RETURN (ret_value); } @@ -1203,11 +1177,10 @@ hdf5_get_object_ids ( (long long int)file_id, hdf5_get_objname (file_id), types, max_objs, obj_id_list); if ((ret_value = H5Fget_obj_ids (file_id, types, max_objs, obj_id_list)) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get object id list for file %lld.", - (long long)file_id)); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get object id list for file %lld.", + (long long)file_id); H5_RETURN (ret_value); } @@ -1248,11 +1221,10 @@ hdf5_close_file ( H5_RETURN (H5_SUCCESS); return_with_error: - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot close file '%s'.", - hdf5_get_objname (file_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot close file '%s'.", + hdf5_get_objname (file_id)); } static inline h5_err_t @@ -1261,10 +1233,10 @@ hdf5_close ( ) { HDF5_WRAPPER_ENTER (h5_err_t, "%s", "void"); if (H5close () < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot close HDF5 library.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot close HDF5 library."); H5_RETURN (H5_SUCCESS); } @@ -1278,11 +1250,10 @@ hdf5_flush ( (long long int)obj_id, hdf5_get_objname (obj_id)); if (H5Fflush (obj_id, scope) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot flush data \"%s\".", - hdf5_get_objname (obj_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot flush data \"%s\".", + hdf5_get_objname (obj_id)); H5_RETURN (H5_SUCCESS); } @@ -1298,10 +1269,10 @@ hdf5_set_errorhandler ( "estack_id=%lld, func=%p, client_data=%p", (long long int)estack_id, func, client_data); if (H5Eset_auto (estack_id, func, client_data) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot initialize H5.")); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot initialize H5."); H5_RETURN (H5_SUCCESS); } @@ -1317,12 +1288,11 @@ hdf5_attribute_exists ( hdf5_get_objname (loc_id), attrib_name); htri_t exists = H5Aexists (loc_id, attrib_name); if (exists < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot query attribute '%s' of '%s'.", - attrib_name, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot query attribute '%s' of '%s'.", + attrib_name, + hdf5_get_objname (loc_id)); H5_RETURN (exists); } @@ -1337,12 +1307,11 @@ hdf5_open_attribute_by_name ( hdf5_get_objname (loc_id), attrib_name); hid_t attrib_id = H5Aopen (loc_id, attrib_name, H5P_DEFAULT); if (attrib_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot open attribute '%s' of '%s'.", - attrib_name, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot open attribute '%s' of '%s'.", + attrib_name, + hdf5_get_objname (loc_id)); H5_RETURN (attrib_id); } @@ -1356,12 +1325,11 @@ hdf5_open_attribute_by_idx ( (long long int)loc_id, hdf5_get_objname (loc_id), idx); hid_t attr_id = H5Aopen_idx (loc_id, idx); if (attr_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot open attribute '%u' of '%s'.", - idx, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot open attribute '%u' of '%s'.", + idx, + hdf5_get_objname (loc_id)); H5_RETURN (attr_id); } @@ -1386,12 +1354,11 @@ hdf5_create_attribute ( acpl_id, aapl_id); if (attr_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot create attribute '%s' for '%s'.", - attr_name, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot create attribute '%s' for '%s'.", + attr_name, + hdf5_get_objname (loc_id)); H5_RETURN (attr_id); } @@ -1406,11 +1373,10 @@ hdf5_read_attribute ( (long long int)attr_id, hdf5_get_objname (attr_id), (long long int)mem_type_id, buf); if (H5Aread (attr_id, mem_type_id, buf) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot read attribute '%s'.", - hdf5_get_objname (attr_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot read attribute '%s'.", + hdf5_get_objname (attr_id)); H5_RETURN (H5_SUCCESS); } @@ -1428,11 +1394,10 @@ hdf5_write_attribute ( (long long int)attr_id, hdf5_get_objname (attr_id), (long long int)mem_type_id, buf); if (H5Awrite (attr_id, mem_type_id, buf) < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot write attribute '%s'.", - hdf5_get_objname (attr_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot write attribute '%s'.", + hdf5_get_objname (attr_id)); H5_RETURN (H5_SUCCESS); } @@ -1449,10 +1414,10 @@ hdf5_get_attribute_name ( (unsigned long long)buf_size, buf); ssize_t size = H5Aget_name ( attr_id, buf_size, buf ); if (size < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get attribute name." )); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "%s", + "Cannot get attribute name." ); H5_RETURN ((h5_size_t)size); } @@ -1465,11 +1430,10 @@ hdf5_get_attribute_type ( (long long int)attr_id, hdf5_get_objname (attr_id)); hid_t datatype_id = H5Aget_type (attr_id); if (datatype_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get type of attribute '%s'.", - hdf5_get_objname (attr_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get type of attribute '%s'.", + hdf5_get_objname (attr_id)); H5_RETURN (datatype_id); } @@ -1482,11 +1446,10 @@ hdf5_get_attribute_dataspace ( (long long int)attr_id, hdf5_get_objname (attr_id)); hid_t space_id = H5Aget_space (attr_id); if (space_id < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get dataspace of attribute '%s'.", - hdf5_get_objname (attr_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get dataspace of attribute '%s'.", + hdf5_get_objname (attr_id)); H5_RETURN (space_id); } @@ -1499,11 +1462,10 @@ hdf5_get_num_attribute ( (long long int)loc_id, hdf5_get_objname (loc_id)); int num = H5Aget_num_attrs (loc_id); if (num < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot get number of attributes of '%s'.", - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot get number of attributes of '%s'.", + hdf5_get_objname (loc_id)); H5_RETURN (num); } @@ -1517,12 +1479,11 @@ hdf5_delete_attribute ( (long long int)loc_id, hdf5_get_objname (loc_id), attrib_name); herr_t herr = H5Adelete (loc_id, attrib_name); if (herr < 0) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot delete attribute '%s' of '%s'.", - attrib_name, - hdf5_get_objname (loc_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot delete attribute '%s' of '%s'.", + attrib_name, + hdf5_get_objname (loc_id)); H5_RETURN (herr); } @@ -1534,11 +1495,10 @@ hdf5_close_attribute ( "attr_id=%lld (%s)", (long long int)attr_id, hdf5_get_objname (attr_id)); if (H5Aclose (attr_id)) - H5_LEAVE ( - h5_error ( - H5_ERR_HDF5, - "Cannot close attribute '%s'.", - hdf5_get_objname (attr_id))); + H5_RETURN_ERROR ( + H5_ERR_HDF5, + "Cannot close attribute '%s'.", + hdf5_get_objname (attr_id)); H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5_model.h b/src/h5core/private/h5_model.h index 97ad407..0dc647a 100644 --- a/src/h5core/private/h5_model.h +++ b/src/h5core/private/h5_model.h @@ -159,10 +159,9 @@ h5priv_map_enum_to_normalized_type ( ret_value = H5_FLOAT64; break; default: - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Unknown type %d", (int)type)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Unknown type %d", (int)type); } H5_RETURN (ret_value); } @@ -220,10 +219,9 @@ h5priv_normalize_type ( break; } if (ret_value < 0) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Unknown type %d", (int)type)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Unknown type %d", (int)type); } H5_RETURN (ret_value); } @@ -280,10 +278,9 @@ h5priv_map_hdf5_type_to_enum ( ret_value = H5_STRING_T; break; default: - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Unknown type %d", (int)type)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Unknown type %d", (int)type); } H5_RETURN (ret_value); } diff --git a/src/h5core/private/h5_mpi.h b/src/h5core/private/h5_mpi.h index 13d2473..96f33f1 100644 --- a/src/h5core/private/h5_mpi.h +++ b/src/h5core/private/h5_mpi.h @@ -42,10 +42,10 @@ h5priv_mpi_alltoall ( recvtype, comm); if (err != MPI_SUCCESS) - H5_LEAVE ( - h5_error ( - H5_ERR_MPI, - "Cannot perform all to all communication")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot perform all to all communication"); H5_RETURN (H5_SUCCESS); } @@ -78,10 +78,10 @@ h5priv_mpi_alltoallv ( recvtype, comm); if (err != MPI_SUCCESS) - H5_LEAVE ( - h5_error ( - H5_ERR_MPI, - "Cannot perform all to all communication")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot perform all to all communication"); H5_RETURN (H5_SUCCESS); } @@ -93,10 +93,10 @@ h5priv_mpi_barrier ( MPI_WRAPPER_ENTER (h5_err_t, "comm=%p",&comm); int err = MPI_Barrier(comm); if (err != MPI_SUCCESS) - H5_LEAVE ( - h5_error ( - H5_ERR_MPI, - "MPI Barrier was not successful")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "MPI Barrier was not successful"); H5_RETURN (H5_SUCCESS); } @@ -123,7 +123,10 @@ h5priv_mpi_recv( MPI_STATUS_IGNORE ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot receive data")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot receive data"); H5_RETURN (H5_SUCCESS); } @@ -148,7 +151,10 @@ h5priv_mpi_send( comm ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot send data")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot send data"); H5_RETURN (H5_SUCCESS); } @@ -171,7 +177,10 @@ h5priv_mpi_bcast ( comm ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform broadcast")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot perform broadcast"); H5_RETURN (H5_SUCCESS); } @@ -195,7 +204,10 @@ h5priv_mpi_sum ( comm ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform MPI_SUM reduction")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot perform MPI_SUM reduction"); H5_RETURN (H5_SUCCESS); } @@ -218,8 +230,10 @@ h5priv_mpi_allreduce_max ( MPI_MAX, comm ) != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, - "Cannot perform MPI_MAX reduction")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot perform MPI_MAX reduction"); H5_RETURN (H5_SUCCESS); } @@ -243,7 +257,10 @@ h5priv_mpi_prefix_sum ( comm ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform prefix sum")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot perform prefix sum"); H5_RETURN (H5_SUCCESS); } @@ -271,7 +288,10 @@ mpi_allgather ( recvtype, comm); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot gather data"); H5_RETURN (H5_SUCCESS); } #define h5priv_mpi_allgatherv mpi_allgatherv @@ -301,7 +321,10 @@ mpi_allgatherv ( recvtype, comm); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot gather data"); H5_RETURN (H5_SUCCESS); } @@ -314,7 +337,10 @@ h5priv_mpi_comm_size ( MPI_WRAPPER_ENTER (h5_err_t, "comm=?, size=%p", size); int err = MPI_Comm_size (comm, size); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot get communicator size")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot get communicator size"); H5_RETURN (H5_SUCCESS); } @@ -326,7 +352,10 @@ h5priv_mpi_comm_rank ( MPI_WRAPPER_ENTER (h5_err_t, "comm=?, rank=%p", rank); int err = MPI_Comm_rank (comm, rank); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot get this task's rank")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot get this task's rank"); H5_RETURN (H5_SUCCESS); } @@ -342,10 +371,16 @@ h5priv_mpi_type_contiguous ( int err; err = MPI_Type_contiguous ( nelems, oldtype, newtype ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot create new MPI type")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot create new MPI type"); err = MPI_Type_commit ( newtype ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot commit new MPI type")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot commit new MPI type"); H5_RETURN (H5_SUCCESS); } @@ -358,10 +393,9 @@ mpi_get_address ( MPI_WRAPPER_ENTER (h5_err_t, "location=%p, address=%p", location, address); int err = MPI_Get_address (location, address); if (err != MPI_SUCCESS) { - H5_LEAVE ( - h5_error ( - H5_ERR_MPI, - "Cannot get MPI address of location=%p", location)); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "Cannot get MPI address of location=%p", location); } H5_RETURN (H5_SUCCESS); } @@ -380,10 +414,10 @@ mpi_create_type_struct ( count, blocklens, indices, old_types, new_type); int err = MPI_Type_create_struct (count, blocklens, indices, old_types, new_type); if (err != MPI_SUCCESS) { - H5_LEAVE ( - h5_error ( - H5_ERR_MPI, - "Cannot create new MPI struct")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot create new MPI struct"); } H5_RETURN (H5_SUCCESS); } @@ -394,12 +428,12 @@ h5priv_mpi_type_commit ( ) { MPI_WRAPPER_ENTER (h5_err_t, "type=%p", type); int err = MPI_Type_commit (type); - if (err != MPI_SUCCESS) { - H5_LEAVE ( - h5_error ( - H5_ERR_MPI, - "Cannot commit MPI datatype")); - } + if (err != MPI_SUCCESS) { + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot commit MPI datatype"); + } H5_RETURN (H5_SUCCESS); } @@ -411,7 +445,10 @@ h5priv_mpi_type_free ( MPI_WRAPPER_ENTER (h5_err_t, "type=%p", type); int err = MPI_Type_free( type ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot free MPI type")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot free MPI type"); H5_RETURN (H5_SUCCESS); } @@ -430,7 +467,10 @@ h5priv_mpi_cart_create ( int err = MPI_Cart_create( old_comm, ndims, dims, period, reorder, new_comm); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot create cartesian grid"); H5_RETURN (H5_SUCCESS); } @@ -445,7 +485,10 @@ h5priv_mpi_cart_coords ( rank, maxdim, coords); int err = MPI_Cart_coords( comm, rank, maxdim, coords ); if (err != MPI_SUCCESS) - H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid")); + H5_RETURN_ERROR ( + H5_ERR_MPI, + "%s", + "Cannot create cartesian grid"); H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5t_model_tetm.c b/src/h5core/private/h5t_model_tetm.c index b3261ca..8a53e38 100644 --- a/src/h5core/private/h5t_model_tetm.c +++ b/src/h5core/private/h5t_model_tetm.c @@ -151,11 +151,10 @@ h5t_add_tetrahedral_mesh ( TETRAHEDRAL_MESHES_GRPNAME, name)); if (exists) { - H5_LEAVE ( - h5_error ( - H5_ERR, - "Tetrahedral mesh '%s' already exists!", - name)); + H5_RETURN_ERROR ( + H5_ERR, + "Tetrahedral mesh '%s' already exists!", + name); } hid_t mesh_hid; TRY (mesh_hid = h5priv_open_group ( @@ -209,11 +208,10 @@ h5t_add_chunked_tetrahedral_mesh ( TETRAHEDRAL_MESHES_GRPNAME, name)); if (exists) { - H5_LEAVE ( - h5_error ( - H5_ERR, - "Tetrahedral mesh '%s' already exists!", - name)); + H5_RETURN_ERROR ( + H5_ERR, + "Tetrahedral mesh '%s' already exists!", + name); } hid_t mesh_hid; TRY (mesh_hid = h5priv_open_group ( diff --git a/src/h5core/private/h5t_model_trim.c b/src/h5core/private/h5t_model_trim.c index cb3e88b..9fe9df2 100644 --- a/src/h5core/private/h5t_model_trim.c +++ b/src/h5core/private/h5t_model_trim.c @@ -170,11 +170,10 @@ h5t_add_triangle_mesh ( TRIANGLE_MESHES_GRPNAME, name)); if (exists) { - H5_LEAVE ( - h5_error ( - H5_ERR, - "Tetrahedral mesh '%s' already exists!", - name)); + H5_RETURN_ERROR ( + H5_ERR, + "Tetrahedral mesh '%s' already exists!", + name); } hid_t mesh_hid; TRY (mesh_hid = h5priv_open_group ( @@ -221,11 +220,10 @@ h5t_add_chunked_triangle_mesh( int size = -1; TRY (h5priv_mpi_comm_size (f->props->comm, &size)); if (size != 1) { - H5_LEAVE ( - h5_error ( - H5_ERR, - "Trying to create a chunked mesh with '%d' procs instead of 1!", - size)); + H5_RETURN_ERROR ( + H5_ERR, + "Trying to create a chunked mesh with '%d' procs instead of 1!", + size); } CHECK_WRITABLE_MODE (f); @@ -236,11 +234,10 @@ h5t_add_chunked_triangle_mesh( TRIANGLE_MESHES_GRPNAME, name)); if (exists) { - H5_LEAVE ( - h5_error ( - H5_ERR, - "Triangle mesh '%s' already exists!", - name)); + H5_RETURN_ERROR ( + H5_ERR, + "Triangle mesh '%s' already exists!", + name); } hid_t mesh_hid; TRY (mesh_hid = h5priv_open_group ( diff --git a/src/h5core/private/h5t_store_tetm.c b/src/h5core/private/h5t_store_tetm.c index 69d4cae..6b789da 100644 --- a/src/h5core/private/h5t_store_tetm.c +++ b/src/h5core/private/h5t_store_tetm.c @@ -151,11 +151,10 @@ refine_tet ( h5_loc_tet_t* el = (h5_loc_tet_t*)m->loc_elems + elem_idx; if ( el->child_idx >= 0 ) - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Tetrahedron %lld already refined.", - (long long)elem_idx )); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Tetrahedron %lld already refined.", + (long long)elem_idx); vertices[0] = el->vertex_indices[0]; vertices[1] = el->vertex_indices[1]; vertices[2] = el->vertex_indices[2]; @@ -312,13 +311,12 @@ compute_neighbors_of_elems ( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, level=%d", m, level); if (level < 0 || level >= m->num_leaf_levels) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "level idx %lld out of bound, must be in [%lld,%lld]", - (long long)level, - (long long)0, - (long long)m->num_leaf_levels)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "level idx %lld out of bound, must be in [%lld,%lld]", + (long long)level, + (long long)0, + (long long)m->num_leaf_levels); } h5_loc_idx_t elem_idx = level == 0 ? 0 : m->num_interior_elems[level-1]; const h5_loc_idx_t last_idx = m->num_interior_elems[level] - 1; diff --git a/src/h5core/private/h5t_store_trim.c b/src/h5core/private/h5t_store_trim.c index 4613847..50e7a51 100644 --- a/src/h5core/private/h5t_store_trim.c +++ b/src/h5core/private/h5t_store_trim.c @@ -130,11 +130,10 @@ refine_triangle ( h5_loc_tri_t* el = (h5_loc_tri_t*)m->loc_elems + elem_idx; if (el->child_idx >= 0) - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "Element %lld already refined.", - (long long)elem_idx)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "Element %lld already refined.", + (long long)elem_idx); vertices[0] = el->vertex_indices[0]; vertices[1] = el->vertex_indices[1]; @@ -236,13 +235,12 @@ compute_neighbors_of_elems ( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, level=%d", m, level); if (level < 0 || level >= m->num_leaf_levels) { - H5_LEAVE ( - h5_error ( - H5_ERR_INVAL, - "level idx %lld out of bound, must be in [%lld,%lld]", - (long long)level, - (long long)0, - (long long)m->num_leaf_levels)); + H5_RETURN_ERROR ( + H5_ERR_INVAL, + "level idx %lld out of bound, must be in [%lld,%lld]", + (long long)level, + (long long)0, + (long long)m->num_leaf_levels); } h5_loc_idx_t elem_idx = level == 0 ? 0 : m->num_interior_elems[level-1]; const h5_loc_idx_t last_idx = m->num_interior_elems[level] - 1; diff --git a/src/include/h5core/h5_log.h b/src/include/h5core/h5_log.h index 350cdcb..c0dee76 100644 --- a/src/include/h5core/h5_log.h +++ b/src/include/h5core/h5_log.h @@ -214,9 +214,14 @@ h5_get_loglevel ( ////////////////////////////////////////////////////////////////////////////// #define H5_LEAVE(expr) { \ - ret_value = expr; \ - goto done; \ -} + ret_value = expr; \ + goto done; \ + } + +#define H5_RETURN_ERROR(errno, fmt, ...) { \ + ret_value = h5_error (errno, "(" fmt ")", __VA_ARGS__); \ + goto done; \ + } ////////////////////////////////////////////////////////////////////////////// // function return macro @@ -234,7 +239,7 @@ done: \ ret_value = expr; \ goto done; \ done: \ -if (__log__ ) { \ + if (__log__ ) { \ char fmt[256]; \ snprintf (fmt, sizeof(fmt), "return: %s", \ h5_rfmts[h5_call_stack_get_type()]); \