summaryrefslogtreecommitdiffstats
path: root/src/H5Pfcpl.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-09-08 20:15:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-09-08 20:15:37 (GMT)
commiteaf4ee3eb992809394f74e607b932482126a5b57 (patch)
tree1a0b803f84532ddf92543239009c5df1a1a43a4d /src/H5Pfcpl.c
parent1cad9f47513a8819c82397371ebe25f83b9917e6 (diff)
downloadhdf5-eaf4ee3eb992809394f74e607b932482126a5b57.zip
hdf5-eaf4ee3eb992809394f74e607b932482126a5b57.tar.gz
hdf5-eaf4ee3eb992809394f74e607b932482126a5b57.tar.bz2
[svn-r17459] Description:
Correct bad interaction between non-zero userblocks with non-zero alignments. Also add some additional range checking and tests for invalid userblock sizes. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production 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 production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'src/H5Pfcpl.c')
-rw-r--r--src/H5Pfcpl.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/H5Pfcpl.c b/src/H5Pfcpl.c
index 4d576c6..406dbe1 100644
--- a/src/H5Pfcpl.c
+++ b/src/H5Pfcpl.c
@@ -261,44 +261,39 @@ done:
* Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
- * Modifications:
- *
- * Raymond Lu, Oct 14, 2001
- * Changed to the new generic property list.
- *
*-------------------------------------------------------------------------
*/
herr_t
H5Pset_userblock(hid_t plist_id, hsize_t size)
{
- unsigned i;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value=SUCCEED; /* return value */
+ herr_t ret_value = SUCCEED; /* return value */
- FUNC_ENTER_API(H5Pset_userblock, FAIL);
+ FUNC_ENTER_API(H5Pset_userblock, FAIL)
H5TRACE2("e", "ih", plist_id, size);
- /* Check that the userblock size is a power of two */
- for (i=8; i<8*sizeof(hsize_t); i++) {
- hsize_t p2 = 8==i ? 0 : ((hsize_t)1<<i);
+ /* Sanity check non-zero userblock sizes */
+ if(size > 0) {
+ /* Check that the userblock size is >=512 */
+ if(size < 512)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and less than 512")
- if (size == p2)
- break;
- }
- if (i>=8*sizeof(hsize_t))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is not valid");
+ /* Check that the userblock size is a power of two */
+ if(!POWER_OF_TWO(size))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and not a power of two")
+ } /* end if */
/* Get the plist structure */
- if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_CREATE)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID");
+ if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Set value */
if(H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block");
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block")
done:
- FUNC_LEAVE_API(ret_value);
-}
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_userblock() */
/*-------------------------------------------------------------------------