summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-05-27 18:30:22 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-05-27 18:30:22 (GMT)
commit6bd725cec32a1d173707402e3815b7c1bccd00e0 (patch)
treef130fc6aa03f210901fca9d9cc3e616041f4259f
parent4f4902d0830cca2cb9d175f8510d5c4d673794d5 (diff)
downloadhdf5-6bd725cec32a1d173707402e3815b7c1bccd00e0.zip
hdf5-6bd725cec32a1d173707402e3815b7c1bccd00e0.tar.gz
hdf5-6bd725cec32a1d173707402e3815b7c1bccd00e0.tar.bz2
[svn-r16987] Description:
Bring r16986 from trunk to 1.8 branch: Clean up formatting & error reporting. Tested on: Mac OS X/32 10.5.7 (amazon) (h5committest done on trunk)
-rw-r--r--src/H5O.c13
-rw-r--r--src/H5S.c73
-rw-r--r--src/H5Sprivate.h2
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*/],