summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2019-11-28 04:48:01 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2019-11-28 04:48:01 (GMT)
commitece625e3b680aafb33b0ef4ec101792e20be4aac (patch)
treef3d6a34b9ad7e6cfd9e8f5e4f19ba603f927e3ad
parente23e67798ace036628f291c4f77831a895b67286 (diff)
downloadhdf5-ece625e3b680aafb33b0ef4ec101792e20be4aac.zip
hdf5-ece625e3b680aafb33b0ef4ec101792e20be4aac.tar.gz
hdf5-ece625e3b680aafb33b0ef4ec101792e20be4aac.tar.bz2
Fix bugs in H5VL file comparison code. Add short circuit success to
H5VL_cmp_connector_cls().
-rw-r--r--src/H5Tref.c12
-rw-r--r--src/H5VLcallback.c8
-rw-r--r--src/H5VLint.c6
3 files changed, 16 insertions, 10 deletions
diff --git a/src/H5Tref.c b/src/H5Tref.c
index ad00761..886891c 100644
--- a/src/H5Tref.c
+++ b/src/H5Tref.c
@@ -301,7 +301,7 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf
/* Set external flag if referenced file is not destination file */
if(H5VL_file_specific(vol_obj, H5VL_FILE_IS_EQUAL, H5P_DATASET_XFER_DEFAULT, NULL, dst_file, &files_equal) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, 0, "can't check if files are equal")
- flags |= files_equal ? H5R_IS_EXTERNAL : 0;
+ flags |= !files_equal ? H5R_IS_EXTERNAL : 0;
/* Force re-calculating encoding size if any flags are set */
if(flags || !src_ref->encode_size) {
@@ -324,12 +324,12 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf
} /* end if */
/* Get file name */
- if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0)
+ if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
if(file_name_len >= (ssize_t)sizeof(file_name_buf_static)) {
if(NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name")
- if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0)
+ if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
} /* end if */
@@ -390,7 +390,7 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf,
/* Set external flag if referenced file is not destination file */
if(H5VL_file_specific(vol_obj, H5VL_FILE_IS_EQUAL, H5P_DATASET_XFER_DEFAULT, NULL, dst_file, &files_equal) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCOMPARE, FAIL, "can't check if files are equal")
- flags |= files_equal ? H5R_IS_EXTERNAL : 0;
+ flags |= !files_equal ? H5R_IS_EXTERNAL : 0;
/* Pass the correct encoding version for the selection depending on the
* file libver bounds, this is later retrieved in H5S hyper encode */
@@ -411,12 +411,12 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf,
} /* end if */
/* Get file name */
- if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0)
+ if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
if(file_name_len >= (ssize_t)sizeof(file_name_buf_static)) {
if(NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1)))
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name")
- if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0)
+ if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE, (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
} /* end if */
diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c
index b20494a..77df207 100644
--- a/src/H5VLcallback.c
+++ b/src/H5VLcallback.c
@@ -3077,10 +3077,10 @@ H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t spe
if(H5VL__file_specific_wrap_va_list(obj, cls, specific_type, dxpl_id, req, vol_obj2->data, is_equal) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed")
} /* end if */
-
- /* Call the corresponding VOL callback */
- if((cls->file_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed")
+ else
+ /* Call the corresponding VOL callback */
+ if((cls->file_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 733a2b5..284b266 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -1639,6 +1639,12 @@ H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_clas
HDassert(cls1);
HDassert(cls2);
+ /* If the pointers are the same the classes are the same */
+ if(cls1 == cls2) {
+ *cmp_value = 0;
+ HGOTO_DONE(SUCCEED);
+ } /* end if */
+
/* Compare connector "values" */
if(cls1->value < cls2->value) {
*cmp_value = -1;