Commit c80f6f56 authored by gsell's avatar gsell

use new macro H5_RETURN_ERROR where possible

parent 7b1079ae
Pipeline #15 skipped
......@@ -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));
......
......@@ -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;
......
......@@ -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);
}
......@@ -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)",
......
......@@ -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;
......
......@@ -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,
......
......@@ -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]);
......
......@@ -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));
......
......@@ -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
......
......@@ -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"));
......
......@@ -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,