Commit c80f6f56 authored by gsell's avatar gsell
Browse files

use new macro H5_RETURN_ERROR where possible

parent 7b1079ae
Pipeline #15 skipped
...@@ -38,11 +38,10 @@ h5_add_attachment ( ...@@ -38,11 +38,10 @@ h5_add_attachment (
struct stat st; struct stat st;
if (stat (fname, &st) < 0) { if (stat (fname, &st) < 0) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_HDF5,
H5_ERR_HDF5, "Cannot stat file '%s'",
"Cannot stat file '%s'", fname);
fname));
} }
hsize_t fsize = st.st_size; hsize_t fsize = st.st_size;
hsize_t write_length; hsize_t write_length;
...@@ -52,30 +51,27 @@ h5_add_attachment ( ...@@ -52,30 +51,27 @@ h5_add_attachment (
write_length = fsize; write_length = fsize;
int fd; int fd;
if ((fd = open (fname, O_RDONLY)) < 0) { if ((fd = open (fname, O_RDONLY)) < 0) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_HDF5,
H5_ERR_HDF5, "Cannot open file '%s' for reading",
"Cannot open file '%s' for reading", fname);
fname));
} }
again: again:
if (read (fd, buf, fsize) < 0) { if (read (fd, buf, fsize) < 0) {
if (errno == EINTR) { if (errno == EINTR) {
goto again; goto again;
} else { } else {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_HDF5,
H5_ERR_HDF5, "Cannot read file '%s'",
"Cannot read file '%s'", fname);
fname));
} }
} }
if (close (fd) < 0) { if (close (fd) < 0) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_HDF5,
H5_ERR_HDF5, "Cannot close file '%s'",
"Cannot close file '%s'", fname);
fname));
} }
} else { } else {
...@@ -284,25 +280,22 @@ h5_get_attachment ( ...@@ -284,25 +280,22 @@ h5_get_attachment (
if (f->myproc == 0) { if (f->myproc == 0) {
int fd; int fd;
if ((fd = open (fname, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) { if ((fd = open (fname, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_H5,
H5_ERR_H5, "Error opening file '%s': %s",
"Error opening file '%s': %s", fname, strerror(errno));
fname, strerror(errno)));
} }
if (write (fd, buf, fsize) != fsize) { if (write (fd, buf, fsize) != fsize) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_H5,
H5_ERR_H5, "Error writing to file '%s': %s",
"Error writing to file '%s': %s", fname, strerror(errno));
fname, strerror(errno)));
} }
if (close (fd) < 0) { if (close (fd) < 0) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_H5,
H5_ERR_H5, "Error closing file '%s': %s",
"Error closing file '%s': %s", fname, strerror(errno));
fname, strerror(errno)));
} }
} }
TRY (h5_free (buf)); TRY (h5_free (buf));
......
...@@ -193,11 +193,10 @@ h5_set_prop_file_mpio_collective ( ...@@ -193,11 +193,10 @@ h5_set_prop_file_mpio_collective (
H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm); H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm);
if (props->class != H5_PROP_FILE) { if (props->class != H5_PROP_FILE) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)props->class);
(long long int)props->class));
} }
props->flags &= ~(H5_VFD_MPIO_POSIX | H5_VFD_MPIO_INDEPENDENT | H5_VFD_CORE); props->flags &= ~(H5_VFD_MPIO_POSIX | H5_VFD_MPIO_INDEPENDENT | H5_VFD_CORE);
props->flags |= H5_VFD_MPIO_COLLECTIVE; props->flags |= H5_VFD_MPIO_COLLECTIVE;
...@@ -219,11 +218,10 @@ h5_set_prop_file_mpio_independent ( ...@@ -219,11 +218,10 @@ h5_set_prop_file_mpio_independent (
H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm); H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm);
if (props->class != H5_PROP_FILE) { if (props->class != H5_PROP_FILE) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)props->class);
(long long int)props->class));
} }
props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE); props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE);
props->flags |= H5_VFD_MPIO_INDEPENDENT; props->flags |= H5_VFD_MPIO_INDEPENDENT;
...@@ -241,11 +239,10 @@ h5_set_prop_file_mpio_posix ( ...@@ -241,11 +239,10 @@ h5_set_prop_file_mpio_posix (
H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm); H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm);
if (props->class != H5_PROP_FILE) { if (props->class != H5_PROP_FILE) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)props->class);
(long long int)props->class));
} }
props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE); props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE);
props->flags |= H5_VFD_MPIO_INDEPENDENT; props->flags |= H5_VFD_MPIO_INDEPENDENT;
...@@ -263,11 +260,10 @@ h5_set_prop_file_core_vfd ( ...@@ -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); H5_CORE_API_ENTER (h5_err_t, "props=%p, increment=%lld", props, (long long int)increment);
if (props->class != H5_PROP_FILE) { if (props->class != H5_PROP_FILE) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)props->class);
(long long int)props->class));
} }
props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_INDEPENDENT | H5_VFD_MPIO_POSIX); props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_INDEPENDENT | H5_VFD_MPIO_POSIX);
props->flags |= H5_VFD_MPIO_INDEPENDENT; props->flags |= H5_VFD_MPIO_INDEPENDENT;
...@@ -292,11 +288,10 @@ h5_set_prop_file_align ( ...@@ -292,11 +288,10 @@ h5_set_prop_file_align (
"props=%p, align=%lld", "props=%p, align=%lld",
props, (long long int)align); props, (long long int)align);
if (props->class != H5_PROP_FILE) { if (props->class != H5_PROP_FILE) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)props->class);
(long long int)props->class));
} }
props->align = align; props->align = align;
H5_RETURN (H5_SUCCESS); H5_RETURN (H5_SUCCESS);
...@@ -313,11 +308,10 @@ h5_set_prop_file_throttle ( ...@@ -313,11 +308,10 @@ h5_set_prop_file_throttle (
"props=%p, throttle=%lld", "props=%p, throttle=%lld",
props, (long long int)throttle); props, (long long int)throttle);
if (props->class != H5_PROP_FILE) { if (props->class != H5_PROP_FILE) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)props->class);
(long long int)props->class));
} }
// throttle only if VFD is MPIO independent od POSIX // throttle only if VFD is MPIO independent od POSIX
h5_int64_t mask = H5_VFD_MPIO_INDEPENDENT; h5_int64_t mask = H5_VFD_MPIO_INDEPENDENT;
...@@ -357,11 +351,10 @@ h5_create_prop ( ...@@ -357,11 +351,10 @@ h5_create_prop (
set_default_file_props ((h5_prop_file_t*)prop); set_default_file_props ((h5_prop_file_t*)prop);
break; break;
default: default:
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)class);
(long long int)class));
} }
H5_RETURN ((h5_prop_t)prop); H5_RETURN ((h5_prop_t)prop);
} }
...@@ -379,11 +372,10 @@ h5_close_prop ( ...@@ -379,11 +372,10 @@ h5_close_prop (
break; break;
} }
default: default:
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld",
"Invalid property class: %lld", (long long int)prop->class);
(long long int)prop->class));
} }
H5_RETURN (h5_free (prop)); H5_RETURN (h5_free (prop));
} }
...@@ -441,19 +433,17 @@ open_file ( ...@@ -441,19 +433,17 @@ open_file (
} }
} }
else { else {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid file access mode '%lld'.",
"Invalid file access mode '%lld'.", (long long int)f->props->flags & 0xff);
(long long int)f->props->flags & 0xff));
} }
if (f->file < 0) if (f->file < 0)
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_HDF5,
H5_ERR_HDF5, "Cannot open file '%s' with mode '%s'",
"Cannot open file '%s' with mode '%s'", filename, H5_O_MODES[f->props->flags & 0xff]);
filename, H5_O_MODES[f->props->flags & 0xff]));
TRY (f->root_gid = hdf5_open_group (f->file, "/" )); TRY (f->root_gid = hdf5_open_group (f->file, "/" ));
TRY (h5upriv_open_file (f)); TRY (h5upriv_open_file (f));
...@@ -482,11 +472,10 @@ h5_open_file2 ( ...@@ -482,11 +472,10 @@ h5_open_file2 (
if (props != H5_PROP_DEFAULT) { if (props != H5_PROP_DEFAULT) {
if (props->class != H5_PROP_FILE) { if (props->class != H5_PROP_FILE) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Invalid property class: %lld.",
"Invalid property class: %lld.", (long long int)props->class);
(long long int)props->class));
} }
f->props->comm = props->comm; f->props->comm = props->comm;
f->props->flags = props->flags; f->props->flags = props->flags;
......
...@@ -93,12 +93,11 @@ h5priv_normalize_dataset_name ( ...@@ -93,12 +93,11 @@ h5priv_normalize_dataset_name (
} }
if ( strcmp( name2, H5BLOCK_GROUPNAME_BLOCK ) == 0 ) { if ( strcmp( name2, H5BLOCK_GROUPNAME_BLOCK ) == 0 ) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL, "Can't create dataset or field with name '%s'"
"Can't create dataset or field with name '%s'" " because it is reserved by H5Block.",
" because it is reserved by H5Block.", H5BLOCK_GROUPNAME_BLOCK);
H5BLOCK_GROUPNAME_BLOCK));
} }
H5_RETURN (H5_SUCCESS); H5_RETURN (H5_SUCCESS);
} }
...@@ -215,14 +215,13 @@ _write_data ( ...@@ -215,14 +215,13 @@ _write_data (
hid_t type_file; hid_t type_file;
TRY( type_file = hdf5_get_dataset_type (dataset) ); TRY( type_file = hdf5_get_dataset_type (dataset) );
if ( type != type_file ) { if ( type != type_file ) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error( H5_ERR_HDF5,
H5_ERR_HDF5, "Field '%s' already has type '%s' "
"Field '%s' already has type '%s' " "but was written as '%s'.",
"but was written as '%s'.", field_name,
field_name, hdf5_get_type_name (type_file),
hdf5_get_type_name (type_file), hdf5_get_type_name (type));
hdf5_get_type_name (type)));
} }
} else { } else {
TRY (dataset = hdf5_create_dataset( TRY (dataset = hdf5_create_dataset(
...@@ -328,21 +327,20 @@ _select_hyperslab_for_reading ( ...@@ -328,21 +327,20 @@ _select_hyperslab_for_reading (
TRY (rank = hdf5_get_dims_of_dataspace(b->diskshape, field_dims, NULL)); TRY (rank = hdf5_get_dims_of_dataspace(b->diskshape, field_dims, NULL));
if (rank != 3) if (rank != 3)
H5_LEAVE ( H5_RETURN_ERROR (
h5_error( H5_ERR_INVAL,
H5_ERR_INVAL, "H5Block dataset has bad rank '%d' instead"
"H5Block dataset has bad rank '%d' instead" " of rank 3! Is the file corrupt?",
" of rank 3! Is the file corrupt?", rank);
rank));
if ( (field_dims[0] < (hsize_t)b->k_max) || if ( (field_dims[0] < (hsize_t)b->k_max) ||
(field_dims[1] < (hsize_t)b->j_max) || (field_dims[1] < (hsize_t)b->j_max) ||
(field_dims[2] < (hsize_t)b->i_max) ) (field_dims[2] < (hsize_t)b->i_max) )
H5_LEAVE ( H5_RETURN_ERROR (
h5_error( H5_ERR_VIEW,
H5_ERR_VIEW, "%s",
"H5Block dataset has invalid view. " "H5Block dataset has invalid view. "
"Is the file corrupt?")); "Is the file corrupt?");
h5_debug ( h5_debug (
"field_dims: (%lld,%lld,%lld)", "field_dims: (%lld,%lld,%lld)",
......
...@@ -454,9 +454,10 @@ h5bpriv_open_block_group ( ...@@ -454,9 +454,10 @@ h5bpriv_open_block_group (
TRY (hdf5_close_group (b->block_gid)); TRY (hdf5_close_group (b->block_gid));
b->block_gid = hdf5_open_group (f->step_gid, H5BLOCK_GROUPNAME_BLOCK); b->block_gid = hdf5_open_group (f->step_gid, H5BLOCK_GROUPNAME_BLOCK);
if (f->b->block_gid < 0) if (f->b->block_gid < 0)
H5_LEAVE (h5_error( H5_RETURN_ERROR (
H5_ERR_INVAL, H5_ERR_INVAL,
"Time step does not contain H5Block data!")); "%s",
"Time step does not contain H5Block data!");
H5_RETURN (H5_SUCCESS); H5_RETURN (H5_SUCCESS);
} }
...@@ -761,14 +762,14 @@ h5b_3d_set_grid ( ...@@ -761,14 +762,14 @@ h5b_3d_set_grid (
(long long unsigned)j, (long long unsigned)j,
(long long unsigned)k); (long long unsigned)k);
if (i*j*k != f->nprocs) { if (i*j*k != f->nprocs) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error(H5_ERR_INVAL, H5_ERR_INVAL,
"Grid dimensions (%lld,%lld,%lld) do not multiply " "Grid dimensions (%lld,%lld,%lld) do not multiply "
"out to %d MPI processors!", "out to %d MPI processors!",
(long long)i, (long long)i,
(long long)j, (long long)j,
(long long)k, (long long)k,
f->nprocs)); f->nprocs);
} }
f->b->k_grid = i; f->b->k_grid = i;
...@@ -798,9 +799,10 @@ h5b_3d_get_grid_coords ( ...@@ -798,9 +799,10 @@ h5b_3d_get_grid_coords (
"f=%p, proc=%d, i=%p, j=%p, k=%p", "f=%p, proc=%d, i=%p, j=%p, k=%p",
f, proc, i, j, k); f, proc, i, j, k);
if ( !f->b->have_grid ) if ( !f->b->have_grid )
H5_LEAVE ( H5_RETURN_ERROR (
h5_error(H5_ERR_INVAL, H5_ERR_INVAL,
"Grid dimensions have not been set!")); "%s",
"Grid dimensions have not been set!");
int coords[3]; int coords[3];
TRY( h5priv_mpi_cart_coords(f->b->cart_comm, proc, 3, coords) ); TRY( h5priv_mpi_cart_coords(f->b->cart_comm, proc, 3, coords) );
...@@ -825,9 +827,10 @@ h5b_3d_set_dims ( ...@@ -825,9 +827,10 @@ h5b_3d_set_dims (
(long long unsigned)j, (long long unsigned)j,
(long long unsigned)k); (long long unsigned)k);
if ( !f->b->have_grid ) if ( !f->b->have_grid )
H5_LEAVE ( H5_RETURN_ERROR (
h5_error(H5_ERR_INVAL, H5_ERR_INVAL,
"Grid dimensions have not been set!")); "%s",
"Grid dimensions have not been set!");
h5_size_t dims[3] = { k, j, i }; h5_size_t dims[3] = { k, j, i };
h5_size_t check_dims[3] = { k, j, i }; h5_size_t check_dims[3] = { k, j, i };
...@@ -839,17 +842,17 @@ h5b_3d_set_dims ( ...@@ -839,17 +842,17 @@ h5b_3d_set_dims (
dims[1] != check_dims[1] || dims[1] != check_dims[1] ||
dims[2] != check_dims[2] dims[2] != check_dims[2]
) { ) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error(H5_ERR_INVAL, H5_ERR_INVAL,
"[%d] Block dimensions do not agree: " "[%d] Block dimensions do not agree: "
"(%lld,%lld,%lld) != (%lld,%lld,%lld)!", "(%lld,%lld,%lld) != (%lld,%lld,%lld)!",
f->myproc, f->myproc,
(long long)dims[0], (long long)dims[0],
(long long)dims[1], (long long)dims[1],
(long long)dims[2], (long long)dims[2],
(long long)check_dims[0], (long long)check_dims[0],
(long long)check_dims[1], (long long)check_dims[1],
(long long)check_dims[2])); (long long)check_dims[2]);
} }
h5_int64_t coords[3]; h5_int64_t coords[3];
TRY( h5b_3d_get_grid_coords((h5_file_t)f, TRY( h5b_3d_get_grid_coords((h5_file_t)f,
...@@ -892,13 +895,15 @@ h5b_3d_set_halo ( ...@@ -892,13 +895,15 @@ h5b_3d_set_halo (
(long long unsigned)k); (long long unsigned)k);
if ( !f->b->have_grid ) { if ( !f->b->have_grid ) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error(H5_ERR_INVAL, H5_ERR_INVAL,
"Grid dimensions have not been set!")); "%s",
"Grid dimensions have not been set!");
} else if ( !f->b->have_layout ) { } else if ( !f->b->have_layout ) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error(H5_ERR_INVAL, H5_ERR_INVAL,
"Block dimensions for grid have not been set!")); "%s",
"Block dimensions for grid have not been set!");
} }
h5b_fdata_t *b = f->b; h5b_fdata_t *b = f->b;
......
...@@ -1317,8 +1317,9 @@ part_kway ( ...@@ -1317,8 +1317,9 @@ part_kway (
&m->f->props->comm &m->f->props->comm
); );
if (rc != METIS_OK) { if (rc != METIS_OK) {
H5_LEAVE( H5_RETURN_ERROR (
h5_error (H5_ERR, "ParMETIS failed")); H5_ERR,
"ParMETIS failed");
} }
TRY (h5_free (vtxdist)); TRY (h5_free (vtxdist));
TRY (h5_free (xadj)); TRY (h5_free (xadj));
...@@ -2150,8 +2151,9 @@ distribute_octree_parmetis ( ...@@ -2150,8 +2151,9 @@ distribute_octree_parmetis (
&m->f->props->comm &m->f->props->comm
); );
if (rc != METIS_OK) { if (rc != METIS_OK) {
H5_LEAVE( H5_RETURN_ERROR (
h5_error (H5_ERR, "ParMETIS failed")); H5_ERR,
"ParMETIS failed");
} }
TRY (h5_free (xadj)); TRY (h5_free (xadj));
...@@ -2709,11 +2711,10 @@ read_elems_part ( ...@@ -2709,11 +2711,10 @@ read_elems_part (
i++; hcount++; i++; hcount++;
} }
if (hstart+hcount > num_glb_elems) { if (hstart+hcount > num_glb_elems) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_H5FED,
H5_ERR_H5FED, "invalid selection: start=%lld, count=%lld",
"invalid selection: start=%lld, count=%lld", (long long)hstart, (long long)hcount);
(long long)hstart, (long long)hcount));
} }
TRY (hdf5_select_hyperslab_of_dataspace ( TRY (hdf5_select_hyperslab_of_dataspace (
dspace_id, dspace_id,
......
...@@ -500,12 +500,11 @@ h5priv_exchange_loc_list_to_glb ( ...@@ -500,12 +500,11 @@ h5priv_exchange_loc_list_to_glb (
// loc -> glb // loc -> glb
for (int i = 0; i < m->marked_entities->num_items; i++) { for (int i = 0; i < m->marked_entities->num_items; i++) {
if (m->marked_entities->items[i] > m->last_stored_eid) { if (m->marked_entities->items[i] > m->last_stored_eid) {
H5_LEAVE ( H5_RETURN_ERROR (
h5_error ( H5_ERR_INVAL,
H5_ERR_INVAL,