summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2014-09-15 18:30:00 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2014-09-15 18:30:00 (GMT)
commite0ccecfeb185193b45d84728f77c382ff4d3c610 (patch)
tree98df20cf513e636a32781c627748e48a87121333
parentcefacc4de4e59963fd1f2d41bb62109ad2b897d9 (diff)
downloadhdf5-e0ccecfeb185193b45d84728f77c382ff4d3c610.zip
hdf5-e0ccecfeb185193b45d84728f77c382ff4d3c610.tar.gz
hdf5-e0ccecfeb185193b45d84728f77c382ff4d3c610.tar.bz2
[svn-r25593] - rename values for VOL class.
- add more sanity checks in H5VL APIs.
-rw-r--r--src/H5PL.c2
-rw-r--r--src/H5VL.c26
-rw-r--r--src/H5VLnative.c2
-rw-r--r--src/H5VLpublic.h4
-rw-r--r--test/vol_test.c2
5 files changed, 26 insertions, 10 deletions
diff --git a/src/H5PL.c b/src/H5PL.c
index 3ec66e8..96d2e84 100644
--- a/src/H5PL.c
+++ b/src/H5PL.c
@@ -622,7 +622,7 @@ H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const char *pl_name, c
} /* end if */
/* Successfully found plugin library, check if it's the right one */
- if((pl_id > MAX_VOL_LIB_VALUE && plugin_info->value == pl_id) ||
+ if((pl_id > H5_VOL_MAX_LIB_VALUE && plugin_info->value == pl_id) ||
(pl_name && !strcmp(pl_name, plugin_info->name))) {
/* Expand the table if it is too small */
if(H5PL_vol_table_used_g >= H5PL_vol_table_alloc_g) {
diff --git a/src/H5VL.c b/src/H5VL.c
index f1a39ee..fd7443e 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -258,6 +258,7 @@ H5VL__get_plugin_cb(void *obj, hid_t id, void *_op_data)
hid_t
H5VLregister(const H5VL_class_t *cls)
{
+ H5VL_get_plugin_ud_t op_data;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -267,11 +268,22 @@ H5VLregister(const H5VL_class_t *cls)
if(!cls)
HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed")
- if(cls->value < MAX_VOL_LIB_VALUE)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "registered class value must not be smaller than %d", MAX_VOL_LIB_VALUE)
+ if(cls->value < H5_VOL_MAX_LIB_VALUE)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL,
+ "registered class value must not be smaller than %d", H5_VOL_MAX_LIB_VALUE)
+
+ if(!cls->name)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "invalid VOL class name");
+
+ op_data.ret_id = FAIL;
+ op_data.name = cls->name;
+
+ /* check if plugin is already registered */
+ if(H5I_iterate(H5I_VOL, H5VL__get_plugin_cb, &op_data, TRUE) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_BADITER,FAIL, "can't iterate over VOL ids")
- /* MSC - check if required callback are defined?? */
+ if(op_data.ret_id != FAIL)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "VOL plugin with the same name is already registered.")
/* Create the new class ID */
if((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0)
@@ -362,15 +374,19 @@ done:
herr_t
H5VLunregister(hid_t vol_id)
{
+ H5VL_class_t *cls = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", vol_id);
/* Check arguments */
- if(NULL == H5I_object_verify(vol_id, H5I_VOL))
+ if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(vol_id, H5I_VOL)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol plugin")
+ if(cls->value <= H5_VOL_MAX_LIB_VALUE)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't unregister an internal plugin")
+
/* The H5VL_class_t struct will be freed by this function */
if(H5I_dec_app_ref(vol_id) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister vol plugin")
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index b528121..9675655 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -124,7 +124,7 @@ static herr_t H5VL_native_object_optional(void *obj, hid_t dxpl_id, void **req,
static H5VL_class_t H5VL_native_g = {
HDF5_VOL_NATIVE_VERSION_1, /* Version number */
- NATIVE, /* Plugin value */
+ H5_VOL_NATIVE, /* Plugin value */
"native", /* Plugin name */
NULL, /* initialize */
NULL, /* terminate */
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index dc3ece3..220b6ed 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -319,8 +319,8 @@ typedef struct H5VL_async_class_t {
/* enum value to identify the class of a VOL plugin (mostly for comparison purposes) */
typedef enum H5VL_class_value_t {
- NATIVE = 0, /* This should be first */
- MAX_VOL_LIB_VALUE = 128 /* This should be last */
+ H5_VOL_NATIVE = 0, /* This should be first */
+ H5_VOL_MAX_LIB_VALUE = 128 /* This should be last */
} H5VL_class_value_t;
/* Class information for each VOL driver */
diff --git a/test/vol_test.c b/test/vol_test.c
index 146af4f..2d84066 100644
--- a/test/vol_test.c
+++ b/test/vol_test.c
@@ -46,7 +46,7 @@ int main(int argc, char **argv) {
ssize_t len;
char name[25];
static hsize_t ds_size[2] = {10, 20};
- getchar();
+
for(n=1 ; n<3 ; n++) {
char pl_name[10];
char file_name[50];