summaryrefslogtreecommitdiffstats
path: root/src/H5S.c
diff options
context:
space:
mode:
authorVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-10-03 19:57:36 (GMT)
committerVailin Choi <vchoi@jam.ad.hdfgroup.org>2017-10-03 19:57:36 (GMT)
commitfe70476a225d2e0576149e0f1bdf95689f922c77 (patch)
treeca07b675475ec83f9c8588c0256d585e69688578 /src/H5S.c
parent9d6ba29a01079e0f81ffa530605d8cd830378f9c (diff)
downloadhdf5-fe70476a225d2e0576149e0f1bdf95689f922c77.zip
hdf5-fe70476a225d2e0576149e0f1bdf95689f922c77.tar.gz
hdf5-fe70476a225d2e0576149e0f1bdf95689f922c77.tar.bz2
Initial checkin for library version bounds
Code changes to provide versioning support when adding to the enumerated defines for H5F_libver_t.
Diffstat (limited to 'src/H5S.c')
-rw-r--r--src/H5S.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/H5S.c b/src/H5S.c
index 9ac40a7..01cacf0 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -84,6 +84,13 @@ static const H5I_class_t H5I_DATASPACE_CLS[1] = {{
(H5I_free_t)H5S_close /* Callback routine for closing objects of this class */
}};
+/* Format version bounds for dataspace */
+static const unsigned H5O_sdspace_ver_bounds[] = {
+ H5O_SDSPACE_VERSION_1, /* H5F_LIBVER_EARLIEST */
+ H5O_SDSPACE_VERSION_2, /* H5F_LIBVER_V18 */
+ H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */
+};
+
/* Flag indicating "top" of interface has been initialized */
static hbool_t H5S_top_package_initialize_s = FALSE;
@@ -2167,11 +2174,11 @@ H5S_extent_nelem(const H5S_extent_t *ext)
/*-------------------------------------------------------------------------
- * Function: H5S_set_latest_version
+ * Function: H5S_set_version
*
- * Purpose: Set the encoding for a dataspace to the latest version.
+ * Purpose: Set the version to encode a dataspace with.
*
- * Return: Non-negative on success/Negative on failure
+ * Return: Non-negative on success/Negative on failure
*
* Programmer: Quincey Koziol
* Tuesday, July 24, 2007
@@ -2179,18 +2186,27 @@ H5S_extent_nelem(const H5S_extent_t *ext)
*-------------------------------------------------------------------------
*/
herr_t
-H5S_set_latest_version(H5S_t *ds)
+H5S_set_version(H5F_t *f, H5S_t *ds)
{
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
+ HDassert(f);
HDassert(ds);
- /* Set encoding of extent to latest version */
- ds->extent.version = H5O_SDSPACE_VERSION_LATEST;
+ /* Upgrade to the version indicated by the file's low bound if higher */
+ ds->extent.version = MAX(ds->extent.version, H5O_sdspace_ver_bounds[H5F_LOW_BOUND(f)]);
+
+ /* File bound check */
+ if(ds->extent.version > H5O_sdspace_ver_bounds[H5F_HIGH_BOUND(f)])
+ HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "Dataspace version out of bounds")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* end H5S_set_latest_version() */
+} /* end H5S_set_version() */
#ifndef H5_NO_DEPRECATED_SYMBOLS