From fc6f3e165087f272a37b86307b329cb6281b9798 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 27 May 2009 13:08:46 -0500 Subject: [svn-r16986] Description: Clean up formatting & error reporting. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.6 (amazon) in debug mode Mac OS X/32 10.5.6 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode --- src/H5O.c | 13 ++++------ src/H5S.c | 73 ++++++++++++++++++++++++++++---------------------------- src/H5Sprivate.h | 2 +- 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/H5O.c b/src/H5O.c index 85fda74..8b684d4 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -1580,20 +1580,17 @@ H5O_protect(H5O_loc_t *loc, hid_t dxpl_id) /* Lock the object header into the cache */ if(NULL == (ret_value = (H5O_t *)H5AC_protect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "unable to load object header") + HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, NULL, "unable to load object header") /* Mark object header as un-evictable */ - if(H5AC_pin_protected_entry(loc->file, ret_value) < 0) { - if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, ret_value, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_OHDR, H5E_PROTECT, NULL, "unable to release object header") - + if(H5AC_pin_protected_entry(loc->file, ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTPIN, NULL, "unable to pin object header") - } /* end if */ +done: /* Release the object header from the cache */ if(H5AC_unprotect(loc->file, dxpl_id, H5AC_OHDR, loc->addr, ret_value, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_PROTECT, NULL, "unable to release object header") -done: + HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, NULL, "unable to release object header") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_protect() */ diff --git a/src/H5S.c b/src/H5S.c index 40134a6..9de4e95 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1756,27 +1756,25 @@ done: /*------------------------------------------------------------------------- - * Function: H5S_set_extent + * Function: H5S_set_extent * - * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend + * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend * - * Return: Success: Non-negative + * Return: Success: Non-negative + * Failure: Negative * - * Failure: Negative - * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu - * - * Date: March 13, 2002 + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * March 13, 2002 * *------------------------------------------------------------------------- */ -int +htri_t H5S_set_extent(H5S_t *space, const hsize_t *size) { unsigned u; /* Local index variable */ - herr_t ret_value = 0; /* Return value */ + htri_t ret_value = FALSE; /* Return value */ - FUNC_ENTER_NOAPI(H5S_set_extent, FAIL); + FUNC_ENTER_NOAPI(H5S_set_extent, FAIL) /* Check args */ HDassert(space && H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space)); @@ -1785,21 +1783,26 @@ H5S_set_extent(H5S_t *space, const hsize_t *size) /* Verify that the dimensions being changed are allowed to change */ for(u = 0; u < space->extent.rank; u++) { if(space->extent.size[u] != size[u]) { + /* Check for invalid dimension size modification */ if(space->extent.max && H5S_UNLIMITED != space->extent.max[u] && space->extent.max[u] < size[u]) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dimension cannot be modified") - ret_value++; + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "dimension cannot be modified") + + /* Indicate that dimension size can be modified */ + ret_value = TRUE; } /* end if */ } /* end for */ - /* Update */ + /* Update dimension size(s) */ if(ret_value) - H5S_set_extent_real(space, size); + if(H5S_set_extent_real(space, size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "failed to change dimension size(s)") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5S_set_extent() */ + /*------------------------------------------------------------------------- * Function: H5S_has_extent * @@ -1824,7 +1827,7 @@ H5S_has_extent(const H5S_t *ds) HDassert(ds); - if(ds->extent.rank==0 && ds->extent.nelem == 0 && ds->extent.type != H5S_NULL) + if(0 == ds->extent.rank && 0 == ds->extent.nelem && H5S_NULL != ds->extent.type) ret_value = FALSE; else ret_value = TRUE; @@ -1835,43 +1838,41 @@ done: /*------------------------------------------------------------------------- - * Function: H5S_set_extent_real - * - * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend - * - * Return: Success: Non-negative + * Function: H5S_set_extent_real * - * Failure: Negative + * Purpose: Modify the dimensions of a dataspace. Based on H5S_extend * - * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * Return: Success: Non-negative + * Failure: Negative * - * Date: March 13, 2002 + * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu + * March 13, 2002 * *------------------------------------------------------------------------- */ herr_t -H5S_set_extent_real( H5S_t *space, const hsize_t *size ) +H5S_set_extent_real(H5S_t *space, const hsize_t *size) { hsize_t nelem; /* Number of elements in extent */ unsigned u; /* Local index variable */ - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5S_set_extent_real, FAIL ); + FUNC_ENTER_NOAPI(H5S_set_extent_real, FAIL) /* Check args */ - assert(space && H5S_SIMPLE==H5S_GET_EXTENT_TYPE(space)); - assert(size); + HDassert(space && H5S_SIMPLE == H5S_GET_EXTENT_TYPE(space)); + HDassert(size); /* Change the dataspace size & re-compute the number of elements in the extent */ - for (u=0, nelem=1; u < space->extent.rank; u++ ) { + for(u = 0, nelem = 1; u < space->extent.rank; u++ ) { space->extent.size[u] = size[u]; - nelem*=space->extent.size[u]; + nelem *= space->extent.size[u]; } /* end for */ space->extent.nelem = nelem; /* If the selection is 'all', update the number of elements selected */ - if(H5S_GET_SELECT_TYPE(space)==H5S_SEL_ALL) - if(H5S_select_all(space, FALSE)<0) + if(H5S_SEL_ALL == H5S_GET_SELECT_TYPE(space)) + if(H5S_select_all(space, FALSE) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") /* Mark the dataspace as no longer shared if it was before */ @@ -1879,7 +1880,7 @@ H5S_set_extent_real( H5S_t *space, const hsize_t *size ) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRESET, FAIL, "can't stop sharing dataspace") done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_set_extent_real() */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index e78fb51..3514670 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -184,7 +184,7 @@ H5_DLL herr_t H5S_write(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned update_flag H5S_t *ds); H5_DLL herr_t H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, H5S_t *ds); H5_DLL H5S_t *H5S_read(const struct H5O_loc_t *loc, hid_t dxpl_id); -H5_DLL int H5S_set_extent(H5S_t *space, const hsize_t *size); +H5_DLL htri_t H5S_set_extent(H5S_t *space, const hsize_t *size); H5_DLL herr_t H5S_set_extent_real(H5S_t *space, const hsize_t *size); H5_DLL H5S_t *H5S_create(H5S_class_t type); H5_DLL H5S_t *H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], -- cgit v0.12